Merge lp:~rpadovani/ubuntu-calendar-app/1231136 into lp:ubuntu-calendar-app

Proposed by Riccardo Padovani
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„
Approved revision: 136
Merged at revision: 155
Proposed branch: lp:~rpadovani/ubuntu-calendar-app/1231136
Merge into: lp:ubuntu-calendar-app
Diff against target: 224 lines (+159/-9)
3 files modified
NewEvent.qml (+13/-6)
calendar-app.desktop (+1/-1)
calendar.qml (+145/-2)
To merge this branch: bzr merge lp:~rpadovani/ubuntu-calendar-app/1231136
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Mihir Soni Approve
Charles Kerr (community) Approve
Ted Gould (community) Approve
Review via email: mp+188002@code.launchpad.net

Commit message

Fixed #1231136, add support for Arguments

Description of the change

Added support for three arguments:
--newevent, to open new event popup

If --newevent is set:
 --starttime, to set start time of new event
 --endtime, to set end time of new event. It has to be > of start time. If start time is not set, it's ignored

If --newevent is not set:
 --starttime, to open calendar in a precise day
 --endtime, to choose the view

If endtime - starttime > month, year view is open
If entdime - starttime > week, month view is open
If endtime - starttime > day, week view is open

--endtime and --starttime accept integer value of the number of seconds since UNIX epoch in the UTC timezone.

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
Ted Gould (ted) wrote :

Hello Riccardo,

Thanks for working on this! The big issue I see is that the calendar app itself needs to be the one to parse the URL, we don't do that externally. So the exec line needs to look something like:

Exec=qmlscene /usr/share/calendar-app/calendar.qml %u

So then the URL will get passed onto the application. The QUrl() branch provides some functions for dealing with URLs that should make this a bit easier.

Ted

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

Ted, could you point us to the QUrl() branch? Where does that live?

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
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (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: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Here are the docs on QUrl:

http://qt-project.org/doc/qt-5.0/qtcore/qurl.html

What you need your exec line to look like is something like this:

Exec=qmlscene /usr/share/calendar-app/calendar.qml %u

Then the actual call will be:

qmlscene /usr/share/calendar-app/calendar.qml calendar:///?starttime=20130913

So the only argument will be the URL itself, you can then use QUrl to help break that down into the values you need.

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

I implemented it, but due to bug #1231558 we have to pass args before command:
qmlscene calendar:///?starttime=1234567889 /usr/share/calendar-app/calendar.qml

I implemented starttime and endtime with value as number of seconds since UNIX epoch in the UTC timezone.

https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1231558

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: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

The desktop file and arguments comments look correct.

review: Approve
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
Charles Kerr (charlesk) wrote :

I see that this MP is blocked awaiting my review.

The approach looks sane and the coding is fine; I'm happy enough to Approve on that level.

From an indicator-datetime perspective, I don't have much of substance to add to this review. The indicator doesn't know or care what the contents of the calendar:/// url are as long as it can be fetched from EDS and dispatched via url-dispatcher.

review: Approve
Revision history for this message
Mihir Soni (mihirsoni) wrote :

Riccardo , can you remove the changes in manifest.json , I don't know why everybody is facing this issue.

Revision history for this message
Mihir Soni (mihirsoni) wrote :

Thank you Riccardo ,

it looks fine to me

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)
136. By Riccardo Padovani

Fixed newEvent

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 'NewEvent.qml'
--- NewEvent.qml 2013-10-15 15:01:07 +0000
+++ NewEvent.qml 2013-10-16 14:15:26 +0000
@@ -10,17 +10,24 @@
10 id: root10 id: root
1111
12 property var date: new Date();12 property var date: new Date();
13 property var startDate: date13 property var startDate;
14 property var endDate: date14 property var endDate;
15
15 property alias scrollY: flickable.contentY16 property alias scrollY: flickable.contentY
1617
17 Component.onCompleted: {18 Component.onCompleted: {
19 // If startDate is setted by argument we have to not change it
20 if (typeof(startDate) === 'undefined')
21 startDate = new Date(date)
22
23 // If endDate is setted by argument we have to not change it
24 if (typeof(endDate) === 'undefined') {
25 endDate = new Date(date)
26 endDate.setMinutes( endDate.getMinutes() + 10)
27 }
28
18 internal.eventModel = GlobalModel.gloablModel();29 internal.eventModel = GlobalModel.gloablModel();
1930
20 startDate = new Date(date)
21 endDate = new Date(date)
22 endDate.setMinutes( endDate.getMinutes() + 10)
23
24 startTime.text = Qt.formatDateTime(startDate, "dd MMM yyyy hh:mm");31 startTime.text = Qt.formatDateTime(startDate, "dd MMM yyyy hh:mm");
25 endTime.text = Qt.formatDateTime(endDate, "dd MMM yyyy hh:mm");32 endTime.text = Qt.formatDateTime(endDate, "dd MMM yyyy hh:mm");
26 }33 }
2734
=== modified file 'calendar-app.desktop'
--- calendar-app.desktop 2013-06-12 15:23:13 +0000
+++ calendar-app.desktop 2013-10-16 14:15:26 +0000
@@ -3,7 +3,7 @@
3Version=1.03Version=1.0
4Type=Application4Type=Application
5Terminal=false5Terminal=false
6Exec=qmlscene /usr/share/calendar-app/calendar.qml6Exec=qmlscene %u /usr/share/calendar-app/calendar.qml
7Icon=/usr/share/calendar-app/calendar64.png7Icon=/usr/share/calendar-app/calendar64.png
8Name=Calendar8Name=Calendar
9X-Ubuntu-Touch=true9X-Ubuntu-Touch=true
1010
=== modified file 'calendar.qml'
--- calendar.qml 2013-10-15 15:01:07 +0000
+++ calendar.qml 2013-10-16 14:15:26 +0000
@@ -8,6 +8,46 @@
8MainView {8MainView {
9 id: mainView9 id: mainView
1010
11 // Argument during startup
12 Arguments {
13 id: args;
14
15 // Example of argument: calendar:///new-event
16
17 // IMPORTANT
18 // Due to bug #1231558 you have to pass arguments BEFORE app:
19 // qmlscene calendar:///new-event calendar.qml
20
21 defaultArgument.help: i18n.tr("Calendar app accept three arguments: --starttime, --endtime and --newevet. They will be managed by system. See the source for a full comment about them");
22 //defaultArgument.required: false;
23 defaultArgument.valueNames: ["URL"]
24
25 /* ARGUMENTS on startup
26 * (no one is required)
27 *
28 * Create a new event
29 * Keyword: newevent
30 *
31 * Create a new event. If starttime or endtime are set they are used to set start and end time of the new event.
32 * It accepts no value.
33 *
34 *
35 * Choose the view
36 * Keyword: starttime
37 *
38 * If newevent has been called, starttime is the start time of event. Otherwise is the day on which app is focused on startup.
39 * It accepts an integer value of the number of seconds since UNIX epoch in the UTC timezone.
40 * 0 means today.
41 *
42 * Keyword: endtime
43 *
44 * If newevent is set it's the end time of the event, has to be > of starttime.
45 * If newevent isn't set and startime is set, its value is used to choose the right view.
46 * If neither of precendet flags are set, endtime is ignored.
47 * It accepts an integer value of the number of seconds since UNIX epoch in the UTC timezone.
48 */
49 }
50
11 objectName: "calendar"51 objectName: "calendar"
12 applicationName: "com.ubuntu.calendar"52 applicationName: "com.ubuntu.calendar"
1353
@@ -30,6 +70,11 @@
30 property var currentDay: DateExt.today();70 property var currentDay: DateExt.today();
31 property var globalModel;71 property var globalModel;
3272
73 // Arguments on startup
74 property bool newevent: false;
75 property int starttime: -1;
76 property int endtime: -1;
77
33 onCurrentDayChanged: {78 onCurrentDayChanged: {
34 if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay))79 if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay))
35 monthView.currentMonth = currentDay.midnight();80 monthView.currentMonth = currentDay.midnight();
@@ -51,13 +96,111 @@
51 }96 }
5297
53 function newEvent() {98 function newEvent() {
54 PopupUtils.open(newEventComponent, tabPage, {"defaultDate": currentDay})99 var startDate = new Date();
100 var endDate = new Date();
101 var startTime;
102 var endTime;
103
104 if (starttime === 0) { // startime 0 means now
105 if (endtime !== -1) { // If also endtime has been invoked
106 endTime = parseInt(endtime);
107 if (endTime > startDate) // If endtime is after startime
108 endDate = new Date(endTime);
109 }
110 }
111 else if (starttime !== -1) { // If starttime has been invoked
112 startTime = parseInt(starttime);
113 startDate = new Date(startTime);
114 if (endtime !== -1) { // If --endtime has been invoked
115 endTime = parseInt(endtime);
116 if (endTime > startDate)
117 endDate = new Date(endTime);
118 }
119 }
120 pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"startDate": startDate, "endDate": endDate});
121 }
122
123 // This function calculate the difference between --endtime and --starttime and choose the better view
124 function calculateDifferenceStarttimeEndtime(startTime, endTime) {
125 var minute = 60 * 1000;
126 var hour = 60 * minute;
127 var day = 24 * hour;
128 var month = 30 * day;
129
130 var difference = endTime - startTime;
131
132 if (difference > month)
133 return 0; // Year view
134 else if (difference > 7 * day)
135 return 1; // Month view}
136 else if (difference > day)
137 return 2; // Week view
138 else
139 return 3; // Day view
140 }
141
142 // This function parse the argument
143 function parseArguments(url) {
144 var newevenpattern= new RegExp ("newevent");
145 var starttimepattern = new RegExp ("starttime=\\d+");
146 var endtimepattern = new RegExp ("endtime=\\d+");
147
148 newevent = newevenpattern.test(url);
149
150 if (starttimepattern.test(url))
151 starttime = url.match(/starttime=(\d+)/)[0].replace("starttime=", '');
152
153 if (endtimepattern.test(url))
154 endtime = url.match(/endtime=(\d+)/)[0].replace("endtime=", '');
155
55 }156 }
56157
57 Component.onCompleted: {158 Component.onCompleted: {
159 // If an url has been set
160 if (args.defaultArgument.at(0)) {
161 parseArguments(args.defaultArgument.at(0))
162 tabPage.currentDay = new Date()
163 // If newevent has been called on startup
164 if (newevent) {
165 timer.running = true;
166 }
167 else if (starttime !== -1) { // If no newevent has been setted, but starttime
168 var startTime = parseInt(starttime);
169 tabPage.currentDay = new Date(startTime);
170
171 // If also endtime has been settend
172 if (endtime !== -1) {
173 var endTime = parseInt(endtime);
174 tabs.selectedTabIndex = calculateDifferenceStarttimeEndtime(startTime, endTime);
175 }
176 else {
177 // If no endtime has been setted, open the starttime date in day view
178 tabs.selectedTabIndex = 3;
179 }
180 } // End of else if (starttime)
181 else {
182 // Due to bug #1231558 {if (args.defaultArgument.at(0))} is always true
183 // After the fix we can delete this else
184 tabs.selectedTabIndex= 1;
185 }
186 } // End of if about args.values
187 else {
188 tabs.selectedTabIndex= 1;
189 }
190
58 globalModel = GlobalModel.gloablModel();191 globalModel = GlobalModel.gloablModel();
59 setStartEndDateToModel();192 setStartEndDateToModel();
60 tabs.selectedTabIndex = 1;193 } // End of Component.onCompleted:
194
195 // This is for wait that the app is load when newEvent is invoked by argument
196 Timer {
197 id: timer
198 interval: 200;
199 running: false;
200 repeat: false
201 onTriggered: {
202 tabPage.newEvent();
203 }
61 }204 }
62205
63 ToolbarItems {206 ToolbarItems {

Subscribers

People subscribed via source and target branches

to status/vote changes: