| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef SENDERIDENTITIES_H |
| 19 |
#define SENDERIDENTITIES_H |
| 20 |
|
| 21 |
#include <QObject> |
| 22 |
#include <QmlObjectListModel.h> |
| 23 |
#include <Account.h> |
| 24 |
#include <Identities.h> |
| 25 |
#include <Helpers.h> |
| 26 |
|
| 27 |
class IdentityWrapper : public QObject |
| 28 |
{ |
| 29 |
Q_OBJECT |
| 30 |
QML_WRITABLE_PROPERTY(Account*, account) |
| 31 |
QML_WRITABLE_PROPERTY(Identity*, identity) |
| 32 |
public: |
| 33 |
explicit IdentityWrapper(QObject *parent = Q_NULLPTR) : |
| 34 |
QObject(parent), m_account(0), m_identity(0) {} |
| 35 |
}; |
| 36 |
|
| 37 |
class SenderIdentities : public QObject |
| 38 |
{ |
| 39 |
Q_OBJECT |
| 40 |
Q_PROPERTY(QObject *model READ model NOTIFY modelsChanged) |
| 41 |
|
| 42 |
Q_PROPERTY(QObject *accountsModel READ accountsModel WRITE setAccountsModel NOTIFY modelsChanged) |
| 43 |
Q_PROPERTY(Identities *accountIdentities READ identities WRITE setIdentities NOTIFY modelsChanged) |
| 44 |
Q_PROPERTY(QObject *selectedAccount READ selectedAccount NOTIFY selectedIndexChanged) |
| 45 |
Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged) |
| 46 |
public: |
| 47 |
explicit SenderIdentities(QObject *parent = 0); |
| 48 |
|
| 49 |
QObject *model() const; |
| 50 |
int selectedIndex() const; |
| 51 |
QObject *selectedAccount() const; |
| 52 |
QObject *accountsModel() const; |
| 53 |
bool isEmpty(); |
| 54 |
bool hasAddress(const QString &address); |
| 55 |
|
| 56 |
Identities *identities() const; |
| 57 |
|
| 58 |
int determinePreferredIdentity(const QMailMessage &message); |
| 59 |
|
| 60 |
signals: |
| 61 |
void selectedIndexChanged(); |
| 62 |
void modelsChanged(); |
| 63 |
|
| 64 |
public slots: |
| 65 |
void setSelectedIndex(int selectedIndex); |
| 66 |
void setAccountsModel(QObject *accountsModel); |
| 67 |
void setSelectedIndexFromAccountId(quint64 accountId); |
| 68 |
void reset(); |
| 69 |
void setIdentities(Identities *accountIdentities); |
| 70 |
|
| 71 |
private slots: |
| 72 |
void accountsChanged(void); |
| 73 |
|
| 74 |
private: |
| 75 |
int findIndexOf(const quint64 &id); |
| 76 |
IdentityWrapper *createIdentityFromAccount(Account *account); |
| 77 |
IdentityWrapper *createIdentity(Account *account, const QVariantMap &identity); |
| 78 |
int m_selectedIndex; |
| 79 |
QQmlObjectListModel<Account> *m_accountsModel; |
| 80 |
Identities *m_accountIdentities; |
| 81 |
QQmlObjectListModel<IdentityWrapper> *m_model; |
| 82 |
}; |
| 83 |
|
| 84 |
#endif |