Changeset View
Changeset View
Standalone View
Standalone View
src/lib/providersmodel.h
- This file was added.
1 | /************************************************************************************* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2020 by Dan Leinir Turthra Jensen <admin@leinir.dk> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or * | ||||
5 | * modify it under the terms of the GNU General Public License * | ||||
6 | * as published by the Free Software Foundation; either version 2 * | ||||
7 | * of the License, or (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, write to the Free Software * | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | ||||
17 | *************************************************************************************/ | ||||
18 | | ||||
19 | #ifndef PROVIDERS_MODEL_H | ||||
20 | #define PROVIDERS_MODEL_H | ||||
21 | | ||||
22 | #include "kaccounts_export.h" | ||||
23 | | ||||
24 | #include <QAbstractListModel> | ||||
25 | | ||||
26 | /** | ||||
27 | * @brief A model which represents the available providers | ||||
28 | * | ||||
29 | * # Roles | ||||
30 | * | ||||
31 | * The role names available in this model are: | ||||
32 | * | ||||
33 | * * name: The internal name identifying this provider | ||||
34 | * * displayName: The human-readable name for this provider | ||||
35 | * * description: A (usually single sentence) description of this provider | ||||
36 | * * iconName: An XDG Icon specification icon name for this provider | ||||
37 | * * supportsMultipleAccounts: Whether or not this provider supports multiple simultaneous accounts | ||||
38 | * * accountsCount: The number of accounts which already exist on the system for this provider | ||||
39 | */ | ||||
40 | class KACCOUNTS_EXPORT ProvidersModel : public QAbstractListModel | ||||
41 | { | ||||
42 | Q_OBJECT | ||||
43 | public: | ||||
44 | enum Roles { | ||||
45 | NameRole = Qt::UserRole + 1, ///< The unique name identifier for this provider | ||||
46 | DisplayNameRole, ///< The human-readable name for this provider | ||||
47 | DescriptionRole, ///< A (usually single sentence) description of this provider | ||||
48 | IconNameRole, ///< The name of the icon to be used for this provider (an XDG Icon Spec style name) | ||||
49 | SupportsMultipleAccountsRole, ///< Whether or not this provider supports multiple simultaneous accounts | ||||
50 | AccountsCountRole ///< The number of accounts which already exist for this provider | ||||
51 | }; | ||||
52 | explicit ProvidersModel(QObject* parent = nullptr); | ||||
53 | virtual ~ProvidersModel(); | ||||
54 | | ||||
55 | QHash< int, QByteArray > roleNames() const override; | ||||
56 | virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||||
57 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||||
58 | | ||||
59 | private: | ||||
60 | class Private; | ||||
61 | Private *d; | ||||
62 | }; | ||||
63 | | ||||
64 | #endif//PROVIDERS_MODEL_H |