diff options
Diffstat (limited to 'framework/domain/folderlistmodel.cpp')
-rw-r--r-- | framework/domain/folderlistmodel.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index ce6fb4fd..f212e336 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include "folderlistmodel.h" | 21 | #include "folderlistmodel.h" |
22 | #include <sink/store.h> | 22 | #include <sink/store.h> |
23 | #include <settings/settings.h> | ||
23 | 24 | ||
24 | FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() | 25 | FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() |
25 | { | 26 | { |
@@ -27,8 +28,7 @@ FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() | |||
27 | query.liveQuery = true; | 28 | query.liveQuery = true; |
28 | query.requestedProperties << "name" << "icon" << "parent"; | 29 | query.requestedProperties << "name" << "icon" << "parent"; |
29 | query.parentProperty = "parent"; | 30 | query.parentProperty = "parent"; |
30 | mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 31 | runQuery(query); |
31 | setSourceModel(mModel.data()); | ||
32 | } | 32 | } |
33 | 33 | ||
34 | FolderListModel::~FolderListModel() | 34 | FolderListModel::~FolderListModel() |
@@ -63,3 +63,33 @@ QVariant FolderListModel::data(const QModelIndex &idx, int role) const | |||
63 | } | 63 | } |
64 | return QIdentityProxyModel::data(idx, role); | 64 | return QIdentityProxyModel::data(idx, role); |
65 | } | 65 | } |
66 | |||
67 | void FolderListModel::runQuery(const Sink::Query &query) | ||
68 | { | ||
69 | mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | ||
70 | setSourceModel(mModel.data()); | ||
71 | } | ||
72 | |||
73 | void FolderListModel::setAccountId(const QVariant &accountId) | ||
74 | { | ||
75 | const auto account = accountId.toString(); | ||
76 | Kube::Account accountSettings(account.toUtf8()); | ||
77 | //FIXME maildirResource is obviously not good. We need a way to find resources that belong to the account and provide folders. | ||
78 | const auto resourceId = accountSettings.property("maildirResource").toString(); | ||
79 | qDebug() << "Running query for account " << account; | ||
80 | qDebug() << "Found resources " << resourceId; | ||
81 | |||
82 | Sink::Query query; | ||
83 | query.liveQuery = true; | ||
84 | query.requestedProperties << "name" << "icon" << "parent"; | ||
85 | query.parentProperty = "parent"; | ||
86 | query.resources << resourceId.toUtf8(); | ||
87 | |||
88 | runQuery(query); | ||
89 | } | ||
90 | |||
91 | QVariant FolderListModel::accountId() const | ||
92 | { | ||
93 | return QVariant(); | ||
94 | } | ||
95 | |||