CuteLogger
Fast and simple logging solution for Qt based applications
metadatamodel.h
1/*
2 * Copyright (c) 2014-2023 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 METADATAMODEL_H
19#define METADATAMODEL_H
20
21#include <QAbstractListModel>
22#include <QList>
23
24class QmlMetadata;
25
26class MetadataModel : public QAbstractListModel
27{
28 Q_OBJECT
29 Q_ENUMS(MetadataFilter)
30 Q_PROPERTY(MetadataFilter filter READ filter WRITE setFilter NOTIFY filterChanged)
31 Q_PROPERTY(QString search READ search WRITE setSearch NOTIFY searchChanged)
32
33public:
34
35 enum ModelRoles {
36 NameRole = Qt::UserRole + 1,
37 HiddenRole,
38 FavoriteRole,
39 ServiceRole,
40 IsAudioRole,
41 NeedsGpuRole,
42 VisibleRole,
43 PluginTypeRole,
44 };
45
46 enum MetadataFilter {
47 NoFilter,
48 FavoritesFilter,
49 VideoFilter,
50 AudioFilter,
51 LinkFilter,
52 FilterSetFilter,
53 GPUFilter,
54 };
55
56 enum FilterMaskBits {
57 HiddenMaskBit = 1 << 0,
58 clipOnlyMaskBit = 1 << 1,
59 gpuIncompatibleMaskBit = 1 << 2,
60 gpuAlternativeMaskBit = 1 << 3,
61 needsGPUMaskBit = 1 << 4,
62 linkMaskBit = 1 << 5,
63 trackOnlyMaskBit = 1 << 6,
64 outputOnlyMaskBit = 1 << 7,
65 };
66
67 explicit MetadataModel(QObject *parent = 0);
68
69 // Implement QAbstractListModel
70 Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;
71 QVariant data(const QModelIndex &index, int role) const;
72 bool setData(const QModelIndex &index, const QVariant &value, int role);
73 QHash<int, QByteArray> roleNames() const;
74 Qt::ItemFlags flags(const QModelIndex &index) const;
75
76 // Direct access to QmlMetadata
77 void add(QmlMetadata *data);
78 Q_INVOKABLE QmlMetadata *get(int index) const;
79 MetadataFilter filter() const
80 {
81 return m_filter;
82 }
83 void setFilter(MetadataFilter);
84 QString search() const
85 {
86 return m_search;
87 }
88 void setSearch(const QString &search);
89 Q_INVOKABLE bool isVisible(int row) const;
90 void updateFilterMask(bool isClipProducer, bool isChainProducer, bool isTrackProducer,
91 bool isOutputProducer);
92 Q_INVOKABLE void saveFilterSet(const QString &name);
93 Q_INVOKABLE void deleteFilterSet(const QString &name);
94
95signals:
96 void filterChanged();
97 void searchChanged();
98
99private:
100 typedef QList<QmlMetadata *> MetadataList;
101 MetadataList m_list;
102 MetadataFilter m_filter;
103 bool m_isClipProducer;
104 bool m_isChainProducer;
105 bool m_isTrackProducer;
106 bool m_isOutputProducer;
107 QString m_search;
108 unsigned m_filterMask;
109
110 unsigned computeFilterMask(const QmlMetadata *meta);
111};
112
113#endif // METADATAMODEL_H