Merge lp:~mzanetti/reminders-app/delete-tags-and-notebooks into lp:reminders-app

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
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.

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
=== modified file 'src/app/qml/components/NotebooksDelegate.qml'
--- src/app/qml/components/NotebooksDelegate.qml 2014-12-16 23:01:22 +0000
+++ src/app/qml/components/NotebooksDelegate.qml 2015-03-04 00:26:40 +0000
@@ -22,12 +22,38 @@
22import Ubuntu.Components.ListItems 1.022import Ubuntu.Components.ListItems 1.0
23import Evernote 0.123import Evernote 0.1
2424
25Empty {25ListItemWithActions {
26 id: root26 id: root
27 height: units.gu(10)
2827
29 property string notebookColor: preferences.colorForNotebook(model.guid)28 property string notebookColor: preferences.colorForNotebook(model.guid)
3029
30 signal deleteNotebook();
31 signal setAsDefault();
32 signal renameNotebook();
33
34 leftSideAction: Action {
35 iconName: "delete"
36 text: i18n.tr("Delete")
37 onTriggered: {
38 root.deleteNotebook();
39 }
40 }
41
42 rightSideActions: [
43 Action {
44 iconName: model.isDefaultNotebook ? "starred" : "non-starred"
45 onTriggered: {
46 root.setAsDefault();
47 }
48 },
49 Action {
50 iconName: "edit"
51 onTriggered: {
52 root.renameNotebook();
53 }
54 }
55 ]
56
31 Rectangle {57 Rectangle {
32 anchors.fill: parent58 anchors.fill: parent
33 color: "#f9f9f9"59 color: "#f9f9f9"
@@ -61,34 +87,6 @@
61 color: root.notebookColor87 color: root.notebookColor
62 fontSize: "large"88 fontSize: "large"
63 Layout.fillWidth: true89 Layout.fillWidth: true
64
65 MouseArea {
66 onPressAndHold: {
67 notebookTitleLabel.visible = false;
68 notebookTitleTextField.forceActiveFocus();
69 }
70 anchors.fill: parent
71 propagateComposedEvents: true
72 }
73 }
74
75 TextField {
76 id: notebookTitleTextField
77 text: model.name
78 color: root.notebookColor
79 visible: !notebookTitleLabel.visible
80 Layout.fillWidth: true
81
82 InverseMouseArea {
83 onClicked: {
84 if (notebookTitleTextField.text) {
85 notebooks.notebook(index).name = notebookTitleTextField.text;
86 NotesStore.saveNotebook(notebooks.notebook(index).guid);
87 notebookTitleLabel.visible = true;
88 }
89 }
90 anchors.fill: parent
91 }
92 }90 }
9391
94 Label {92 Label {
@@ -99,14 +97,25 @@
99 Layout.fillWidth: true97 Layout.fillWidth: true
100 }98 }
10199
102 Label {100 Row {
103 objectName: 'notebookPublishedLabel'
104 Layout.fillHeight: true101 Layout.fillHeight: true
105 text: model.published ? i18n.tr("Shared") : i18n.tr("Private")102 spacing: units.gu(1)
106 color: model.published ? "black" : "#b3b3b3"103 Icon {
107 fontSize: "x-small"104 height: parent.height
108 verticalAlignment: Text.AlignVCenter105 width: height
109 font.bold: model.published106 name: "starred"
107 visible: model.isDefaultNotebook
108 }
109
110 Label {
111 objectName: 'notebookPublishedLabel'
112 anchors.verticalCenter: parent.verticalCenter
113 text: model.published ? i18n.tr("Shared") : i18n.tr("Private")
114 color: model.published ? "black" : "#b3b3b3"
115 fontSize: "x-small"
116 verticalAlignment: Text.AlignVCenter
117 font.bold: model.published
118 }
110 }119 }
111 }120 }
112121
113122
=== modified file 'src/app/qml/components/StatusBar.qml'
--- src/app/qml/components/StatusBar.qml 2014-12-08 10:25:48 +0000
+++ src/app/qml/components/StatusBar.qml 2015-03-04 00:26:40 +0000
@@ -21,20 +21,22 @@
21 anchors { left: parent.left; top: parent.top; right: parent.right }21 anchors { left: parent.left; top: parent.top; right: parent.right }
22 spacing: units.gu(1)22 spacing: units.gu(1)
2323
24 RowLayout {24 Row {
25 anchors { left: parent.left; right: parent.right; margins: units.gu(1) }25 anchors { left: parent.left; right: parent.right; margins: units.gu(1) }
26 spacing: units.gu(1)26 spacing: units.gu(1)
27 height: label.height
2728
28 Icon {29 Icon {
29 id: icon30 id: icon
30 height: units.gu(3)31 height: units.gu(3)
31 width: height32 width: height
32 color: UbuntuColors.red33 color: UbuntuColors.red
34 anchors.verticalCenter: parent.verticalCenter
33 }35 }
3436
35 Label {37 Label {
36 id: label38 id: label
37 Layout.fillWidth: true39 width: parent.width - x
38 wrapMode: Text.WordWrap40 wrapMode: Text.WordWrap
39 }41 }
40 }42 }
4143
=== modified file 'src/app/qml/components/TagsDelegate.qml'
--- src/app/qml/components/TagsDelegate.qml 2014-12-14 21:52:26 +0000
+++ src/app/qml/components/TagsDelegate.qml 2015-03-04 00:26:40 +0000
@@ -22,10 +22,30 @@
22import Ubuntu.Components.ListItems 1.022import Ubuntu.Components.ListItems 1.0
23import Evernote 0.123import Evernote 0.1
2424
25Empty {25ListItemWithActions {
26 id: root26 id: root
27 height: units.gu(10)27 height: units.gu(10)
2828
29 signal deleteTag();
30 signal renameTag();
31
32 leftSideAction: Action {
33 iconName: "delete"
34 text: i18n.tr("Delete")
35 onTriggered: {
36 root.deleteTag()
37 }
38 }
39
40 rightSideActions: [
41 Action {
42 iconName: "edit"
43 onTriggered: {
44 root.renameTag();
45 }
46 }
47 ]
48
29 Rectangle {49 Rectangle {
30 anchors.fill: parent50 anchors.fill: parent
31 color: "#f9f9f9"51 color: "#f9f9f9"
@@ -58,32 +78,6 @@
58 text: model.name78 text: model.name
59 fontSize: "large"79 fontSize: "large"
60 Layout.fillWidth: true80 Layout.fillWidth: true
61
62 MouseArea {
63 onPressAndHold: {
64 tagTitleLabel.visible = false;
65 tagTitleTextField.forceActiveFocus();
66 }
67 anchors.fill: parent
68 propagateComposedEvents: true
69 }
70 }
71
72 TextField {
73 id: tagTitleTextField
74 text: model.name
75 visible: !tagTitleLabel.visible
76
77 InverseMouseArea {
78 onClicked: {
79 if (tagTitleTextField.text) {
80 tags.tag(index).name = tagTitleTextField.text;
81 NotesStore.saveTag(tags.tag(index).guid);
82 tagTitleLabel.visible = true;
83 }
84 }
85 anchors.fill: parent
86 }
87 }81 }
88 }82 }
8983
9084
=== modified file 'src/app/qml/reminders.qml'
--- src/app/qml/reminders.qml 2015-03-01 22:32:41 +0000
+++ src/app/qml/reminders.qml 2015-03-04 00:26:40 +0000
@@ -422,9 +422,21 @@
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) }
423 color: root.backgroundColor423 color: root.backgroundColor
424 shown: text424 shown: text
425 text: EvernoteConnection.error || NotesStore.error || NotesStore.notebooksError || NotesStore.tagsError425 text: EvernoteConnection.error || NotesStore.error
426 iconName: "sync-error"426 iconName: "sync-error"
427427
428 Timer {
429 interval: 5000
430 repeat: true
431 running: NotesStore.error
432 onTriggered: NotesStore.clearError();
433 }
434
435 MouseArea {
436 anchors.fill: parent
437 onClicked: NotesStore.clearError();
438 }
439
428 }440 }
429441
430 PageStack {442 PageStack {
431443
=== modified file 'src/app/qml/ui/NotebooksPage.qml'
--- src/app/qml/ui/NotebooksPage.qml 2015-03-01 22:32:41 +0000
+++ src/app/qml/ui/NotebooksPage.qml 2015-03-04 00:26:40 +0000
@@ -19,6 +19,7 @@
19import QtQuick 2.319import QtQuick 2.3
20import Ubuntu.Components 1.120import Ubuntu.Components 1.1
21import Ubuntu.Components.ListItems 1.021import Ubuntu.Components.ListItems 1.0
22import Ubuntu.Components.Popups 1.0
22import Evernote 0.123import Evernote 0.1
23import "../components"24import "../components"
2425
@@ -116,10 +117,30 @@
116 }117 }
117118
118 delegate: NotebooksDelegate {119 delegate: NotebooksDelegate {
119 onClicked: {120 width: parent.width
121 height: units.gu(10)
122 triggerActionOnMouseRelease: true
123
124 onItemClicked: {
120 print("selected notebook:", model.guid)125 print("selected notebook:", model.guid)
121 root.openNotebook(model.guid)126 root.openNotebook(model.guid)
122 }127 }
128
129 onDeleteNotebook: {
130 NotesStore.expungeNotebook(model.guid)
131 }
132
133 onSetAsDefault: {
134 NotesStore.setDefaultNotebook(model.guid)
135 }
136
137 onRenameNotebook: {
138 var popup = PopupUtils.open(renameNotebookDialogComponent, root, {name: model.name})
139 popup.accepted.connect(function(newName) {
140 notebooks.notebook(index).name = newName;
141 NotesStore.saveNotebook(model.guid);
142 })
143 }
123 }144 }
124145
125 BouncingProgressBar {146 BouncingProgressBar {
@@ -170,4 +191,32 @@
170 height: Qt.inputMethod.keyboardRectangle.height191 height: Qt.inputMethod.keyboardRectangle.height
171 }192 }
172 }193 }
194
195 Component {
196 id: renameNotebookDialogComponent
197 Dialog {
198 id: renameNotebookDialog
199 title: i18n.tr("Rename notebook")
200 text: i18n.tr("Enter a new name for notebook %1").arg(name)
201
202 property string name
203
204 signal accepted(string newName)
205
206 TextField {
207 id: nameTextField
208 text: renameNotebookDialog.name
209 placeholderText: i18n.tr("Name cannot be empty")
210 }
211
212 Button {
213 text: i18n.tr("OK")
214 enabled: nameTextField.text
215 onClicked: {
216 renameNotebookDialog.accepted(nameTextField.text)
217 PopupUtils.close(renameNotebookDialog)
218 }
219 }
220 }
221 }
173}222}
174223
=== modified file 'src/app/qml/ui/TagsPage.qml'
--- src/app/qml/ui/TagsPage.qml 2015-03-01 22:32:41 +0000
+++ src/app/qml/ui/TagsPage.qml 2015-03-04 00:26:40 +0000
@@ -19,6 +19,7 @@
19import QtQuick 2.319import QtQuick 2.3
20import Ubuntu.Components 1.120import Ubuntu.Components 1.1
21import Ubuntu.Components.ListItems 1.021import Ubuntu.Components.ListItems 1.0
22import Ubuntu.Components.Popups 1.0
22import Evernote 0.123import Evernote 0.1
23import "../components"24import "../components"
2425
@@ -80,10 +81,25 @@
80 }81 }
8182
82 delegate: TagsDelegate {83 delegate: TagsDelegate {
83 onClicked: {84 width: parent.width
85 height: units.gu(10)
86 triggerActionOnMouseRelease: true
87
88 onItemClicked: {
84 print("selected tag:", model.guid)89 print("selected tag:", model.guid)
85 root.openTaggedNotes(model.guid)90 root.openTaggedNotes(model.guid)
86 }91 }
92 onDeleteTag: {
93 NotesStore.expungeTag(model.guid);
94 }
95
96 onRenameTag: {
97 var popup = PopupUtils.open(renameTagDialogComponent, root, {name: model.name})
98 popup.accepted.connect(function(newName) {
99 tags.tag(index).name = newName;
100 NotesStore.saveTag(model.guid);
101 })
102 }
87 }103 }
88104
89 ActivityIndicator {105 ActivityIndicator {
@@ -92,15 +108,6 @@
92 visible: running108 visible: running
93 }109 }
94110
95 Label {
96 anchors.centerIn: parent
97 width: parent.width - units.gu(4)
98 wrapMode: Text.WordWrap
99 horizontalAlignment: Text.AlignHCenter
100 visible: !tags.loading && tags.error
101 text: tags.error
102 }
103
104 Scrollbar {111 Scrollbar {
105 flickableItem: parent112 flickableItem: parent
106 }113 }
@@ -121,4 +128,32 @@
121 horizontalAlignment: Text.AlignHCenter128 horizontalAlignment: Text.AlignHCenter
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.")
123 }130 }
131
132 Component {
133 id: renameTagDialogComponent
134 Dialog {
135 id: renameTagDialog
136 title: i18n.tr("Rename tag")
137 text: i18n.tr("Enter a new name for tag %1").arg(name)
138
139 property string name
140
141 signal accepted(string newName)
142
143 TextField {
144 id: nameTextField
145 text: renameTagDialog.name
146 placeholderText: i18n.tr("Name cannot be empty")
147 }
148
149 Button {
150 text: i18n.tr("OK")
151 enabled: nameTextField.text
152 onClicked: {
153 renameTagDialog.accepted(nameTextField.text)
154 PopupUtils.close(renameTagDialog)
155 }
156 }
157 }
158 }
124}159}
125160
=== modified file 'src/libqtevernote/jobs/savenotebookjob.cpp'
--- src/libqtevernote/jobs/savenotebookjob.cpp 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/jobs/savenotebookjob.cpp 2015-03-04 00:26:40 +0000
@@ -56,6 +56,8 @@
56 m_resultNotebook.__isset.name = true;56 m_resultNotebook.__isset.name = true;
57 m_resultNotebook.updateSequenceNum = m_notebook->updateSequenceNumber();57 m_resultNotebook.updateSequenceNum = m_notebook->updateSequenceNumber();
58 m_resultNotebook.__isset.updateSequenceNum = true;58 m_resultNotebook.__isset.updateSequenceNum = true;
59 m_resultNotebook.defaultNotebook = m_notebook->isDefaultNotebook();
60 m_resultNotebook.__isset.defaultNotebook = true;
5961
60 client()->updateNotebook(token().toStdString(), m_resultNotebook);62 client()->updateNotebook(token().toStdString(), m_resultNotebook);
61}63}
6264
=== modified file 'src/libqtevernote/notebook.cpp'
--- src/libqtevernote/notebook.cpp 2015-02-24 22:21:04 +0000
+++ src/libqtevernote/notebook.cpp 2015-03-04 00:26:40 +0000
@@ -32,6 +32,7 @@
32 m_updateSequenceNumber(updateSequenceNumber),32 m_updateSequenceNumber(updateSequenceNumber),
33 m_guid(guid),33 m_guid(guid),
34 m_published(false),34 m_published(false),
35 m_isDefaultNotebook(false),
35 m_loading(false),36 m_loading(false),
36 m_syncError(false)37 m_syncError(false)
37{38{
@@ -41,6 +42,7 @@
41 m_published = infoFile.value("published").toBool();42 m_published = infoFile.value("published").toBool();
42 m_lastUpdated = infoFile.value("lastUpdated").toDateTime();43 m_lastUpdated = infoFile.value("lastUpdated").toDateTime();
43 m_lastSyncedSequenceNumber = infoFile.value("lastSyncedSequenceNumber", 0).toUInt();44 m_lastSyncedSequenceNumber = infoFile.value("lastSyncedSequenceNumber", 0).toUInt();
45 m_isDefaultNotebook = infoFile.value("isDefaultNotebook", false).toBool();
44 m_synced = m_lastSyncedSequenceNumber == m_updateSequenceNumber;46 m_synced = m_lastSyncedSequenceNumber == m_updateSequenceNumber;
4547
46 foreach (Note *note, NotesStore::instance()->notes()) {48 foreach (Note *note, NotesStore::instance()->notes()) {
@@ -77,6 +79,11 @@
77 return m_notesList.count();79 return m_notesList.count();
78}80}
7981
82QString Notebook::noteAt(int index) const
83{
84 return m_notesList.at(index);
85}
86
80bool Notebook::published() const87bool Notebook::published() const
81{88{
82 return m_published;89 return m_published;
@@ -129,6 +136,19 @@
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());
130}137}
131138
139bool Notebook::isDefaultNotebook() const
140{
141 return m_isDefaultNotebook;
142}
143
144void Notebook::setIsDefaultNotebook(bool isDefaultNotebook)
145{
146 if (m_isDefaultNotebook != isDefaultNotebook) {
147 m_isDefaultNotebook = isDefaultNotebook;
148 emit isDefaultNotebookChanged();
149 }
150}
151
132Notebook *Notebook::clone()152Notebook *Notebook::clone()
133{153{
134 Notebook *notebook = new Notebook(m_guid, m_updateSequenceNumber);154 Notebook *notebook = new Notebook(m_guid, m_updateSequenceNumber);
@@ -212,6 +232,7 @@
212 infoFile.setValue("published", m_published);232 infoFile.setValue("published", m_published);
213 infoFile.value("lastUpdated", m_lastUpdated);233 infoFile.value("lastUpdated", m_lastUpdated);
214 infoFile.setValue("lastSyncedSequenceNumber", m_lastSyncedSequenceNumber);234 infoFile.setValue("lastSyncedSequenceNumber", m_lastSyncedSequenceNumber);
235 infoFile.setValue("isDefaultNotebook", m_isDefaultNotebook);
215}236}
216237
217void Notebook::deleteInfoFile()238void Notebook::deleteInfoFile()
218239
=== modified file 'src/libqtevernote/notebook.h'
--- src/libqtevernote/notebook.h 2014-12-13 00:41:41 +0000
+++ src/libqtevernote/notebook.h 2015-03-04 00:26:40 +0000
@@ -36,6 +36,7 @@
36 Q_PROPERTY(bool published READ published NOTIFY publishedChanged)36 Q_PROPERTY(bool published READ published NOTIFY publishedChanged)
37 Q_PROPERTY(QDateTime lastUpdated READ lastUpdated NOTIFY lastUpdatedChanged)37 Q_PROPERTY(QDateTime lastUpdated READ lastUpdated NOTIFY lastUpdatedChanged)
38 Q_PROPERTY(QString lastUpdatedString READ lastUpdatedString NOTIFY lastUpdatedChanged)38 Q_PROPERTY(QString lastUpdatedString READ lastUpdatedString NOTIFY lastUpdatedChanged)
39 Q_PROPERTY(bool isDefaultNotebook READ isDefaultNotebook WRITE setIsDefaultNotebook NOTIFY isDefaultNotebookChanged)
39 // Don't forget to update clone() if you add new properties40 // Don't forget to update clone() if you add new properties
4041
41 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)42 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
@@ -51,6 +52,7 @@
51 void setName(const QString &name);52 void setName(const QString &name);
5253
53 int noteCount() const;54 int noteCount() const;
55 QString noteAt(int index) const;
5456
55 bool published() const;57 bool published() const;
56 void setPublished(bool published);58 void setPublished(bool published);
@@ -60,6 +62,9 @@
6062
61 QString lastUpdatedString() const;63 QString lastUpdatedString() const;
6264
65 bool isDefaultNotebook() const;
66 void setIsDefaultNotebook(bool isDefaultNotebook);
67
63 quint32 updateSequenceNumber() const;68 quint32 updateSequenceNumber() const;
64 quint32 lastSyncedSequenceNumber() const;69 quint32 lastSyncedSequenceNumber() const;
6570
@@ -81,6 +86,7 @@
81 void loadingChanged();86 void loadingChanged();
82 void syncedChanged();87 void syncedChanged();
83 void syncErrorChanged();88 void syncErrorChanged();
89 void isDefaultNotebookChanged();
8490
85private slots:91private slots:
86 void noteAdded(const QString &noteGuid, const QString &notebookGuid);92 void noteAdded(const QString &noteGuid, const QString &notebookGuid);
@@ -106,6 +112,7 @@
106 QString m_name;112 QString m_name;
107 bool m_published;113 bool m_published;
108 QDateTime m_lastUpdated;114 QDateTime m_lastUpdated;
115 bool m_isDefaultNotebook;
109 QList<QString> m_notesList;116 QList<QString> m_notesList;
110117
111 QString m_infoFile;118 QString m_infoFile;
112119
=== modified file 'src/libqtevernote/notebooks.cpp'
--- src/libqtevernote/notebooks.cpp 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/notebooks.cpp 2015-03-04 00:26:40 +0000
@@ -32,7 +32,6 @@
32 }32 }
3333
34 connect(NotesStore::instance(), &NotesStore::notebooksLoadingChanged, this, &Notebooks::loadingChanged);34 connect(NotesStore::instance(), &NotesStore::notebooksLoadingChanged, this, &Notebooks::loadingChanged);
35 connect(NotesStore::instance(), &NotesStore::notebooksErrorChanged, this, &Notebooks::errorChanged);
36 connect(NotesStore::instance(), &NotesStore::notebookAdded, this, &Notebooks::notebookAdded);35 connect(NotesStore::instance(), &NotesStore::notebookAdded, this, &Notebooks::notebookAdded);
37 connect(NotesStore::instance(), &NotesStore::notebookRemoved, this, &Notebooks::notebookRemoved);36 connect(NotesStore::instance(), &NotesStore::notebookRemoved, this, &Notebooks::notebookRemoved);
38 connect(NotesStore::instance(), &NotesStore::notebookGuidChanged, this, &Notebooks::notebookGuidChanged);37 connect(NotesStore::instance(), &NotesStore::notebookGuidChanged, this, &Notebooks::notebookGuidChanged);
@@ -43,11 +42,6 @@
43 return NotesStore::instance()->notebooksLoading();42 return NotesStore::instance()->notebooksLoading();
44}43}
4544
46QString Notebooks::error() const
47{
48 return NotesStore::instance()->notebooksError();
49}
50
51int Notebooks::count() const45int Notebooks::count() const
52{46{
53 return rowCount();47 return rowCount();
@@ -76,6 +70,8 @@
76 return notebook->synced();70 return notebook->synced();
77 case RoleSyncError:71 case RoleSyncError:
78 return notebook->syncError();72 return notebook->syncError();
73 case RoleIsDefaultNotebook:
74 return notebook->isDefaultNotebook();
79 }75 }
80 return QVariant();76 return QVariant();
81}77}
@@ -99,6 +95,7 @@
99 roles.insert(RoleLoading, "loading");95 roles.insert(RoleLoading, "loading");
100 roles.insert(RoleSynced, "synced");96 roles.insert(RoleSynced, "synced");
101 roles.insert(RoleSyncError, "syncError");97 roles.insert(RoleSyncError, "syncError");
98 roles.insert(RoleIsDefaultNotebook, "isDefaultNotebook");
102 return roles;99 return roles;
103}100}
104101
@@ -125,6 +122,7 @@
125 connect(notebook, &Notebook::syncedChanged, this, &Notebooks::syncedChanged);122 connect(notebook, &Notebook::syncedChanged, this, &Notebooks::syncedChanged);
126 connect(notebook, &Notebook::loadingChanged, this, &Notebooks::notebookLoadingChanged);123 connect(notebook, &Notebook::loadingChanged, this, &Notebooks::notebookLoadingChanged);
127 connect(notebook, &Notebook::syncErrorChanged, this, &Notebooks::syncErrorChanged);124 connect(notebook, &Notebook::syncErrorChanged, this, &Notebooks::syncErrorChanged);
125 connect(notebook, &Notebook::isDefaultNotebookChanged, this, &Notebooks::isDefaultNotebookChanged);
128126
129 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());127 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
130 m_list.append(guid);128 m_list.append(guid);
@@ -147,6 +145,13 @@
147 emit dataChanged(index(idx), index(idx));145 emit dataChanged(index(idx), index(idx));
148}146}
149147
148void Notebooks::isDefaultNotebookChanged()
149{
150 Notebook *notebook = static_cast<Notebook*>(sender());
151 QModelIndex idx = index(m_list.indexOf((notebook->guid())));
152 emit dataChanged(idx, idx, QVector<int>() << RoleIsDefaultNotebook);
153}
154
150void Notebooks::nameChanged()155void Notebooks::nameChanged()
151{156{
152 Notebook *notebook = static_cast<Notebook*>(sender());157 Notebook *notebook = static_cast<Notebook*>(sender());
153158
=== modified file 'src/libqtevernote/notebooks.h'
--- src/libqtevernote/notebooks.h 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/notebooks.h 2015-03-04 00:26:40 +0000
@@ -29,7 +29,6 @@
29{29{
30 Q_OBJECT30 Q_OBJECT
31 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)31 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
32 Q_PROPERTY(QString error READ error NOTIFY errorChanged)
33 Q_PROPERTY(int count READ count NOTIFY countChanged)32 Q_PROPERTY(int count READ count NOTIFY countChanged)
3433
35public:34public:
@@ -42,7 +41,8 @@
42 RoleLastUpdatedString,41 RoleLastUpdatedString,
43 RoleLoading,42 RoleLoading,
44 RoleSynced,43 RoleSynced,
45 RoleSyncError44 RoleSyncError,
45 RoleIsDefaultNotebook
46 };46 };
47 explicit Notebooks(QObject *parent = 0);47 explicit Notebooks(QObject *parent = 0);
4848
@@ -61,7 +61,6 @@
6161
62signals:62signals:
63 void loadingChanged();63 void loadingChanged();
64 void errorChanged();
65 void countChanged();64 void countChanged();
6665
67private slots:66private slots:
@@ -76,6 +75,7 @@
76 void syncedChanged();75 void syncedChanged();
77 void notebookLoadingChanged();76 void notebookLoadingChanged();
78 void syncErrorChanged();77 void syncErrorChanged();
78 void isDefaultNotebookChanged();
7979
80private:80private:
81 QList<QString> m_list;81 QList<QString> m_list;
8282
=== modified file 'src/libqtevernote/notesstore.cpp'
--- src/libqtevernote/notesstore.cpp 2015-02-28 03:59:56 +0000
+++ src/libqtevernote/notesstore.cpp 2015-03-04 00:26:40 +0000
@@ -143,17 +143,7 @@
143143
144QString NotesStore::error() const144QString NotesStore::error() const
145{145{
146 return m_error;146 return m_errorQueue.count() > 0 ? m_errorQueue.first() : QString();
147}
148
149QString NotesStore::notebooksError() const
150{
151 return m_notebooksError;
152}
153
154QString NotesStore::tagsError() const
155{
156 return m_tagsError;
157}147}
158148
159int NotesStore::count() const149int NotesStore::count() const
@@ -284,6 +274,9 @@
284{274{
285 Notebook *notebook = new Notebook(QUuid::createUuid().toString().remove(QRegExp("[\{\}]*")), 1, this);275 Notebook *notebook = new Notebook(QUuid::createUuid().toString().remove(QRegExp("[\{\}]*")), 1, this);
286 notebook->setName(name);276 notebook->setName(name);
277 if (m_notebooks.isEmpty()) {
278 notebook->setIsDefaultNotebook(true);
279 }
287280
288 m_notebooks.append(notebook);281 m_notebooks.append(notebook);
289 m_notebooksHash.insert(notebook->guid(), notebook);282 m_notebooksHash.insert(notebook->guid(), notebook);
@@ -359,6 +352,27 @@
359 emit notebookChanged(notebook->guid());352 emit notebookChanged(notebook->guid());
360}353}
361354
355void NotesStore::setDefaultNotebook(const QString &guid)
356{
357 Notebook *notebook = m_notebooksHash.value(guid);
358 if (!notebook) {
359 qWarning() << "[NotesStore] Notebook guid not found:" << guid;
360 return;
361 }
362
363 qDebug() << "[NotesStore] Setting default notebook:" << guid;
364 foreach (Notebook *tmp, m_notebooks) {
365 if (tmp->isDefaultNotebook()) {
366 tmp->setIsDefaultNotebook(false);
367 saveNotebook(tmp->guid());
368 break;
369 }
370 }
371 notebook->setIsDefaultNotebook(true);
372 saveNotebook(guid);
373 emit defaultNotebookChanged(guid);
374}
375
362void NotesStore::saveTag(const QString &guid)376void NotesStore::saveTag(const QString &guid)
363{377{
364 Tag *tag = m_tagsHash.value(guid);378 Tag *tag = m_tagsHash.value(guid);
@@ -381,9 +395,66 @@
381395
382void NotesStore::expungeNotebook(const QString &guid)396void NotesStore::expungeNotebook(const QString &guid)
383{397{
384 ExpungeNotebookJob *job = new ExpungeNotebookJob(guid);398 if (m_username != "@local") {
385 connect(job, &ExpungeNotebookJob::jobDone, this, &NotesStore::expungeNotebookJobDone);399 qWarning() << "[NotesStore] Account managed by Evernote. Cannot delete notebooks.";
386 EvernoteConnection::instance()->enqueue(job);400 m_errorQueue.append(QString(gettext("This account is managed by Evernote. Use the Evernote website to delete notebooks.")));
401 emit errorChanged();
402 return;
403 }
404
405 Notebook* notebook = m_notebooksHash.value(guid);
406 if (!notebook) {
407 qWarning() << "[NotesStore] Cannot delete notebook. Notebook not found for guid:" << guid;
408 return;
409 }
410
411 if (notebook->isDefaultNotebook()) {
412 qWarning() << "[NotesStore] Cannot delete the default notebook.";
413 m_errorQueue.append(QString(gettext("Cannot delete the default notebook. Set another notebook to be the default first.")));
414 emit errorChanged();
415 return;
416 }
417
418 if (notebook->noteCount() > 0) {
419 QString defaultNotebook;
420 foreach (const Notebook *notebook, m_notebooks) {
421 if (notebook->isDefaultNotebook()) {
422 defaultNotebook = notebook->guid();
423 break;
424 }
425 }
426 if (defaultNotebook.isEmpty()) {
427 qWarning() << "[NotesStore] No default notebook set. Can't delete notebooks.";
428 return;
429 }
430
431 while (notebook->noteCount() > 0) {
432 QString noteGuid = notebook->noteAt(0);
433 Note *note = m_notesHash.value(noteGuid);
434 if (!note) {
435 qWarning() << "[NotesStore] Notebook holds a noteGuid which cannot be found in notes store";
436 Q_ASSERT(false);
437 continue;
438 }
439 qDebug() << "[NotesStore] Moving note" << noteGuid << "to default Notebook";
440 note->setNotebookGuid(defaultNotebook);
441 saveNote(note->guid());
442 emit noteChanged(note->guid(), defaultNotebook);
443 syncToCacheFile(note);
444 }
445 }
446
447 m_notebooks.removeAll(notebook);
448 m_notebooksHash.remove(notebook->guid());
449 emit notebookRemoved(notebook->guid());
450
451 QSettings settings(m_cacheFile, QSettings::IniFormat);
452 settings.beginGroup("notebooks");
453 settings.remove(notebook->guid());
454 settings.endGroup();
455
456 notebook->deleteInfoFile();
457 notebook->deleteLater();
387}458}
388459
389QList<Tag *> NotesStore::tags() const460QList<Tag *> NotesStore::tags() const
@@ -548,11 +619,7 @@
548{619{
549 switch (errorCode) {620 switch (errorCode) {
550 case EvernoteConnection::ErrorCodeNoError:621 case EvernoteConnection::ErrorCodeNoError:
551 // All is well, reset error code.622 // All is well...
552 if (!m_error.isEmpty()) {
553 m_error.clear();
554 emit errorChanged();
555 }
556 break;623 break;
557 case EvernoteConnection::ErrorCodeUserException:624 case EvernoteConnection::ErrorCodeUserException:
558 qWarning() << "FetchNotesJobDone: EDAMUserException:" << errorMessage;625 qWarning() << "FetchNotesJobDone: EDAMUserException:" << errorMessage;
@@ -571,8 +638,6 @@
571 return; // silently discarding...638 return; // silently discarding...
572 default:639 default:
573 qWarning() << "FetchNotesJobDone: Failed to fetch notes list:" << errorMessage << errorCode;640 qWarning() << "FetchNotesJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
574 m_error = QString(gettext("Error refreshing notes: %1")).arg(errorMessage);
575 emit errorChanged();
576 m_loading = false;641 m_loading = false;
577 emit loadingChanged();642 emit loadingChanged();
578 return;643 return;
@@ -875,11 +940,7 @@
875940
876 switch (errorCode) {941 switch (errorCode) {
877 case EvernoteConnection::ErrorCodeNoError:942 case EvernoteConnection::ErrorCodeNoError:
878 // All is well, reset error code.943 // All is well...
879 if (!m_notebooksError.isEmpty()) {
880 m_notebooksError.clear();
881 emit notebooksErrorChanged();
882 }
883 break;944 break;
884 case EvernoteConnection::ErrorCodeUserException:945 case EvernoteConnection::ErrorCodeUserException:
885 qWarning() << "FetchNotebooksJobDone: EDAMUserException:" << errorMessage;946 qWarning() << "FetchNotebooksJobDone: EDAMUserException:" << errorMessage;
@@ -890,19 +951,19 @@
890 return; // silently discarding951 return; // silently discarding
891 default:952 default:
892 qWarning() << "FetchNotebooksJobDone: Failed to fetch notes list:" << errorMessage << errorCode;953 qWarning() << "FetchNotebooksJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
893 m_notebooksError = tr("Error refreshing notebooks: %1").arg(errorMessage);954 return; // silently discarding
894 emit notebooksErrorChanged();
895 return;
896 }955 }
897956
898 QList<Notebook*> unhandledNotebooks = m_notebooks;957 QList<Notebook*> unhandledNotebooks = m_notebooks;
899958
959 qDebug() << "[NotesStore] Have" << results.size() << "from Evernote.";
900 for (unsigned int i = 0; i < results.size(); ++i) {960 for (unsigned int i = 0; i < results.size(); ++i) {
901 evernote::edam::Notebook result = results.at(i);961 evernote::edam::Notebook result = results.at(i);
902 Notebook *notebook = m_notebooksHash.value(QString::fromStdString(result.guid));962 Notebook *notebook = m_notebooksHash.value(QString::fromStdString(result.guid));
903 unhandledNotebooks.removeAll(notebook);963 unhandledNotebooks.removeAll(notebook);
904 bool newNotebook = notebook == 0;964 bool newNotebook = notebook == 0;
905 if (newNotebook) {965 if (newNotebook) {
966 qDebug() << "[NotesStore] Found new notebook on Evernote:" << QString::fromStdString(result.guid);
906 notebook = new Notebook(QString::fromStdString(result.guid), 0, this);967 notebook = new Notebook(QString::fromStdString(result.guid), 0, this);
907 updateFromEDAM(result, notebook);968 updateFromEDAM(result, notebook);
908 m_notebooksHash.insert(notebook->guid(), notebook);969 m_notebooksHash.insert(notebook->guid(), notebook);
@@ -911,20 +972,25 @@
911 syncToCacheFile(notebook);972 syncToCacheFile(notebook);
912 } else if (notebook->synced()) {973 } else if (notebook->synced()) {
913 if (notebook->updateSequenceNumber() < result.updateSequenceNum) {974 if (notebook->updateSequenceNumber() < result.updateSequenceNum) {
975 qDebug() << "[NotesStore] Notebook on Evernote is newer than local copy. Updating:" << notebook->guid();
914 updateFromEDAM(result, notebook);976 updateFromEDAM(result, notebook);
915 emit notebookChanged(notebook->guid());977 emit notebookChanged(notebook->guid());
916 syncToCacheFile(notebook);978 syncToCacheFile(notebook);
979 } else {
980 qDebug() << "[NotesStore] Notebook is in sync:" << notebook->guid();
917 }981 }
918 } else {982 } else {
919 // Local notebook changed. See if we can push our changes983 // Local notebook changed. See if we can push our changes
920 if (result.updateSequenceNum == notebook->lastSyncedSequenceNumber()) {984 if (result.updateSequenceNum == notebook->lastSyncedSequenceNumber()) {
985 qDebug() << "[NotesStore] Local Notebook changed. Uploading changes to Evernote:" << notebook->guid();
921 SaveNotebookJob *job = new SaveNotebookJob(notebook);986 SaveNotebookJob *job = new SaveNotebookJob(notebook);
922 connect(job, &SaveNotebookJob::jobDone, this, &NotesStore::saveNotebookJobDone);987 connect(job, &SaveNotebookJob::jobDone, this, &NotesStore::saveNotebookJobDone);
923 EvernoteConnection::instance()->enqueue(job);988 EvernoteConnection::instance()->enqueue(job);
924 notebook->setLoading(true);989 notebook->setLoading(true);
925 emit notebookChanged(notebook->guid());990 emit notebookChanged(notebook->guid());
926 } else {991 } else {
927 qWarning() << "CONFLICT in notebook:" << notebook->name();992 qWarning() << "[NotesStore] Sync conflict in notebook:" << notebook->name();
993 qWarning() << "[NotesStore] Resolving of sync conflicts is not implemented yet.";
928 notebook->setSyncError(true);994 notebook->setSyncError(true);
929 emit notebookChanged(notebook->guid());995 emit notebookChanged(notebook->guid());
930 }996 }
@@ -933,18 +999,20 @@
933999
934 foreach (Notebook *notebook, unhandledNotebooks) {1000 foreach (Notebook *notebook, unhandledNotebooks) {
935 if (notebook->lastSyncedSequenceNumber() == 0) {1001 if (notebook->lastSyncedSequenceNumber() == 0) {
1002 qDebug() << "[NotesStore] Have a local notebook that doesn't exist on Evernote. Creating on server:" << notebook->guid();
936 notebook->setLoading(true);1003 notebook->setLoading(true);
937 CreateNotebookJob *job = new CreateNotebookJob(notebook);1004 CreateNotebookJob *job = new CreateNotebookJob(notebook);
938 connect(job, &CreateNotebookJob::jobDone, this, &NotesStore::createNotebookJobDone);1005 connect(job, &CreateNotebookJob::jobDone, this, &NotesStore::createNotebookJobDone);
939 EvernoteConnection::instance()->enqueue(job);1006 EvernoteConnection::instance()->enqueue(job);
940 emit notebookChanged(notebook->guid());1007 emit notebookChanged(notebook->guid());
941 } else {1008 } else {
1009 qDebug() << "[NotesStore] Notebook has been deleted on the server. Deleting local copy:" << notebook->guid();
942 m_notebooks.removeAll(notebook);1010 m_notebooks.removeAll(notebook);
943 m_notebooksHash.remove(notebook->guid());1011 m_notebooksHash.remove(notebook->guid());
944 emit notebookRemoved(notebook->guid());1012 emit notebookRemoved(notebook->guid());
9451013
946 QSettings settings(m_cacheFile, QSettings::IniFormat);1014 QSettings settings(m_cacheFile, QSettings::IniFormat);
947 settings.beginGroup("notenooks");1015 settings.beginGroup("notebooks");
948 settings.remove(notebook->guid());1016 settings.remove(notebook->guid());
949 settings.endGroup();1017 settings.endGroup();
9501018
@@ -967,6 +1035,14 @@
967 EvernoteConnection::instance()->enqueue(job);1035 EvernoteConnection::instance()->enqueue(job);
968}1036}
9691037
1038void NotesStore::clearError()
1039{
1040 if (m_errorQueue.count() > 0) {
1041 m_errorQueue.takeFirst();
1042 emit errorChanged();
1043 }
1044}
1045
970void NotesStore::fetchTagsJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const std::vector<evernote::edam::Tag> &results)1046void NotesStore::fetchTagsJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage, const std::vector<evernote::edam::Tag> &results)
971{1047{
972 m_tagsLoading = false;1048 m_tagsLoading = false;
@@ -974,11 +1050,7 @@
9741050
975 switch (errorCode) {1051 switch (errorCode) {
976 case EvernoteConnection::ErrorCodeNoError:1052 case EvernoteConnection::ErrorCodeNoError:
977 // All is well, reset error code.1053 // All is well...
978 if (!m_tagsError.isEmpty()) {
979 m_tagsError.clear();
980 emit tagsErrorChanged();
981 }
982 break;1054 break;
983 case EvernoteConnection::ErrorCodeUserException:1055 case EvernoteConnection::ErrorCodeUserException:
984 qWarning() << "FetchTagsJobDone: EDAMUserException:" << errorMessage;1056 qWarning() << "FetchTagsJobDone: EDAMUserException:" << errorMessage;
@@ -989,9 +1061,7 @@
989 return; // silently discarding1061 return; // silently discarding
990 default:1062 default:
991 qWarning() << "FetchTagsJobDone: Failed to fetch notes list:" << errorMessage << errorCode;1063 qWarning() << "FetchTagsJobDone: Failed to fetch notes list:" << errorMessage << errorCode;
992 m_tagsError = tr("Error refreshing tags: %1").arg(errorMessage);1064 return; // silently discarding
993 emit tagsErrorChanged();
994 return;
995 }1065 }
9961066
997 QHash<QString, Tag*> unhandledTags = m_tagsHash;1067 QHash<QString, Tag*> unhandledTags = m_tagsHash;
@@ -1067,10 +1137,18 @@
1067 connect(note, &Note::reminderDoneChanged, this, &NotesStore::emitDataChanged);1137 connect(note, &Note::reminderDoneChanged, this, &NotesStore::emitDataChanged);
10681138
1069 note->setTitle(title);1139 note->setTitle(title);
1070 if (notebookGuid.isEmpty() && m_notebooks.count() > 0) {1140
1071 note->setNotebookGuid(m_notebooks.first()->guid());1141 if (!notebookGuid.isEmpty()) {
1072 } else {
1073 note->setNotebookGuid(notebookGuid);1142 note->setNotebookGuid(notebookGuid);
1143 } else if (m_notebooks.count() > 0){
1144 QString generatedNotebook = m_notebooks.first()->guid();
1145 foreach (Notebook *notebook, m_notebooks) {
1146 if (notebook->isDefaultNotebook()) {
1147 generatedNotebook = notebook->guid();
1148 break;
1149 }
1150 }
1151 note->setNotebookGuid(generatedNotebook);
1074 }1152 }
1075 note->setEnmlContent(content.enml());1153 note->setEnmlContent(content.enml());
1076 note->setCreated(QDateTime::currentDateTime());1154 note->setCreated(QDateTime::currentDateTime());
@@ -1534,5 +1612,49 @@
1534 if (evNotebook.__isset.published && evNotebook.published != notebook->published()) {1612 if (evNotebook.__isset.published && evNotebook.published != notebook->published()) {
1535 notebook->setPublished(evNotebook.published);1613 notebook->setPublished(evNotebook.published);
1536 }1614 }
1615 qDebug() << "readong from evernote:" << evNotebook.__isset.defaultNotebook << evNotebook.defaultNotebook << notebook->name();
1616 if (evNotebook.__isset.defaultNotebook && evNotebook.defaultNotebook != notebook->isDefaultNotebook()) {
1617 notebook->setIsDefaultNotebook(evNotebook.defaultNotebook);
1618 }
1537 notebook->setLastSyncedSequenceNumber(evNotebook.updateSequenceNum);1619 notebook->setLastSyncedSequenceNumber(evNotebook.updateSequenceNum);
1538}1620}
1621
1622
1623void NotesStore::expungeTag(const QString &guid)
1624{
1625 if (m_username != "@local") {
1626 qWarning() << "This account is managed by Evernote. Cannot delete tags.";
1627 m_errorQueue.append(gettext("This account is managed by Evernote. Please use the Evernote website to delete tags."));
1628 emit errorChanged();
1629 return;
1630 }
1631
1632 Tag *tag = m_tagsHash.value(guid);
1633 if (!tag) {
1634 qWarning() << "[NotesStore] No tag with guid" << guid;
1635 return;
1636 }
1637
1638 while (tag->noteCount() > 0) {
1639 QString noteGuid = tag->noteAt(0);
1640 Note *note = m_notesHash.value(noteGuid);
1641 if (!note) {
1642 qWarning() << "[NotesStore] Tag holds note" << noteGuid << "which hasn't been found in Notes Store";
1643 continue;
1644 }
1645 untagNote(noteGuid, guid);
1646 }
1647
1648 emit tagRemoved(guid);
1649 m_tagsHash.remove(guid);
1650 m_tags.removeAll(tag);
1651
1652 QSettings cacheFile(m_cacheFile, QSettings::IniFormat);
1653 cacheFile.beginGroup("tags");
1654 cacheFile.remove(guid);
1655 cacheFile.endGroup();
1656 tag->syncToInfoFile();
1657
1658 tag->deleteInfoFile();
1659 tag->deleteLater();
1660}
15391661
=== modified file 'src/libqtevernote/notesstore.h'
--- src/libqtevernote/notesstore.h 2015-02-26 22:47:10 +0000
+++ src/libqtevernote/notesstore.h 2015-03-04 00:26:40 +0000
@@ -59,7 +59,6 @@
59 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)59 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
60 Q_PROPERTY(bool notebooksLoading READ notebooksLoading NOTIFY notebooksLoadingChanged)60 Q_PROPERTY(bool notebooksLoading READ notebooksLoading NOTIFY notebooksLoadingChanged)
61 Q_PROPERTY(QString error READ error NOTIFY errorChanged)61 Q_PROPERTY(QString error READ error NOTIFY errorChanged)
62 Q_PROPERTY(QString notebooksError READ notebooksError NOTIFY notebooksErrorChanged)
63 Q_PROPERTY(int count READ count NOTIFY countChanged)62 Q_PROPERTY(int count READ count NOTIFY countChanged)
6463
65public:64public:
@@ -105,8 +104,6 @@
105 bool tagsLoading() const;104 bool tagsLoading() const;
106105
107 QString error() const;106 QString error() const;
108 QString notebooksError() const;
109 QString tagsError() const;
110107
111 int count() const;108 int count() const;
112109
@@ -129,6 +126,7 @@
129 Q_INVOKABLE Notebook* notebook(const QString &guid);126 Q_INVOKABLE Notebook* notebook(const QString &guid);
130 Q_INVOKABLE void createNotebook(const QString &name);127 Q_INVOKABLE void createNotebook(const QString &name);
131 Q_INVOKABLE void saveNotebook(const QString &guid);128 Q_INVOKABLE void saveNotebook(const QString &guid);
129 Q_INVOKABLE void setDefaultNotebook(const QString &guid);
132 Q_INVOKABLE void expungeNotebook(const QString &guid);130 Q_INVOKABLE void expungeNotebook(const QString &guid);
133131
134 QList<Tag*> tags() const;132 QList<Tag*> tags() const;
@@ -137,6 +135,7 @@
137 Q_INVOKABLE void saveTag(const QString &guid);135 Q_INVOKABLE void saveTag(const QString &guid);
138 Q_INVOKABLE void tagNote(const QString &noteGuid, const QString &tagGuid);136 Q_INVOKABLE void tagNote(const QString &noteGuid, const QString &tagGuid);
139 Q_INVOKABLE void untagNote(const QString &noteGuid, const QString &tagGuid);137 Q_INVOKABLE void untagNote(const QString &noteGuid, const QString &tagGuid);
138 Q_INVOKABLE void expungeTag(const QString &guid);
140139
141public slots:140public slots:
142 void refreshNotes(const QString &filterNotebookGuid = QString(), int startIndex = 0);141 void refreshNotes(const QString &filterNotebookGuid = QString(), int startIndex = 0);
@@ -146,14 +145,14 @@
146 void refreshNotebooks();145 void refreshNotebooks();
147 void refreshTags();146 void refreshTags();
148147
148 void clearError();
149
149signals:150signals:
150 void usernameChanged();151 void usernameChanged();
151 void loadingChanged();152 void loadingChanged();
152 void notebooksLoadingChanged();153 void notebooksLoadingChanged();
153 void tagsLoadingChanged();154 void tagsLoadingChanged();
154 void errorChanged();155 void errorChanged();
155 void notebooksErrorChanged();
156 void tagsErrorChanged();
157 void countChanged();156 void countChanged();
158157
159 void noteCreated(const QString &guid, const QString &notebookGuid);158 void noteCreated(const QString &guid, const QString &notebookGuid);
@@ -167,6 +166,7 @@
167 void notebookChanged(const QString &guid);166 void notebookChanged(const QString &guid);
168 void notebookRemoved(const QString &guid);167 void notebookRemoved(const QString &guid);
169 void notebookGuidChanged(const QString &oldGuid, const QString &newGuid);168 void notebookGuidChanged(const QString &oldGuid, const QString &newGuid);
169 void defaultNotebookChanged(const QString &guid);
170170
171 void tagAdded(const QString &guid);171 void tagAdded(const QString &guid);
172 void tagChanged(const QString &guid);172 void tagChanged(const QString &guid);
@@ -213,9 +213,7 @@
213 bool m_notebooksLoading;213 bool m_notebooksLoading;
214 bool m_tagsLoading;214 bool m_tagsLoading;
215215
216 QString m_error;216 QStringList m_errorQueue;
217 QString m_notebooksError;
218 QString m_tagsError;
219217
220 QList<Note*> m_notes;218 QList<Note*> m_notes;
221 QList<Notebook*> m_notebooks;219 QList<Notebook*> m_notebooks;
222220
=== modified file 'src/libqtevernote/tag.cpp'
--- src/libqtevernote/tag.cpp 2015-02-24 22:21:04 +0000
+++ src/libqtevernote/tag.cpp 2015-03-04 00:26:40 +0000
@@ -219,3 +219,9 @@
219 emit syncErrorChanged();219 emit syncErrorChanged();
220 }220 }
221}221}
222
223
224QString Tag::noteAt(int index) const
225{
226 return m_notesList.at(index);
227}
222228
=== modified file 'src/libqtevernote/tag.h'
--- src/libqtevernote/tag.h 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/tag.h 2015-03-04 00:26:40 +0000
@@ -61,6 +61,7 @@
61 void setName(const QString &guid);61 void setName(const QString &guid);
6262
63 int noteCount() const;63 int noteCount() const;
64 QString noteAt(int index) const;
6465
65 bool loading() const;66 bool loading() const;
66 bool synced() const;67 bool synced() const;
6768
=== modified file 'src/libqtevernote/tags.cpp'
--- src/libqtevernote/tags.cpp 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/tags.cpp 2015-03-04 00:26:40 +0000
@@ -32,7 +32,6 @@
32 }32 }
3333
34 connect(NotesStore::instance(), &NotesStore::tagsLoadingChanged, this, &Tags::loadingChanged);34 connect(NotesStore::instance(), &NotesStore::tagsLoadingChanged, this, &Tags::loadingChanged);
35 connect(NotesStore::instance(), &NotesStore::tagsErrorChanged, this, &Tags::errorChanged);
36 connect(NotesStore::instance(), &NotesStore::tagAdded, this, &Tags::tagAdded);35 connect(NotesStore::instance(), &NotesStore::tagAdded, this, &Tags::tagAdded);
37 connect(NotesStore::instance(), &NotesStore::tagRemoved, this, &Tags::tagRemoved);36 connect(NotesStore::instance(), &NotesStore::tagRemoved, this, &Tags::tagRemoved);
38 connect(NotesStore::instance(), &NotesStore::tagGuidChanged, this, &Tags::tagGuidChanged);37 connect(NotesStore::instance(), &NotesStore::tagGuidChanged, this, &Tags::tagGuidChanged);
@@ -43,11 +42,6 @@
43 return NotesStore::instance()->tagsLoading();42 return NotesStore::instance()->tagsLoading();
44}43}
4544
46QString Tags::error() const
47{
48 return NotesStore::instance()->tagsError();
49}
50
51int Tags::count() const45int Tags::count() const
52{46{
53 return rowCount();47 return rowCount();
5448
=== modified file 'src/libqtevernote/tags.h'
--- src/libqtevernote/tags.h 2014-12-13 03:55:52 +0000
+++ src/libqtevernote/tags.h 2015-03-04 00:26:40 +0000
@@ -29,7 +29,6 @@
29{29{
30 Q_OBJECT30 Q_OBJECT
31 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)31 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
32 Q_PROPERTY(QString error READ error NOTIFY errorChanged)
33 Q_PROPERTY(int count READ count NOTIFY countChanged)32 Q_PROPERTY(int count READ count NOTIFY countChanged)
3433
35public:34public:
@@ -44,7 +43,6 @@
44 explicit Tags(QObject *parent = 0);43 explicit Tags(QObject *parent = 0);
4544
46 bool loading() const;45 bool loading() const;
47 QString error() const;
48 int count() const;46 int count() const;
4947
50 QVariant data(const QModelIndex &index, int role) const;48 QVariant data(const QModelIndex &index, int role) const;
@@ -58,7 +56,6 @@
5856
59signals:57signals:
60 void loadingChanged();58 void loadingChanged();
61 void errorChanged();
62 void countChanged();59 void countChanged();
6360
64private slots:61private slots:

Subscribers

People subscribed via source and target branches