| 1 |
#ifndef IDENTITIES_H |
| 2 |
#define IDENTITIES_H |
| 3 |
|
| 4 |
#include <QObject> |
| 5 |
#include <MazDB.h> |
| 6 |
#include <Helpers.h> |
| 7 |
#include <qmailmessage.h> |
| 8 |
#include "Identity.h" |
| 9 |
|
| 10 |
typedef QList<QVariantMap> IdentityList; |
| 11 |
|
| 12 |
class Identities : public QObject |
| 13 |
{ |
| 14 |
Q_OBJECT |
| 15 |
QML_READONLY_PROPERTY(QString, sourcePath) |
| 16 |
QML_READONLY_PROPERTY(QString, errorString) |
| 17 |
Q_PROPERTY(int defaultIdentity READ defaultIdentity WRITE setDefaultIdentity NOTIFY defaultIdentityChanged) |
| 18 |
Q_ENUMS(Error) |
| 19 |
public: |
| 20 |
explicit Identities(QObject *parent = 0); |
| 21 |
|
| 22 |
enum Error { |
| 23 |
InvalidId, |
| 24 |
InvalidParent |
| 25 |
}; |
| 26 |
|
| 27 |
Q_INVOKABLE bool add(const QVariantMap &map); |
| 28 |
Q_INVOKABLE bool update(const QVariantMap &map); |
| 29 |
Q_INVOKABLE bool remove(const int &id); |
| 30 |
Q_INVOKABLE bool remove(const QVariantMap &map); |
| 31 |
Q_INVOKABLE bool removeAccount(const int &id); |
| 32 |
Q_INVOKABLE QVariantMap get(const int &id); |
| 33 |
IdentityList getAllForAccount(const int &id); |
| 34 |
|
| 35 |
int defaultIdentity() const; |
| 36 |
|
| 37 |
int determineBestIdentityFromMessage(const QMailMessage &message); |
| 38 |
|
| 39 |
public slots: |
| 40 |
void setDefaultIdentity(int defaultIdentity); |
| 41 |
|
| 42 |
signals: |
| 43 |
void error(Error error); |
| 44 |
void identitiesChanged(); |
| 45 |
void defaultIdentityChanged(int defaultIdentity); |
| 46 |
|
| 47 |
private: |
| 48 |
QString key(const QString &k); |
| 49 |
Q_DISABLE_COPY(Identities) |
| 50 |
MazDB *m_db; |
| 51 |
int m_defaultIdentity; |
| 52 |
}; |
| 53 |
|
| 54 |
#endif |