diff options
-rw-r--r-- | components/mail/contents/ui/Mail.qml | 32 | ||||
-rw-r--r-- | framework/accounts/accountsmodel.cpp | 33 | ||||
-rw-r--r-- | framework/accounts/accountsmodel.h | 4 |
3 files changed, 55 insertions, 14 deletions
diff --git a/components/mail/contents/ui/Mail.qml b/components/mail/contents/ui/Mail.qml index 528c9073..1ae4062d 100644 --- a/components/mail/contents/ui/Mail.qml +++ b/components/mail/contents/ui/Mail.qml | |||
@@ -28,6 +28,7 @@ import org.kube.framework.actions 1.0 as KubeAction | |||
28 | import org.kube.framework.settings 1.0 as KubeSettings | 28 | import org.kube.framework.settings 1.0 as KubeSettings |
29 | import org.kube.framework.domain 1.0 as KubeFramework | 29 | import org.kube.framework.domain 1.0 as KubeFramework |
30 | import org.kube.framework.notifications 1.0 as KubeNotifications | 30 | import org.kube.framework.notifications 1.0 as KubeNotifications |
31 | import org.kube.framework.accounts 1.0 as KubeAccountsFramework | ||
31 | import org.kube.components 1.0 as KubeComponents | 32 | import org.kube.components 1.0 as KubeComponents |
32 | import org.kube.components.accounts 1.0 as KubeAccounts | 33 | import org.kube.components.accounts 1.0 as KubeAccounts |
33 | 34 | ||
@@ -270,16 +271,31 @@ Controls2.ApplicationWindow { | |||
270 | } | 271 | } |
271 | } | 272 | } |
272 | 273 | ||
273 | Text { | 274 | Repeater { |
274 | anchors { | 275 | model: KubeAccountsFramework.AccountsModel { |
275 | bottom: parent.bottom | 276 | accountId: accountSwitcher.accountId |
276 | left: parent.left | ||
277 | leftMargin: Kirigami.Units.smallSpacing | ||
278 | } | 277 | } |
279 | 278 | ||
280 | text: accountSwitcher.accountName | 279 | RowLayout { |
281 | font.weight: Font.DemiBold | 280 | anchors { |
282 | color: "white" | 281 | bottom: parent.bottom |
282 | left: parent.left | ||
283 | leftMargin: Kirigami.Units.smallSpacing | ||
284 | } | ||
285 | Layout.fillHeight: true | ||
286 | |||
287 | Text { | ||
288 | text: model.name | ||
289 | font.weight: Font.DemiBold | ||
290 | color: "white" | ||
291 | } | ||
292 | |||
293 | ToolButton { | ||
294 | visible: model.showStatus | ||
295 | iconName: model.statusIcon | ||
296 | enabled: false | ||
297 | } | ||
298 | } | ||
283 | } | 299 | } |
284 | } | 300 | } |
285 | 301 | ||
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 | } | ||
diff --git a/framework/accounts/accountsmodel.h b/framework/accounts/accountsmodel.h index e3c08cd4..3a2dd712 100644 --- a/framework/accounts/accountsmodel.h +++ b/framework/accounts/accountsmodel.h | |||
@@ -32,6 +32,7 @@ class AccountsModel : public QIdentityProxyModel | |||
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | 34 | ||
35 | Q_PROPERTY (QByteArray accountId READ accountId WRITE setAccountId) | ||
35 | public: | 36 | public: |
36 | AccountsModel(QObject *parent = Q_NULLPTR); | 37 | AccountsModel(QObject *parent = Q_NULLPTR); |
37 | ~AccountsModel(); | 38 | ~AccountsModel(); |
@@ -50,6 +51,9 @@ public: | |||
50 | 51 | ||
51 | QHash<int, QByteArray> roleNames() const; | 52 | QHash<int, QByteArray> roleNames() const; |
52 | 53 | ||
54 | void setAccountId(const QByteArray &id); | ||
55 | QByteArray accountId() const; | ||
56 | |||
53 | private: | 57 | private: |
54 | void runQuery(const Sink::Query &query); | 58 | void runQuery(const Sink::Query &query); |
55 | QSharedPointer<QAbstractItemModel> mModel; | 59 | QSharedPointer<QAbstractItemModel> mModel; |