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