From 26e02b898d3f4e63c942d2742cb920aec9e6489c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 22 Jul 2017 01:39:09 +0200 Subject: Display corresponding account information with log entry --- framework/src/accounts/accountsmodel.cpp | 24 ++++++++++++++++++++++++ framework/src/accounts/accountsmodel.h | 4 ++++ 2 files changed, 28 insertions(+) (limited to 'framework') diff --git a/framework/src/accounts/accountsmodel.cpp b/framework/src/accounts/accountsmodel.cpp index 8b46f4d3..153cdc45 100644 --- a/framework/src/accounts/accountsmodel.cpp +++ b/framework/src/accounts/accountsmodel.cpp @@ -103,3 +103,27 @@ QByteArray AccountsModel::accountId() const { return {}; } + +void AccountsModel::setResourceId(const QByteArray &resourceId) +{ + qWarning() << "Setting resource id" << resourceId; + if (resourceId.isEmpty()) { + setSourceModel(nullptr); + mModel.clear(); + return; + } + + Sink::Store::fetchOne(Sink::Query{}.filter(resourceId)).guard(this).then([this] (const Sink::ApplicationDomain::SinkResource &resource) { + Sink::Query query; + query.filter(resource.getAccount()); + query.request(); + query.request(); + query.request(); + runQuery(query); + }).exec(); +} + +QByteArray AccountsModel::resourceId() const +{ + return {}; +} diff --git a/framework/src/accounts/accountsmodel.h b/framework/src/accounts/accountsmodel.h index 2c82a8b9..4991f7e0 100644 --- a/framework/src/accounts/accountsmodel.h +++ b/framework/src/accounts/accountsmodel.h @@ -33,6 +33,7 @@ class AccountsModel : public QIdentityProxyModel Q_OBJECT Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId) + Q_PROPERTY (QByteArray resourceId READ resourceId WRITE setResourceId) public: enum Status { OfflineStatus, @@ -61,6 +62,9 @@ public: void setAccountId(const QByteArray &id); QByteArray accountId() const; + void setResourceId(const QByteArray &id); + QByteArray resourceId() const; + private: void runQuery(const Sink::Query &query); QSharedPointer mModel; -- cgit v1.2.3