summaryrefslogtreecommitdiffstats
path: root/framework/domain/folderlistmodel.cpp
diff options
context:
space:
mode:
authorSandro Knauß <sknauss@kde.org>2016-10-10 13:01:15 +0200
committerSandro Knauß <sknauss@kde.org>2016-10-10 13:01:15 +0200
commit6b6f20ffbe06402abcc7d4721ad1f647c3fc4c46 (patch)
tree6e2762d879c64373519b0506e9a66ddc27f04830 /framework/domain/folderlistmodel.cpp
parent349e404b539c1f9d1feb54658e2e6fbbd2165462 (diff)
parent5fa8608e9877eab40336a60ed8ed979aaf3cfbd0 (diff)
downloadkube-6b6f20ffbe06402abcc7d4721ad1f647c3fc4c46.tar.gz
kube-6b6f20ffbe06402abcc7d4721ad1f647c3fc4c46.zip
Merge branch 'develop' into dev/mimetreeinterface
Diffstat (limited to 'framework/domain/folderlistmodel.cpp')
-rw-r--r--framework/domain/folderlistmodel.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp
index 14d3d5a7..7cf5ad5d 100644
--- a/framework/domain/folderlistmodel.cpp
+++ b/framework/domain/folderlistmodel.cpp
@@ -22,11 +22,14 @@
22#include <sink/store.h> 22#include <sink/store.h>
23#include <settings/settings.h> 23#include <settings/settings.h>
24 24
25using namespace Sink;
26using namespace Sink::ApplicationDomain;
27
25FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel() 28FolderListModel::FolderListModel(QObject *parent) : QIdentityProxyModel()
26{ 29{
27 Sink::Query query; 30 Query query;
28 query.liveQuery = true; 31 query.liveQuery = true;
29 query.requestedProperties << "name" << "icon" << "parent"; 32 query.request<Folder::Name>().request<Folder::Icon>().request<Folder::Parent>();
30 query.parentProperty = "parent"; 33 query.parentProperty = "parent";
31 runQuery(query); 34 runQuery(query);
32} 35}
@@ -57,34 +60,32 @@ QVariant FolderListModel::data(const QModelIndex &idx, int role) const
57 case Icon: 60 case Icon:
58 return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); 61 return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString();
59 case Id: 62 case Id:
60 return srcIdx.data(Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); 63 return srcIdx.data(Store::DomainObjectBaseRole).value<ApplicationDomainType::Ptr>()->identifier();
61 case DomainObject: 64 case DomainObject:
62 return srcIdx.data(Sink::Store::DomainObjectRole); 65 return srcIdx.data(Store::DomainObjectRole);
63 } 66 }
64 return QIdentityProxyModel::data(idx, role); 67 return QIdentityProxyModel::data(idx, role);
65} 68}
66 69
67void FolderListModel::runQuery(const Sink::Query &query) 70void FolderListModel::runQuery(const Query &query)
68{ 71{
69 mModel = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); 72 mModel = Store::loadModel<Folder>(query);
70 setSourceModel(mModel.data()); 73 setSourceModel(mModel.data());
71} 74}
72 75
73void FolderListModel::setAccountId(const QVariant &accountId) 76void FolderListModel::setAccountId(const QVariant &accountId)
74{ 77{
75 const auto account = accountId.toString().toUtf8(); 78 const auto account = accountId.toString().toUtf8();
76 Sink::Store::fetchAll<Sink::ApplicationDomain::SinkResource>(Sink::Query::PropertyFilter("account", QVariant::fromValue(account))) 79
77 .then<void, QList<Sink::ApplicationDomain::SinkResource::Ptr>>([this, account](const QList<Sink::ApplicationDomain::SinkResource::Ptr> &resources) { 80 //Get all folders of an account
78 Sink::Query query; 81 auto query = Query();
79 query.liveQuery = true; 82 query.resourceFilter<SinkResource::Account>(account);
80 query.requestedProperties << "name" << "icon" << "parent"; 83 query.liveQuery = true;
81 query.parentProperty = "parent"; 84 query.request<Folder::Name>()
82 for (const auto &r : resources) { 85 .request<Folder::Icon>()
83 qDebug() << "Found resources for account: " << r->identifier() << account; 86 .request<Folder::Parent>();
84 query.resources << r->identifier(); 87 query.parentProperty = Folder::Parent::name;
85 } 88 runQuery(query);
86 runQuery(query);
87 }).exec();
88} 89}
89 90
90QVariant FolderListModel::accountId() const 91QVariant FolderListModel::accountId() const