Merge lp:~mzanetti/reminders-app/notes-headers-to-trunk into lp:reminders-app

Proposed by Michael Zanetti
Status: Merged
Approved by: David Planella
Approved revision: 119
Merged at revision: 118
Proposed branch: lp:~mzanetti/reminders-app/notes-headers-to-trunk
Merge into: lp:reminders-app
Diff against target: 194 lines (+71/-7)
7 files modified
src/app/qml/ui/NotesPage.qml (+20/-0)
src/plugin/Evernote/note.cpp (+28/-6)
src/plugin/Evernote/note.h (+2/-0)
src/plugin/Evernote/notes.cpp (+14/-0)
src/plugin/Evernote/notes.h (+2/-0)
src/plugin/Evernote/notesstore.cpp (+3/-0)
src/plugin/Evernote/notesstore.h (+2/-1)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/notes-headers-to-trunk
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
David Planella Approve
Review via email: mp+218462@code.launchpad.net

Commit message

cherry-picks notes-headers from new-design branch into trunk

To post a comment you must log in.
Revision history for this message
David Planella (dpm) wrote :

82 + return createdDate.toString("MMMM yyyy");

Could we make this something along the lines of:

const QLocale l = QLocale::system();

return QString(gettext("%1 %2")).arg(l.standaloneMonthName(createdDate.month())).arg(createdDate.year());

The issue here is that the QDate formats don't work very well for all locales. So "MMMM" does not return the standalone month name in e.g. Catalan. I.e. instead of "gener" it returns "de gener" - the translation in English would be "January" vs. "of January"

review: Needs Fixing
Revision history for this message
David Planella (dpm) wrote :

Also, as per the IRC conversation, we'll need to wait for qtdeclarative5-quicklayouts-plugin to land in an image before this can land.

Revision history for this message
David Planella (dpm) wrote :

80 + return gettext("Two weeks ago");

It's just a nitpick, so I won't mark it as "Needs fixing", but for the sake of being pedantic :) Generally gettext calls are done using the _() macro in C, although I'm not sure what the general practice is for C++ code using it.

118. By Michael Zanetti

use QLocale to obtain the Month to work around some language corner cases

119. By Michael Zanetti

don't use QtQuick.Layouts just yet

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 :

Looks good to me and works well, thanks for getting around the Layouts dependency!

review: Approve
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
1=== modified file 'src/app/qml/ui/NotesPage.qml'
2--- src/app/qml/ui/NotesPage.qml 2014-04-30 21:53:07 +0000
3+++ src/app/qml/ui/NotesPage.qml 2014-05-06 17:04:10 +0000
4@@ -120,6 +120,26 @@
5 root.selectedNote = NotesStore.note(guid);
6 }
7 }
8+
9+ section.criteria: ViewSection.FullString
10+ section.property: "createdString"
11+ section.delegate: Empty {
12+ height: units.gu(5)
13+ Item {
14+ anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: units.gu(1) }
15+ Label {
16+ text: section
17+ anchors.left: parent.left
18+ anchors.verticalCenter: parent.verticalCenter
19+ }
20+ Label {
21+ text: "(" + notes.sectionCount("createdString", section) + ")"
22+ anchors.right: parent.right
23+ anchors.verticalCenter: parent.verticalCenter
24+ }
25+ }
26+ }
27+
28 ActivityIndicator {
29 anchors.centerIn: parent
30 running: notes.loading
31
32=== modified file 'src/plugin/Evernote/note.cpp'
33--- src/plugin/Evernote/note.cpp 2014-04-30 16:52:15 +0000
34+++ src/plugin/Evernote/note.cpp 2014-05-06 17:04:10 +0000
35@@ -22,6 +22,8 @@
36
37 #include "notesstore.h"
38
39+#include <libintl.h>
40+
41 #include <QDateTime>
42 #include <QUrl>
43 #include <QUrlQuery>
44@@ -72,6 +74,26 @@
45 return m_created;
46 }
47
48+QString Note::createdString() const
49+{
50+ QDate createdDate = m_created.date();
51+ QDate today = QDate::currentDate();
52+ if (createdDate == today) {
53+ return gettext("Today");
54+ }
55+ if (createdDate == today.addDays(-1)) {
56+ return gettext("Yesterday");
57+ }
58+ if (createdDate >= today.addDays(-7)) {
59+ return gettext("Last week");
60+ }
61+ if (createdDate >= today.addDays(-14)) {
62+ return gettext("Two weeks ago");
63+ }
64+
65+ return QString(gettext("%1 %2")).arg(QLocale::system().standaloneMonthName(createdDate.month())).arg(createdDate.year());
66+}
67+
68 QString Note::title() const
69 {
70 return m_title;
71@@ -204,21 +226,21 @@
72 QDate reminderDate = m_reminderTime.date();
73 QDate today = QDate::currentDate();
74 if (reminderDate < today) {
75- return QStringLiteral("Overdue");
76+ return gettext("Overdue");
77 }
78 if (reminderDate == today) {
79- return QStringLiteral("Today");
80+ return gettext("Today");
81 }
82 if (reminderDate == today.addDays(1)) {
83- return QStringLiteral("Tomorrow");
84+ return gettext("Tomorrow");
85 }
86 if (reminderDate <= today.addDays(7)) {
87- return QStringLiteral("Next week");
88+ return gettext("Next week");
89 }
90 if (reminderDate <= today.addDays(14)) {
91- return QStringLiteral("In two weeks");
92+ return gettext("In two weeks");
93 }
94- return QStringLiteral("Later");
95+ return gettext("Later");
96 }
97
98 QDateTime Note::reminderDoneTime() const
99
100=== modified file 'src/plugin/Evernote/note.h'
101--- src/plugin/Evernote/note.h 2014-04-30 16:52:15 +0000
102+++ src/plugin/Evernote/note.h 2014-05-06 17:04:10 +0000
103@@ -38,6 +38,7 @@
104 Q_PROPERTY(QString guid READ guid CONSTANT)
105 Q_PROPERTY(QString notebookGuid READ notebookGuid WRITE setNotebookGuid NOTIFY notebookGuidChanged)
106 Q_PROPERTY(QDateTime created READ created CONSTANT)
107+ Q_PROPERTY(QString createdString READ createdString CONSTANT)
108 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
109 Q_PROPERTY(QString htmlContent READ htmlContent NOTIFY contentChanged)
110 Q_PROPERTY(QString richTextContent READ richTextContent WRITE setRichTextContent NOTIFY contentChanged)
111@@ -68,6 +69,7 @@
112 void setNotebookGuid(const QString &notebookGuid);
113
114 QDateTime created() const;
115+ QString createdString() const;
116
117 QString title() const;
118 void setTitle(const QString &title);
119
120=== modified file 'src/plugin/Evernote/notes.cpp'
121--- src/plugin/Evernote/notes.cpp 2014-04-30 21:53:07 +0000
122+++ src/plugin/Evernote/notes.cpp 2014-05-06 17:04:10 +0000
123@@ -98,6 +98,20 @@
124 return NotesStore::instance()->note(guid);
125 }
126
127+int Notes::sectionCount(const QString &sectionRole, const QString &section)
128+{
129+ NotesStore::Role role = (NotesStore::Role)roleNames().key(sectionRole.toLatin1());
130+ int count = 0;
131+ for (int i = 0; i < rowCount(); i++) {
132+ QString itemSection;
133+ itemSection = data(index(i, 0), role).toString();
134+ if (section == itemSection) {
135+ count++;
136+ }
137+ }
138+ return count;
139+}
140+
141 bool Notes::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
142 {
143 QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);
144
145=== modified file 'src/plugin/Evernote/notes.h'
146--- src/plugin/Evernote/notes.h 2014-04-30 21:53:07 +0000
147+++ src/plugin/Evernote/notes.h 2014-05-06 17:04:10 +0000
148@@ -51,6 +51,8 @@
149
150 Q_INVOKABLE Note* note(const QString &guid);
151
152+ Q_INVOKABLE int sectionCount(const QString &sectionRole, const QString &section);
153+
154 protected:
155 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
156
157
158=== modified file 'src/plugin/Evernote/notesstore.cpp'
159--- src/plugin/Evernote/notesstore.cpp 2014-04-30 21:53:07 +0000
160+++ src/plugin/Evernote/notesstore.cpp 2014-05-06 17:04:10 +0000
161@@ -97,6 +97,8 @@
162 return m_notes.at(index.row())->notebookGuid();
163 case RoleCreated:
164 return m_notes.at(index.row())->created();
165+ case RoleCreatedString:
166+ return m_notes.at(index.row())->createdString();
167 case RoleTitle:
168 return m_notes.at(index.row())->title();
169 case RoleReminder:
170@@ -129,6 +131,7 @@
171 roles.insert(RoleGuid, "guid");
172 roles.insert(RoleNotebookGuid, "notebookGuid");
173 roles.insert(RoleCreated, "created");
174+ roles.insert(RoleCreatedString, "createdString");
175 roles.insert(RoleTitle, "title");
176 roles.insert(RoleReminder, "reminder");
177 roles.insert(RoleReminderTime, "reminderTime");
178
179=== modified file 'src/plugin/Evernote/notesstore.h'
180--- src/plugin/Evernote/notesstore.h 2014-04-30 21:53:07 +0000
181+++ src/plugin/Evernote/notesstore.h 2014-05-06 17:04:10 +0000
182@@ -53,10 +53,11 @@
183 Q_PROPERTY(QString notebooksError READ notebooksError NOTIFY notebooksErrorChanged)
184
185 public:
186- enum Roles {
187+ enum Role {
188 RoleGuid,
189 RoleNotebookGuid,
190 RoleCreated,
191+ RoleCreatedString,
192 RoleTitle,
193 RoleReminder,
194 RoleReminderTime,

Subscribers

People subscribed via source and target branches