Changeset View
Changeset View
Standalone View
Standalone View
src/lib/accountsmodel.h
- This file was added.
1 | /************************************************************************************* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> * | ||||
3 | * Copyright (C) 2020 by Dan Leinir Turthra Jensen <admin@leinir.dk> * | ||||
4 | * * | ||||
5 | * This program is free software; you can redistribute it and/or * | ||||
6 | * modify it under the terms of the GNU General Public License * | ||||
7 | * as published by the Free Software Foundation; either version 2 * | ||||
8 | * of the License, or (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, write to the Free Software * | ||||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | ||||
18 | *************************************************************************************/ | ||||
19 | | ||||
20 | #ifndef ACCOUNTS_MODEL_H | ||||
21 | #define ACCOUNTS_MODEL_H | ||||
22 | | ||||
23 | #include "kaccounts_export.h" | ||||
24 | | ||||
25 | #include <QAbstractListModel> | ||||
26 | | ||||
27 | #include <Accounts/Account> | ||||
28 | | ||||
29 | /** | ||||
30 | * @brief A model representing all the accounts registered on a system | ||||
31 | * | ||||
32 | * # Roles | ||||
33 | * | ||||
34 | * The following role names are available in this model: | ||||
35 | * | ||||
36 | * * id: The internal ID of the account | ||||
37 | * * services: A model which contains information about the services this account supports (see ServicesModel) | ||||
38 | * * enabled: Whether or not this account is enabled | ||||
39 | * * credentialsId: The internal ID for any stored credentials for this account | ||||
40 | * * displayName: A human-readable name for this account (change this using ChangeAccountDisplayNameJob) | ||||
41 | * * providerName: The internal name of the provider this account is registered through | ||||
42 | * * iconName: An XDG Icon specification icon name | ||||
43 | * * dataObject: The instance of Accounts::Account which the data for this account is fetched from | ||||
44 | */ | ||||
45 | class KACCOUNTS_EXPORT AccountsModel : public QAbstractListModel | ||||
46 | { | ||||
47 | Q_OBJECT | ||||
48 | | ||||
49 | public: | ||||
50 | enum Roles { | ||||
51 | IdRole = Qt::UserRole + 1, | ||||
52 | ServicesRole, | ||||
53 | EnabledRole, | ||||
54 | CredentialsIdRole, | ||||
55 | DisplayNameRole, | ||||
56 | ProviderNameRole, | ||||
57 | IconNameRole, | ||||
58 | DataObjectRole | ||||
59 | }; | ||||
60 | explicit AccountsModel(QObject* parent = nullptr); | ||||
61 | virtual ~AccountsModel(); | ||||
62 | | ||||
63 | QHash< int, QByteArray > roleNames() const override; | ||||
64 | virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||||
65 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||||
66 | | ||||
67 | private: | ||||
68 | class Private; | ||||
69 | Private *d; | ||||
70 | }; | ||||
71 | | ||||
72 | #endif //ACCOUNTS_MODEL_H |