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

Proposed by Michael Zanetti
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 37
Merged at revision: 53
Proposed branch: lp:~mzanetti/reminders-app/reminders
Merge into: lp:reminders-app
Diff against target: 351 lines (+247/-6)
7 files modified
src/app/qml/components/RemindersDelegate.qml (+202/-0)
src/app/qml/ui/RemindersPage.qml (+2/-4)
src/plugin/Evernote/note.cpp (+19/-0)
src/plugin/Evernote/note.h (+7/-2)
src/plugin/Evernote/notes.cpp (+5/-0)
src/plugin/Evernote/notes.h (+2/-0)
src/plugin/Evernote/notesstore.cpp (+10/-0)
To merge this branch: bzr merge lp:~mzanetti/reminders-app/reminders
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Riccardo Padovani Approve
Review via email: mp+203522@code.launchpad.net

Commit message

Implement more reminders functionality

Description of the change

This makes the Remidners page look like in the wireframe and enables marking it as done and setting a reminder time.

There is one issue:
You can only edit reminders where you have fetched the content first, otherwise the enml validation will fail when trying to save the note. I need to fix that in a separate, long overdue branch where we only save stuff that has actually changed instead of always setting the whole note, regardless if there are changes or not.

So when testing this, please only test on notes which you have once opened first or it will fail.

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: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

anyone can review this?

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Works as expected!
Good work :-)

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=== added file 'src/app/qml/components/RemindersDelegate.qml'
2--- src/app/qml/components/RemindersDelegate.qml 1970-01-01 00:00:00 +0000
3+++ src/app/qml/components/RemindersDelegate.qml 2014-01-28 12:02:41 +0000
4@@ -0,0 +1,202 @@
5+/*
6+ * Copyright: 2013 Canonical, Ltd
7+ *
8+ * This file is part of reminders-app
9+ *
10+ * reminders-app is free software: you can redistribute it and/or modify
11+ * it under the terms of the GNU General Public License as published by
12+ * the Free Software Foundation; version 3.
13+ *
14+ * reminders-app is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public License
20+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+import QtQuick 2.0
24+import Ubuntu.Components 0.1
25+import Ubuntu.Components.ListItems 0.1
26+import Ubuntu.Components.Popups 0.1
27+import Ubuntu.Components.Pickers 0.1
28+
29+Empty {
30+ id: root
31+ height: expanded ? mainColumn.height : implicitHeight
32+ clip: true
33+
34+ property var note
35+
36+ property bool expanded: false
37+
38+ onExpandedChanged: {
39+ if (expanded) {
40+ if (note.hasReminderTime) {
41+ date.setDate(note.reminderTime.getDate())
42+ }
43+ } else {
44+ note.save();
45+ }
46+ }
47+
48+ Behavior on height {
49+ UbuntuNumberAnimation {}
50+ }
51+
52+ Column {
53+ id: mainColumn
54+ anchors { left: parent.left; right: parent.right; top: parent.top; leftMargin: units.gu(2); rightMargin: units.gu(2) }
55+ spacing: units.gu(2)
56+ height: implicitHeight + units.gu(1)
57+
58+ Row {
59+ anchors { left: parent.left; right: parent.right }
60+ height: root.implicitHeight
61+ spacing: units.gu(1)
62+
63+ CheckBox {
64+ id: checkBox
65+ anchors.verticalCenter: parent.verticalCenter
66+ checked: note.reminderDone
67+ onClicked: {
68+ note.reminderDone = checked;
69+ note.save();
70+ }
71+ }
72+
73+ Label {
74+ anchors.verticalCenter: parent.verticalCenter
75+ text: note.title
76+ width: parent.width - checkBox.width - reminderTimeRow.width - parent.spacing * 2
77+ }
78+ Row {
79+ id: reminderTimeRow
80+ anchors { top: parent.top; bottom: parent.bottom }
81+ spacing: units.gu(2)
82+
83+ Label {
84+ id: timeLabel
85+ anchors.verticalCenter: parent.verticalCenter
86+ text: Qt.formatDate(note.reminderTime)
87+ visible: note.hasReminderTime
88+ Component.onCompleted: print("Got reminder time", note.reminderTime)
89+ }
90+ Icon {
91+ id: alarmIcon
92+ anchors.verticalCenter: parent.verticalCenter
93+ width: units.gu(4)
94+ height: width
95+ name: "alarm-clock"
96+
97+ MouseArea {
98+ anchors.fill: parent
99+ onClicked: root.expanded = !root.expanded;
100+ }
101+ }
102+ }
103+ }
104+
105+
106+ Row {
107+ id: datePicker
108+ width: childrenRect.width
109+ height: monthPicker.height
110+ anchors.horizontalCenter: parent.horizontalCenter
111+ spacing: units.gu(1)
112+
113+ property var date: new Date()
114+ property int minYear: 2010
115+ property bool editing: false
116+
117+ Picker {
118+ id: dayPicker
119+ model: getDays(monthPicker.selectedIndex, yearPicker.selectedIndex + 2010)
120+ function getDays(month, year) {
121+ switch(month) {
122+ case 1:
123+ if (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) {
124+ return 29;
125+ }
126+ return 28;
127+ case 3:
128+ case 5:
129+ case 8:
130+ case 10:
131+ return 30;
132+ default:
133+ return 31;
134+ }
135+ }
136+ delegate: PickerDelegate {
137+ Label {
138+ anchors.centerIn: parent
139+ text: modelData + 1
140+ }
141+ }
142+ selectedIndex: datePicker.date.getDate() - 1
143+ onSelectedIndexChanged: {
144+ datePicker.date.setDate(selectedIndex + 1)
145+ }
146+ }
147+ Picker {
148+ id: monthPicker
149+ model: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]
150+ delegate: PickerDelegate {
151+ Label {
152+ anchors.centerIn: parent
153+ text: modelData
154+ }
155+ }
156+ selectedIndex: datePicker.date.getMonth()
157+ onSelectedIndexChanged: {
158+ var selectedDay = dayPicker.selectedIndex;
159+ datePicker.date.setMonth(selectedIndex)
160+ dayPicker.selectedIndex = selectedDay;
161+ }
162+ }
163+ Picker {
164+ id: yearPicker
165+ model: 100
166+ circular: false
167+ delegate: PickerDelegate {
168+ Label {
169+ anchors.centerIn: parent
170+ text: datePicker.minYear + modelData
171+ }
172+ }
173+ selectedIndex: datePicker.date.getFullYear() - datePicker.minYear
174+ onSelectedIndexChanged: {
175+ var selectedDay = dayPicker.selectedIndex;
176+ datePicker.date.setFullYear(selectedIndex + datePicker.minYear)
177+ dayPicker.selectedIndex = selectedDay;
178+ }
179+ }
180+ }
181+
182+ Row {
183+ spacing: units.gu(2)
184+ anchors { left: parent.left; right: parent.right }
185+ height: childrenRect.height
186+
187+ Button {
188+ text: "Clear"
189+ width: (parent.width - parent.spacing) / 2
190+ onClicked: {
191+ note.hasReminderTime = false;
192+ root.expanded = false;
193+ }
194+ }
195+ Button {
196+ text: "OK"
197+ width: (parent.width - parent.spacing) / 2
198+ onClicked: {
199+ print("setting date to ", datePicker.date)
200+ note.reminderTime = datePicker.date
201+ root.expanded = false;
202+ }
203+ }
204+ }
205+ }
206+}
207
208=== modified file 'src/app/qml/ui/RemindersPage.qml'
209--- src/app/qml/ui/RemindersPage.qml 2013-12-15 02:48:04 +0000
210+++ src/app/qml/ui/RemindersPage.qml 2014-01-28 12:02:41 +0000
211@@ -53,10 +53,8 @@
212
213 anchors.fill: parent
214
215- delegate: Subtitled {
216- text: '<b>Name:</b> ' + model.title
217- subText: '<b>Date:</b> ' + Qt.formatDateTime(model.created) +
218- (model.reminderDone ? " - <b>Done:</b> " + Qt.formatDate(model.reminderDoneTime) : "")
219+ delegate: RemindersDelegate {
220+ note: notes.note(guid)
221 }
222
223 model: notes
224
225=== modified file 'src/plugin/Evernote/note.cpp'
226--- src/plugin/Evernote/note.cpp 2014-01-23 09:46:02 +0000
227+++ src/plugin/Evernote/note.cpp 2014-01-28 12:02:41 +0000
228@@ -144,6 +144,22 @@
229 }
230 }
231
232+bool Note::hasReminderTime() const
233+{
234+ return !m_reminderTime.isNull();
235+}
236+
237+void Note::setHasReminderTime(bool hasReminderTime)
238+{
239+ if (hasReminderTime && m_reminderTime.isNull()) {
240+ m_reminderTime = QDateTime::currentDateTime();
241+ emit reminderTimeChanged();
242+ } else if (!hasReminderTime && !m_reminderTime.isNull()) {
243+ m_reminderTime = QDateTime();
244+ emit reminderTimeChanged();
245+ }
246+}
247+
248 QDateTime Note::reminderTime() const
249 {
250 return m_reminderTime;
251@@ -167,6 +183,9 @@
252 if (reminderDone && m_reminderDoneTime.isNull()) {
253 m_reminderDoneTime = QDateTime::currentDateTime();
254 emit reminderDoneChanged();
255+ } else if (!reminderDone && !m_reminderDoneTime.isNull()) {
256+ m_reminderDoneTime = QDateTime();
257+ emit reminderDoneChanged();
258 }
259 }
260
261
262=== modified file 'src/plugin/Evernote/note.h'
263--- src/plugin/Evernote/note.h 2014-01-24 18:13:04 +0000
264+++ src/plugin/Evernote/note.h 2014-01-28 12:02:41 +0000
265@@ -44,6 +44,7 @@
266 Q_PROPERTY(QString plaintextContent READ plaintextContent NOTIFY contentChanged)
267 Q_PROPERTY(QStringList resourceUrls READ resourceUrls NOTIFY contentChanged)
268 Q_PROPERTY(bool reminder READ reminder WRITE setReminder NOTIFY reminderChanged)
269+ Q_PROPERTY(bool hasReminderTime READ hasReminderTime WRITE setHasReminderTime NOTIFY reminderTimeChanged)
270 Q_PROPERTY(QDateTime reminderTime READ reminderTime WRITE setReminderTime NOTIFY reminderTimeChanged)
271 Q_PROPERTY(bool reminderDone READ reminderDone WRITE setReminderDone NOTIFY reminderDoneChanged)
272 Q_PROPERTY(QDateTime reminderDoneTime READ reminderDoneTime WRITE setReminderDoneTime NOTIFY reminderDoneChanged)
273@@ -74,8 +75,7 @@
274
275 QString plaintextContent() const;
276
277- // This is the QML representation as we don't want to deal with timestamps there.
278- // setting it to false will reset the reminderOrder to 0, setting it to true will
279+ // setting reminder to false will reset the reminderOrder to 0, setting it to true will
280 // create a new timestamp for it.
281 bool reminder() const;
282 void setReminder(bool reminder);
283@@ -83,6 +83,11 @@
284 qint64 reminderOrder() const;
285 void setReminderOrder(qint64 reminderOrder);
286
287+ // setting hasReminderTime to false will reset reminderTime to 0, setting it to true will
288+ // create a new timestamp for it.
289+ bool hasReminderTime() const;
290+ void setHasReminderTime(bool hasReminderTime);
291+
292 QDateTime reminderTime() const;
293 void setReminderTime(const QDateTime &reminderTime);
294
295
296=== modified file 'src/plugin/Evernote/notes.cpp'
297--- src/plugin/Evernote/notes.cpp 2013-12-13 00:17:48 +0000
298+++ src/plugin/Evernote/notes.cpp 2014-01-28 12:02:41 +0000
299@@ -74,6 +74,11 @@
300 }
301 }
302
303+Note *Notes::note(const QString &guid)
304+{
305+ return NotesStore::instance()->note(guid);
306+}
307+
308 bool Notes::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
309 {
310 QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);
311
312=== modified file 'src/plugin/Evernote/notes.h'
313--- src/plugin/Evernote/notes.h 2013-12-18 20:57:07 +0000
314+++ src/plugin/Evernote/notes.h 2014-01-28 12:02:41 +0000
315@@ -44,6 +44,8 @@
316 bool onlySearchResults() const;
317 void setOnlySearchResults(bool onlySearchResults);
318
319+ Q_INVOKABLE Note* note(const QString &guid);
320+
321 protected:
322 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
323
324
325=== modified file 'src/plugin/Evernote/notesstore.cpp'
326--- src/plugin/Evernote/notesstore.cpp 2014-01-23 09:39:43 +0000
327+++ src/plugin/Evernote/notesstore.cpp 2014-01-28 12:02:41 +0000
328@@ -188,6 +188,11 @@
329 note->setIsSearchResult(true);
330 }
331
332+ QDateTime reminderTime;
333+ if (result.attributes.reminderTime > 0) {
334+ reminderTime = QDateTime::fromMSecsSinceEpoch(result.attributes.reminderTime);
335+ }
336+ note->setReminderTime(reminderTime);
337 QDateTime reminderDoneTime;
338 if (result.attributes.reminderDoneTime > 0) {
339 reminderDoneTime = QDateTime::fromMSecsSinceEpoch(result.attributes.reminderDoneTime);
340@@ -241,6 +246,11 @@
341
342 note->setEnmlContent(QString::fromStdString(result.content));
343 note->setReminderOrder(result.attributes.reminderOrder);
344+ QDateTime reminderTime;
345+ if (result.attributes.reminderTime > 0) {
346+ reminderTime = QDateTime::fromMSecsSinceEpoch(result.attributes.reminderTime);
347+ }
348+ note->setReminderTime(reminderTime);
349 QDateTime reminderDoneTime;
350 if (result.attributes.reminderDoneTime > 0) {
351 reminderDoneTime = QDateTime::fromMSecsSinceEpoch(result.attributes.reminderDoneTime);

Subscribers

People subscribed via source and target branches