blob: da399f7c4865488db7a47289293030b8c9521f41 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
2 * Copyright (C) 2019-2020 by Savoir-faire Linux
3 * Author: Yang Wang <yang.wang@savoirfairelinux.com>
4 *
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
30
31public:
32 enum Role { PluginName = Qt::UserRole + 1, PluginId, PluginIcon, IsLoaded };
33 Q_ENUM(Role)
34
35 explicit PluginItemListModel(QObject *parent = 0);
36 ~PluginItemListModel();
37
38 /*
39 * QAbstractListModel override.
40 */
41 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
42 int columnCount(const QModelIndex &parent) const override;
43 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
44 /*
45 * Override role name as access point in qml.
46 */
47 QHash<int, QByteArray> roleNames() const override;
48 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
49 QModelIndex parent(const QModelIndex &child) const;
50 Qt::ItemFlags flags(const QModelIndex &index) const;
51
52 /*
53 * This function is to reset the model when there's new account added.
54 */
55 Q_INVOKABLE void reset();
56};