CuteLogger
Fast and simple logging solution for Qt based applications
filtercontroller.h
1 /*
2  * Copyright (c) 2014-2020 Meltytech, LLC
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef FILTERCONTROLLER_H
19 #define FILTERCONTROLLER_H
20 
21 #include <QObject>
22 #include <QScopedPointer>
23 #include <QFuture>
24 #include "models/metadatamodel.h"
25 #include "models/attachedfiltersmodel.h"
26 #include "qmltypes/qmlmetadata.h"
27 #include "qmltypes/qmlfilter.h"
28 
29 class QTimerEvent;
30 
31 
32 class FilterController : public QObject
33 {
34  Q_OBJECT
35 
36 public:
37  explicit FilterController(QObject* parent = 0);
38  MetadataModel* metadataModel();
39  AttachedFiltersModel* attachedModel();
40 
41  QmlMetadata* metadataForService(Mlt::Service *service);
42  QmlFilter* currentFilter() const { return m_currentFilter.data(); }
43 
44 protected:
45  void timerEvent(QTimerEvent*);
46 
47 signals:
48  void currentFilterChanged(QmlFilter* filter, QmlMetadata* meta, int index);
49  void statusChanged(QString);
50  void filterChanged(Mlt::Service*);
51 
52 public slots:
53  void setProducer(Mlt::Producer *producer = 0);
54  void setCurrentFilter(int attachedIndex, bool isNew = false);
55  void onFadeInChanged();
56  void onFadeOutChanged();
57  void onServiceInChanged(int delta, Mlt::Service* service = 0);
58  void onServiceOutChanged(int delta, Mlt::Service* service = 0);
59  void removeCurrent();
60  void onProducerChanged();
61 
62 private slots:
63  void handleAttachedModelChange();
64  void handleAttachedModelAboutToReset();
65  void addMetadata(QmlMetadata*);
66  void handleAttachedRowsRemoved(const QModelIndex & parent, int first, int last);
67  void handleAttachedRowsInserted(const QModelIndex & parent, int first, int last);
68  void handleAttachDuplicateFailed(int index);
69  void onQmlFilterChanged();
70  void onQmlFilterChanged(const QString& name);
71 
72 private:
73  void loadFilterMetadata();
74 
75  QFuture<void> m_future;
76  QScopedPointer<QmlFilter> m_currentFilter;
77  Mlt::Service* m_mltService;
78  MetadataModel m_metadataModel;
79  AttachedFiltersModel m_attachedModel;
80  int m_currentFilterIndex;
81 };
82 
83 #endif // FILTERCONTROLLER_H