blob: 3a6b7ef65840b7091b0470340296daa2d0bd6a72 [file] [log] [blame]
agsantos78726ec2020-08-18 17:41:05 -04001/**
Sébastien Blin1f915762020-08-03 13:27:42 -04002 * Copyright (C) 2019-2020 by Savoir-faire Linux
agsantos78726ec2020-08-18 17:41:05 -04003 * 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 PluginItemListModel : public QAbstractListModel
28{
29 Q_OBJECT
agsantos78726ec2020-08-18 17:41:05 -040030 Q_PROPERTY(int pluginsCount READ pluginsCount)
Sébastien Blin1f915762020-08-03 13:27:42 -040031
32public:
33 enum Role { PluginName = Qt::UserRole + 1, PluginId, PluginIcon, IsLoaded };
34 Q_ENUM(Role)
35
agsantos78726ec2020-08-18 17:41:05 -040036 explicit PluginItemListModel(QObject* parent = 0);
Sébastien Blin1f915762020-08-03 13:27:42 -040037 ~PluginItemListModel();
38
39 /*
40 * QAbstractListModel override.
41 */
agsantos78726ec2020-08-18 17:41:05 -040042 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
43 int columnCount(const QModelIndex& parent) const override;
44 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
Sébastien Blin1f915762020-08-03 13:27:42 -040045 /*
46 * Override role name as access point in qml.
47 */
48 QHash<int, QByteArray> roleNames() const override;
agsantos78726ec2020-08-18 17:41:05 -040049 QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const;
50 QModelIndex parent(const QModelIndex& child) const;
51 Qt::ItemFlags flags(const QModelIndex& index) const;
Sébastien Blin1f915762020-08-03 13:27:42 -040052
agsantos78726ec2020-08-18 17:41:05 -040053 int pluginsCount();
Sébastien Blin1f915762020-08-03 13:27:42 -040054 /*
55 * This function is to reset the model when there's new account added.
56 */
57 Q_INVOKABLE void reset();
58};