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
=== modified file 'src/plugin/Evernote/notes.cpp'
--- src/plugin/Evernote/notes.cpp 2014-10-20 18:53:50 +0000
+++ src/plugin/Evernote/notes.cpp 2014-11-06 13:08:02 +0000
@@ -163,3 +163,15 @@
163 }163 }
164 return true;164 return true;
165}165}
166
167bool Notes::lessThan(const QModelIndex &left, const QModelIndex &right) const
168{
169 QVariant leftValue = sourceModel()->data(left, sortRole()).toString();
170 QVariant rightValue = sourceModel()->data(right, sortRole()).toString();
171
172 if (leftValue == rightValue) {
173 return sourceModel()->data(left, NotesStore::RoleTitle).toString() < sourceModel()->data(right, NotesStore::RoleTitle).toString();
174 }
175
176 return leftValue < rightValue;
177}
166178
=== modified file 'src/plugin/Evernote/notes.h'
--- src/plugin/Evernote/notes.h 2014-10-09 00:08:52 +0000
+++ src/plugin/Evernote/notes.h 2014-11-06 13:08:02 +0000
@@ -60,7 +60,8 @@
60 Q_INVOKABLE int sectionCount(const QString &sectionRole, const QString &section);60 Q_INVOKABLE int sectionCount(const QString &sectionRole, const QString &section);
6161
62protected:62protected:
63 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;63 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
64 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
6465
65signals:66signals:
66 void filterNotebookGuidChanged();67 void filterNotebookGuidChanged();

Subscribers

People subscribed via source and target branches