diff options
Diffstat (limited to 'framework/src')
-rw-r--r-- | framework/src/accounts/accountsmodel.cpp | 24 | ||||
-rw-r--r-- | framework/src/accounts/accountsmodel.h | 4 |
2 files changed, 28 insertions, 0 deletions
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 | |||
103 | { | 103 | { |
104 | return {}; | 104 | return {}; |
105 | } | 105 | } |
106 | |||
107 | void AccountsModel::setResourceId(const QByteArray &resourceId) | ||
108 | { | ||
109 | qWarning() << "Setting resource id" << resourceId; | ||
110 | if (resourceId.isEmpty()) { | ||
111 | setSourceModel(nullptr); | ||
112 | mModel.clear(); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | Sink::Store::fetchOne<SinkResource>(Sink::Query{}.filter(resourceId)).guard(this).then([this] (const Sink::ApplicationDomain::SinkResource &resource) { | ||
117 | Sink::Query query; | ||
118 | query.filter(resource.getAccount()); | ||
119 | query.request<SinkAccount::Name>(); | ||
120 | query.request<SinkAccount::Icon>(); | ||
121 | query.request<SinkAccount::Status>(); | ||
122 | runQuery(query); | ||
123 | }).exec(); | ||
124 | } | ||
125 | |||
126 | QByteArray AccountsModel::resourceId() const | ||
127 | { | ||
128 | return {}; | ||
129 | } | ||
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 | |||
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId) | 35 | Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId) |
36 | Q_PROPERTY (QByteArray resourceId READ resourceId WRITE setResourceId) | ||
36 | public: | 37 | public: |
37 | enum Status { | 38 | enum Status { |
38 | OfflineStatus, | 39 | OfflineStatus, |
@@ -61,6 +62,9 @@ public: | |||
61 | void setAccountId(const QByteArray &id); | 62 | void setAccountId(const QByteArray &id); |
62 | QByteArray accountId() const; | 63 | QByteArray accountId() const; |
63 | 64 | ||
65 | void setResourceId(const QByteArray &id); | ||
66 | QByteArray resourceId() const; | ||
67 | |||
64 | private: | 68 | private: |
65 | void runQuery(const Sink::Query &query); | 69 | void runQuery(const Sink::Query &query); |
66 | QSharedPointer<QAbstractItemModel> mModel; | 70 | QSharedPointer<QAbstractItemModel> mModel; |