Merge lp:~mzanetti/reminders-app/fix-search into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 375
Merged at revision: 376
Proposed branch: lp:~mzanetti/reminders-app/fix-search
Merge into: lp:reminders-app
Diff against target: 114 lines (+28/-10)
3 files modified
src/app/qml/reminders.qml (+4/-0)
src/app/qml/ui/SearchNotesPage.qml (+12/-3)
src/libqtevernote/notesstore.cpp (+12/-7)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/fix-search
Reviewer Review Type Date Requested Status
Riccardo Padovani Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+251846@code.launchpad.net

Commit message

some more fixes for search

* fix actions invoked from search page
* make note page work from everywhere
* make search work in offline mode
* properly reset the search when needed

To post a comment you must log in.
375. By Michael Zanetti

make search work in offline mode

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

lgtm

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/reminders.qml'
2--- src/app/qml/reminders.qml 2015-03-04 14:31:29 +0000
3+++ src/app/qml/reminders.qml 2015-03-04 23:25:12 +0000
4@@ -149,6 +149,7 @@
5 var page = component.createObject();
6 pagestack.push(page)
7 page.noteSelected.connect(function(note) {root.displayNote(note)})
8+ page.editNote.connect(function(note) {root.switchToEditMode(note)})
9 }
10
11 function doLogin() {
12@@ -502,6 +503,9 @@
13 page.editNote.connect(function(note) {
14 root.switchToEditMode(note)
15 })
16+ page.openSearch.connect(function() {
17+ root.openSearch();
18+ })
19 NotesStore.refreshNotes();
20 }
21
22
23=== modified file 'src/app/qml/ui/SearchNotesPage.qml'
24--- src/app/qml/ui/SearchNotesPage.qml 2015-02-28 01:43:49 +0000
25+++ src/app/qml/ui/SearchNotesPage.qml 2015-03-04 23:25:12 +0000
26@@ -19,6 +19,7 @@
27 import QtQuick 2.3
28 import Ubuntu.Components 1.1
29 import Ubuntu.Components.ListItems 1.0
30+import Ubuntu.Components.Popups 1.0
31 import Evernote 0.1
32 import "../components"
33
34@@ -26,6 +27,7 @@
35 id: root
36
37 signal noteSelected(var note)
38+ signal editNote(var note)
39
40 title: i18n.tr("Search notes")
41
42@@ -49,7 +51,7 @@
43 }
44
45 onAccepted: {
46- NotesStore.findNotes(searchField.text + "*")
47+ NotesStore.findNotes(searchField.text)
48 }
49 }
50 Button {
51@@ -57,7 +59,7 @@
52 height: searchField.height
53 text: i18n.tr("Search")
54 onClicked: {
55- NotesStore.findNotes(searchField.text + "*")
56+ NotesStore.findNotes(searchField.text)
57 }
58 }
59 }
60@@ -69,6 +71,12 @@
61
62 model: Notes {
63 onlySearchResults: true
64+
65+ Component.onCompleted: {
66+ if (count > 0) {
67+ NotesStore.clearSearchResults();
68+ }
69+ }
70 }
71
72 delegate: NotesDelegate {
73@@ -105,8 +113,9 @@
74 pageStack.push(Qt.resolvedUrl("SetReminderPage.qml"), { note: NotesStore.note(model.guid) });
75 }
76 onEditTags: {
77- PopupUtils.open(Qt.resolvedUrl("../components/EditTagsDialog.qml"), root,
78+ var popup = PopupUtils.open(Qt.resolvedUrl("../components/EditTagsDialog.qml"), root,
79 { note: NotesStore.note(model.guid), pageHeight: root.height });
80+ popup.done.connect(function() { NotesStore.saveNote(popup.note.guid)})
81 }
82 }
83 }
84
85=== modified file 'src/libqtevernote/notesstore.cpp'
86--- src/libqtevernote/notesstore.cpp 2015-03-04 20:30:55 +0000
87+++ src/libqtevernote/notesstore.cpp 2015-03-04 23:25:12 +0000
88@@ -1374,14 +1374,19 @@
89
90 void NotesStore::findNotes(const QString &searchWords)
91 {
92- foreach (Note *note, m_notes) {
93- note->setIsSearchResult(false);
94+ if (EvernoteConnection::instance()->isConnected()) {
95+ clearSearchResults();
96+ FetchNotesJob *job = new FetchNotesJob(QString(), searchWords + "*");
97+ connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);
98+ EvernoteConnection::instance()->enqueue(job);
99+ } else {
100+ foreach (Note *note, m_notes) {
101+ bool matches = note->title().contains(searchWords, Qt::CaseInsensitive);
102+ matches |= note->plaintextContent().contains(searchWords, Qt::CaseInsensitive);
103+ note->setIsSearchResult(matches);
104+ }
105+ emit dataChanged(index(0), index(m_notes.count()-1), QVector<int>() << RoleIsSearchResult);
106 }
107- emit dataChanged(index(0), index(m_notes.count()), QVector<int>() << RoleIsSearchResult);
108-
109- FetchNotesJob *job = new FetchNotesJob(QString(), searchWords);
110- connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);
111- EvernoteConnection::instance()->enqueue(job);
112 }
113
114 void NotesStore::clearSearchResults()

Subscribers

People subscribed via source and target branches