1 /*
2  *  SPDX-FileCopyrightText: 2012 Alejandro Fiestas Olivares <afiestas@kde.org>
3  *  SPDX-FileCopyrightText: 2020 Dan Leinir Turthra Jensen <admin@leinir.dk>
4  *
5  *  SPDX-License-Identifier: GPL-2.0-or-later
6  */
7 
8 #ifndef ACCOUNTS_MODEL_H
9 #define ACCOUNTS_MODEL_H
10 
11 #include "kaccounts_export.h"
12 
13 #include <QAbstractListModel>
14 
15 #include <Accounts/Account>
16 
17 /**
18  * @brief A model representing all the accounts registered on a system
19  *
20  * # Roles
21  *
22  * The following role names are available in this model:
23  *
24  * * id: The internal ID of the account
25  * * services: A model which contains information about the services this account supports (see ServicesModel)
26  * * enabled: Whether or not this account is enabled
27  * * credentialsId: The internal ID for any stored credentials for this account
28  * * displayName: A human-readable name for this account (change this using ChangeAccountDisplayNameJob)
29  * * providerName: The internal name of the provider this account is registered through
30  * * iconName: An XDG Icon specification icon name
31  * * dataObject: The instance of Accounts::Account which the data for this account is fetched from
32  */
33 class KACCOUNTS_EXPORT AccountsModel : public QAbstractListModel
34 {
35     Q_OBJECT
36 
37 public:
38     enum Roles {
39         IdRole = Qt::UserRole + 1,
40         ServicesRole,
41         EnabledRole,
42         CredentialsIdRole,
43         DisplayNameRole,
44         ProviderNameRole,
45         IconNameRole,
46         DataObjectRole,
47     };
48     explicit AccountsModel(QObject *parent = nullptr);
49     virtual ~AccountsModel();
50 
51     QHash<int, QByteArray> roleNames() const override;
52     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
53     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
54 
55 private:
56     class Private;
57     Private *d;
58 };
59 
60 #endif // ACCOUNTS_MODEL_H
61