diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-20 12:03:33 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-20 12:03:33 +0200 |
commit | be511a719851c14c5ea5c1479ed2d814fbd3a8e6 (patch) | |
tree | 96b4d73cb249bd39c24ac627d05201f4ea033e9d | |
parent | fa8703974b98622f3f0dcd31cc1bdef554fb227b (diff) | |
download | kube-be511a719851c14c5ea5c1479ed2d814fbd3a8e6.tar.gz kube-be511a719851c14c5ea5c1479ed2d814fbd3a8e6.zip |
Get the folder name in the status bar
-rw-r--r-- | framework/qml/Messages.qml | 1 | ||||
-rw-r--r-- | framework/qml/StatusBar.qml | 28 | ||||
-rw-r--r-- | framework/src/domain/folderlistmodel.cpp | 24 | ||||
-rw-r--r-- | framework/src/domain/folderlistmodel.h | 4 | ||||
-rw-r--r-- | framework/src/sinkfabric.cpp | 5 |
5 files changed, 56 insertions, 6 deletions
diff --git a/framework/qml/Messages.qml b/framework/qml/Messages.qml index aa43de76..485f7816 100644 --- a/framework/qml/Messages.qml +++ b/framework/qml/Messages.qml | |||
@@ -36,6 +36,7 @@ Item { | |||
36 | 36 | ||
37 | property string notification: "notification" | 37 | property string notification: "notification" |
38 | property string progressNotification: "progressNotification" | 38 | property string progressNotification: "progressNotification" |
39 | property string errorNotification: "errorNotification" | ||
39 | property string search: "search" | 40 | property string search: "search" |
40 | property string synchronize: "synchronize" | 41 | property string synchronize: "synchronize" |
41 | property string reply: "reply" | 42 | property string reply: "reply" |
diff --git a/framework/qml/StatusBar.qml b/framework/qml/StatusBar.qml index fa85f872..ea2b4db5 100644 --- a/framework/qml/StatusBar.qml +++ b/framework/qml/StatusBar.qml | |||
@@ -22,6 +22,18 @@ import org.kube.framework 1.0 as Kube | |||
22 | Item { | 22 | Item { |
23 | id: root | 23 | id: root |
24 | property string accountId: "" | 24 | property string accountId: "" |
25 | property string currentFolderName: "" | ||
26 | property string currentFolderId: "" | ||
27 | property string errorText: "Error" | ||
28 | |||
29 | onCurrentFolderIdChanged: root.currentFolderName = "" | ||
30 | Kube.FolderListModel { | ||
31 | id: folderModel | ||
32 | folderId: root.currentFolderId | ||
33 | onRowsInserted: root.currentFolderName = folderModel.data(folderModel.index(0, 0), Kube.FolderListModel.Name) | ||
34 | onRowsRemoved: root.currentFolderName = "" | ||
35 | } | ||
36 | |||
25 | Repeater { | 37 | Repeater { |
26 | model: Kube.AccountsModel { | 38 | model: Kube.AccountsModel { |
27 | accountId: root.accountId | 39 | accountId: root.accountId |
@@ -44,14 +56,13 @@ Item { | |||
44 | State { | 56 | State { |
45 | name: "busy"; when: model.status == Kube.AccountsModel.BusyStatus | 57 | name: "busy"; when: model.status == Kube.AccountsModel.BusyStatus |
46 | PropertyChanges { target: statusBar; visible: true } | 58 | PropertyChanges { target: statusBar; visible: true } |
47 | PropertyChanges { target: statusText; text: "Synchronizing..."; visible: true } | 59 | PropertyChanges { target: statusText; text: root.currentFolderName.length > 0 ? "Synchronizing " + root.currentFolderName: "Synchronizing..."; visible: true } |
48 | PropertyChanges { target: progressBar; visible: true } | 60 | PropertyChanges { target: progressBar; visible: true } |
49 | }, | 61 | }, |
50 | State { | 62 | State { |
51 | name: "error"; when: model.status == Kube.AccountsModel.ErrorStatus | 63 | name: "error"; when: model.status == Kube.AccountsModel.ErrorStatus |
52 | PropertyChanges { target: statusBar; visible: true } | 64 | PropertyChanges { target: statusBar; visible: true } |
53 | //TODO get to an error description | 65 | PropertyChanges { target: statusText; text: root.errorText; visible: true } |
54 | PropertyChanges { target: statusText; text: "Error"; visible: true } | ||
55 | } | 66 | } |
56 | ] | 67 | ] |
57 | } | 68 | } |
@@ -71,6 +82,17 @@ Item { | |||
71 | progressBar.from = 0 | 82 | progressBar.from = 0 |
72 | progressBar.to = message.total | 83 | progressBar.to = message.total |
73 | progressBar.value = message.progress | 84 | progressBar.value = message.progress |
85 | if (message.folderId) { | ||
86 | root.currentFolderId = message.folderId | ||
87 | } else { | ||
88 | root.currentFolderId = "" | ||
89 | } | ||
90 | } | ||
91 | } | ||
92 | Kube.Listener { | ||
93 | filter: Kube.Messages.errorNotification | ||
94 | onMessageReceived: { | ||
95 | root.errorText = message.message | ||
74 | } | 96 | } |
75 | } | 97 | } |
76 | } | 98 | } |
diff --git a/framework/src/domain/folderlistmodel.cpp b/framework/src/domain/folderlistmodel.cpp index 4437e75b..1ef6f761 100644 --- a/framework/src/domain/folderlistmodel.cpp +++ b/framework/src/domain/folderlistmodel.cpp | |||
@@ -105,7 +105,6 @@ void FolderListModel::setAccountId(const QVariant &accountId) | |||
105 | auto query = Query(); | 105 | auto query = Query(); |
106 | query.resourceFilter<SinkResource::Account>(account); | 106 | query.resourceFilter<SinkResource::Account>(account); |
107 | query.setFlags(Sink::Query::LiveQuery | Sink::Query::UpdateStatus); | 107 | query.setFlags(Sink::Query::LiveQuery | Sink::Query::UpdateStatus); |
108 | query.requestTree<Folder::Parent>(); | ||
109 | query.request<Folder::Name>() | 108 | query.request<Folder::Name>() |
110 | .request<Folder::Icon>() | 109 | .request<Folder::Icon>() |
111 | .request<Folder::Parent>() | 110 | .request<Folder::Parent>() |
@@ -115,6 +114,11 @@ void FolderListModel::setAccountId(const QVariant &accountId) | |||
115 | runQuery(query); | 114 | runQuery(query); |
116 | } | 115 | } |
117 | 116 | ||
117 | QVariant FolderListModel::accountId() const | ||
118 | { | ||
119 | return {}; | ||
120 | } | ||
121 | |||
118 | static int getPriority(const Sink::ApplicationDomain::Folder &folder) | 122 | static int getPriority(const Sink::ApplicationDomain::Folder &folder) |
119 | { | 123 | { |
120 | auto specialPurpose = folder.getSpecialPurpose(); | 124 | auto specialPurpose = folder.getSpecialPurpose(); |
@@ -144,8 +148,22 @@ bool FolderListModel::lessThan(const QModelIndex &left, const QModelIndex &right | |||
144 | return leftPriority < rightPriority; | 148 | return leftPriority < rightPriority; |
145 | } | 149 | } |
146 | 150 | ||
147 | QVariant FolderListModel::accountId() const | 151 | void FolderListModel::setFolderId(const QVariant &folderId) |
148 | { | 152 | { |
149 | return QVariant(); | 153 | const auto folder = folderId.toString().toUtf8(); |
154 | |||
155 | //Get all folders of an account | ||
156 | auto query = Query(); | ||
157 | query.filter(folder); | ||
158 | query.request<Folder::Name>() | ||
159 | .request<Folder::Icon>() | ||
160 | .request<Folder::Parent>() | ||
161 | .request<Folder::SpecialPurpose>(); | ||
162 | query.setId("folder" + folder); | ||
163 | runQuery(query); | ||
150 | } | 164 | } |
151 | 165 | ||
166 | QVariant FolderListModel::folderId() const | ||
167 | { | ||
168 | return {}; | ||
169 | } | ||
diff --git a/framework/src/domain/folderlistmodel.h b/framework/src/domain/folderlistmodel.h index 8f157ca2..0e412202 100644 --- a/framework/src/domain/folderlistmodel.h +++ b/framework/src/domain/folderlistmodel.h | |||
@@ -34,6 +34,7 @@ class FolderListModel : public QSortFilterProxyModel | |||
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | 35 | ||
36 | Q_PROPERTY (QVariant accountId READ accountId WRITE setAccountId) | 36 | Q_PROPERTY (QVariant accountId READ accountId WRITE setAccountId) |
37 | Q_PROPERTY (QVariant folderId READ folderId WRITE setFolderId) | ||
37 | 38 | ||
38 | public: | 39 | public: |
39 | enum Status { | 40 | enum Status { |
@@ -63,6 +64,9 @@ public: | |||
63 | 64 | ||
64 | void setAccountId(const QVariant &accountId); | 65 | void setAccountId(const QVariant &accountId); |
65 | QVariant accountId() const; | 66 | QVariant accountId() const; |
67 | |||
68 | void setFolderId(const QVariant &folderId); | ||
69 | QVariant folderId() const; | ||
66 | protected: | 70 | protected: |
67 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; | 71 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; |
68 | 72 | ||
diff --git a/framework/src/sinkfabric.cpp b/framework/src/sinkfabric.cpp index 8231b7df..82351ebb 100644 --- a/framework/src/sinkfabric.cpp +++ b/framework/src/sinkfabric.cpp | |||
@@ -160,6 +160,7 @@ public: | |||
160 | default: | 160 | default: |
161 | message["message"] = "An unknown error occurred: " + notification.message; | 161 | message["message"] = "An unknown error occurred: " + notification.message; |
162 | } | 162 | } |
163 | Fabric::Fabric{}.postMessage("errorNotification", message); | ||
163 | } else if (notification.type == Sink::Notification::Info) { | 164 | } else if (notification.type == Sink::Notification::Info) { |
164 | if (notification.code == Sink::ApplicationDomain::TransmissionSuccess) { | 165 | if (notification.code == Sink::ApplicationDomain::TransmissionSuccess) { |
165 | message["type"] = Notification::Info; | 166 | message["type"] = Notification::Info; |
@@ -170,6 +171,10 @@ public: | |||
170 | } else if (notification.type == Sink::Notification::Progress) { | 171 | } else if (notification.type == Sink::Notification::Progress) { |
171 | message["progress"] = notification.progress; | 172 | message["progress"] = notification.progress; |
172 | message["total"] = notification.total; | 173 | message["total"] = notification.total; |
174 | if (!notification.entities.isEmpty()) { | ||
175 | message["folderId"] = notification.entities.first(); | ||
176 | } | ||
177 | message["resourceId"] = notification.resource; | ||
173 | Fabric::Fabric{}.postMessage("progressNotification", message); | 178 | Fabric::Fabric{}.postMessage("progressNotification", message); |
174 | return; | 179 | return; |
175 | } else { | 180 | } else { |