Changeset View
Changeset View
Standalone View
Standalone View
src/lib/accountsmodel.h
- This file was moved from src/jobs/accountservicetoggle.h.
1 | /************************************************************************************* | 1 | /************************************************************************************* | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> * | ||||
2 | * Copyright (C) 2020 by Dan Leinir Turthra Jensen <admin@leinir.dk> * | 3 | * Copyright (C) 2020 by Dan Leinir Turthra Jensen <admin@leinir.dk> * | ||
3 | * * | 4 | * * | ||
4 | * This program is free software; you can redistribute it and/or * | 5 | * This program is free software; you can redistribute it and/or * | ||
5 | * modify it under the terms of the GNU General Public License * | 6 | * modify it under the terms of the GNU General Public License * | ||
6 | * as published by the Free Software Foundation; either version 2 * | 7 | * as published by the Free Software Foundation; either version 2 * | ||
7 | * of the License, or (at your option) any later version. * | 8 | * of the License, or (at your option) any later version. * | ||
8 | * * | 9 | * * | ||
9 | * This program is distributed in the hope that it will be useful, * | 10 | * This program is distributed in the hope that it will be useful, * | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
12 | * GNU General Public License for more details. * | 13 | * GNU General Public License for more details. * | ||
13 | * * | 14 | * * | ||
14 | * You should have received a copy of the GNU General Public License * | 15 | * You should have received a copy of the GNU General Public License * | ||
15 | * along with this program; if not, write to the Free Software * | 16 | * along with this program; if not, write to the Free Software * | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | ||
17 | *************************************************************************************/ | 18 | *************************************************************************************/ | ||
18 | 19 | | |||
19 | #ifndef ACCOUNTSERVICETOGGLE_H | 20 | #ifndef ACCOUNTS_MODEL_H | ||
20 | #define ACCOUNTSERVICETOGGLE_H | 21 | #define ACCOUNTS_MODEL_H | ||
21 | 22 | | |||
23 | #include "kaccounts_export.h" | ||||
22 | 24 | | |||
23 | #include <kjob.h> | 25 | #include <QAbstractListModel> | ||
24 | 26 | | |||
25 | #include <QStringList> | 27 | #include <Accounts/Account> | ||
26 | 28 | | |||
27 | class AccountServiceToggle : public KJob | 29 | class KACCOUNTS_EXPORT AccountsModel : public QAbstractListModel | ||
28 | { | 30 | { | ||
29 | Q_OBJECT | 31 | Q_OBJECT | ||
30 | Q_PROPERTY(QString accountId READ accountId WRITE setAccountId NOTIFY accountIdChanged) | 32 | | ||
31 | Q_PROPERTY(QString serviceId READ serviceId WRITE setServiceId NOTIFY serviceIdChanged) | | |||
32 | Q_PROPERTY(bool serviceEnabled READ serviceEnabled WRITE setServiceEnabled NOTIFY serviceEnabledChanged) | | |||
33 | public: | 33 | public: | ||
34 | explicit AccountServiceToggle(QObject* parent = nullptr); | 34 | enum Roles { | ||
35 | virtual ~AccountServiceToggle(); | 35 | IdRole = Qt::UserRole + 1, | ||
36 | ServicesRole, | ||||
37 | EnabledRole, | ||||
38 | CredentialsIdRole, | ||||
39 | DisplayNameRole, | ||||
40 | ProviderNameRole, | ||||
41 | IconNameRole, | ||||
42 | DataObjectRole | ||||
43 | }; | ||||
44 | explicit AccountsModel(QObject* parent = nullptr); | ||||
45 | virtual ~AccountsModel(); | ||||
36 | 46 | | |||
37 | void start() override; | 47 | QHash< int, QByteArray > roleNames() const override; | ||
48 | virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||||
49 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; | ||||
50 | | ||||
51 | public Q_SLOTS: | ||||
52 | void accountCreated(Accounts::AccountId accountId); | ||||
53 | void accountRemoved(Accounts::AccountId accountId); | ||||
54 | void accountUpdated(); | ||||
38 | 55 | | |||
39 | QString accountId() const; | | |||
40 | void setAccountId(const QString& accountId); | | |||
41 | Q_SIGNAL void accountIdChanged(); | | |||
42 | | ||||
43 | QString serviceId() const; | | |||
44 | void setServiceId(const QString& serviceId); | | |||
45 | Q_SIGNAL void serviceIdChanged(); | | |||
46 | | ||||
47 | bool serviceEnabled() const; | | |||
48 | void setServiceEnabled(bool serviceEnabled); | | |||
49 | Q_SIGNAL void serviceEnabledChanged(); | | |||
50 | private: | 56 | private: | ||
51 | class Private; | 57 | class Private; | ||
52 | Private* d; | 58 | Private *d; | ||
53 | }; | 59 | }; | ||
54 | #endif//ACCOUNTSERVICETOGGLE_H | 60 | | ||
61 | #endif //ACCOUNTS_MODEL_H |