From b0d06e04e4f4a0c8645288d4a31449215ce58770 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 17 Mar 2016 20:59:19 +0100 Subject: Store accounts in sink --- framework/domain/folderlistmodel.cpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'framework/domain/folderlistmodel.cpp') diff --git a/framework/domain/folderlistmodel.cpp b/framework/domain/folderlistmodel.cpp index f212e336..14d3d5a7 100644 --- a/framework/domain/folderlistmodel.cpp +++ b/framework/domain/folderlistmodel.cpp @@ -72,20 +72,19 @@ void FolderListModel::runQuery(const Sink::Query &query) void FolderListModel::setAccountId(const QVariant &accountId) { - const auto account = accountId.toString(); - Kube::Account accountSettings(account.toUtf8()); - //FIXME maildirResource is obviously not good. We need a way to find resources that belong to the account and provide folders. - const auto resourceId = accountSettings.property("maildirResource").toString(); - qDebug() << "Running query for account " << account; - qDebug() << "Found resources " << resourceId; - - Sink::Query query; - query.liveQuery = true; - query.requestedProperties << "name" << "icon" << "parent"; - query.parentProperty = "parent"; - query.resources << resourceId.toUtf8(); - - runQuery(query); + const auto account = accountId.toString().toUtf8(); + Sink::Store::fetchAll(Sink::Query::PropertyFilter("account", QVariant::fromValue(account))) + .then>([this, account](const QList &resources) { + Sink::Query query; + query.liveQuery = true; + query.requestedProperties << "name" << "icon" << "parent"; + query.parentProperty = "parent"; + for (const auto &r : resources) { + qDebug() << "Found resources for account: " << r->identifier() << account; + query.resources << r->identifier(); + } + runQuery(query); + }).exec(); } QVariant FolderListModel::accountId() const -- cgit v1.2.3