blob: 4c53d74cc32e2ddfb09d9925391bc2b55865dd2c [file] [log] [blame]
agsantos655d8e22020-08-10 17:36:47 -04001/**
2 * Copyright (C) 2020 by Savoir-faire Linux
3 * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
Sébastien Blin1f915762020-08-03 13:27:42 -04004 *
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#pragma once
20
21#include <QAbstractItemModel>
22
23#include "api/pluginmodel.h"
24
25#include "lrcinstance.h"
26
27class PreferenceItemListModel : public QAbstractListModel
28{
29 Q_OBJECT
agsantos655d8e22020-08-10 17:36:47 -040030
Sébastien Blin1f915762020-08-03 13:27:42 -040031 Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
32public:
33 enum Role { PreferenceKey = Qt::UserRole + 1, PreferenceName, PreferenceSummary, PreferenceType, PreferenceDefaultValue, PreferenceEntries, PreferenceEntryValues};
agsantos655d8e22020-08-10 17:36:47 -040034
Sébastien Blin1f915762020-08-03 13:27:42 -040035 typedef enum {
36 LIST,
37 DEFAULT,
38 } Type;
agsantos655d8e22020-08-10 17:36:47 -040039
Sébastien Blin1f915762020-08-03 13:27:42 -040040 Q_ENUM(Role)
41
42 explicit PreferenceItemListModel(QObject *parent = 0);
43 ~PreferenceItemListModel();
44
45 /*
46 * QAbstractListModel override.
47 */
48 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
49 int columnCount(const QModelIndex &parent) const override;
50 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
51 /*
52 * Override role name as access point in qml.
53 */
54 QHash<int, QByteArray> roleNames() const override;
55 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
56 QModelIndex parent(const QModelIndex &child) const;
57 Qt::ItemFlags flags(const QModelIndex &index) const;
58
59 /*
agsantos655d8e22020-08-10 17:36:47 -040060 * This function is to reset the model when there's new plugin added or modified.
Sébastien Blin1f915762020-08-03 13:27:42 -040061 */
62 Q_INVOKABLE void reset();
63
64 QString pluginId() const;
65 void setPluginId(const QString &pluginId);
66// signals:
67// void pluginIdChanged();
68private:
69 QString pluginId_;
70};