CuteLogger
Fast and simple logging solution for Qt based applications
addonservicemodel.h
1/*
2 * Copyright (c) 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 ADDONSERVICEMODEL_H
19#define ADDONSERVICEMODEL_H
20
21#include <QAbstractListModel>
22#include <QStringList>
23
24class AddOnServiceModel : public QAbstractListModel
25{
26 Q_OBJECT
27
28public:
29 enum ModelRoles {
30 ServiceRole = Qt::UserRole + 1,
31 TitleRole,
32 DescriptionRole,
33 IsAudioRole,
34 SupportsRgbaRole,
35 SupportsYuvRole,
36 SupportsTenBitRole,
37 EnabledRole,
38 };
39
40 explicit AddOnServiceModel(QObject *parent = nullptr);
41
42 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
43 QVariant data(const QModelIndex &index, int role) const override;
44 QHash<int, QByteArray> roleNames() const override;
45
46 Q_INVOKABLE void reload();
47 Q_INVOKABLE bool isEnabled(const QString &service) const;
48 Q_INVOKABLE void setEnabled(const QString &service, bool enabled);
49 Q_INVOKABLE void setEnabledServices(const QStringList &services);
50 Q_INVOKABLE QStringList enabledServices() const;
51
52signals:
53 void enabledServicesChanged();
54
55private:
56 struct Item
57 {
58 QString service;
59 QString title;
60 QString description;
61 bool isAudio{false};
62 bool supportsRgba{false};
63 bool supportsYuv{false};
64 bool supportsTenBit{false};
65 };
66
67 QList<Item> m_items;
68 QStringList m_enabledServices;
69
70 int indexOfService(const QString &service) const;
71 void saveEnabledServices();
72};
73
74#endif // ADDONSERVICEMODEL_H