diff options
Diffstat (limited to 'framework/accounts/accountsmodel.cpp')
-rw-r--r-- | framework/accounts/accountsmodel.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/framework/accounts/accountsmodel.cpp b/framework/accounts/accountsmodel.cpp index ea37784b..f0487f4f 100644 --- a/framework/accounts/accountsmodel.cpp +++ b/framework/accounts/accountsmodel.cpp | |||
@@ -19,13 +19,16 @@ | |||
19 | #include "accountsmodel.h" | 19 | #include "accountsmodel.h" |
20 | #include <sink/store.h> | 20 | #include <sink/store.h> |
21 | 21 | ||
22 | using namespace Sink; | ||
23 | using namespace Sink::ApplicationDomain; | ||
24 | |||
22 | AccountsModel::AccountsModel(QObject *parent) : QIdentityProxyModel() | 25 | AccountsModel::AccountsModel(QObject *parent) : QIdentityProxyModel() |
23 | { | 26 | { |
24 | Sink::Query query; | 27 | Sink::Query query; |
25 | query.setFlags(Sink::Query::LiveQuery); | 28 | query.setFlags(Query::LiveQuery); |
26 | query.request<Sink::ApplicationDomain::SinkAccount::Name>(); | 29 | query.request<SinkAccount::Name>(); |
27 | query.request<Sink::ApplicationDomain::SinkAccount::Icon>(); | 30 | query.request<SinkAccount::Icon>(); |
28 | query.request<Sink::ApplicationDomain::SinkAccount::Status>(); | 31 | query.request<SinkAccount::Status>(); |
29 | runQuery(query); | 32 | runQuery(query); |
30 | } | 33 | } |
31 | 34 | ||
@@ -51,7 +54,7 @@ QHash< int, QByteArray > AccountsModel::roleNames() const | |||
51 | QVariant AccountsModel::data(const QModelIndex &idx, int role) const | 54 | QVariant AccountsModel::data(const QModelIndex &idx, int role) const |
52 | { | 55 | { |
53 | auto srcIdx = mapToSource(idx); | 56 | auto srcIdx = mapToSource(idx); |
54 | auto account = srcIdx.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>(); | 57 | auto account = srcIdx.data(Sink::Store::DomainObjectRole).value<SinkAccount::Ptr>(); |
55 | switch (role) { | 58 | switch (role) { |
56 | case Name: | 59 | case Name: |
57 | return account->getName(); | 60 | return account->getName(); |
@@ -77,6 +80,24 @@ QVariant AccountsModel::data(const QModelIndex &idx, int role) const | |||
77 | 80 | ||
78 | void AccountsModel::runQuery(const Sink::Query &query) | 81 | void AccountsModel::runQuery(const Sink::Query &query) |
79 | { | 82 | { |
80 | mModel = Sink::Store::loadModel<Sink::ApplicationDomain::SinkAccount>(query); | 83 | mModel = Sink::Store::loadModel<SinkAccount>(query); |
81 | setSourceModel(mModel.data()); | 84 | setSourceModel(mModel.data()); |
82 | } | 85 | } |
86 | |||
87 | void AccountsModel::setAccountId(const QByteArray &accountId) | ||
88 | { | ||
89 | qWarning() << "Setting account id" << accountId; | ||
90 | //Get all folders of an account | ||
91 | Sink::Query query; | ||
92 | query.filter(accountId); | ||
93 | query.setFlags(Query::LiveQuery); | ||
94 | query.request<SinkAccount::Name>(); | ||
95 | query.request<SinkAccount::Icon>(); | ||
96 | query.request<SinkAccount::Status>(); | ||
97 | runQuery(query); | ||
98 | } | ||
99 | |||
100 | QByteArray AccountsModel::accountId() const | ||
101 | { | ||
102 | return {}; | ||
103 | } | ||