Merge lp:~mzanetti/reminders-app/improve-sorting into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: David Planella
Approved revision: 292
Merged at revision: 298
Proposed branch: lp:~mzanetti/reminders-app/improve-sorting
Merge into: lp:reminders-app
Diff against target: 33 lines (+14/-1)
2 files modified
src/plugin/Evernote/notes.cpp (+12/-0)
src/plugin/Evernote/notes.h (+2/-1)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/improve-sorting
Reviewer Review Type Date Requested Status
David Planella Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+240848@code.launchpad.net

Commit message

improve sorting by falling back on title if the first sortrole is equal

Description of the change

improve sorting by falling back on title if the first sortrole is equal

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
David Planella (dpm) wrote :

After a discussion on IRC, I understand the context: essentially, if the timestamp is the same, then we compare and sort on title. Works well for me, no more jumping up and down of notes in the list.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/Evernote/notes.cpp'
2--- src/plugin/Evernote/notes.cpp 2014-10-20 18:53:50 +0000
3+++ src/plugin/Evernote/notes.cpp 2014-11-06 13:08:02 +0000
4@@ -163,3 +163,15 @@
5 }
6 return true;
7 }
8+
9+bool Notes::lessThan(const QModelIndex &left, const QModelIndex &right) const
10+{
11+ QVariant leftValue = sourceModel()->data(left, sortRole()).toString();
12+ QVariant rightValue = sourceModel()->data(right, sortRole()).toString();
13+
14+ if (leftValue == rightValue) {
15+ return sourceModel()->data(left, NotesStore::RoleTitle).toString() < sourceModel()->data(right, NotesStore::RoleTitle).toString();
16+ }
17+
18+ return leftValue < rightValue;
19+}
20
21=== modified file 'src/plugin/Evernote/notes.h'
22--- src/plugin/Evernote/notes.h 2014-10-09 00:08:52 +0000
23+++ src/plugin/Evernote/notes.h 2014-11-06 13:08:02 +0000
24@@ -60,7 +60,8 @@
25 Q_INVOKABLE int sectionCount(const QString &sectionRole, const QString &section);
26
27 protected:
28- bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
29+ bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
30+ bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
31
32 signals:
33 void filterNotebookGuidChanged();

Subscribers

People subscribed via source and target branches