Changeset View
Changeset View
Standalone View
Standalone View
src/lib/servicesmodel.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 SERVICES_MODEL_H | ||||
21 | #define SERVICES_MODEL_H | ||||
22 | | ||||
23 | #include "kaccounts_export.h" | ||||
24 | | ||||
25 | #include <QAbstractListModel> | ||||
26 | | ||||
27 | /** | ||||
28 | * @brief A model which represents the services in a single account | ||||
29 | * | ||||
30 | * You can create this manually, but usually you would get an instance of it from the | ||||
31 | * AccountsModel::Roles::ServicesRole data role (model.services) of an AccountsModel | ||||
32 | * instance. | ||||
33 | */ | ||||
34 | class KACCOUNTS_EXPORT ServicesModel : public QAbstractListModel | ||||
35 | { | ||||
36 | Q_OBJECT | ||||
37 | Q_PROPERTY(QObject* account READ account WRITE setAccount NOTIFY accountChanged) | ||||
38 | Q_PROPERTY(quint32 accountId READ accountId NOTIFY accountChanged) | ||||
39 | Q_PROPERTY(QString accountDisplayName READ accountDisplayName NOTIFY accountChanged) | ||||
40 | Q_PROPERTY(QString accountProviderName READ accountProviderName NOTIFY accountChanged) | ||||
41 | Q_PROPERTY(QString accountIconName READ accountIconName NOTIFY accountChanged) | ||||
42 | public: | ||||
43 | enum Roles { | ||||
44 | NameRole = Qt::UserRole + 1, | ||||
45 | DescriptionRole, | ||||
46 | DisplayNameRole, | ||||
47 | ServiceTypeRole, | ||||
48 | ProviderNameRole, | ||||
49 | IconNameRole, | ||||
50 | TagsRole, | ||||
51 | EnabledRole | ||||
52 | }; | ||||
53 | explicit ServicesModel(QObject* parent = nullptr); | ||||
54 | virtual ~ServicesModel(); | ||||
55 | | ||||
56 | QHash< int, QByteArray > roleNames() const override; | ||||
57 | virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||||
58 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||||
59 | | ||||
60 | void setAccount(QObject* account); | ||||
61 | QObject* account() const; | ||||
62 | quint32 accountId() const; | ||||
63 | QString accountDisplayName() const; | ||||
64 | QString accountProviderName() const; | ||||
65 | QString accountIconName() const; | ||||
66 | Q_SIGNAL void accountChanged(); | ||||
67 | | ||||
68 | private: | ||||
69 | class Private; | ||||
70 | Private *d; | ||||
71 | }; | ||||
72 | | ||||
73 | #endif//SERVICES_MODEL_H |