Merge lp:~mzanetti/reminders-app/new-notebooks-design into lp:~notes-app-dev/reminders-app/new-design

Proposed by Michael Zanetti
Status: Superseded
Proposed branch: lp:~mzanetti/reminders-app/new-notebooks-design
Merge into: lp:~notes-app-dev/reminders-app/new-design
Prerequisite: lp:~mzanetti/reminders-app/notes-headers
Diff against target: 266 lines (+109/-41)
7 files modified
src/app/qml/components/NotebooksDelegate.qml (+55/-34)
src/app/qml/ui/NotebooksPage.qml (+1/-5)
src/plugin/Evernote/notebook.cpp (+32/-0)
src/plugin/Evernote/notebook.h (+10/-0)
src/plugin/Evernote/notebooks.cpp (+7/-1)
src/plugin/Evernote/notebooks.h (+3/-1)
src/plugin/Evernote/notesstore.cpp (+1/-0)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/new-notebooks-design
Reviewer Review Type Date Requested Status
David Planella Needs Fixing
Review via email: mp+218343@code.launchpad.net

This proposal supersedes a proposal from 2014-05-05.

This proposal has been superseded by a proposal from 2014-05-06.

Commit message

Implement NotebookDelegate according to new design

To post a comment you must log in.
98. By Michael Zanetti

merge

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

Looks really good!

One thing I've noticed, and that's related to the same comment on the notes MP [1]:

151 + return QStringLiteral("today");

This will need internationalization.

Would it not be better to just return a date from the plugin and then let the frontend figure out how it wants to display it? I.e. do the fuzzy date naming via JS.

[1] https://code.launchpad.net/~mzanetti/reminders-app/notes-headers/+merge/218328

review: Needs Fixing
99. By Michael Zanetti

merge upstream

100. By Michael Zanetti

make it translatable

101. By Michael Zanetti

merge upstream

102. By Michael Zanetti

add context comments for translators

103. By Michael Zanetti

use wording like David proposed

104. By Michael Zanetti

finetuning reminders removal

Unmerged revisions

104. By Michael Zanetti

finetuning reminders removal

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/qml/components/NotebooksDelegate.qml'
2--- src/app/qml/components/NotebooksDelegate.qml 2014-05-05 17:46:10 +0000
3+++ src/app/qml/components/NotebooksDelegate.qml 2014-05-05 23:15:38 +0000
4@@ -17,46 +17,67 @@
5 */
6
7 import QtQuick 2.0
8+import QtQuick.Layouts 1.0
9 import Ubuntu.Components 0.1
10 import Ubuntu.Components.ListItems 0.1
11
12 Empty {
13 id: root
14- height: units.gu(6)
15-
16- property string name
17- property int noteCount
18- property string shareStatus
19- property color notebookColor
20-
21- Column {
22- id: contentColumn
23- anchors {
24- top: parent.top
25- topMargin: units.gu(1)
26- left: parent.left
27- leftMargin: units.gu(2)
28- right: resourceImage.left
29- rightMargin: units.gu(2)
30- }
31- Label {
32- anchors { left: parent.left; right: parent.right }
33- text: root.name
34- font.bold: true
35- elide: Text.ElideRight
36- color: root.notebookColor
37- }
38- Label {
39- anchors { left: parent.left; right: parent.right }
40- text: root.shareStatus
41- wrapMode: Text.WordWrap
42- textFormat: Text.StyledText
43- }
44+ height: units.gu(9)
45+
46+ property string notebookColor: preferences.colorForNotebook(model.guid)
47+
48+ Rectangle {
49+ anchors.fill: parent
50+ color: "#f9f9f9"
51+ anchors.bottomMargin: units.dp(1)
52 }
53
54- Label {
55- id: resourceImage
56- anchors { top: parent.top; right: parent.right; bottom: parent.bottom; topMargin: units.gu(1); rightMargin: units.gu(2) }
57- text: i18n.tr("%1 note", "%1 notes", root.noteCount).arg(root.noteCount)
58+ RowLayout {
59+ anchors.fill: parent
60+ anchors.margins: units.gu(1)
61+
62+ Item {
63+ anchors { top: parent.top; bottom: parent.bottom }
64+ width: units.gu(1)
65+ Rectangle {
66+ anchors { top: parent.top; bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; margins: units.gu(1.5) }
67+ width: units.gu(.5)
68+ color: root.notebookColor
69+ radius: width / 2
70+ }
71+ }
72+
73+ ColumnLayout {
74+ height: parent.height
75+ Layout.fillWidth: true
76+
77+ Label {
78+ text: model.name
79+ color: root.notebookColor
80+ fontSize: "medium"
81+ font.bold: true
82+ }
83+ Label {
84+ text: i18n.tr("Last edited %1").arg(model.lastUpdatedString)
85+ fontSize: "small"
86+ color: "black"
87+ }
88+ Label {
89+ Layout.fillHeight: true
90+ text: model.published ? i18n.tr("Shared") : i18n.tr("Private")
91+ color: model.published ? "black" : "#b3b3b3"
92+ fontSize: "x-small"
93+ verticalAlignment: Text.AlignVCenter
94+ font.bold: model.published
95+ }
96+ }
97+
98+ Label {
99+ Layout.fillHeight: true
100+ verticalAlignment: Text.AlignVCenter
101+ text: "(" + model.noteCount + ")"
102+ color: "#b3b3b3"
103+ }
104 }
105 }
106
107=== modified file 'src/app/qml/ui/NotebooksPage.qml'
108--- src/app/qml/ui/NotebooksPage.qml 2014-05-05 23:02:32 +0000
109+++ src/app/qml/ui/NotebooksPage.qml 2014-05-05 23:15:38 +0000
110@@ -109,13 +109,9 @@
111 model: notebooks
112 anchors { left: parent.left; right: parent.right }
113 height: parent.height - y - buttonRow.height - keyboardRect.height
114+ clip: true
115
116 delegate: NotebooksDelegate {
117- name: model.name
118- noteCount: model.noteCount
119- shareStatus: model.publised ? i18n.tr("Shared") : i18n.tr("Private")
120- notebookColor: preferences.colorForNotebook(model.guid)
121-
122 onClicked: {
123 print("selected notebook:", model.guid)
124 root.openNotebook(name, model.guid)
125
126=== modified file 'src/plugin/Evernote/notebook.cpp'
127--- src/plugin/Evernote/notebook.cpp 2014-02-18 14:04:33 +0000
128+++ src/plugin/Evernote/notebook.cpp 2014-05-05 23:15:38 +0000
129@@ -75,6 +75,38 @@
130 }
131 }
132
133+QDateTime Notebook::lastUpdated() const
134+{
135+ return m_lastUpdated;
136+}
137+
138+void Notebook::setLastUpdated(const QDateTime &lastUpdated)
139+{
140+ if (m_lastUpdated != lastUpdated) {
141+ m_lastUpdated = lastUpdated;
142+ emit lastUpdatedChanged();
143+ }
144+}
145+
146+QString Notebook::lastUpdatedString() const
147+{
148+ QDate updateDate = m_lastUpdated.date();
149+ QDate today = QDate::currentDate();
150+ if (updateDate == today) {
151+ return QStringLiteral("today");
152+ }
153+ if (updateDate == today.addDays(-1)) {
154+ return QStringLiteral("yesterday");
155+ }
156+ if (updateDate <= today.addDays(-7)) {
157+ return QStringLiteral("last week");
158+ }
159+ if (updateDate <= today.addDays(-14)) {
160+ return QStringLiteral("two weeks ago");
161+ }
162+ return QString("on %1").arg(updateDate.toString("MMMM yyyy"));
163+}
164+
165 void Notebook::noteAdded(const QString &noteGuid, const QString &notebookGuid)
166 {
167 Q_UNUSED(noteGuid)
168
169=== modified file 'src/plugin/Evernote/notebook.h'
170--- src/plugin/Evernote/notebook.h 2014-01-27 13:00:41 +0000
171+++ src/plugin/Evernote/notebook.h 2014-05-05 23:15:38 +0000
172@@ -22,6 +22,7 @@
173 #define NOTEBOOK_H
174
175 #include <QObject>
176+#include <QDateTime>
177
178 class Notebook : public QObject
179 {
180@@ -31,6 +32,8 @@
181 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
182 Q_PROPERTY(int noteCount READ noteCount NOTIFY noteCountChanged)
183 Q_PROPERTY(bool published READ published NOTIFY publishedChanged)
184+ Q_PROPERTY(QDateTime lastUpdated READ lastUpdated NOTIFY lastUpdatedChanged)
185+ Q_PROPERTY(QString lastUpdatedString READ lastUpdatedString NOTIFY lastUpdatedChanged)
186
187 public:
188 explicit Notebook(QString guid, QObject *parent = 0);
189@@ -45,10 +48,16 @@
190 bool published() const;
191 void setPublished(bool published);
192
193+ QDateTime lastUpdated() const;
194+ void setLastUpdated(const QDateTime &lastUpdated);
195+
196+ QString lastUpdatedString() const;
197+
198 signals:
199 void nameChanged();
200 void noteCountChanged();
201 void publishedChanged();
202+ void lastUpdatedChanged();
203
204 private slots:
205 void noteAdded(const QString &noteGuid, const QString &notebookGuid);
206@@ -59,6 +68,7 @@
207 QString m_name;
208 int m_noteCount;
209 bool m_published;
210+ QDateTime m_lastUpdated;
211 };
212
213 #endif // NOTEBOOK_H
214
215=== modified file 'src/plugin/Evernote/notebooks.cpp'
216--- src/plugin/Evernote/notebooks.cpp 2014-04-30 21:53:07 +0000
217+++ src/plugin/Evernote/notebooks.cpp 2014-05-05 23:15:38 +0000
218@@ -59,6 +59,10 @@
219 return notebook->noteCount();
220 case RolePublished:
221 return notebook->published();
222+ case RoleLastUpdated:
223+ return notebook->lastUpdated();
224+ case RoleLastUpdatedString:
225+ return notebook->lastUpdatedString();
226 }
227 return QVariant();
228 }
229@@ -75,7 +79,9 @@
230 roles.insert(RoleGuid, "guid");
231 roles.insert(RoleName, "name");
232 roles.insert(RoleNoteCount, "noteCount");
233- roles.insert(RolePublished, "publised");
234+ roles.insert(RolePublished, "published");
235+ roles.insert(RoleLastUpdated, "lastUpdated");
236+ roles.insert(RoleLastUpdatedString, "lastUpdatedString");
237 return roles;
238 }
239
240
241=== modified file 'src/plugin/Evernote/notebooks.h'
242--- src/plugin/Evernote/notebooks.h 2014-04-30 21:53:07 +0000
243+++ src/plugin/Evernote/notebooks.h 2014-05-05 23:15:38 +0000
244@@ -36,7 +36,9 @@
245 RoleGuid,
246 RoleName,
247 RoleNoteCount,
248- RolePublished
249+ RolePublished,
250+ RoleLastUpdated,
251+ RoleLastUpdatedString
252 };
253 explicit Notebooks(QObject *parent = 0);
254
255
256=== modified file 'src/plugin/Evernote/notesstore.cpp'
257--- src/plugin/Evernote/notesstore.cpp 2014-05-05 23:15:38 +0000
258+++ src/plugin/Evernote/notesstore.cpp 2014-05-05 23:15:38 +0000
259@@ -363,6 +363,7 @@
260 }
261 notebook->setName(QString::fromStdString(result.name));
262 notebook->setPublished(result.published);
263+ notebook->setLastUpdated(QDateTime::fromMSecsSinceEpoch(result.serviceUpdated));
264
265 if (newNoteNotebook) {
266 m_notebooksHash.insert(notebook->guid(), notebook);

Subscribers

People subscribed via source and target branches