Merge lp:~mzanetti/reminders-app/delete-tags-and-notebooks into lp:reminders-app
- delete-tags-and-notebooks
- Merge into trunk
Proposed by
Michael Zanetti
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Riccardo Padovani | ||||||||
Approved revision: | 369 | ||||||||
Merged at revision: | 369 | ||||||||
Proposed branch: | lp:~mzanetti/reminders-app/delete-tags-and-notebooks | ||||||||
Merge into: | lp:reminders-app | ||||||||
Diff against target: |
1122 lines (+400/-146) 17 files modified
src/app/qml/components/NotebooksDelegate.qml (+46/-37) src/app/qml/components/StatusBar.qml (+4/-2) src/app/qml/components/TagsDelegate.qml (+21/-27) src/app/qml/reminders.qml (+13/-1) src/app/qml/ui/NotebooksPage.qml (+50/-1) src/app/qml/ui/TagsPage.qml (+45/-10) src/libqtevernote/jobs/savenotebookjob.cpp (+2/-0) src/libqtevernote/notebook.cpp (+21/-0) src/libqtevernote/notebook.h (+7/-0) src/libqtevernote/notebooks.cpp (+11/-6) src/libqtevernote/notebooks.h (+3/-3) src/libqtevernote/notesstore.cpp (+164/-42) src/libqtevernote/notesstore.h (+6/-8) src/libqtevernote/tag.cpp (+6/-0) src/libqtevernote/tag.h (+1/-0) src/libqtevernote/tags.cpp (+0/-6) src/libqtevernote/tags.h (+0/-3) |
||||||||
To merge this branch: | bzr merge lp:~mzanetti/reminders-app/delete-tags-and-notebooks | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Riccardo Padovani | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+251677@code.launchpad.net |
Commit message
implement support for deleting notebooks and tags
both features can only be used with offline mode because the evernote api
doesn't allow 3rd Party applications to execute those methods. However,
this required using ListItemWithAction for notebooks and tags and with
that some polishing of those delegates. Also makes better use of the
error label.
Description of the change
To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
review:
Approve
(continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote : | # |
Tested both locally and with online account, works like charm!
Code looks good to me.
Good job!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/app/qml/components/NotebooksDelegate.qml' | |||
2 | --- src/app/qml/components/NotebooksDelegate.qml 2014-12-16 23:01:22 +0000 | |||
3 | +++ src/app/qml/components/NotebooksDelegate.qml 2015-03-04 00:26:40 +0000 | |||
4 | @@ -22,12 +22,38 @@ | |||
5 | 22 | import Ubuntu.Components.ListItems 1.0 | 22 | import Ubuntu.Components.ListItems 1.0 |
6 | 23 | import Evernote 0.1 | 23 | import Evernote 0.1 |
7 | 24 | 24 | ||
9 | 25 | Empty { | 25 | ListItemWithActions { |
10 | 26 | id: root | 26 | id: root |
11 | 27 | height: units.gu(10) | ||
12 | 28 | 27 | ||
13 | 29 | property string notebookColor: preferences.colorForNotebook(model.guid) | 28 | property string notebookColor: preferences.colorForNotebook(model.guid) |
14 | 30 | 29 | ||
15 | 30 | signal deleteNotebook(); | ||
16 | 31 | signal setAsDefault(); | ||
17 | 32 | signal renameNotebook(); | ||
18 | 33 | |||
19 | 34 | leftSideAction: Action { | ||
20 | 35 | iconName: "delete" | ||
21 | 36 | text: i18n.tr("Delete") | ||
22 | 37 | onTriggered: { | ||
23 | 38 | root.deleteNotebook(); | ||
24 | 39 | } | ||
25 | 40 | } | ||
26 | 41 | |||
27 | 42 | rightSideActions: [ | ||
28 | 43 | Action { | ||
29 | 44 | iconName: model.isDefaultNotebook ? "starred" : "non-starred" | ||
30 | 45 | onTriggered: { | ||
31 | 46 | root.setAsDefault(); | ||
32 | 47 | } | ||
33 | 48 | }, | ||
34 | 49 | Action { | ||
35 | 50 | iconName: "edit" | ||
36 | 51 | onTriggered: { | ||
37 | 52 | root.renameNotebook(); | ||
38 | 53 | } | ||
39 | 54 | } | ||
40 | 55 | ] | ||
41 | 56 | |||
42 | 31 | Rectangle { | 57 | Rectangle { |
43 | 32 | anchors.fill: parent | 58 | anchors.fill: parent |
44 | 33 | color: "#f9f9f9" | 59 | color: "#f9f9f9" |
45 | @@ -61,34 +87,6 @@ | |||
46 | 61 | color: root.notebookColor | 87 | color: root.notebookColor |
47 | 62 | fontSize: "large" | 88 | fontSize: "large" |
48 | 63 | Layout.fillWidth: true | 89 | Layout.fillWidth: true |
49 | 64 | |||
50 | 65 | MouseArea { | ||
51 | 66 | onPressAndHold: { | ||
52 | 67 | notebookTitleLabel.visible = false; | ||
53 | 68 | notebookTitleTextField.forceActiveFocus(); | ||
54 | 69 | } | ||
55 | 70 | anchors.fill: parent | ||
56 | 71 | propagateComposedEvents: true | ||
57 | 72 | } | ||
58 | 73 | } | ||
59 | 74 | |||
60 | 75 | TextField { | ||
61 | 76 | id: notebookTitleTextField | ||
62 | 77 | text: model.name | ||
63 | 78 | color: root.notebookColor | ||
64 | 79 | visible: !notebookTitleLabel.visible | ||
65 | 80 | Layout.fillWidth: true | ||
66 | 81 | |||
67 | 82 | InverseMouseArea { | ||
68 | 83 | onClicked: { | ||
69 | 84 | if (notebookTitleTextField.text) { | ||
70 | 85 | notebooks.notebook(index).name = notebookTitleTextField.text; | ||
71 | 86 | NotesStore.saveNotebook(notebooks.notebook(index).guid); | ||
72 | 87 | notebookTitleLabel.visible = true; | ||
73 | 88 | } | ||
74 | 89 | } | ||
75 | 90 | anchors.fill: parent | ||
76 | 91 | } | ||
77 | 92 | } | 90 | } |
78 | 93 | 91 | ||
79 | 94 | Label { | 92 | Label { |
80 | @@ -99,14 +97,25 @@ | |||
81 | 99 | Layout.fillWidth: true | 97 | Layout.fillWidth: true |
82 | 100 | } | 98 | } |
83 | 101 | 99 | ||
86 | 102 | Label { | 100 | Row { |
85 | 103 | objectName: 'notebookPublishedLabel' | ||
87 | 104 | Layout.fillHeight: true | 101 | Layout.fillHeight: true |
93 | 105 | text: model.published ? i18n.tr("Shared") : i18n.tr("Private") | 102 | spacing: units.gu(1) |
94 | 106 | color: model.published ? "black" : "#b3b3b3" | 103 | Icon { |
95 | 107 | fontSize: "x-small" | 104 | height: parent.height |
96 | 108 | verticalAlignment: Text.AlignVCenter | 105 | width: height |
97 | 109 | font.bold: model.published | 106 | name: "starred" |
98 | 107 | visible: model.isDefaultNotebook | ||
99 | 108 | } | ||
100 | 109 | |||
101 | 110 | Label { | ||
102 | 111 | objectName: 'notebookPublishedLabel' | ||
103 | 112 | anchors.verticalCenter: parent.verticalCenter | ||
104 | 113 | text: model.published ? i18n.tr("Shared") : i18n.tr("Private") | ||
105 | 114 | color: model.published ? "black" : "#b3b3b3" | ||
106 | 115 | fontSize: "x-small" | ||
107 | 116 | verticalAlignment: Text.AlignVCenter | ||
108 | 117 | font.bold: model.published | ||
109 | 118 | } | ||
110 | 110 | } | 119 | } |
111 | 111 | } | 120 | } |
112 | 112 | 121 | ||
113 | 113 | 122 | ||
114 | === modified file 'src/app/qml/components/StatusBar.qml' | |||
115 | --- src/app/qml/components/StatusBar.qml 2014-12-08 10:25:48 +0000 | |||
116 | +++ src/app/qml/components/StatusBar.qml 2015-03-04 00:26:40 +0000 | |||
117 | @@ -21,20 +21,22 @@ | |||
118 | 21 | anchors { left: parent.left; top: parent.top; right: parent.right } | 21 | anchors { left: parent.left; top: parent.top; right: parent.right } |
119 | 22 | spacing: units.gu(1) | 22 | spacing: units.gu(1) |
120 | 23 | 23 | ||
122 | 24 | RowLayout { | 24 | Row { |
123 | 25 | anchors { left: parent.left; right: parent.right; margins: units.gu(1) } | 25 | anchors { left: parent.left; right: parent.right; margins: units.gu(1) } |
124 | 26 | spacing: units.gu(1) | 26 | spacing: units.gu(1) |
125 | 27 | height: label.height | ||
126 | 27 | 28 | ||
127 | 28 | Icon { | 29 | Icon { |
128 | 29 | id: icon | 30 | id: icon |
129 | 30 | height: units.gu(3) | 31 | height: units.gu(3) |
130 | 31 | width: height | 32 | width: height |
131 | 32 | color: UbuntuColors.red | 33 | color: UbuntuColors.red |
132 | 34 | anchors.verticalCenter: parent.verticalCenter | ||
133 | 33 | } | 35 | } |
134 | 34 | 36 | ||
135 | 35 | Label { | 37 | Label { |
136 | 36 | id: label | 38 | id: label |
138 | 37 | Layout.fillWidth: true | 39 | width: parent.width - x |
139 | 38 | wrapMode: Text.WordWrap | 40 | wrapMode: Text.WordWrap |
140 | 39 | } | 41 | } |
141 | 40 | } | 42 | } |
142 | 41 | 43 | ||
143 | === modified file 'src/app/qml/components/TagsDelegate.qml' | |||
144 | --- src/app/qml/components/TagsDelegate.qml 2014-12-14 21:52:26 +0000 | |||
145 | +++ src/app/qml/components/TagsDelegate.qml 2015-03-04 00:26:40 +0000 | |||
146 | @@ -22,10 +22,30 @@ | |||
147 | 22 | import Ubuntu.Components.ListItems 1.0 | 22 | import Ubuntu.Components.ListItems 1.0 |
148 | 23 | import Evernote 0.1 | 23 | import Evernote 0.1 |
149 | 24 | 24 | ||
151 | 25 | Empty { | 25 | ListItemWithActions { |
152 | 26 | id: root | 26 | id: root |
153 | 27 | height: units.gu(10) | 27 | height: units.gu(10) |
154 | 28 | 28 | ||
155 | 29 | signal deleteTag(); | ||
156 | 30 | signal renameTag(); | ||
157 | 31 | |||
158 | 32 | leftSideAction: Action { | ||
159 | 33 | iconName: "delete" | ||
160 | 34 | text: i18n.tr("Delete") | ||
161 | 35 | onTriggered: { | ||
162 | 36 | root.deleteTag() | ||
163 | 37 | } | ||
164 | 38 | } | ||
165 | 39 | |||
166 | 40 | rightSideActions: [ | ||
167 | 41 | Action { | ||
168 | 42 | iconName: "edit" | ||
169 | 43 | onTriggered: { | ||
170 | 44 | root.renameTag(); | ||
171 | 45 | } | ||
172 | 46 | } | ||
173 | 47 | ] | ||
174 | 48 | |||
175 | 29 | Rectangle { | 49 | Rectangle { |
176 | 30 | anchors.fill: parent | 50 | anchors.fill: parent |
177 | 31 | color: "#f9f9f9" | 51 | color: "#f9f9f9" |
178 | @@ -58,32 +78,6 @@ | |||
179 | 58 | text: model.name | 78 | text: model.name |
180 | 59 | fontSize: "large" | 79 | fontSize: "large" |
181 | 60 | Layout.fillWidth: true | 80 | Layout.fillWidth: true |
182 | 61 | |||
183 | 62 | MouseArea { | ||
184 | 63 | onPressAndHold: { | ||
185 | 64 | tagTitleLabel.visible = false; | ||
186 | 65 | tagTitleTextField.forceActiveFocus(); | ||
187 | 66 | } | ||
188 | 67 | anchors.fill: parent | ||
189 | 68 | propagateComposedEvents: true | ||
190 | 69 | } | ||
191 | 70 | } | ||
192 | 71 | |||
193 | 72 | TextField { | ||
194 | 73 | id: tagTitleTextField | ||
195 | 74 | text: model.name | ||
196 | 75 | visible: !tagTitleLabel.visible | ||
197 | 76 | |||
198 | 77 | InverseMouseArea { | ||
199 | 78 | onClicked: { | ||
200 | 79 | if (tagTitleTextField.text) { | ||
201 | 80 | tags.tag(index).name = tagTitleTextField.text; | ||
202 | 81 | NotesStore.saveTag(tags.tag(index).guid); | ||
203 | 82 | tagTitleLabel.visible = true; | ||
204 | 83 | } | ||
205 | 84 | } | ||
206 | 85 | anchors.fill: parent | ||
207 | 86 | } | ||
208 | 87 | } | 81 | } |
209 | 88 | } | 82 | } |
210 | 89 | 83 | ||
211 | 90 | 84 | ||
212 | === modified file 'src/app/qml/reminders.qml' | |||
213 | --- src/app/qml/reminders.qml 2015-03-01 22:32:41 +0000 | |||
214 | +++ src/app/qml/reminders.qml 2015-03-04 00:26:40 +0000 | |||
215 | @@ -422,9 +422,21 @@ | |||
216 | 422 | anchors { left: parent.left; right: parent.right; top: parent.top; topMargin: units.gu(9) } | 422 | anchors { left: parent.left; right: parent.right; top: parent.top; topMargin: units.gu(9) } |
217 | 423 | color: root.backgroundColor | 423 | color: root.backgroundColor |
218 | 424 | shown: text | 424 | shown: text |
220 | 425 | text: EvernoteConnection.error || NotesStore.error || NotesStore.notebooksError || NotesStore.tagsError | 425 | text: EvernoteConnection.error || NotesStore.error |
221 | 426 | iconName: "sync-error" | 426 | iconName: "sync-error" |
222 | 427 | 427 | ||
223 | 428 | Timer { | ||
224 | 429 | interval: 5000 | ||
225 | 430 | repeat: true | ||
226 | 431 | running: NotesStore.error | ||
227 | 432 | onTriggered: NotesStore.clearError(); | ||
228 | 433 | } | ||
229 | 434 | |||
230 | 435 | MouseArea { | ||
231 | 436 | anchors.fill: parent | ||
232 | 437 | onClicked: NotesStore.clearError(); | ||
233 | 438 | } | ||
234 | 439 | |||
235 | 428 | } | 440 | } |
236 | 429 | 441 | ||
237 | 430 | PageStack { | 442 | PageStack { |
238 | 431 | 443 | ||
239 | === modified file 'src/app/qml/ui/NotebooksPage.qml' | |||
240 | --- src/app/qml/ui/NotebooksPage.qml 2015-03-01 22:32:41 +0000 | |||
241 | +++ src/app/qml/ui/NotebooksPage.qml 2015-03-04 00:26:40 +0000 | |||
242 | @@ -19,6 +19,7 @@ | |||
243 | 19 | import QtQuick 2.3 | 19 | import QtQuick 2.3 |
244 | 20 | import Ubuntu.Components 1.1 | 20 | import Ubuntu.Components 1.1 |
245 | 21 | import Ubuntu.Components.ListItems 1.0 | 21 | import Ubuntu.Components.ListItems 1.0 |
246 | 22 | import Ubuntu.Components.Popups 1.0 | ||
247 | 22 | import Evernote 0.1 | 23 | import Evernote 0.1 |
248 | 23 | import "../components" | 24 | import "../components" |
249 | 24 | 25 | ||
250 | @@ -116,10 +117,30 @@ | |||
251 | 116 | } | 117 | } |
252 | 117 | 118 | ||
253 | 118 | delegate: NotebooksDelegate { | 119 | delegate: NotebooksDelegate { |
255 | 119 | onClicked: { | 120 | width: parent.width |
256 | 121 | height: units.gu(10) | ||
257 | 122 | triggerActionOnMouseRelease: true | ||
258 | 123 | |||
259 | 124 | onItemClicked: { | ||
260 | 120 | print("selected notebook:", model.guid) | 125 | print("selected notebook:", model.guid) |
261 | 121 | root.openNotebook(model.guid) | 126 | root.openNotebook(model.guid) |
262 | 122 | } | 127 | } |
263 | 128 | |||
264 | 129 | onDeleteNotebook: { | ||
265 | 130 | NotesStore.expungeNotebook(model.guid) | ||
266 | 131 | } | ||
267 | 132 | |||
268 | 133 | onSetAsDefault: { | ||
269 | 134 | NotesStore.setDefaultNotebook(model.guid) | ||
270 | 135 | } | ||
271 | 136 | |||
272 | 137 | onRenameNotebook: { | ||
273 | 138 | var popup = PopupUtils.open(renameNotebookDialogComponent, root, {name: model.name}) | ||
274 | 139 | popup.accepted.connect(function(newName) { | ||
275 | 140 | notebooks.notebook(index).name = newName; | ||
276 | 141 | NotesStore.saveNotebook(model.guid); | ||
277 | 142 | }) | ||
278 | 143 | } | ||
279 | 123 | } | 144 | } |
280 | 124 | 145 | ||
281 | 125 | BouncingProgressBar { | 146 | BouncingProgressBar { |
282 | @@ -170,4 +191,32 @@ | |||
283 | 170 | height: Qt.inputMethod.keyboardRectangle.height | 191 | height: Qt.inputMethod.keyboardRectangle.height |
284 | 171 | } | 192 | } |
285 | 172 | } | 193 | } |
286 | 194 | |||
287 | 195 | Component { | ||
288 | 196 | id: renameNotebookDialogComponent | ||
289 | 197 | Dialog { | ||
290 | 198 | id: renameNotebookDialog | ||
291 | 199 | title: i18n.tr("Rename notebook") | ||
292 | 200 | text: i18n.tr("Enter a new name for notebook %1").arg(name) | ||
293 | 201 | |||
294 | 202 | property string name | ||
295 | 203 | |||
296 | 204 | signal accepted(string newName) | ||
297 | 205 | |||
298 | 206 | TextField { | ||
299 | 207 | id: nameTextField | ||
300 | 208 | text: renameNotebookDialog.name | ||
301 | 209 | placeholderText: i18n.tr("Name cannot be empty") | ||
302 | 210 | } | ||
303 | 211 | |||
304 | 212 | Button { | ||
305 | 213 | text: i18n.tr("OK") | ||
306 | 214 | enabled: nameTextField.text | ||
307 | 215 | onClicked: { | ||
308 | 216 | renameNotebookDialog.accepted(nameTextField.text) | ||
309 | 217 | PopupUtils.close(renameNotebookDialog) | ||
310 | 218 | } | ||
311 | 219 | } | ||
312 | 220 | } | ||
313 | 221 | } | ||
314 | 173 | } | 222 | } |
315 | 174 | 223 | ||
316 | === modified file 'src/app/qml/ui/TagsPage.qml' | |||
317 | --- src/app/qml/ui/TagsPage.qml 2015-03-01 22:32:41 +0000 | |||
318 | +++ src/app/qml/ui/TagsPage.qml 2015-03-04 00:26:40 +0000 | |||
319 | @@ -19,6 +19,7 @@ | |||
320 | 19 | import QtQuick 2.3 | 19 | import QtQuick 2.3 |
321 | 20 | import Ubuntu.Components 1.1 | 20 | import Ubuntu.Components 1.1 |
322 | 21 | import Ubuntu.Components.ListItems 1.0 | 21 | import Ubuntu.Components.ListItems 1.0 |
323 | 22 | import Ubuntu.Components.Popups 1.0 | ||
324 | 22 | import Evernote 0.1 | 23 | import Evernote 0.1 |
325 | 23 | import "../components" | 24 | import "../components" |
326 | 24 | 25 | ||
327 | @@ -80,10 +81,25 @@ | |||
328 | 80 | } | 81 | } |
329 | 81 | 82 | ||
330 | 82 | delegate: TagsDelegate { | 83 | delegate: TagsDelegate { |
332 | 83 | onClicked: { | 84 | width: parent.width |
333 | 85 | height: units.gu(10) | ||
334 | 86 | triggerActionOnMouseRelease: true | ||
335 | 87 | |||
336 | 88 | onItemClicked: { | ||
337 | 84 | print("selected tag:", model.guid) | 89 | print("selected tag:", model.guid) |
338 | 85 | root.openTaggedNotes(model.guid) | 90 | root.openTaggedNotes(model.guid) |
339 | 86 | } | 91 | } |
340 | 92 | onDeleteTag: { | ||
341 | 93 | NotesStore.expungeTag(model.guid); | ||
342 | 94 | } | ||
343 | 95 | |||
344 | 96 | onRenameTag: { | ||
345 | 97 | var popup = PopupUtils.open(renameTagDialogComponent, root, {name: model.name}) | ||
346 | 98 | popup.accepted.connect(function(newName) { | ||
347 | 99 | tags.tag(index).name = newName; | ||
348 | 100 | NotesStore.saveTag(model.guid); | ||
349 | 101 | }) | ||
350 | 102 | } | ||
351 | 87 | } | 103 | } |
352 | 88 | 104 | ||
353 | 89 | ActivityIndicator { | 105 | ActivityIndicator { |
354 | @@ -92,15 +108,6 @@ | |||
355 | 92 | visible: running | 108 | visible: running |
356 | 93 | } | 109 | } |
357 | 94 | 110 | ||
358 | 95 | Label { | ||
359 | 96 | anchors.centerIn: parent | ||
360 | 97 | width: parent.width - units.gu(4) | ||
361 | 98 | wrapMode: Text.WordWrap | ||
362 | 99 | horizontalAlignment: Text.AlignHCenter | ||
363 | 100 | visible: !tags.loading && tags.error | ||
364 | 101 | text: tags.error | ||
365 | 102 | } | ||
366 | 103 | |||
367 | 104 | Scrollbar { | 111 | Scrollbar { |
368 | 105 | flickableItem: parent | 112 | flickableItem: parent |
369 | 106 | } | 113 | } |
370 | @@ -121,4 +128,32 @@ | |||
371 | 121 | horizontalAlignment: Text.AlignHCenter | 128 | horizontalAlignment: Text.AlignHCenter |
372 | 122 | text: i18n.tr("No tags available. You can tag notes while viewing them.") | 129 | text: i18n.tr("No tags available. You can tag notes while viewing them.") |
373 | 123 | } | 130 | } |
374 | 131 | |||
375 | 132 | Component { | ||
376 | 133 | id: renameTagDialogComponent | ||
377 | 134 | Dialog { | ||
378 | 135 | id: renameTagDialog | ||
379 | 136 | title: i18n.tr("Rename tag") | ||
380 | 137 | text: i18n.tr("Enter a new name for tag %1").arg(name) | ||
381 | 138 | |||
382 | 139 | property string name | ||
383 | 140 | |||
384 | 141 | signal accepted(string newName) | ||
385 | 142 | |||
386 | 143 | TextField { | ||
387 | 144 | id: nameTextField | ||
388 | 145 | text: renameTagDialog.name | ||
389 | 146 | placeholderText: i18n.tr("Name cannot be empty") | ||
390 | 147 | } | ||
391 | 148 | |||
392 | 149 | Button { | ||
393 | 150 | text: i18n.tr("OK") | ||
394 | 151 | enabled: nameTextField.text | ||
395 | 152 | onClicked: { | ||
396 | 153 | renameTagDialog.accepted(nameTextField.text) | ||
397 | 154 | PopupUtils.close(renameTagDialog) | ||
398 | 155 | } | ||
399 | 156 | } | ||
400 | 157 | } | ||
401 | 158 | } | ||
402 | 124 | } | 159 | } |
403 | 125 | 160 | ||
404 | === modified file 'src/libqtevernote/jobs/savenotebookjob.cpp' | |||
405 | --- src/libqtevernote/jobs/savenotebookjob.cpp 2014-12-13 03:55:52 +0000 | |||
406 | +++ src/libqtevernote/jobs/savenotebookjob.cpp 2015-03-04 00:26:40 +0000 | |||
407 | @@ -56,6 +56,8 @@ | |||
408 | 56 | m_resultNotebook.__isset.name = true; | 56 | m_resultNotebook.__isset.name = true; |
409 | 57 | m_resultNotebook.updateSequenceNum = m_notebook->updateSequenceNumber(); | 57 | m_resultNotebook.updateSequenceNum = m_notebook->updateSequenceNumber(); |
410 | 58 | m_resultNotebook.__isset.updateSequenceNum = true; | 58 | m_resultNotebook.__isset.updateSequenceNum = true; |
411 | 59 | m_resultNotebook.defaultNotebook = m_notebook->isDefaultNotebook(); | ||
412 | 60 | m_resultNotebook.__isset.defaultNotebook = true; | ||
413 | 59 | 61 | ||
414 | 60 | client()->updateNotebook(token().toStdString(), m_resultNotebook); | 62 | client()->updateNotebook(token().toStdString(), m_resultNotebook); |
415 | 61 | } | 63 | } |
416 | 62 | 64 | ||
417 | === modified file 'src/libqtevernote/notebook.cpp' | |||
418 | --- src/libqtevernote/notebook.cpp 2015-02-24 22:21:04 +0000 | |||
419 | +++ src/libqtevernote/notebook.cpp 2015-03-04 00:26:40 +0000 | |||
420 | @@ -32,6 +32,7 @@ | |||
421 | 32 | m_updateSequenceNumber(updateSequenceNumber), | 32 | m_updateSequenceNumber(updateSequenceNumber), |
422 | 33 | m_guid(guid), | 33 | m_guid(guid), |
423 | 34 | m_published(false), | 34 | m_published(false), |
424 | 35 | m_isDefaultNotebook(false), | ||
425 | 35 | m_loading(false), | 36 | m_loading(false), |
426 | 36 | m_syncError(false) | 37 | m_syncError(false) |
427 | 37 | { | 38 | { |
428 | @@ -41,6 +42,7 @@ | |||
429 | 41 | m_published = infoFile.value("published").toBool(); | 42 | m_published = infoFile.value("published").toBool(); |
430 | 42 | m_lastUpdated = infoFile.value("lastUpdated").toDateTime(); | 43 | m_lastUpdated = infoFile.value("lastUpdated").toDateTime(); |
431 | 43 | m_lastSyncedSequenceNumber = infoFile.value("lastSyncedSequenceNumber", 0).toUInt(); | 44 | m_lastSyncedSequenceNumber = infoFile.value("lastSyncedSequenceNumber", 0).toUInt(); |
432 | 45 | m_isDefaultNotebook = infoFile.value("isDefaultNotebook", false).toBool(); | ||
433 | 44 | m_synced = m_lastSyncedSequenceNumber == m_updateSequenceNumber; | 46 | m_synced = m_lastSyncedSequenceNumber == m_updateSequenceNumber; |
434 | 45 | 47 | ||
435 | 46 | foreach (Note *note, NotesStore::instance()->notes()) { | 48 | foreach (Note *note, NotesStore::instance()->notes()) { |
436 | @@ -77,6 +79,11 @@ | |||
437 | 77 | return m_notesList.count(); | 79 | return m_notesList.count(); |
438 | 78 | } | 80 | } |
439 | 79 | 81 | ||
440 | 82 | QString Notebook::noteAt(int index) const | ||
441 | 83 | { | ||
442 | 84 | return m_notesList.at(index); | ||
443 | 85 | } | ||
444 | 86 | |||
445 | 80 | bool Notebook::published() const | 87 | bool Notebook::published() const |
446 | 81 | { | 88 | { |
447 | 82 | return m_published; | 89 | return m_published; |
448 | @@ -129,6 +136,19 @@ | |||
449 | 129 | return QString(gettext("on %1 %2")).arg(QLocale::system().standaloneMonthName(updateDate.month())).arg(updateDate.year()); | 136 | return QString(gettext("on %1 %2")).arg(QLocale::system().standaloneMonthName(updateDate.month())).arg(updateDate.year()); |
450 | 130 | } | 137 | } |
451 | 131 | 138 | ||
452 | 139 | bool Notebook::isDefaultNotebook() const | ||
453 | 140 | { | ||
454 | 141 | return m_isDefaultNotebook; | ||
455 | 142 | } | ||
456 | 143 | |||
457 | 144 | void Notebook::setIsDefaultNotebook(bool isDefaultNotebook) | ||
458 | 145 | { | ||
459 | 146 | if (m_isDefaultNotebook != isDefaultNotebook) { | ||
460 | 147 | m_isDefaultNotebook = isDefaultNotebook; | ||
461 | 148 | emit isDefaultNotebookChanged(); | ||
462 | 149 | } | ||
463 | 150 | } | ||
464 | 151 | |||
465 | 132 | Notebook *Notebook::clone() | 152 | Notebook *Notebook::clone() |
466 | 133 | { | 153 | { |
467 | 134 | Notebook *notebook = new Notebook(m_guid, m_updateSequenceNumber); | 154 | Notebook *notebook = new Notebook(m_guid, m_updateSequenceNumber); |
468 | @@ -212,6 +232,7 @@ | |||
469 | 212 | infoFile.setValue("published", m_published); | 232 | infoFile.setValue("published", m_published); |
470 | 213 | infoFile.value("lastUpdated", m_lastUpdated); | 233 | infoFile.value("lastUpdated", m_lastUpdated); |
471 | 214 | infoFile.setValue("lastSyncedSequenceNumber", m_lastSyncedSequenceNumber); | 234 | infoFile.setValue("lastSyncedSequenceNumber", m_lastSyncedSequenceNumber); |
472 | 235 | infoFile.setValue("isDefaultNotebook", m_isDefaultNotebook); | ||
473 | 215 | } | 236 | } |
474 | 216 | 237 | ||
475 | 217 | void Notebook::deleteInfoFile() | 238 | void Notebook::deleteInfoFile() |
476 | 218 | 239 | ||
477 | === modified file 'src/libqtevernote/notebook.h' | |||
478 | --- src/libqtevernote/notebook.h 2014-12-13 00:41:41 +0000 | |||
479 | +++ src/libqtevernote/notebook.h 2015-03-04 00:26:40 +0000 | |||
480 | @@ -36,6 +36,7 @@ | |||
481 | 36 | Q_PROPERTY(bool published READ published NOTIFY publishedChanged) | 36 | Q_PROPERTY(bool published READ published NOTIFY publishedChanged) |
482 | 37 | Q_PROPERTY(QDateTime lastUpdated READ lastUpdated NOTIFY lastUpdatedChanged) | 37 | Q_PROPERTY(QDateTime lastUpdated READ lastUpdated NOTIFY lastUpdatedChanged) |
483 | 38 | Q_PROPERTY(QString lastUpdatedString READ lastUpdatedString NOTIFY lastUpdatedChanged) | 38 | Q_PROPERTY(QString lastUpdatedString READ lastUpdatedString NOTIFY lastUpdatedChanged) |
484 | 39 | Q_PROPERTY(bool isDefaultNotebook READ isDefaultNotebook WRITE setIsDefaultNotebook NOTIFY isDefaultNotebookChanged) | ||
485 | 39 | // Don't forget to update clone() if you add new properties | 40 | // Don't forget to update clone() if you add new properties |
486 | 40 | 41 | ||
487 | 41 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) | 42 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) |
488 | @@ -51,6 +52,7 @@ | |||
489 | 51 | void setName(const QString &name); | 52 | void setName(const QString &name); |
490 | 52 | 53 | ||
491 | 53 | int noteCount() const; | 54 | int noteCount() const; |
492 | 55 | QString noteAt(int index) const; | ||
493 | 54 | 56 | ||
494 | 55 | bool published() const; | 57 | bool published() const; |
495 | 56 | void setPublished(bool published); | 58 | void setPublished(bool published); |
496 | @@ -60,6 +62,9 @@ | |||
497 | 60 | 62 | ||
498 | 61 | QString lastUpdatedString() const; | 63 | QString lastUpdatedString() const; |
499 | 62 | 64 | ||
500 | 65 | bool isDefaultNotebook() const; | ||
501 | 66 | void setIsDefaultNotebook(bool isDefaultNotebook); | ||
502 | 67 | |||
503 | 63 | quint32 updateSequenceNumber() const; | 68 | quint32 updateSequenceNumber() const; |
504 | 64 | quint32 lastSyncedSequenceNumber() const; | 69 | quint32 lastSyncedSequenceNumber() const; |
505 | 65 | 70 | ||
506 | @@ -81,6 +86,7 @@ | |||
507 | 81 | void loadingChanged(); | 86 | void loadingChanged(); |
508 | 82 | void syncedChanged(); | 87 | void syncedChanged(); |
509 | 83 | void syncErrorChanged(); | 88 | void syncErrorChanged(); |
510 | 89 | void isDefaultNotebookChanged(); | ||
511 | 84 | 90 | ||
512 | 85 | private slots: | 91 | private slots: |
513 | 86 | void noteAdded(const QString ¬eGuid, const QString ¬ebookGuid); | 92 | void noteAdded(const QString ¬eGuid, const QString ¬ebookGuid); |
514 | @@ -106,6 +112,7 @@ | |||
515 | 106 | QString m_name; | 112 | QString m_name; |
516 | 107 | bool m_published; | 113 | bool m_published; |
517 | 108 | QDateTime m_lastUpdated; | 114 | QDateTime m_lastUpdated; |
518 | 115 | bool m_isDefaultNotebook; | ||
519 | 109 | QList<QString> m_notesList; | 116 | QList<QString> m_notesList; |
520 | 110 | 117 | ||
521 | 111 | QString m_infoFile; | 118 | QString m_infoFile; |
522 | 112 | 119 | ||
523 | === modified file 'src/libqtevernote/notebooks.cpp' | |||
524 | --- src/libqtevernote/notebooks.cpp 2014-12-13 03:55:52 +0000 | |||
525 | +++ src/libqtevernote/notebooks.cpp 2015-03-04 00:26:40 +0000 | |||
526 | @@ -32,7 +32,6 @@ | |||
527 | 32 | } | 32 | } |
528 | 33 | 33 | ||
529 | 34 | connect(NotesStore::instance(), &NotesStore::notebooksLoadingChanged, this, &Notebooks::loadingChanged); | 34 | connect(NotesStore::instance(), &NotesStore::notebooksLoadingChanged, this, &Notebooks::loadingChanged); |
530 | 35 | connect(NotesStore::instance(), &NotesStore::notebooksErrorChanged, this, &Notebooks::errorChanged); | ||
531 | 36 | connect(NotesStore::instance(), &NotesStore::notebookAdded, this, &Notebooks::notebookAdded); | 35 | connect(NotesStore::instance(), &NotesStore::notebookAdded, this, &Notebooks::notebookAdded); |
532 | 37 | connect(NotesStore::instance(), &NotesStore::notebookRemoved, this, &Notebooks::notebookRemoved); | 36 | connect(NotesStore::instance(), &NotesStore::notebookRemoved, this, &Notebooks::notebookRemoved); |
533 | 38 | connect(NotesStore::instance(), &NotesStore::notebookGuidChanged, this, &Notebooks::notebookGuidChanged); | 37 | connect(NotesStore::instance(), &NotesStore::notebookGuidChanged, this, &Notebooks::notebookGuidChanged); |
534 | @@ -43,11 +42,6 @@ | |||
535 | 43 | return NotesStore::instance()->notebooksLoading(); | 42 | return NotesStore::instance()->notebooksLoading(); |
536 | 44 | } | 43 | } |
537 | 45 | 44 | ||
538 | 46 | QString Notebooks::error() const | ||
539 | 47 | { | ||
540 | 48 | return NotesStore::instance()->notebooksError(); | ||
541 | 49 | } | ||
542 | 50 | |||
543 | 51 | int Notebooks::count() const | 45 | int Notebooks::count() const |
544 | 52 | { | 46 | { |
545 | 53 | return rowCount(); | 47 | return rowCount(); |
546 | @@ -76,6 +70,8 @@ | |||
547 | 76 | return notebook->synced(); | 70 | return notebook->synced(); |
548 | 77 | case RoleSyncError: | 71 | case RoleSyncError: |
549 | 78 | return notebook->syncError(); | 72 | return notebook->syncError(); |
550 | 73 | case RoleIsDefaultNotebook: | ||
551 | 74 | return notebook->isDefaultNotebook(); | ||
552 | 79 | } | 75 | } |
553 | 80 | return QVariant(); | 76 | return QVariant(); |
554 | 81 | } | 77 | } |
555 | @@ -99,6 +95,7 @@ | |||
556 | 99 | roles.insert(RoleLoading, "loading"); | 95 | roles.insert(RoleLoading, "loading"); |
557 | 100 | roles.insert(RoleSynced, "synced"); | 96 | roles.insert(RoleSynced, "synced"); |
558 | 101 | roles.insert(RoleSyncError, "syncError"); | 97 | roles.insert(RoleSyncError, "syncError"); |
559 | 98 | roles.insert(RoleIsDefaultNotebook, "isDefaultNotebook"); | ||
560 | 102 | return roles; | 99 | return roles; |
561 | 103 | } | 100 | } |
562 | 104 | 101 | ||
563 | @@ -125,6 +122,7 @@ | |||
564 | 125 | connect(notebook, &Notebook::syncedChanged, this, &Notebooks::syncedChanged); | 122 | connect(notebook, &Notebook::syncedChanged, this, &Notebooks::syncedChanged); |
565 | 126 | connect(notebook, &Notebook::loadingChanged, this, &Notebooks::notebookLoadingChanged); | 123 | connect(notebook, &Notebook::loadingChanged, this, &Notebooks::notebookLoadingChanged); |
566 | 127 | connect(notebook, &Notebook::syncErrorChanged, this, &Notebooks::syncErrorChanged); | 124 | connect(notebook, &Notebook::syncErrorChanged, this, &Notebooks::syncErrorChanged); |
567 | 125 | connect(notebook, &Notebook::isDefaultNotebookChanged, this, &Notebooks::isDefaultNotebookChanged); | ||
568 | 128 | 126 | ||
569 | 129 | beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); | 127 | beginInsertRows(QModelIndex(), m_list.count(), m_list.count()); |
570 | 130 | m_list.append(guid); | 128 | m_list.append(guid); |
571 | @@ -147,6 +145,13 @@ | |||
572 | 147 | emit dataChanged(index(idx), index(idx)); | 145 | emit dataChanged(index(idx), index(idx)); |
573 | 148 | } | 146 | } |
574 | 149 | 147 | ||
575 | 148 | void Notebooks::isDefaultNotebookChanged() | ||
576 | 149 | { | ||
577 | 150 | Notebook *notebook = static_cast<Notebook*>(sender()); | ||
578 | 151 | QModelIndex idx = index(m_list.indexOf((notebook->guid()))); | ||
579 | 152 | emit dataChanged(idx, idx, QVector<int>() << RoleIsDefaultNotebook); | ||
580 | 153 | } | ||
581 | 154 | |||
582 | 150 | void Notebooks::nameChanged() | 155 | void Notebooks::nameChanged() |
583 | 151 | { | 156 | { |
584 | 152 | Notebook *notebook = static_cast<Notebook*>(sender()); | 157 | Notebook *notebook = static_cast<Notebook*>(sender()); |
585 | 153 | 158 | ||
586 | === modified file 'src/libqtevernote/notebooks.h' | |||
587 | --- src/libqtevernote/notebooks.h 2014-12-13 03:55:52 +0000 | |||
588 | +++ src/libqtevernote/notebooks.h 2015-03-04 00:26:40 +0000 | |||
589 | @@ -29,7 +29,6 @@ | |||
590 | 29 | { | 29 | { |
591 | 30 | Q_OBJECT | 30 | Q_OBJECT |
592 | 31 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) | 31 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) |
593 | 32 | Q_PROPERTY(QString error READ error NOTIFY errorChanged) | ||
594 | 33 | Q_PROPERTY(int count READ count NOTIFY countChanged) | 32 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
595 | 34 | 33 | ||
596 | 35 | public: | 34 | public: |
597 | @@ -42,7 +41,8 @@ | |||
598 | 42 | RoleLastUpdatedString, | 41 | RoleLastUpdatedString, |
599 | 43 | RoleLoading, | 42 | RoleLoading, |
600 | 44 | RoleSynced, | 43 | RoleSynced, |
602 | 45 | RoleSyncError | 44 | RoleSyncError, |
603 | 45 | RoleIsDefaultNotebook | ||
604 | 46 | }; | 46 | }; |
605 | 47 | explicit Notebooks(QObject *parent = 0); | 47 | explicit Notebooks(QObject *parent = 0); |
606 | 48 | 48 | ||
607 | @@ -61,7 +61,6 @@ | |||
608 | 61 | 61 | ||
609 | 62 | signals: | 62 | signals: |
610 | 63 | void loadingChanged(); | 63 | void loadingChanged(); |
611 | 64 | void errorChanged(); | ||
612 | 65 | void countChanged(); | 64 | void countChanged(); |
613 | 66 | 65 | ||
614 | 67 | private slots: | 66 | private slots: |
615 | @@ -76,6 +75,7 @@ | |||
616 | 76 | void syncedChanged(); | 75 | void syncedChanged(); |
617 | 77 | void notebookLoadingChanged(); | 76 | void notebookLoadingChanged(); |
618 | 78 | void syncErrorChanged(); | 77 | void syncErrorChanged(); |
619 | 78 | void isDefaultNotebookChanged(); | ||
620 | 79 | 79 | ||
621 | 80 | private: | 80 | private: |
622 | 81 | QList<QString> m_list; | 81 | QList<QString> m_list; |
623 | 82 | 82 | ||
624 | === modified file 'src/libqtevernote/notesstore.cpp' | |||
625 | --- src/libqtevernote/notesstore.cpp 2015-02-28 03:59:56 +0000 | |||
626 | +++ src/libqtevernote/notesstore.cpp 2015-03-04 00:26:40 +0000 | |||
627 | @@ -143,17 +143,7 @@ | |||
628 | 143 | 143 | ||
629 | 144 | QString NotesStore::error() const | 144 | QString NotesStore::error() const |
630 | 145 | { | 145 | { |
642 | 146 | return m_error; | 146 | return m_errorQueue.count() > 0 ? m_errorQueue.first() : QString(); |
632 | 147 | } | ||
633 | 148 | |||
634 | 149 | QString NotesStore::notebooksError() const | ||
635 | 150 | { | ||
636 | 151 | return m_notebooksError; | ||
637 | 152 | } | ||
638 | 153 | |||
639 | 154 | QString NotesStore::tagsError() const | ||
640 | 155 | { | ||
641 | 156 | return m_tagsError; | ||
643 | 157 | } | 147 | } |
644 | 158 | 148 | ||
645 | 159 | int NotesStore::count() const | 149 | int NotesStore::count() const |
646 | @@ -284,6 +274,9 @@ | |||
647 | 284 | { | 274 | { |
648 | 285 | Notebook *notebook = new Notebook(QUuid::createUuid().toString().remove(QRegExp("[\{\}]*")), 1, this); | 275 | Notebook *notebook = new Notebook(QUuid::createUuid().toString().remove(QRegExp("[\{\}]*")), 1, this); |
649 | 286 | notebook->setName(name); | 276 | notebook->setName(name); |
650 | 277 | if (m_notebooks.isEmpty()) { | ||
651 | 278 | notebook->setIsDefaultNotebook(true); | ||
652 | 279 | } | ||
653 | 287 | 280 | ||
654 | 288 | m_notebooks.append(notebook); | 281 | m_notebooks.append(notebook); |
655 | 289 | m_notebooksHash.insert(notebook->guid(), notebook); | 282 | m_notebooksHash.insert(notebook->guid(), notebook); |
656 | @@ -359,6 +352,27 @@ | |||
657 | 359 | emit notebookChanged(notebook->guid()); | 352 | emit notebookChanged(notebook->guid()); |
658 | 360 | } | 353 | } |
659 | 361 | 354 | ||
660 | 355 | void NotesStore::setDefaultNotebook(const QString &guid) | ||
661 | 356 | { | ||
662 | 357 | Notebook *notebook = m_notebooksHash.value(guid); | ||
663 | 358 | if (!notebook) { | ||
664 | 359 | qWarning() << "[NotesStore] Notebook guid not found:" << guid; | ||
665 | 360 | return; | ||
666 | 361 | } | ||
667 | 362 | |||
668 | 363 | qDebug() << "[NotesStore] Setting default notebook:" << guid; | ||
669 | 364 | foreach (Notebook *tmp, m_notebooks) { | ||
670 | 365 | if (tmp->isDefaultNotebook()) { | ||
671 | 366 | tmp->setIsDefaultNotebook(false); | ||
672 | 367 | saveNotebook(tmp->guid()); | ||
673 | 368 | break; | ||
674 | 369 | } | ||
675 | 370 | } | ||
676 | 371 | notebook->setIsDefaultNotebook(true); | ||
677 | 372 | saveNotebook(guid); | ||
678 | 373 | emit defaultNotebookChanged(guid); | ||
679 | 374 | } | ||
680 | 375 | |||
681 | 362 | void NotesStore::saveTag(const QString &guid) | 376 | void NotesStore::saveTag(const QString &guid) |
682 | 363 | { | 377 | { |
683 | 364 | Tag *tag = m_tagsHash.value(guid); | 378 | Tag *tag = m_tagsHash.value(guid); |
684 | @@ -381,9 +395,66 @@ | |||
685 | 381 | 395 | ||
686 | 382 | void NotesStore::expungeNotebook(const QString &guid) | 396 | void NotesStore::expungeNotebook(const QString &guid) |
687 | 383 | { | 397 | { |
691 | 384 | ExpungeNotebookJob *job = new ExpungeNotebookJob(guid); | 398 | if (m_username != "@local") { |
692 | 385 | connect(job, &ExpungeNotebookJob::jobDone, this, &NotesStore::expungeNotebookJobDone); | 399 | qWarning() << "[NotesStore] Account managed by Evernote. Cannot delete notebooks."; |
693 | 386 | EvernoteConnection::instance()->enqueue(job); | 400 | m_errorQueue.append(QString(gettext("This account is managed by Evernote. Use the Evernote website to delete notebooks."))); |
694 | 401 | emit errorChanged(); | ||
695 | 402 | return; | ||
696 | 403 | } | ||
697 | 404 | |||
698 | 405 | Notebook* notebook = m_notebooksHash.value(guid); | ||
699 | 406 | if (!notebook) { | ||
700 | 407 | qWarning() << "[NotesStore] Cannot delete notebook. Notebook not found for guid:" << guid; | ||
701 | 408 | return; | ||
702 | 409 | } | ||
703 | 410 | |||
704 | 411 | if (notebook->isDefaultNotebook()) { | ||
705 | 412 | qWarning() << "[NotesStore] Cannot delete the default notebook."; | ||
706 | 413 | m_errorQueue.append(QString(gettext("Cannot delete the default notebook. Set another notebook to be the default first."))); | ||
707 | 414 | emit errorChanged(); | ||
708 | 415 | return; | ||
709 | 416 | } | ||
710 | 417 | |||
711 | 418 | if (notebook->noteCount() > 0) { | ||
712 | 419 | QString defaultNotebook; | ||
713 | 420 | foreach (const Notebook *notebook, m_notebooks) { | ||
714 | 421 | if (notebook->isDefaultNotebook()) { | ||
715 | 422 | defaultNotebook = notebook->guid(); | ||
716 | 423 | break; | ||
717 | 424 | } | ||
718 | 425 | } | ||
719 | 426 | if (defaultNotebook.isEmpty()) { | ||
720 | 427 | qWarning() << "[NotesStore] No default notebook set. Can't delete notebooks."; | ||
721 | 428 | return; | ||
722 | 429 | } | ||
723 | 430 | |||
724 | 431 | while (notebook->noteCount() > 0) { | ||
725 | 432 | QString noteGuid = notebook->noteAt(0); | ||
726 | 433 | Note *note = m_notesHash.value(noteGuid); | ||
727 | 434 | if (!note) { | ||
728 | 435 | qWarning() << "[NotesStore] Notebook holds a noteGuid which cannot be found in notes store"; | ||
729 | 436 | Q_ASSERT(false); | ||
730 | 437 | continue; | ||
731 | 438 | } | ||
732 | 439 | qDebug() << "[NotesStore] Moving note" << noteGuid << "to default Notebook"; | ||
733 | 440 | note->setNotebookGuid(defaultNotebook); | ||
734 | 441 | saveNote(note->guid()); | ||
735 | 442 | emit noteChanged(note->guid(), defaultNotebook); | ||
736 | 443 | syncToCacheFile(note); | ||
737 | 444 | } | ||
738 | 445 | } | ||
739 | 446 | |||
740 | 447 | m_notebooks.removeAll(notebook); | ||
741 | 448 | m_notebooksHash.remove(notebook->guid()); | ||
742 | 449 | emit notebookRemoved(notebook->guid()); | ||
743 | 450 | |||
744 | 451 | QSettings settings(m_cacheFile, QSettings::IniFormat); | ||
745 | 452 | settings.beginGroup("notebooks"); | ||
746 | 453 | settings.remove(notebook->guid()); | ||
747 | 454 | settings.endGroup(); | ||
748 | 455 | |||
749 | 456 | notebook->deleteInfoFile(); | ||
750 | 457 | notebook->deleteLater(); | ||
751 | 387 | } | 458 | } |
752 | 388 | 459 | ||
753 | 389 | QList<Tag *> NotesStore::tags() const | 460 | QList<Tag *> NotesStore::tags() const |
754 | @@ -548,11 +619,7 @@ | |||
755 | 548 | { | 619 | { |
756 | 549 | switch (errorCode) { | 620 | switch (errorCode) { |
757 | 550 | case EvernoteConnection::ErrorCodeNoError: | 621 | case EvernoteConnection::ErrorCodeNoError: |
763 | 551 | // All is well, reset error code. | 622 | // All is well... |
759 | 552 | if (!m_error.isEmpty()) { | ||
760 | 553 | m_error.clear(); | ||
761 | 554 | emit errorChanged(); | ||
762 | 555 | } | ||
764 | 556 | break; | 623 | break; |
765 | 557 | case EvernoteConnection::ErrorCodeUserException: | 624 | case EvernoteConnection::ErrorCodeUserException: |
766 | 558 | qWarning() << "FetchNotesJobDone: EDAMUserException:" << errorMessage; | 625 | qWarning() << "FetchNotesJobDone: EDAMUserException:" << errorMessage; |
767 | @@ -571,8 +638,6 @@ | |||
768 | 571 | return; // silently discarding... | 638 | return; // silently discarding... |
769 | 572 | default: | 639 | default: |
770 | 573 | qWarning() << "FetchNotesJobDone: Failed to fetch notes list:" << errorMessage << errorCode; | 640 | qWarning() << "FetchNotesJobDone: Failed to fetch notes list:" << errorMessage << errorCode; |
771 | 574 | m_error = QString(gettext("Error refreshing notes: %1")).arg(errorMessage); | ||
772 | 575 | emit errorChanged(); | ||
773 | 576 | m_loading = false; | 641 | m_loading = false; |
774 | 577 | emit loadingChanged(); | 642 | emit loadingChanged(); |
775 | 578 | return; | 643 | return; |
776 | @@ -875,11 +940,7 @@ | |||
777 | 875 | 940 | ||
778 | 876 | switch (errorCode) { | 941 | switch (errorCode) { |
779 | 877 | case EvernoteConnection::ErrorCodeNoError: | 942 | case EvernoteConnection::ErrorCodeNoError: |
785 | 878 | // All is well, reset error code. | 943 | // All is well... |
781 | 879 | if (!m_notebooksError.isEmpty()) { | ||
782 | 880 | m_notebooksError.clear(); | ||
783 | 881 | emit notebooksErrorChanged(); | ||
784 | 882 | } | ||
786 | 883 | break; | 944 | break; |
787 | 884 | case EvernoteConnection::ErrorCodeUserException: | 945 | case EvernoteConnection::ErrorCodeUserException: |
788 | 885 | qWarning() << "FetchNotebooksJobDone: EDAMUserException:" << errorMessage; | 946 | qWarning() << "FetchNotebooksJobDone: EDAMUserException:" << errorMessage; |
789 | @@ -890,19 +951,19 @@ | |||
790 | 890 | return; // silently discarding | 951 | return; // silently discarding |
791 | 891 | default: | 952 | default: |
792 | 892 | qWarning() << "FetchNotebooksJobDone: Failed to fetch notes list:" << errorMessage << errorCode; | 953 | qWarning() << "FetchNotebooksJobDone: Failed to fetch notes list:" << errorMessage << errorCode; |
796 | 893 | m_notebooksError = tr("Error refreshing notebooks: %1").arg(errorMessage); | 954 | return; // silently discarding |
794 | 894 | emit notebooksErrorChanged(); | ||
795 | 895 | return; | ||
797 | 896 | } | 955 | } |
798 | 897 | 956 | ||
799 | 898 | QList<Notebook*> unhandledNotebooks = m_notebooks; | 957 | QList<Notebook*> unhandledNotebooks = m_notebooks; |
800 | 899 | 958 | ||
801 | 959 | qDebug() << "[NotesStore] Have" << results.size() << "from Evernote."; | ||
802 | 900 | for (unsigned int i = 0; i < results.size(); ++i) { | 960 | for (unsigned int i = 0; i < results.size(); ++i) { |
803 | 901 | evernote::edam::Notebook result = results.at(i); | 961 | evernote::edam::Notebook result = results.at(i); |
804 | 902 | Notebook *notebook = m_notebooksHash.value(QString::fromStdString(result.guid)); | 962 | Notebook *notebook = m_notebooksHash.value(QString::fromStdString(result.guid)); |
805 | 903 | unhandledNotebooks.removeAll(notebook); | 963 | unhandledNotebooks.removeAll(notebook); |
806 | 904 | bool newNotebook = notebook == 0; | 964 | bool newNotebook = notebook == 0; |
807 | 905 | if (newNotebook) { | 965 | if (newNotebook) { |
808 | 966 | qDebug() << "[NotesStore] Found new notebook on Evernote:" << QString::fromStdString(result.guid); | ||
809 | 906 | notebook = new Notebook(QString::fromStdString(result.guid), 0, this); | 967 | notebook = new Notebook(QString::fromStdString(result.guid), 0, this); |
810 | 907 | updateFromEDAM(result, notebook); | 968 | updateFromEDAM(result, notebook); |
811 | 908 | m_notebooksHash.insert(notebook->guid(), notebook); | 969 | m_notebooksHash.insert(notebook->guid(), notebook); |
812 | @@ -911,20 +972,25 @@ | |||
813 | 911 | syncToCacheFile(notebook); | 972 | syncToCacheFile(notebook); |
814 | 912 | } else if (notebook->synced()) { | 973 | } else if (notebook->synced()) { |
815 | 913 | if (notebook->updateSequenceNumber() < result.updateSequenceNum) { | 974 | if (notebook->updateSequenceNumber() < result.updateSequenceNum) { |
816 | 975 | qDebug() << "[NotesStore] Notebook on Evernote is newer than local copy. Updating:" << notebook->guid(); | ||
817 | 914 | updateFromEDAM(result, notebook); | 976 | updateFromEDAM(result, notebook); |
818 | 915 | emit notebookChanged(notebook->guid()); | 977 | emit notebookChanged(notebook->guid()); |
819 | 916 | syncToCacheFile(notebook); | 978 | syncToCacheFile(notebook); |
820 | 979 | } else { | ||
821 | 980 | qDebug() << "[NotesStore] Notebook is in sync:" << notebook->guid(); | ||
822 | 917 | } | 981 | } |
823 | 918 | } else { | 982 | } else { |
824 | 919 | // Local notebook changed. See if we can push our changes | 983 | // Local notebook changed. See if we can push our changes |
825 | 920 | if (result.updateSequenceNum == notebook->lastSyncedSequenceNumber()) { | 984 | if (result.updateSequenceNum == notebook->lastSyncedSequenceNumber()) { |
826 | 985 | qDebug() << "[NotesStore] Local Notebook changed. Uploading changes to Evernote:" << notebook->guid(); | ||
827 | 921 | SaveNotebookJob *job = new SaveNotebookJob(notebook); | 986 | SaveNotebookJob *job = new SaveNotebookJob(notebook); |
828 | 922 | connect(job, &SaveNotebookJob::jobDone, this, &NotesStore::saveNotebookJobDone); | 987 | connect(job, &SaveNotebookJob::jobDone, this, &NotesStore::saveNotebookJobDone); |
829 | 923 | EvernoteConnection::instance()->enqueue(job); | 988 | EvernoteConnection::instance()->enqueue(job); |
830 | 924 | notebook->setLoading(true); | 989 | notebook->setLoading(true); |
831 | 925 | emit notebookChanged(notebook->guid()); | 990 | emit notebookChanged(notebook->guid()); |
832 | 926 | } else { | 991 | } else { |
834 | 927 | qWarning() << "CONFLICT in notebook:" << notebook->name(); | 992 | qWarning() << "[NotesStore] Sync conflict in notebook:" << notebook->name(); |
835 | 993 | qWarning() << "[NotesStore] Resolving of sync conflicts is not implemented yet."; | ||
836 | 928 | notebook->setSyncError(true); | 994 | notebook->setSyncError(true); |
837 | 929 | emit notebookChanged(notebook->guid()); | 995 | emit notebookChanged(notebook->guid()); |
838 | 930 | } | 996 | } |
839 | @@ -933,18 +999,20 @@ | |||
840 | 933 | 999 | ||
841 | 934 | foreach (Notebook *notebook, unhandledNotebooks) { | 1000 | foreach (Notebook *notebook, unhandledNotebooks) { |
842 | 935 | if (notebook->lastSyncedSequenceNumber() == 0) { | 1001 | if (notebook->lastSyncedSequenceNumber() == 0) { |
843 | 1002 | qDebug() << "[NotesStore] Have a local notebook that doesn't exist on Evernote. Creating on server:" << notebook->guid(); | ||
844 | 936 | notebook->setLoading(true); | 1003 | notebook->setLoading(true); |
845 | 937 | CreateNotebookJob *job = new CreateNotebookJob(notebook); | 1004 | CreateNotebookJob *job = new CreateNotebookJob(notebook); |
846 | 938 | connect(job, &CreateNotebookJob::jobDone, this, &NotesStore::createNotebookJobDone); | 1005 | connect(job, &CreateNotebookJob::jobDone, this, &NotesStore::createNotebookJobDone); |
847 | 939 | EvernoteConnection::instance()->enqueue(job); | 1006 | EvernoteConnection::instance()->enqueue(job); |
848 | 940 | emit notebookChanged(notebook->guid()); | 1007 | emit notebookChanged(notebook->guid()); |
849 | 941 | } else { | 1008 | } else { |
850 | 1009 | qDebug() << "[NotesStore] Notebook has been deleted on the server. Deleting local copy:" << notebook->guid(); | ||
851 | 942 | m_notebooks.removeAll(notebook); | 1010 | m_notebooks.removeAll(notebook); |
852 | 943 | m_notebooksHash.remove(notebook->guid()); | 1011 | m_notebooksHash.remove(notebook->guid()); |
853 | 944 | emit notebookRemoved(notebook->guid()); | 1012 | emit notebookRemoved(notebook->guid()); |
854 | 945 | 1013 | ||
855 | 946 | QSettings settings(m_cacheFile, QSettings::IniFormat); | 1014 | QSettings settings(m_cacheFile, QSettings::IniFormat); |
857 | 947 | settings.beginGroup("notenooks"); | 1015 | settings.beginGroup("notebooks"); |
858 | 948 | settings.remove(notebook->guid()); | 1016 | settings.remove(notebook->guid()); |
859 | 949 | settings.endGroup(); | 1017 | settings.endGroup(); |
860 | 950 | 1018 | ||
861 | @@ -967,6 +1035,14 @@ | |||
862 | 967 | EvernoteConnection::instance()->enqueue(job); | 1035 | EvernoteConnection::instance()->enqueue(job); |
863 | 968 | } | 1036 | } |
864 | 969 | 1037 | ||
865 | 1038 | void NotesStore::clearError() | ||
866 | 1039 | { | ||
867 | 1040 | if (m_errorQueue.count() > 0) { | ||
868 | 1041 | m_errorQueue.takeFirst(); | ||
869 | 1042 | emit errorChanged(); | ||
870 | 1043 | } | ||
871 | 1044 | } | ||
872 | 1045 | |||
873 | 970 | void NotesStore::fetchTagsJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const std::vector<evernote::edam::Tag> &results) | 1046 | void NotesStore::fetchTagsJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const std::vector<evernote::edam::Tag> &results) |
874 | 971 | { | 1047 | { |
875 | 972 | m_tagsLoading = false; | 1048 | m_tagsLoading = false; |
876 | @@ -974,11 +1050,7 @@ | |||
877 | 974 | 1050 | ||
878 | 975 | switch (errorCode) { | 1051 | switch (errorCode) { |
879 | 976 | case EvernoteConnection::ErrorCodeNoError: | 1052 | case EvernoteConnection::ErrorCodeNoError: |
885 | 977 | // All is well, reset error code. | 1053 | // All is well... |
881 | 978 | if (!m_tagsError.isEmpty()) { | ||
882 | 979 | m_tagsError.clear(); | ||
883 | 980 | emit tagsErrorChanged(); | ||
884 | 981 | } | ||
886 | 982 | break; | 1054 | break; |
887 | 983 | case EvernoteConnection::ErrorCodeUserException: | 1055 | case EvernoteConnection::ErrorCodeUserException: |
888 | 984 | qWarning() << "FetchTagsJobDone: EDAMUserException:" << errorMessage; | 1056 | qWarning() << "FetchTagsJobDone: EDAMUserException:" << errorMessage; |
889 | @@ -989,9 +1061,7 @@ | |||
890 | 989 | return; // silently discarding | 1061 | return; // silently discarding |
891 | 990 | default: | 1062 | default: |
892 | 991 | qWarning() << "FetchTagsJobDone: Failed to fetch notes list:" << errorMessage << errorCode; | 1063 | qWarning() << "FetchTagsJobDone: Failed to fetch notes list:" << errorMessage << errorCode; |
896 | 992 | m_tagsError = tr("Error refreshing tags: %1").arg(errorMessage); | 1064 | return; // silently discarding |
894 | 993 | emit tagsErrorChanged(); | ||
895 | 994 | return; | ||
897 | 995 | } | 1065 | } |
898 | 996 | 1066 | ||
899 | 997 | QHash<QString, Tag*> unhandledTags = m_tagsHash; | 1067 | QHash<QString, Tag*> unhandledTags = m_tagsHash; |
900 | @@ -1067,10 +1137,18 @@ | |||
901 | 1067 | connect(note, &Note::reminderDoneChanged, this, &NotesStore::emitDataChanged); | 1137 | connect(note, &Note::reminderDoneChanged, this, &NotesStore::emitDataChanged); |
902 | 1068 | 1138 | ||
903 | 1069 | note->setTitle(title); | 1139 | note->setTitle(title); |
907 | 1070 | if (notebookGuid.isEmpty() && m_notebooks.count() > 0) { | 1140 | |
908 | 1071 | note->setNotebookGuid(m_notebooks.first()->guid()); | 1141 | if (!notebookGuid.isEmpty()) { |
906 | 1072 | } else { | ||
909 | 1073 | note->setNotebookGuid(notebookGuid); | 1142 | note->setNotebookGuid(notebookGuid); |
910 | 1143 | } else if (m_notebooks.count() > 0){ | ||
911 | 1144 | QString generatedNotebook = m_notebooks.first()->guid(); | ||
912 | 1145 | foreach (Notebook *notebook, m_notebooks) { | ||
913 | 1146 | if (notebook->isDefaultNotebook()) { | ||
914 | 1147 | generatedNotebook = notebook->guid(); | ||
915 | 1148 | break; | ||
916 | 1149 | } | ||
917 | 1150 | } | ||
918 | 1151 | note->setNotebookGuid(generatedNotebook); | ||
919 | 1074 | } | 1152 | } |
920 | 1075 | note->setEnmlContent(content.enml()); | 1153 | note->setEnmlContent(content.enml()); |
921 | 1076 | note->setCreated(QDateTime::currentDateTime()); | 1154 | note->setCreated(QDateTime::currentDateTime()); |
922 | @@ -1534,5 +1612,49 @@ | |||
923 | 1534 | if (evNotebook.__isset.published && evNotebook.published != notebook->published()) { | 1612 | if (evNotebook.__isset.published && evNotebook.published != notebook->published()) { |
924 | 1535 | notebook->setPublished(evNotebook.published); | 1613 | notebook->setPublished(evNotebook.published); |
925 | 1536 | } | 1614 | } |
926 | 1615 | qDebug() << "readong from evernote:" << evNotebook.__isset.defaultNotebook << evNotebook.defaultNotebook << notebook->name(); | ||
927 | 1616 | if (evNotebook.__isset.defaultNotebook && evNotebook.defaultNotebook != notebook->isDefaultNotebook()) { | ||
928 | 1617 | notebook->setIsDefaultNotebook(evNotebook.defaultNotebook); | ||
929 | 1618 | } | ||
930 | 1537 | notebook->setLastSyncedSequenceNumber(evNotebook.updateSequenceNum); | 1619 | notebook->setLastSyncedSequenceNumber(evNotebook.updateSequenceNum); |
931 | 1538 | } | 1620 | } |
932 | 1621 | |||
933 | 1622 | |||
934 | 1623 | void NotesStore::expungeTag(const QString &guid) | ||
935 | 1624 | { | ||
936 | 1625 | if (m_username != "@local") { | ||
937 | 1626 | qWarning() << "This account is managed by Evernote. Cannot delete tags."; | ||
938 | 1627 | m_errorQueue.append(gettext("This account is managed by Evernote. Please use the Evernote website to delete tags.")); | ||
939 | 1628 | emit errorChanged(); | ||
940 | 1629 | return; | ||
941 | 1630 | } | ||
942 | 1631 | |||
943 | 1632 | Tag *tag = m_tagsHash.value(guid); | ||
944 | 1633 | if (!tag) { | ||
945 | 1634 | qWarning() << "[NotesStore] No tag with guid" << guid; | ||
946 | 1635 | return; | ||
947 | 1636 | } | ||
948 | 1637 | |||
949 | 1638 | while (tag->noteCount() > 0) { | ||
950 | 1639 | QString noteGuid = tag->noteAt(0); | ||
951 | 1640 | Note *note = m_notesHash.value(noteGuid); | ||
952 | 1641 | if (!note) { | ||
953 | 1642 | qWarning() << "[NotesStore] Tag holds note" << noteGuid << "which hasn't been found in Notes Store"; | ||
954 | 1643 | continue; | ||
955 | 1644 | } | ||
956 | 1645 | untagNote(noteGuid, guid); | ||
957 | 1646 | } | ||
958 | 1647 | |||
959 | 1648 | emit tagRemoved(guid); | ||
960 | 1649 | m_tagsHash.remove(guid); | ||
961 | 1650 | m_tags.removeAll(tag); | ||
962 | 1651 | |||
963 | 1652 | QSettings cacheFile(m_cacheFile, QSettings::IniFormat); | ||
964 | 1653 | cacheFile.beginGroup("tags"); | ||
965 | 1654 | cacheFile.remove(guid); | ||
966 | 1655 | cacheFile.endGroup(); | ||
967 | 1656 | tag->syncToInfoFile(); | ||
968 | 1657 | |||
969 | 1658 | tag->deleteInfoFile(); | ||
970 | 1659 | tag->deleteLater(); | ||
971 | 1660 | } | ||
972 | 1539 | 1661 | ||
973 | === modified file 'src/libqtevernote/notesstore.h' | |||
974 | --- src/libqtevernote/notesstore.h 2015-02-26 22:47:10 +0000 | |||
975 | +++ src/libqtevernote/notesstore.h 2015-03-04 00:26:40 +0000 | |||
976 | @@ -59,7 +59,6 @@ | |||
977 | 59 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) | 59 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) |
978 | 60 | Q_PROPERTY(bool notebooksLoading READ notebooksLoading NOTIFY notebooksLoadingChanged) | 60 | Q_PROPERTY(bool notebooksLoading READ notebooksLoading NOTIFY notebooksLoadingChanged) |
979 | 61 | Q_PROPERTY(QString error READ error NOTIFY errorChanged) | 61 | Q_PROPERTY(QString error READ error NOTIFY errorChanged) |
980 | 62 | Q_PROPERTY(QString notebooksError READ notebooksError NOTIFY notebooksErrorChanged) | ||
981 | 63 | Q_PROPERTY(int count READ count NOTIFY countChanged) | 62 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
982 | 64 | 63 | ||
983 | 65 | public: | 64 | public: |
984 | @@ -105,8 +104,6 @@ | |||
985 | 105 | bool tagsLoading() const; | 104 | bool tagsLoading() const; |
986 | 106 | 105 | ||
987 | 107 | QString error() const; | 106 | QString error() const; |
988 | 108 | QString notebooksError() const; | ||
989 | 109 | QString tagsError() const; | ||
990 | 110 | 107 | ||
991 | 111 | int count() const; | 108 | int count() const; |
992 | 112 | 109 | ||
993 | @@ -129,6 +126,7 @@ | |||
994 | 129 | Q_INVOKABLE Notebook* notebook(const QString &guid); | 126 | Q_INVOKABLE Notebook* notebook(const QString &guid); |
995 | 130 | Q_INVOKABLE void createNotebook(const QString &name); | 127 | Q_INVOKABLE void createNotebook(const QString &name); |
996 | 131 | Q_INVOKABLE void saveNotebook(const QString &guid); | 128 | Q_INVOKABLE void saveNotebook(const QString &guid); |
997 | 129 | Q_INVOKABLE void setDefaultNotebook(const QString &guid); | ||
998 | 132 | Q_INVOKABLE void expungeNotebook(const QString &guid); | 130 | Q_INVOKABLE void expungeNotebook(const QString &guid); |
999 | 133 | 131 | ||
1000 | 134 | QList<Tag*> tags() const; | 132 | QList<Tag*> tags() const; |
1001 | @@ -137,6 +135,7 @@ | |||
1002 | 137 | Q_INVOKABLE void saveTag(const QString &guid); | 135 | Q_INVOKABLE void saveTag(const QString &guid); |
1003 | 138 | Q_INVOKABLE void tagNote(const QString ¬eGuid, const QString &tagGuid); | 136 | Q_INVOKABLE void tagNote(const QString ¬eGuid, const QString &tagGuid); |
1004 | 139 | Q_INVOKABLE void untagNote(const QString ¬eGuid, const QString &tagGuid); | 137 | Q_INVOKABLE void untagNote(const QString ¬eGuid, const QString &tagGuid); |
1005 | 138 | Q_INVOKABLE void expungeTag(const QString &guid); | ||
1006 | 140 | 139 | ||
1007 | 141 | public slots: | 140 | public slots: |
1008 | 142 | void refreshNotes(const QString &filterNotebookGuid = QString(), int startIndex = 0); | 141 | void refreshNotes(const QString &filterNotebookGuid = QString(), int startIndex = 0); |
1009 | @@ -146,14 +145,14 @@ | |||
1010 | 146 | void refreshNotebooks(); | 145 | void refreshNotebooks(); |
1011 | 147 | void refreshTags(); | 146 | void refreshTags(); |
1012 | 148 | 147 | ||
1013 | 148 | void clearError(); | ||
1014 | 149 | |||
1015 | 149 | signals: | 150 | signals: |
1016 | 150 | void usernameChanged(); | 151 | void usernameChanged(); |
1017 | 151 | void loadingChanged(); | 152 | void loadingChanged(); |
1018 | 152 | void notebooksLoadingChanged(); | 153 | void notebooksLoadingChanged(); |
1019 | 153 | void tagsLoadingChanged(); | 154 | void tagsLoadingChanged(); |
1020 | 154 | void errorChanged(); | 155 | void errorChanged(); |
1021 | 155 | void notebooksErrorChanged(); | ||
1022 | 156 | void tagsErrorChanged(); | ||
1023 | 157 | void countChanged(); | 156 | void countChanged(); |
1024 | 158 | 157 | ||
1025 | 159 | void noteCreated(const QString &guid, const QString ¬ebookGuid); | 158 | void noteCreated(const QString &guid, const QString ¬ebookGuid); |
1026 | @@ -167,6 +166,7 @@ | |||
1027 | 167 | void notebookChanged(const QString &guid); | 166 | void notebookChanged(const QString &guid); |
1028 | 168 | void notebookRemoved(const QString &guid); | 167 | void notebookRemoved(const QString &guid); |
1029 | 169 | void notebookGuidChanged(const QString &oldGuid, const QString &newGuid); | 168 | void notebookGuidChanged(const QString &oldGuid, const QString &newGuid); |
1030 | 169 | void defaultNotebookChanged(const QString &guid); | ||
1031 | 170 | 170 | ||
1032 | 171 | void tagAdded(const QString &guid); | 171 | void tagAdded(const QString &guid); |
1033 | 172 | void tagChanged(const QString &guid); | 172 | void tagChanged(const QString &guid); |
1034 | @@ -213,9 +213,7 @@ | |||
1035 | 213 | bool m_notebooksLoading; | 213 | bool m_notebooksLoading; |
1036 | 214 | bool m_tagsLoading; | 214 | bool m_tagsLoading; |
1037 | 215 | 215 | ||
1041 | 216 | QString m_error; | 216 | QStringList m_errorQueue; |
1039 | 217 | QString m_notebooksError; | ||
1040 | 218 | QString m_tagsError; | ||
1042 | 219 | 217 | ||
1043 | 220 | QList<Note*> m_notes; | 218 | QList<Note*> m_notes; |
1044 | 221 | QList<Notebook*> m_notebooks; | 219 | QList<Notebook*> m_notebooks; |
1045 | 222 | 220 | ||
1046 | === modified file 'src/libqtevernote/tag.cpp' | |||
1047 | --- src/libqtevernote/tag.cpp 2015-02-24 22:21:04 +0000 | |||
1048 | +++ src/libqtevernote/tag.cpp 2015-03-04 00:26:40 +0000 | |||
1049 | @@ -219,3 +219,9 @@ | |||
1050 | 219 | emit syncErrorChanged(); | 219 | emit syncErrorChanged(); |
1051 | 220 | } | 220 | } |
1052 | 221 | } | 221 | } |
1053 | 222 | |||
1054 | 223 | |||
1055 | 224 | QString Tag::noteAt(int index) const | ||
1056 | 225 | { | ||
1057 | 226 | return m_notesList.at(index); | ||
1058 | 227 | } | ||
1059 | 222 | 228 | ||
1060 | === modified file 'src/libqtevernote/tag.h' | |||
1061 | --- src/libqtevernote/tag.h 2014-12-13 03:55:52 +0000 | |||
1062 | +++ src/libqtevernote/tag.h 2015-03-04 00:26:40 +0000 | |||
1063 | @@ -61,6 +61,7 @@ | |||
1064 | 61 | void setName(const QString &guid); | 61 | void setName(const QString &guid); |
1065 | 62 | 62 | ||
1066 | 63 | int noteCount() const; | 63 | int noteCount() const; |
1067 | 64 | QString noteAt(int index) const; | ||
1068 | 64 | 65 | ||
1069 | 65 | bool loading() const; | 66 | bool loading() const; |
1070 | 66 | bool synced() const; | 67 | bool synced() const; |
1071 | 67 | 68 | ||
1072 | === modified file 'src/libqtevernote/tags.cpp' | |||
1073 | --- src/libqtevernote/tags.cpp 2014-12-13 03:55:52 +0000 | |||
1074 | +++ src/libqtevernote/tags.cpp 2015-03-04 00:26:40 +0000 | |||
1075 | @@ -32,7 +32,6 @@ | |||
1076 | 32 | } | 32 | } |
1077 | 33 | 33 | ||
1078 | 34 | connect(NotesStore::instance(), &NotesStore::tagsLoadingChanged, this, &Tags::loadingChanged); | 34 | connect(NotesStore::instance(), &NotesStore::tagsLoadingChanged, this, &Tags::loadingChanged); |
1079 | 35 | connect(NotesStore::instance(), &NotesStore::tagsErrorChanged, this, &Tags::errorChanged); | ||
1080 | 36 | connect(NotesStore::instance(), &NotesStore::tagAdded, this, &Tags::tagAdded); | 35 | connect(NotesStore::instance(), &NotesStore::tagAdded, this, &Tags::tagAdded); |
1081 | 37 | connect(NotesStore::instance(), &NotesStore::tagRemoved, this, &Tags::tagRemoved); | 36 | connect(NotesStore::instance(), &NotesStore::tagRemoved, this, &Tags::tagRemoved); |
1082 | 38 | connect(NotesStore::instance(), &NotesStore::tagGuidChanged, this, &Tags::tagGuidChanged); | 37 | connect(NotesStore::instance(), &NotesStore::tagGuidChanged, this, &Tags::tagGuidChanged); |
1083 | @@ -43,11 +42,6 @@ | |||
1084 | 43 | return NotesStore::instance()->tagsLoading(); | 42 | return NotesStore::instance()->tagsLoading(); |
1085 | 44 | } | 43 | } |
1086 | 45 | 44 | ||
1087 | 46 | QString Tags::error() const | ||
1088 | 47 | { | ||
1089 | 48 | return NotesStore::instance()->tagsError(); | ||
1090 | 49 | } | ||
1091 | 50 | |||
1092 | 51 | int Tags::count() const | 45 | int Tags::count() const |
1093 | 52 | { | 46 | { |
1094 | 53 | return rowCount(); | 47 | return rowCount(); |
1095 | 54 | 48 | ||
1096 | === modified file 'src/libqtevernote/tags.h' | |||
1097 | --- src/libqtevernote/tags.h 2014-12-13 03:55:52 +0000 | |||
1098 | +++ src/libqtevernote/tags.h 2015-03-04 00:26:40 +0000 | |||
1099 | @@ -29,7 +29,6 @@ | |||
1100 | 29 | { | 29 | { |
1101 | 30 | Q_OBJECT | 30 | Q_OBJECT |
1102 | 31 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) | 31 | Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged) |
1103 | 32 | Q_PROPERTY(QString error READ error NOTIFY errorChanged) | ||
1104 | 33 | Q_PROPERTY(int count READ count NOTIFY countChanged) | 32 | Q_PROPERTY(int count READ count NOTIFY countChanged) |
1105 | 34 | 33 | ||
1106 | 35 | public: | 34 | public: |
1107 | @@ -44,7 +43,6 @@ | |||
1108 | 44 | explicit Tags(QObject *parent = 0); | 43 | explicit Tags(QObject *parent = 0); |
1109 | 45 | 44 | ||
1110 | 46 | bool loading() const; | 45 | bool loading() const; |
1111 | 47 | QString error() const; | ||
1112 | 48 | int count() const; | 46 | int count() const; |
1113 | 49 | 47 | ||
1114 | 50 | QVariant data(const QModelIndex &index, int role) const; | 48 | QVariant data(const QModelIndex &index, int role) const; |
1115 | @@ -58,7 +56,6 @@ | |||
1116 | 58 | 56 | ||
1117 | 59 | signals: | 57 | signals: |
1118 | 60 | void loadingChanged(); | 58 | void loadingChanged(); |
1119 | 61 | void errorChanged(); | ||
1120 | 62 | void countChanged(); | 59 | void countChanged(); |
1121 | 63 | 60 | ||
1122 | 64 | private slots: | 61 | private slots: |
PASSED: Continuous integration, rev:369 91.189. 93.70:8080/ job/reminders- app-ci/ 690/ 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 2220 91.189. 93.70:8080/ job/generic- mediumtests- utopic/ 2220/artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/reminders- app-utopic- amd64-ci/ 292 91.189. 93.70:8080/ job/reminders- app-vivid- amd64-ci/ 111
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/reminders- app-ci/ 690/rebuild
http://