File indexing completed on 2024-04-14 04:51:27
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Alejandro Fiestas Olivares <afiestas@kde.org> 0003 * SPDX-FileCopyrightText: 2020 Dan Leinir Turthra Jensen <admin@leinir.dk> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef ACCOUNTS_MODEL_H 0009 #define ACCOUNTS_MODEL_H 0010 0011 #include "kaccounts_export.h" 0012 0013 #include <QAbstractListModel> 0014 0015 #include <Accounts/Account> 0016 0017 namespace KAccounts 0018 { 0019 0020 /** 0021 * @brief A model representing all the accounts registered on a system 0022 * 0023 * # Roles 0024 * 0025 * The following role names are available in this model: 0026 * 0027 * * id: The internal ID of the account 0028 * * services: A model which contains information about the services this account supports (see ServicesModel) 0029 * * enabled: Whether or not this account is enabled 0030 * * credentialsId: The internal ID for any stored credentials for this account 0031 * * displayName: A human-readable name for this account (change this using ChangeAccountDisplayNameJob) 0032 * * providerName: The internal name of the provider this account is registered through 0033 * * iconName: An XDG Icon specification icon name 0034 * * dataObject: The instance of Accounts::Account which the data for this account is fetched from 0035 */ 0036 class KACCOUNTS_EXPORT AccountsModel : public QAbstractListModel 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 enum Roles { 0042 IdRole = Qt::UserRole + 1, 0043 ServicesRole, 0044 EnabledRole, 0045 CredentialsIdRole, 0046 DisplayNameRole, 0047 ProviderNameRole, 0048 IconNameRole, 0049 DataObjectRole, 0050 ProviderDisplayNameRole, 0051 }; 0052 Q_ENUM(Roles) 0053 explicit AccountsModel(QObject *parent = nullptr); 0054 ~AccountsModel() override; 0055 0056 QHash<int, QByteArray> roleNames() const override; 0057 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0058 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0059 0060 private: 0061 class Private; 0062 Private *d; 0063 }; 0064 0065 }; 0066 0067 #endif // ACCOUNTS_MODEL_H