| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 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 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 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 |