CuteLogger
Fast and simple logging solution for Qt based applications
filtercontroller.h
1 /*
2  * Copyright (c) 2014 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 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 
43 protected:
44  void timerEvent(QTimerEvent*);
45 
46 signals:
47  void currentFilterAboutToChange();
48  void currentFilterChanged(QmlFilter* filter, QmlMetadata* meta, int index);
49  void statusChanged(QString);
50 
51 public slots:
52  void setProducer(Mlt::Producer *producer = 0);
53  void setCurrentFilter(int attachedIndex);
54 
55 private slots:
56  void handleAttachedModelChange();
57  void handleAttachedModelAboutToReset();
58  void addMetadata(QmlMetadata*);
59  void handleAttachedRowsRemoved(const QModelIndex & parent, int first, int last);
60  void handleAttachedRowsInserted(const QModelIndex & parent, int first, int last);
61  void handleAttachDuplicateFailed(int index);
62 
63 private:
64  void loadFilterMetadata();
65 
66  QFuture<void> m_future;
67  QScopedPointer<QmlFilter> m_currentFilter;
68  MetadataModel m_metadataModel;
69  AttachedFiltersModel m_attachedModel;
70  int m_currentFilterIndex;
71 };
72 
73 #endif // FILTERCONTROLLER_H