diff options
author | Michael Bohlender <michael.bohlender@kdemail.net> | 2015-12-07 00:17:51 +0100 |
---|---|---|
committer | Michael Bohlender <michael.bohlender@kdemail.net> | 2015-12-07 00:17:51 +0100 |
commit | 58f9f288fc5b3a7edf42e4dc997fe93418977249 (patch) | |
tree | 0347d0af57ea3fe2eecb795951010a68078897e0 /framework/mail/folderlistmodel.cpp | |
parent | f5b9f73e87d8263428d19b161bdb57b1a5172105 (diff) | |
download | kube-58f9f288fc5b3a7edf42e4dc997fe93418977249.tar.gz kube-58f9f288fc5b3a7edf42e4dc997fe93418977249.zip |
add folderlistmodel
Diffstat (limited to 'framework/mail/folderlistmodel.cpp')
-rw-r--r-- | framework/mail/folderlistmodel.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/framework/mail/folderlistmodel.cpp b/framework/mail/folderlistmodel.cpp new file mode 100644 index 00000000..d7889da4 --- /dev/null +++ b/framework/mail/folderlistmodel.cpp | |||
@@ -0,0 +1,42 @@ | |||
1 | #include "folderlistmodel.h" | ||
2 | #include <akonadi2common/clientapi.h> | ||
3 | |||
4 | FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() | ||
5 | { | ||
6 | Akonadi2::Query query; | ||
7 | query.syncOnDemand = false; | ||
8 | query.processAll = false; | ||
9 | query.liveQuery = true; | ||
10 | QList<QByteArray> requestedProperties; | ||
11 | requestedProperties << "name" << "icon"; | ||
12 | query.requestedProperties = requestedProperties.toSet(); | ||
13 | //TODO | ||
14 | //mModel = Akonadi2::Store::loadModel<Akonadi2::ApplicationDomain::Mail>(query); | ||
15 | //setSourceModel(mModel.data()); | ||
16 | } | ||
17 | |||
18 | FolderListModel::~FolderListModel() | ||
19 | { | ||
20 | |||
21 | } | ||
22 | |||
23 | QHash< int, QByteArray > FolderListModel::roleNames() const | ||
24 | { | ||
25 | QHash<int, QByteArray> roles; | ||
26 | |||
27 | roles[Name] = "name"; | ||
28 | roles[Icon] = "icon"; | ||
29 | |||
30 | return roles; | ||
31 | } | ||
32 | |||
33 | QVariant FolderListModel::data(const QModelIndex &idx, int role) const | ||
34 | { | ||
35 | switch (role) { | ||
36 | case Name: | ||
37 | return mapToSource(idx).data(Qt::DisplayRole).toString(); | ||
38 | case Icon: | ||
39 | return mapToSource(idx).data(Qt::DisplayRole).toString(); | ||
40 | } | ||
41 | return QIdentityProxyModel::data(idx, role); | ||
42 | } | ||