diff options
Diffstat (limited to 'framework/domain')
-rw-r--r-- | framework/domain/accountsmodel.cpp | 26 | ||||
-rw-r--r-- | framework/domain/accountsmodel.h | 5 |
2 files changed, 26 insertions, 5 deletions
diff --git a/framework/domain/accountsmodel.cpp b/framework/domain/accountsmodel.cpp index 8a3ab317..1f034283 100644 --- a/framework/domain/accountsmodel.cpp +++ b/framework/domain/accountsmodel.cpp | |||
@@ -23,7 +23,9 @@ AccountsModel::AccountsModel(QObject *parent) : QIdentityProxyModel() | |||
23 | { | 23 | { |
24 | Sink::Query query; | 24 | Sink::Query query; |
25 | query.liveQuery = true; | 25 | query.liveQuery = true; |
26 | query.requestedProperties << "name" << "icon"; | 26 | query.request<Sink::ApplicationDomain::SinkAccount::Name>(); |
27 | query.request<Sink::ApplicationDomain::SinkAccount::Icon>(); | ||
28 | query.request<Sink::ApplicationDomain::SinkAccount::Status>(); | ||
27 | runQuery(query); | 29 | runQuery(query); |
28 | } | 30 | } |
29 | 31 | ||
@@ -39,6 +41,9 @@ QHash< int, QByteArray > AccountsModel::roleNames() const | |||
39 | roles[Name] = "name"; | 41 | roles[Name] = "name"; |
40 | roles[Icon] = "icon"; | 42 | roles[Icon] = "icon"; |
41 | roles[AccountId] = "accountId"; | 43 | roles[AccountId] = "accountId"; |
44 | roles[Status] = "status"; | ||
45 | roles[StatusIcon] = "statusIcon"; | ||
46 | roles[ShowStatus] = "showStatus"; | ||
42 | 47 | ||
43 | return roles; | 48 | return roles; |
44 | } | 49 | } |
@@ -46,13 +51,26 @@ QHash< int, QByteArray > AccountsModel::roleNames() const | |||
46 | QVariant AccountsModel::data(const QModelIndex &idx, int role) const | 51 | QVariant AccountsModel::data(const QModelIndex &idx, int role) const |
47 | { | 52 | { |
48 | auto srcIdx = mapToSource(idx); | 53 | auto srcIdx = mapToSource(idx); |
54 | auto account = srcIdx.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::SinkAccount::Ptr>(); | ||
49 | switch (role) { | 55 | switch (role) { |
50 | case Name: | 56 | case Name: |
51 | return srcIdx.sibling(srcIdx.row(), 0).data(Qt::DisplayRole).toString(); | 57 | return account->getName(); |
52 | case Icon: | 58 | case Icon: |
53 | return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); | 59 | return account->getIcon(); |
54 | case AccountId: | 60 | case AccountId: |
55 | return srcIdx.data(Sink::Store::DomainObjectBaseRole).value<Sink::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); | 61 | return account->identifier(); |
62 | case Status: | ||
63 | return account->getStatus(); | ||
64 | case StatusIcon: | ||
65 | if (account->getStatus() == Sink::ApplicationDomain::ErrorStatus) { | ||
66 | return "emblem-error"; | ||
67 | } else if (account->getStatus() == Sink::ApplicationDomain::BusyStatus) { | ||
68 | return "view-refresh"; | ||
69 | } else if (account->getStatus() == Sink::ApplicationDomain::ConnectedStatus) { | ||
70 | return "checkmark"; | ||
71 | } | ||
72 | case ShowStatus: | ||
73 | return (account->getStatus() != Sink::ApplicationDomain::OfflineStatus); | ||
56 | } | 74 | } |
57 | return QIdentityProxyModel::data(idx, role); | 75 | return QIdentityProxyModel::data(idx, role); |
58 | } | 76 | } |
diff --git a/framework/domain/accountsmodel.h b/framework/domain/accountsmodel.h index 9180bc09..e3c08cd4 100644 --- a/framework/domain/accountsmodel.h +++ b/framework/domain/accountsmodel.h | |||
@@ -41,7 +41,10 @@ public: | |||
41 | enum Roles { | 41 | enum Roles { |
42 | Name = Qt::UserRole + 1, | 42 | Name = Qt::UserRole + 1, |
43 | Icon, | 43 | Icon, |
44 | AccountId | 44 | AccountId, |
45 | Status, | ||
46 | StatusIcon, | ||
47 | ShowStatus | ||
45 | }; | 48 | }; |
46 | Q_ENUMS(Roles) | 49 | Q_ENUMS(Roles) |
47 | 50 | ||