| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef FOLDER_H |
| 19 |
#define FOLDER_H |
| 20 |
|
| 21 |
#include <QObject> |
| 22 |
#include <QDBusPendingCallWatcher> |
| 23 |
#include <qmailfolder.h> |
| 24 |
#include <qmailmessagekey.h> |
| 25 |
|
| 26 |
class Folder : public QObject |
| 27 |
{ |
| 28 |
Q_OBJECT |
| 29 |
Q_PROPERTY(int folderId READ folderId WRITE setFolderId NOTIFY folderChanged) |
| 30 |
Q_PROPERTY(QVariant messageKey READ messageKey NOTIFY folderChanged) |
| 31 |
Q_PROPERTY(FolderType type READ type NOTIFY folderChanged) |
| 32 |
Q_PROPERTY(QString name READ name NOTIFY folderChanged) |
| 33 |
Q_PROPERTY(QString path READ path NOTIFY folderChanged) |
| 34 |
Q_PROPERTY(int unreadCount READ unreadCount NOTIFY unreadCountChanged) |
| 35 |
Q_PROPERTY(int totalCount READ totalCount NOTIFY countChanged) |
| 36 |
Q_PROPERTY(bool synchronizationEnabled READ syncEnabled NOTIFY folderChanged) |
| 37 |
Q_PROPERTY(bool isSynchronized READ synced NOTIFY folderChanged) |
| 38 |
Q_PROPERTY(bool partialContent READ partialContent NOTIFY folderChanged) |
| 39 |
Q_PROPERTY(bool canCreateChildren READ canCreateChildren NOTIFY folderChanged) |
| 40 |
Q_PROPERTY(bool canRename READ canRename NOTIFY folderChanged) |
| 41 |
Q_PROPERTY(bool canDelete READ canDelete NOTIFY folderChanged) |
| 42 |
Q_PROPERTY(bool isReadOnly READ readOnly NOTIFY folderChanged) |
| 43 |
Q_PROPERTY(bool isFavourite READ isFavourite WRITE setIsFavourite NOTIFY folderChanged) |
| 44 |
Q_PROPERTY(int nestingDepth READ nestingDepth NOTIFY folderChanged) |
| 45 |
Q_ENUMS(FolderType) |
| 46 |
|
| 47 |
public: |
| 48 |
explicit Folder(QObject *parent = 0); |
| 49 |
Folder(QObject *parent, const QMailFolderId &id, |
| 50 |
const QMailMessageKey &key, const int &type); |
| 51 |
|
| 52 |
Folder(QObject *parent, const QMailAccountId &accountId, |
| 53 |
const QMailFolderId &id, const QMailMessageKey &key, const int &type); |
| 54 |
|
| 55 |
enum FolderType { |
| 56 |
StandardFolder, |
| 57 |
SpecialUseInboxFolder, |
| 58 |
SpecialUseOutboxFolder, |
| 59 |
SpecialUseDraftsFolder, |
| 60 |
SpecialUseSentFolder, |
| 61 |
SpecialUseTrashFolder, |
| 62 |
SpecialUseJunkFolder |
| 63 |
}; |
| 64 |
|
| 65 |
int folderId() const; |
| 66 |
QMailFolderId id() const { return m_folder.id(); } |
| 67 |
QVariant messageKey() const; |
| 68 |
void setMessageKey(const QMailMessageKey &key); |
| 69 |
FolderType type() const; |
| 70 |
void setFolderType(const FolderType type); |
| 71 |
QString name(); |
| 72 |
QString path(); |
| 73 |
int unreadCount(); |
| 74 |
int totalCount() const; |
| 75 |
bool syncEnabled() const; |
| 76 |
bool synced() const; |
| 77 |
bool partialContent() const; |
| 78 |
bool canCreateChildren() const; |
| 79 |
bool canRename() const; |
| 80 |
bool canDelete() const; |
| 81 |
bool readOnly() const; |
| 82 |
bool isFavourite() const; |
| 83 |
int nestingDepth(); |
| 84 |
|
| 85 |
|
| 86 |
void emitFolderChanged() { |
| 87 |
emit folderChanged(); |
| 88 |
} |
| 89 |
void emitCountChanged() { |
| 90 |
emit countChanged(); |
| 91 |
} |
| 92 |
|
| 93 |
static FolderType folderTypeFromId(const QMailFolderId &id); |
| 94 |
static QMailFolder::StandardFolder folderFromType(const FolderType &type); |
| 95 |
|
| 96 |
signals: |
| 97 |
void folderChanged(); |
| 98 |
void countChanged(); |
| 99 |
void unreadCountChanged(); |
| 100 |
|
| 101 |
public slots: |
| 102 |
void setFolderId(const int &id); |
| 103 |
void setIsFavourite(const bool &favourite); |
| 104 |
void handleContentsModified(const QMailFolderIdList &idList); |
| 105 |
|
| 106 |
private slots: |
| 107 |
void updateUnreadCount(); |
| 108 |
void handleUnreadCount(QDBusPendingCallWatcher *call); |
| 109 |
|
| 110 |
private: |
| 111 |
QMailAccountId m_account; |
| 112 |
QMailFolder m_folder; |
| 113 |
QMailMessageKey m_key; |
| 114 |
FolderType m_type; |
| 115 |
int m_unreadCount; |
| 116 |
}; |
| 117 |
#endif |