File indexing completed on 2024-11-10 12:54:42

0001 /*
0002  *  SPDX-FileCopyrightText: 2020 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef PROVIDERS_MODEL_H
0008 #define PROVIDERS_MODEL_H
0009 
0010 #include "kaccounts_export.h"
0011 
0012 #include <QAbstractListModel>
0013 
0014 namespace KAccounts
0015 {
0016 
0017 /**
0018  * @brief A model which represents the available providers
0019  *
0020  * # Roles
0021  *
0022  * The role names available in this model are:
0023  *
0024  * * name: The internal name identifying this provider
0025  * * displayName: The human-readable name for this provider
0026  * * description: A (usually single sentence) description of this provider
0027  * * iconName: An XDG Icon specification icon name for this provider
0028  * * supportsMultipleAccounts: Whether or not this provider supports multiple simultaneous accounts
0029  * * accountsCount: The number of accounts which already exist on the system for this provider
0030  */
0031 class KACCOUNTS_EXPORT ProvidersModel : public QAbstractListModel
0032 {
0033     Q_OBJECT
0034 public:
0035     enum Roles {
0036         NameRole = Qt::UserRole + 1, ///< The unique name identifier for this provider
0037         DisplayNameRole, ///< The human-readable name for this provider
0038         DescriptionRole, ///< A (usually single sentence) description of this provider
0039         IconNameRole, ///< The name of the icon to be used for this provider (an XDG Icon Spec style name)
0040         SupportsMultipleAccountsRole, ///< Whether or not this provider supports multiple simultaneous accounts
0041         AccountsCountRole, ///< The number of accounts which already exist for this provider
0042     };
0043     explicit ProvidersModel(QObject *parent = nullptr);
0044     ~ProvidersModel() override;
0045 
0046     QHash<int, QByteArray> roleNames() const override;
0047     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0048     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0049 
0050 private:
0051     class Private;
0052     Private *d;
0053 };
0054 
0055 };
0056 
0057 #endif // PROVIDERS_MODEL_H