CuteLogger
Fast and simple logging solution for Qt based applications
filtercontroller.h
1 /*
2  * Copyright (c) 2014-2024 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 "models/attachedfiltersmodel.h"
22 #include "models/metadatamodel.h"
23 #include "models/motiontrackermodel.h"
24 #include "qmltypes/qmlfilter.h"
25 #include "qmltypes/qmlmetadata.h"
26 
27 #include <QFuture>
28 #include <QObject>
29 #include <QScopedPointer>
30 
31 class QTimerEvent;
32 
33 class FilterController : public QObject
34 {
35  Q_OBJECT
36 
37 public:
38  explicit FilterController(QObject *parent = 0);
39  MetadataModel *metadataModel();
40  MotionTrackerModel *motionTrackerModel() { return &m_motionTrackerModel; }
41  AttachedFiltersModel *attachedModel();
42 
43  QmlMetadata *metadata(const QString &id);
44  QmlMetadata *metadataForService(Mlt::Service *service);
45  QmlFilter *currentFilter() const { return m_currentFilter.data(); }
46  bool isOutputTrackSelected() const;
47  void onUndoOrRedo(Mlt::Service &service);
48  int currentIndex() const { return m_currentFilterIndex; }
49  void addOrEditFilter(Mlt::Filter *filter, const QStringList &key_properties);
50 
51 protected:
52  void timerEvent(QTimerEvent *);
53 
54 signals:
55  void currentFilterChanged(QmlFilter *filter, QmlMetadata *meta, int index);
56  void statusChanged(QString);
57  void filterChanged(Mlt::Service *);
58  void undoOrRedo();
59 
60 public slots:
61  void setProducer(Mlt::Producer *producer = 0);
62  void setCurrentFilter(int attachedIndex);
63  void onFadeInChanged();
64  void onFadeOutChanged();
65  void onServiceInChanged(int delta, Mlt::Service *service = 0);
66  void onServiceOutChanged(int delta, Mlt::Service *service = 0);
67  void removeCurrent();
68  void onProducerChanged();
69  void pauseUndoTracking();
70  void resumeUndoTracking();
71 
72 private slots:
73  void handleAttachedModelChange();
74  void handleAttachedModelAboutToReset();
75  void addMetadata(QmlMetadata *);
76  void handleAttachedRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
77  void handleAttachedRowsRemoved(const QModelIndex &parent, int first, int last);
78  void handleAttachedRowsInserted(const QModelIndex &parent, int first, int last);
79  void handleAttachDuplicateFailed(int index);
80  void onQmlFilterChanged(const QString &name);
81 
82 private:
83  void loadFilterSets();
84  void loadFilterMetadata();
85 
86  QFuture<void> m_future;
87  QScopedPointer<QmlFilter> m_currentFilter;
88  Mlt::Service m_mltService;
89  MetadataModel m_metadataModel;
90  MotionTrackerModel m_motionTrackerModel;
91  AttachedFiltersModel m_attachedModel;
92  int m_currentFilterIndex;
93 };
94 
95 #endif // FILTERCONTROLLER_H