CuteLogger
Fast and simple logging solution for Qt based applications
attachedfiltersmodel.h
1/*
2 * Copyright (c) 2013-2026 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 ATTACHEDFILTERSMODEL_H
19#define ATTACHEDFILTERSMODEL_H
20
21#include <MltEvent.h>
22#include <MltFilter.h>
23#include <MltProducer.h>
24#include <QAbstractListModel>
25
26class QmlMetadata;
27
28class AttachedFiltersModel : public QAbstractListModel
29{
30 Q_OBJECT
31 Q_PROPERTY(QString producerTitle READ producerTitle NOTIFY trackTitleChanged)
32 Q_PROPERTY(bool isProducerSelected READ isProducerSelected NOTIFY isProducerSelectedChanged)
33 Q_PROPERTY(bool supportsLinks READ supportsLinks NOTIFY supportsLinksChanged)
34public:
35 enum ModelRoles {
36 TypeDisplayRole = Qt::UserRole + 1,
37 PluginTypeRole,
38 };
39
40 explicit AttachedFiltersModel(QObject *parent = 0);
41
42 Mlt::Service *getService(int row) const;
43 QmlMetadata *getMetadata(int row) const;
44 void setProducer(Mlt::Producer *producer = 0);
45 QString producerTitle() const;
46 bool isProducerSelected() const;
47 bool isSourceClip() const;
48 bool supportsLinks() const;
49 Mlt::Producer *producer() const { return m_producer.data(); }
50 QString name(int row) const;
51 Q_INVOKABLE bool isTrackVolumeFilter(int row) const;
52 int trackVolumeFilterIndex() const;
53
54 // The below are used by QUndoCommands
55 void doAddService(Mlt::Producer &producer, Mlt::Service &service, int row);
56 void doRemoveService(Mlt::Producer &producer, int row);
57 void doMoveService(Mlt::Producer &producer, int fromRow, int toRow);
58 void doSetDisabled(Mlt::Producer &producer, int row, bool disable);
59 Mlt::Service doGetService(Mlt::Producer &producer, int row);
60
61 // QAbstractListModel Implementation
62 int rowCount(const QModelIndex &parent = QModelIndex()) const;
63 Qt::ItemFlags flags(const QModelIndex &index) const;
64 QVariant data(const QModelIndex &index, int role) const;
65 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
66 QHash<int, QByteArray> roleNames() const;
67 Qt::DropActions supportedDropActions() const;
68 bool insertRows(int row, int count, const QModelIndex &parent);
69 bool removeRows(int row, int count, const QModelIndex &parent);
70 bool moveRows(const QModelIndex &sourceParent,
71 int sourceRow,
72 int count,
73 const QModelIndex &destinationParent,
74 int destinationRow);
75
76signals:
77 void changed();
78 void duplicateAddFailed(int index);
79 void trackTitleChanged();
80 void isProducerSelectedChanged();
81 void supportsLinksChanged();
82 void addedOrRemoved(Mlt::Producer *);
83 void requestConvert(QString, bool set709Convert, bool withSubClip);
84
85public slots:
86 int add(QmlMetadata *meta);
87 int addService(Mlt::Service *service);
88 void remove(int row);
89 bool move(int fromRow, int toRow);
90 void pasteFilters();
91
92private:
93 static void producerChanged(mlt_properties owner, AttachedFiltersModel *model);
94 void reset(Mlt::Producer *producer = 0);
95 bool isProducerLoaded(Mlt::Producer &producer) const;
96 int findInsertRow(QmlMetadata *meta);
97 Mlt::Producer getFilterSetProducer(QmlMetadata *meta);
98
99 int m_dropRow;
100 int m_removeRow;
101 QScopedPointer<Mlt::Producer> m_producer;
102 QScopedPointer<Mlt::Event> m_event;
103 typedef QList<QmlMetadata *> MetadataList;
104 MetadataList m_metaList;
105};
106
107#endif // ATTACHEDFILTERSMODEL_H