Debian Codegraph @

Dekko/backend/accounts/Accounts.h

raw symbols SCIP
1 /* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
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 as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
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, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef ACCOUNTS_H
19 #define ACCOUNTS_H
20
21 #include <QDebug>
22 #include <QLoggingCategory>
23 #include <QObject>
24 #include <qmailaccount.h>
25 #include <qmailaccountkey.h>
26 #include <QmlObjectListModel.h>
27
28 #include "Account.h"
29
30 Q_DECLARE_LOGGING_CATEGORY(D_ACCOUNTS_LIST)
31
32 /** @short Accounts class is the main interface for accessing all account related activities.
33 *
34 * It includes a child "model" property which provides a QList style model that can be used to access specific account actions
35 *
36 * \ingroup group_accounts
37 */
38 class Accounts : public QObject
39 {
40 Q_OBJECT
41 Q_PROPERTY(Filters filter READ filter WRITE setFilter NOTIFY filterChanged)
42 Q_PROPERTY(QObject *model READ model NOTIFY modelChanged)
43 Q_ENUMS(Filters)
44 public:
45 explicit Accounts(QObject *parent = 0);
46
47 enum Filters {
48 Enabled,
49 CanReceive,
50 CanSend,
51 Synchronized,
52 HasPersitentConnection
53 };
54
55 static quint64 maskForFilter(Accounts::Filters filter);
56 Filters filter() const;
57 QObject *model() { return m_model; }
58 QQmlObjectListModel<Account> *internalModel() { return m_model; }
59
60 Q_INVOKABLE bool deleteAccount(const quint64 &id);
61 Q_INVOKABLE bool hasAccount(const quint64 &id);
62 Q_INVOKABLE Account *get(const quint64 &id);
63
64 signals:
65 void filterChanged(Filters filter);
66 void modelChanged();
67
68 public slots:
69 void setFilter(Filters filter);
70 void reset();
71
72 private slots:
73 void accountsAdded(const QMailAccountIdList &ids);
74 void accountsUpdated(const QMailAccountIdList &ids);
75 void accountsRemoved(const QMailAccountIdList &ids);
76
77 private:
78 Filters m_filter;
79 QQmlObjectListModel<Account> *m_model;
80 QMailAccountIdList m_idList;
81 void init();
82 };
83
84 #endif // ACCOUNTS_H