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
=== modified file 'src/app/qml/reminders.qml'
--- src/app/qml/reminders.qml 2015-03-04 14:31:29 +0000
+++ src/app/qml/reminders.qml 2015-03-04 23:25:12 +0000
@@ -149,6 +149,7 @@
149 var page = component.createObject();149 var page = component.createObject();
150 pagestack.push(page)150 pagestack.push(page)
151 page.noteSelected.connect(function(note) {root.displayNote(note)})151 page.noteSelected.connect(function(note) {root.displayNote(note)})
152 page.editNote.connect(function(note) {root.switchToEditMode(note)})
152 }153 }
153154
154 function doLogin() {155 function doLogin() {
@@ -502,6 +503,9 @@
502 page.editNote.connect(function(note) {503 page.editNote.connect(function(note) {
503 root.switchToEditMode(note)504 root.switchToEditMode(note)
504 })505 })
506 page.openSearch.connect(function() {
507 root.openSearch();
508 })
505 NotesStore.refreshNotes();509 NotesStore.refreshNotes();
506 }510 }
507511
508512
=== modified file 'src/app/qml/ui/SearchNotesPage.qml'
--- src/app/qml/ui/SearchNotesPage.qml 2015-02-28 01:43:49 +0000
+++ src/app/qml/ui/SearchNotesPage.qml 2015-03-04 23:25:12 +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
@@ -26,6 +27,7 @@
26 id: root27 id: root
2728
28 signal noteSelected(var note)29 signal noteSelected(var note)
30 signal editNote(var note)
2931
30 title: i18n.tr("Search notes")32 title: i18n.tr("Search notes")
3133
@@ -49,7 +51,7 @@
49 }51 }
5052
51 onAccepted: {53 onAccepted: {
52 NotesStore.findNotes(searchField.text + "*")54 NotesStore.findNotes(searchField.text)
53 }55 }
54 }56 }
55 Button {57 Button {
@@ -57,7 +59,7 @@
57 height: searchField.height59 height: searchField.height
58 text: i18n.tr("Search")60 text: i18n.tr("Search")
59 onClicked: {61 onClicked: {
60 NotesStore.findNotes(searchField.text + "*")62 NotesStore.findNotes(searchField.text)
61 }63 }
62 }64 }
63 }65 }
@@ -69,6 +71,12 @@
6971
70 model: Notes {72 model: Notes {
71 onlySearchResults: true73 onlySearchResults: true
74
75 Component.onCompleted: {
76 if (count > 0) {
77 NotesStore.clearSearchResults();
78 }
79 }
72 }80 }
7381
74 delegate: NotesDelegate {82 delegate: NotesDelegate {
@@ -105,8 +113,9 @@
105 pageStack.push(Qt.resolvedUrl("SetReminderPage.qml"), { note: NotesStore.note(model.guid) });113 pageStack.push(Qt.resolvedUrl("SetReminderPage.qml"), { note: NotesStore.note(model.guid) });
106 }114 }
107 onEditTags: {115 onEditTags: {
108 PopupUtils.open(Qt.resolvedUrl("../components/EditTagsDialog.qml"), root,116 var popup = PopupUtils.open(Qt.resolvedUrl("../components/EditTagsDialog.qml"), root,
109 { note: NotesStore.note(model.guid), pageHeight: root.height });117 { note: NotesStore.note(model.guid), pageHeight: root.height });
118 popup.done.connect(function() { NotesStore.saveNote(popup.note.guid)})
110 }119 }
111 }120 }
112 }121 }
113122
=== modified file 'src/libqtevernote/notesstore.cpp'
--- src/libqtevernote/notesstore.cpp 2015-03-04 20:30:55 +0000
+++ src/libqtevernote/notesstore.cpp 2015-03-04 23:25:12 +0000
@@ -1374,14 +1374,19 @@
13741374
1375void NotesStore::findNotes(const QString &searchWords)1375void NotesStore::findNotes(const QString &searchWords)
1376{1376{
1377 foreach (Note *note, m_notes) {1377 if (EvernoteConnection::instance()->isConnected()) {
1378 note->setIsSearchResult(false);1378 clearSearchResults();
1379 FetchNotesJob *job = new FetchNotesJob(QString(), searchWords + "*");
1380 connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);
1381 EvernoteConnection::instance()->enqueue(job);
1382 } else {
1383 foreach (Note *note, m_notes) {
1384 bool matches = note->title().contains(searchWords, Qt::CaseInsensitive);
1385 matches |= note->plaintextContent().contains(searchWords, Qt::CaseInsensitive);
1386 note->setIsSearchResult(matches);
1387 }
1388 emit dataChanged(index(0), index(m_notes.count()-1), QVector<int>() << RoleIsSearchResult);
1379 }1389 }
1380 emit dataChanged(index(0), index(m_notes.count()), QVector<int>() << RoleIsSearchResult);
1381
1382 FetchNotesJob *job = new FetchNotesJob(QString(), searchWords);
1383 connect(job, &FetchNotesJob::jobDone, this, &NotesStore::fetchNotesJobDone);
1384 EvernoteConnection::instance()->enqueue(job);
1385}1390}
13861391
1387void NotesStore::clearSearchResults()1392void NotesStore::clearSearchResults()

Subscribers

People subscribed via source and target branches