Merge lp:~mzanetti/reminders-app/sort-order into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„
Approved revision: 344
Merged at revision: 345
Proposed branch: lp:~mzanetti/reminders-app/sort-order
Merge into: lp:reminders-app
Diff against target: 367 lines (+230/-8)
7 files modified
src/app/qml/components/NotesDelegate.qml (+2/-5)
src/app/qml/components/SortingDialog.qml (+49/-0)
src/app/qml/images/sorting.svg (+95/-0)
src/app/qml/ui/NotesPage.qml (+24/-2)
src/libqtevernote/notes.cpp (+43/-1)
src/libqtevernote/notes.h (+16/-0)
src/libqtevernote/notesstore.cpp (+1/-0)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/sort-order
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Riccardo Padovani Approve
Review via email: mp+249576@code.launchpad.net

Commit message

add sort order header action

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 :

IMO the preference about the sort order has to be saved, so at every start users haven't to change the sort order again

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> IMO the preference about the sort order has to be saved, so at every start
> users haven't to change the sort order again

fixed. thanks

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

lgtm now, thanks

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
343. By Michael Zanetti

try shuffling the order

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
344. By Michael Zanetti

really don't know why jenkins wouldn't allow me to import Popups from NotesPage.qml

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/qml/components/NotesDelegate.qml'
--- src/app/qml/components/NotesDelegate.qml 2015-02-12 23:47:43 +0000
+++ src/app/qml/components/NotesDelegate.qml 2015-02-21 14:13:56 +0000
@@ -28,8 +28,7 @@
28 width: parent.width28 width: parent.width
2929
30 property string title30 property string title
31 property date creationDate31 property string date
32 property date changedDate
33 property string content32 property string content
34 property string resource33 property string resource
35 property string tags34 property string tags
@@ -124,10 +123,8 @@
124 Label {123 Label {
125 Layout.fillWidth: true124 Layout.fillWidth: true
126 Layout.fillHeight: true125 Layout.fillHeight: true
127 // TRANSLATORS: the argument is a modification date that follows this format:
128 // http://qt-project.org/doc/qt-5/qml-qtqml-date.html
129 text: "<font color=\"" + root.notebookColor + "\">" +126 text: "<font color=\"" + root.notebookColor + "\">" +
130 Qt.formatDateTime(root.creationDate, i18n.tr("yyyy/mm/dd hh:mm")) +127 Qt.formatDateTime(root.date, Qt.LocalDate) +
131 " </font>" + root.content128 " </font>" + root.content
132 wrapMode: Text.WordWrap129 wrapMode: Text.WordWrap
133 textFormat: Text.StyledText130 textFormat: Text.StyledText
134131
=== added file 'src/app/qml/components/SortingDialog.qml'
--- src/app/qml/components/SortingDialog.qml 1970-01-01 00:00:00 +0000
+++ src/app/qml/components/SortingDialog.qml 2015-02-21 14:13:56 +0000
@@ -0,0 +1,49 @@
1import QtQuick 2.2
2import Ubuntu.Components 1.0
3import Ubuntu.Components.Popups 1.0
4import Ubuntu.Components.ListItems 1.0
5import reminders 1.0
6
7Item {
8 id: root
9
10 property int sortOrder
11
12 signal accepted();
13
14 Component.onCompleted: PopupUtils.open(dialogComponent, root, {sortOrder: root.sortOrder})
15
16 Component {
17 id: dialogComponent
18 Dialog {
19 id: dialog
20 title: i18n.tr("Sort by")
21
22 property alias sortOrder: optionSelector.selectedIndex
23
24
25 OptionSelector {
26 id: optionSelector
27 expanded: true
28 model: [
29 i18n.tr("Date created (newest first)"),
30 i18n.tr("Date created (oldest first)"),
31 i18n.tr("Date updated (newest first)"),
32 i18n.tr("Date updated (oldest first)"),
33 i18n.tr("Title (ascending)"),
34 i18n.tr("Title (descending)")
35 ]
36 }
37
38 Button {
39 text: i18n.tr("Close")
40 onClicked: {
41 root.sortOrder = optionSelector.selectedIndex
42 root.accepted();
43 PopupUtils.close(dialog);
44 }
45 }
46 }
47 }
48}
49
050
=== added file 'src/app/qml/images/sorting.svg'
--- src/app/qml/images/sorting.svg 1970-01-01 00:00:00 +0000
+++ src/app/qml/images/sorting.svg 2015-02-21 14:13:56 +0000
@@ -0,0 +1,95 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!-- Created with Inkscape (http://www.inkscape.org/) -->
3
4<svg
5 xmlns:dc="http://purl.org/dc/elements/1.1/"
6 xmlns:cc="http://creativecommons.org/ns#"
7 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8 xmlns:svg="http://www.w3.org/2000/svg"
9 xmlns="http://www.w3.org/2000/svg"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 id="svg4874"
13 height="90"
14 viewBox="0 0 90 90.000001"
15 width="90"
16 version="1.1"
17 inkscape:version="0.48.5 r10040"
18 sodipodi:docname="user-switch.svg">
19 <defs
20 id="defs14" />
21 <sodipodi:namedview
22 pagecolor="#ffffff"
23 bordercolor="#666666"
24 borderopacity="1"
25 objecttolerance="10"
26 gridtolerance="10"
27 guidetolerance="10"
28 inkscape:pageopacity="0"
29 inkscape:pageshadow="2"
30 inkscape:window-width="2880"
31 inkscape:window-height="1752"
32 id="namedview12"
33 showgrid="false"
34 inkscape:zoom="2.6222222"
35 inkscape:cx="45"
36 inkscape:cy="45"
37 inkscape:window-x="0"
38 inkscape:window-y="48"
39 inkscape:window-maximized="1"
40 inkscape:current-layer="svg4874" />
41 <metadata
42 id="metadata4879">
43 <rdf:RDF>
44 <cc:Work
45 rdf:about="">
46 <dc:format>image/svg+xml</dc:format>
47 <dc:type
48 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
49 <dc:title />
50 </cc:Work>
51 </rdf:RDF>
52 </metadata>
53 <g
54 id="layer1"
55 transform="matrix(0,1,-1,0,174.505,67.856999)">
56 <g
57 id="g4115">
58 <rect
59 id="rect4198-7"
60 style="color:#000000;fill:none"
61 height="90"
62 width="90"
63 y="84.504997"
64 x="-67.857002" />
65 <rect
66 id="rect3049"
67 style="color:#000000;fill:none"
68 transform="scale(-1,1)"
69 height="90"
70 width="90"
71 y="84.504997"
72 x="-22.143" />
73 <path
74 id="rect3765"
75 style="color:#000000;fill:#808080"
76 d="m -33.857,152.51 h 36 l 9.2e-6,-9 -36.0000002,1e-5 z"
77 inkscape:connector-curvature="0" />
78 <path
79 id="path4130"
80 style="color:#000000;fill:#808080"
81 d="m -30.717,162.59 c 0,0 -13.63,-5.962 -25.549,-14.552 0,-0.002 0,-0.004 0.0051,-0.009 0,-0.002 0.0051,-0.007 0.006,-0.01 0,-0.002 0.0051,-0.007 0.006,-0.01 0,-0.002 0.0051,-0.007 0.0051,-0.01 12.573,-8.8638 25.532,-14.498 25.532,-14.498 z"
82 inkscape:connector-curvature="0" />
83 <path
84 id="path4118"
85 style="color:#000000;fill:#808080"
86 d="m -11.857,115.51 h -36 l -9e-6,-9 36,10e-6 z"
87 inkscape:connector-curvature="0" />
88 <path
89 id="path4120"
90 style="color:#000000;fill:#808080"
91 d="m -14.998,125.59 c 0,0 13.63,-5.962 25.549,-14.552 0,-0.002 0,-0.004 -0.0051,-0.009 0,-0.002 -0.0051,-0.007 -0.006,-0.01 0,-0.002 -0.0051,-0.007 -0.006,-0.01 0,-0.002 -0.0051,-0.007 -0.0051,-0.01 -12.573,-8.8638 -25.532,-14.498 -25.532,-14.498 z"
92 inkscape:connector-curvature="0" />
93 </g>
94 </g>
95</svg>
096
=== modified file 'src/app/qml/ui/NotesPage.qml'
--- src/app/qml/ui/NotesPage.qml 2015-02-12 23:47:43 +0000
+++ src/app/qml/ui/NotesPage.qml 2015-02-21 14:13:56 +0000
@@ -23,6 +23,7 @@
23import Ubuntu.Components.Popups 1.023import Ubuntu.Components.Popups 1.0
24import Evernote 0.124import Evernote 0.1
25import "../components"25import "../components"
26import Qt.labs.settings 1.0
2627
27PageWithBottomEdge {28PageWithBottomEdge {
28 id: root29 id: root
@@ -80,6 +81,22 @@
8081
81 ToolbarButton {82 ToolbarButton {
82 action: Action {83 action: Action {
84 iconSource: "../images/sorting.svg"
85 text: i18n.tr("Sorting")
86 onTriggered: {
87 var popupComponent = Qt.createComponent(Qt.resolvedUrl("../components/SortingDialog.qml"));
88 var popup = popupComponent.createObject(root, {sortOrder: notes.sortOrder} )
89 popup.accepted.connect( function() {
90 notes.sortOrder = popup.sortOrder
91 popup.destroy();
92 })
93 popup.sortOrder = notes.sortOrder;
94 }
95 }
96 }
97
98 ToolbarButton {
99 action: Action {
83 text: i18n.tr("Accounts")100 text: i18n.tr("Accounts")
84 iconName: "contacts-app-symbolic"101 iconName: "contacts-app-symbolic"
85 onTriggered: {102 onTriggered: {
@@ -127,6 +144,10 @@
127 }144 }
128 }145 }
129146
147 Settings {
148 property alias sortOrder: notes.sortOrder
149 }
150
130 Notes {151 Notes {
131 id: notes152 id: notes
132 }153 }
@@ -146,8 +167,9 @@
146167
147 delegate: NotesDelegate {168 delegate: NotesDelegate {
148 title: model.title169 title: model.title
149 creationDate: model.created170 date: notes.sortOrder == Notes.SortOrderUpdatedOldest || notes.sortOrder == Notes.SortOrderUpdatedNewest ?
150 changedDate: model.updated171 model.updated : model.created
172
151 content: model.tagline173 content: model.tagline
152 triggerActionOnMouseRelease: true174 triggerActionOnMouseRelease: true
153 tags: {175 tags: {
154176
=== modified file 'src/libqtevernote/notes.cpp'
--- src/libqtevernote/notes.cpp 2014-12-10 22:27:42 +0000
+++ src/libqtevernote/notes.cpp 2015-02-21 14:13:56 +0000
@@ -26,7 +26,8 @@
26Notes::Notes(QObject *parent) :26Notes::Notes(QObject *parent) :
27 QSortFilterProxyModel(parent),27 QSortFilterProxyModel(parent),
28 m_onlyReminders(false),28 m_onlyReminders(false),
29 m_showDeleted(false)29 m_showDeleted(false),
30 m_sortOrder(SortOrderDateCreatedNewest)
30{31{
31 connect(NotesStore::instance(), &NotesStore::loadingChanged, this, &Notes::loadingChanged);32 connect(NotesStore::instance(), &NotesStore::loadingChanged, this, &Notes::loadingChanged);
32 connect(NotesStore::instance(), &NotesStore::errorChanged, this, &Notes::errorChanged);33 connect(NotesStore::instance(), &NotesStore::errorChanged, this, &Notes::errorChanged);
@@ -154,6 +155,47 @@
154 return count;155 return count;
155}156}
156157
158Notes::SortOrder Notes::sortOrder() const
159{
160 return m_sortOrder;
161}
162
163void Notes::setSortOrder(Notes::SortOrder sortOrder)
164{
165 if (m_sortOrder != sortOrder) {
166 emit layoutAboutToBeChanged();
167 switch (sortOrder) {
168 case SortOrderDateCreatedNewest:
169 setSortRole(NotesStore::RoleCreated);
170 sort(0, Qt::DescendingOrder);
171 break;
172 case SortOrderDateCreatedOldest:
173 setSortRole(NotesStore::RoleCreated);
174 sort(0, Qt::AscendingOrder);
175 break;
176 case SortOrderDateUpdatedNewest:
177 setSortRole(NotesStore::RoleUpdated);
178 sort(0, Qt::DescendingOrder);
179 break;
180 case SortOrderDateUpdatedOldest:
181 setSortRole(NotesStore::RoleUpdated);
182 sort(0, Qt::AscendingOrder);
183 break;
184 case SortOrderTitleAscending:
185 setSortRole(NotesStore::RoleTitle);
186 sort(0, Qt::AscendingOrder);
187 break;
188 case SortOrderTitleDescending:
189 setSortRole(NotesStore::RoleTitle);
190 sort(0, Qt::DescendingOrder);
191 break;
192 }
193 m_sortOrder = sortOrder;
194 emit sortOrderChanged();
195 emit layoutChanged();
196 }
197}
198
157bool Notes::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const199bool Notes::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
158{200{
159 QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);201 QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);
160202
=== modified file 'src/libqtevernote/notes.h'
--- src/libqtevernote/notes.h 2014-12-08 10:25:48 +0000
+++ src/libqtevernote/notes.h 2015-02-21 14:13:56 +0000
@@ -28,6 +28,7 @@
28class Notes : public QSortFilterProxyModel28class Notes : public QSortFilterProxyModel
29{29{
30 Q_OBJECT30 Q_OBJECT
31 Q_ENUMS(SortOrder)
31 Q_PROPERTY(QString filterNotebookGuid READ filterNotebookGuid WRITE setFilterNotebookGuid NOTIFY filterNotebookGuidChanged)32 Q_PROPERTY(QString filterNotebookGuid READ filterNotebookGuid WRITE setFilterNotebookGuid NOTIFY filterNotebookGuidChanged)
32 Q_PROPERTY(QString filterTagGuid READ filterTagGuid WRITE setFilterTagGuid NOTIFY filterTagGuidChanged)33 Q_PROPERTY(QString filterTagGuid READ filterTagGuid WRITE setFilterTagGuid NOTIFY filterTagGuidChanged)
33 Q_PROPERTY(bool onlyReminders READ onlyReminders WRITE setOnlyReminders NOTIFY onlyRemindersChanged)34 Q_PROPERTY(bool onlyReminders READ onlyReminders WRITE setOnlyReminders NOTIFY onlyRemindersChanged)
@@ -36,8 +37,18 @@
36 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)37 Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
37 Q_PROPERTY(QString error READ error NOTIFY errorChanged)38 Q_PROPERTY(QString error READ error NOTIFY errorChanged)
38 Q_PROPERTY(int count READ count NOTIFY countChanged)39 Q_PROPERTY(int count READ count NOTIFY countChanged)
40 Q_PROPERTY(SortOrder sortOrder READ sortOrder WRITE setSortOrder NOTIFY sortOrderChanged)
3941
40public:42public:
43 enum SortOrder {
44 SortOrderDateCreatedNewest,
45 SortOrderDateCreatedOldest,
46 SortOrderDateUpdatedNewest,
47 SortOrderDateUpdatedOldest,
48 SortOrderTitleAscending,
49 SortOrderTitleDescending
50 };
51
41 explicit Notes(QObject *parent = 0);52 explicit Notes(QObject *parent = 0);
4253
43 QString filterNotebookGuid() const;54 QString filterNotebookGuid() const;
@@ -63,6 +74,9 @@
6374
64 Q_INVOKABLE int sectionCount(const QString &sectionRole, const QString &section);75 Q_INVOKABLE int sectionCount(const QString &sectionRole, const QString &section);
6576
77 SortOrder sortOrder() const;
78 void setSortOrder(SortOrder sortOrder);
79
66protected:80protected:
67 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;81 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
68 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;82 bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
@@ -76,6 +90,7 @@
76 void loadingChanged();90 void loadingChanged();
77 void errorChanged();91 void errorChanged();
78 void countChanged();92 void countChanged();
93 void sortOrderChanged();
7994
80private:95private:
81 QString m_filterNotebookGuid;96 QString m_filterNotebookGuid;
@@ -83,6 +98,7 @@
83 bool m_onlyReminders;98 bool m_onlyReminders;
84 bool m_onlySearchResults;99 bool m_onlySearchResults;
85 bool m_showDeleted;100 bool m_showDeleted;
101 SortOrder m_sortOrder;
86};102};
87103
88#endif // NOTES_H104#endif // NOTES_H
89105
=== modified file 'src/libqtevernote/notesstore.cpp'
--- src/libqtevernote/notesstore.cpp 2014-12-16 21:01:28 +0000
+++ src/libqtevernote/notesstore.cpp 2015-02-21 14:13:56 +0000
@@ -1142,6 +1142,7 @@
1142 return;1142 return;
1143 }1143 }
1144 note->setUpdateSequenceNumber(note->updateSequenceNumber()+1);1144 note->setUpdateSequenceNumber(note->updateSequenceNumber()+1);
1145 note->setUpdated(QDateTime::currentDateTime());
1145 syncToCacheFile(note);1146 syncToCacheFile(note);
1146 note->syncToCacheFile();1147 note->syncToCacheFile();
11471148

Subscribers

People subscribed via source and target branches