Merge lp:~rpadovani/ubuntu-calendar-app/1231136 into lp:ubuntu-calendar-app
- 1231136
- Merge into trunk
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 | ||||
Related bugs: |
|
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.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
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/
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
David Planella (dpm) wrote : | # |
Ted, could you point us to the QUrl() branch? Where does that live?
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:124
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:125
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:126
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:127
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ted Gould (ted) wrote : | # |
Here are the docs on QUrl:
http://
What you need your exec line to look like is something like this:
Exec=qmlscene /usr/share/
Then the actual call will be:
qmlscene /usr/share/
So the only argument will be the URL itself, you can then use QUrl to help break that down into the values you need.
Riccardo Padovani (rpadovani) wrote : | # |
I implemented it, but due to bug #1231558 we have to pass args before command:
qmlscene calendar:
I implemented starttime and endtime with value as number of seconds since UNIX epoch in the UTC timezone.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:128
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:129
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:130
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ted Gould (ted) wrote : | # |
The desktop file and arguments comments look correct.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:134
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
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.
Mihir Soni (mihirsoni) wrote : | # |
Riccardo , can you remove the changes in manifest.json , I don't know why everybody is facing this issue.
Mihir Soni (mihirsoni) wrote : | # |
Thank you Riccardo ,
it looks fine to me
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:135
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
- 136. By Riccardo Padovani
-
Fixed newEvent
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:136
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'NewEvent.qml' | |||
2 | --- NewEvent.qml 2013-10-15 15:01:07 +0000 | |||
3 | +++ NewEvent.qml 2013-10-16 14:15:26 +0000 | |||
4 | @@ -10,17 +10,24 @@ | |||
5 | 10 | id: root | 10 | id: root |
6 | 11 | 11 | ||
7 | 12 | property var date: new Date(); | 12 | property var date: new Date(); |
10 | 13 | property var startDate: date | 13 | property var startDate; |
11 | 14 | property var endDate: date | 14 | property var endDate; |
12 | 15 | |||
13 | 15 | property alias scrollY: flickable.contentY | 16 | property alias scrollY: flickable.contentY |
14 | 16 | 17 | ||
15 | 17 | Component.onCompleted: { | 18 | Component.onCompleted: { |
16 | 19 | // If startDate is setted by argument we have to not change it | ||
17 | 20 | if (typeof(startDate) === 'undefined') | ||
18 | 21 | startDate = new Date(date) | ||
19 | 22 | |||
20 | 23 | // If endDate is setted by argument we have to not change it | ||
21 | 24 | if (typeof(endDate) === 'undefined') { | ||
22 | 25 | endDate = new Date(date) | ||
23 | 26 | endDate.setMinutes( endDate.getMinutes() + 10) | ||
24 | 27 | } | ||
25 | 28 | |||
26 | 18 | internal.eventModel = GlobalModel.gloablModel(); | 29 | internal.eventModel = GlobalModel.gloablModel(); |
27 | 19 | 30 | ||
28 | 20 | startDate = new Date(date) | ||
29 | 21 | endDate = new Date(date) | ||
30 | 22 | endDate.setMinutes( endDate.getMinutes() + 10) | ||
31 | 23 | |||
32 | 24 | startTime.text = Qt.formatDateTime(startDate, "dd MMM yyyy hh:mm"); | 31 | startTime.text = Qt.formatDateTime(startDate, "dd MMM yyyy hh:mm"); |
33 | 25 | endTime.text = Qt.formatDateTime(endDate, "dd MMM yyyy hh:mm"); | 32 | endTime.text = Qt.formatDateTime(endDate, "dd MMM yyyy hh:mm"); |
34 | 26 | } | 33 | } |
35 | 27 | 34 | ||
36 | === modified file 'calendar-app.desktop' | |||
37 | --- calendar-app.desktop 2013-06-12 15:23:13 +0000 | |||
38 | +++ calendar-app.desktop 2013-10-16 14:15:26 +0000 | |||
39 | @@ -3,7 +3,7 @@ | |||
40 | 3 | Version=1.0 | 3 | Version=1.0 |
41 | 4 | Type=Application | 4 | Type=Application |
42 | 5 | Terminal=false | 5 | Terminal=false |
44 | 6 | Exec=qmlscene /usr/share/calendar-app/calendar.qml | 6 | Exec=qmlscene %u /usr/share/calendar-app/calendar.qml |
45 | 7 | Icon=/usr/share/calendar-app/calendar64.png | 7 | Icon=/usr/share/calendar-app/calendar64.png |
46 | 8 | Name=Calendar | 8 | Name=Calendar |
47 | 9 | X-Ubuntu-Touch=true | 9 | X-Ubuntu-Touch=true |
48 | 10 | 10 | ||
49 | === modified file 'calendar.qml' | |||
50 | --- calendar.qml 2013-10-15 15:01:07 +0000 | |||
51 | +++ calendar.qml 2013-10-16 14:15:26 +0000 | |||
52 | @@ -8,6 +8,46 @@ | |||
53 | 8 | MainView { | 8 | MainView { |
54 | 9 | id: mainView | 9 | id: mainView |
55 | 10 | 10 | ||
56 | 11 | // Argument during startup | ||
57 | 12 | Arguments { | ||
58 | 13 | id: args; | ||
59 | 14 | |||
60 | 15 | // Example of argument: calendar:///new-event | ||
61 | 16 | |||
62 | 17 | // IMPORTANT | ||
63 | 18 | // Due to bug #1231558 you have to pass arguments BEFORE app: | ||
64 | 19 | // qmlscene calendar:///new-event calendar.qml | ||
65 | 20 | |||
66 | 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"); | ||
67 | 22 | //defaultArgument.required: false; | ||
68 | 23 | defaultArgument.valueNames: ["URL"] | ||
69 | 24 | |||
70 | 25 | /* ARGUMENTS on startup | ||
71 | 26 | * (no one is required) | ||
72 | 27 | * | ||
73 | 28 | * Create a new event | ||
74 | 29 | * Keyword: newevent | ||
75 | 30 | * | ||
76 | 31 | * Create a new event. If starttime or endtime are set they are used to set start and end time of the new event. | ||
77 | 32 | * It accepts no value. | ||
78 | 33 | * | ||
79 | 34 | * | ||
80 | 35 | * Choose the view | ||
81 | 36 | * Keyword: starttime | ||
82 | 37 | * | ||
83 | 38 | * If newevent has been called, starttime is the start time of event. Otherwise is the day on which app is focused on startup. | ||
84 | 39 | * It accepts an integer value of the number of seconds since UNIX epoch in the UTC timezone. | ||
85 | 40 | * 0 means today. | ||
86 | 41 | * | ||
87 | 42 | * Keyword: endtime | ||
88 | 43 | * | ||
89 | 44 | * If newevent is set it's the end time of the event, has to be > of starttime. | ||
90 | 45 | * If newevent isn't set and startime is set, its value is used to choose the right view. | ||
91 | 46 | * If neither of precendet flags are set, endtime is ignored. | ||
92 | 47 | * It accepts an integer value of the number of seconds since UNIX epoch in the UTC timezone. | ||
93 | 48 | */ | ||
94 | 49 | } | ||
95 | 50 | |||
96 | 11 | objectName: "calendar" | 51 | objectName: "calendar" |
97 | 12 | applicationName: "com.ubuntu.calendar" | 52 | applicationName: "com.ubuntu.calendar" |
98 | 13 | 53 | ||
99 | @@ -30,6 +70,11 @@ | |||
100 | 30 | property var currentDay: DateExt.today(); | 70 | property var currentDay: DateExt.today(); |
101 | 31 | property var globalModel; | 71 | property var globalModel; |
102 | 32 | 72 | ||
103 | 73 | // Arguments on startup | ||
104 | 74 | property bool newevent: false; | ||
105 | 75 | property int starttime: -1; | ||
106 | 76 | property int endtime: -1; | ||
107 | 77 | |||
108 | 33 | onCurrentDayChanged: { | 78 | onCurrentDayChanged: { |
109 | 34 | if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay)) | 79 | if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay)) |
110 | 35 | monthView.currentMonth = currentDay.midnight(); | 80 | monthView.currentMonth = currentDay.midnight(); |
111 | @@ -51,13 +96,111 @@ | |||
112 | 51 | } | 96 | } |
113 | 52 | 97 | ||
114 | 53 | function newEvent() { | 98 | function newEvent() { |
116 | 54 | PopupUtils.open(newEventComponent, tabPage, {"defaultDate": currentDay}) | 99 | var startDate = new Date(); |
117 | 100 | var endDate = new Date(); | ||
118 | 101 | var startTime; | ||
119 | 102 | var endTime; | ||
120 | 103 | |||
121 | 104 | if (starttime === 0) { // startime 0 means now | ||
122 | 105 | if (endtime !== -1) { // If also endtime has been invoked | ||
123 | 106 | endTime = parseInt(endtime); | ||
124 | 107 | if (endTime > startDate) // If endtime is after startime | ||
125 | 108 | endDate = new Date(endTime); | ||
126 | 109 | } | ||
127 | 110 | } | ||
128 | 111 | else if (starttime !== -1) { // If starttime has been invoked | ||
129 | 112 | startTime = parseInt(starttime); | ||
130 | 113 | startDate = new Date(startTime); | ||
131 | 114 | if (endtime !== -1) { // If --endtime has been invoked | ||
132 | 115 | endTime = parseInt(endtime); | ||
133 | 116 | if (endTime > startDate) | ||
134 | 117 | endDate = new Date(endTime); | ||
135 | 118 | } | ||
136 | 119 | } | ||
137 | 120 | pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"startDate": startDate, "endDate": endDate}); | ||
138 | 121 | } | ||
139 | 122 | |||
140 | 123 | // This function calculate the difference between --endtime and --starttime and choose the better view | ||
141 | 124 | function calculateDifferenceStarttimeEndtime(startTime, endTime) { | ||
142 | 125 | var minute = 60 * 1000; | ||
143 | 126 | var hour = 60 * minute; | ||
144 | 127 | var day = 24 * hour; | ||
145 | 128 | var month = 30 * day; | ||
146 | 129 | |||
147 | 130 | var difference = endTime - startTime; | ||
148 | 131 | |||
149 | 132 | if (difference > month) | ||
150 | 133 | return 0; // Year view | ||
151 | 134 | else if (difference > 7 * day) | ||
152 | 135 | return 1; // Month view} | ||
153 | 136 | else if (difference > day) | ||
154 | 137 | return 2; // Week view | ||
155 | 138 | else | ||
156 | 139 | return 3; // Day view | ||
157 | 140 | } | ||
158 | 141 | |||
159 | 142 | // This function parse the argument | ||
160 | 143 | function parseArguments(url) { | ||
161 | 144 | var newevenpattern= new RegExp ("newevent"); | ||
162 | 145 | var starttimepattern = new RegExp ("starttime=\\d+"); | ||
163 | 146 | var endtimepattern = new RegExp ("endtime=\\d+"); | ||
164 | 147 | |||
165 | 148 | newevent = newevenpattern.test(url); | ||
166 | 149 | |||
167 | 150 | if (starttimepattern.test(url)) | ||
168 | 151 | starttime = url.match(/starttime=(\d+)/)[0].replace("starttime=", ''); | ||
169 | 152 | |||
170 | 153 | if (endtimepattern.test(url)) | ||
171 | 154 | endtime = url.match(/endtime=(\d+)/)[0].replace("endtime=", ''); | ||
172 | 155 | |||
173 | 55 | } | 156 | } |
174 | 56 | 157 | ||
175 | 57 | Component.onCompleted: { | 158 | Component.onCompleted: { |
176 | 159 | // If an url has been set | ||
177 | 160 | if (args.defaultArgument.at(0)) { | ||
178 | 161 | parseArguments(args.defaultArgument.at(0)) | ||
179 | 162 | tabPage.currentDay = new Date() | ||
180 | 163 | // If newevent has been called on startup | ||
181 | 164 | if (newevent) { | ||
182 | 165 | timer.running = true; | ||
183 | 166 | } | ||
184 | 167 | else if (starttime !== -1) { // If no newevent has been setted, but starttime | ||
185 | 168 | var startTime = parseInt(starttime); | ||
186 | 169 | tabPage.currentDay = new Date(startTime); | ||
187 | 170 | |||
188 | 171 | // If also endtime has been settend | ||
189 | 172 | if (endtime !== -1) { | ||
190 | 173 | var endTime = parseInt(endtime); | ||
191 | 174 | tabs.selectedTabIndex = calculateDifferenceStarttimeEndtime(startTime, endTime); | ||
192 | 175 | } | ||
193 | 176 | else { | ||
194 | 177 | // If no endtime has been setted, open the starttime date in day view | ||
195 | 178 | tabs.selectedTabIndex = 3; | ||
196 | 179 | } | ||
197 | 180 | } // End of else if (starttime) | ||
198 | 181 | else { | ||
199 | 182 | // Due to bug #1231558 {if (args.defaultArgument.at(0))} is always true | ||
200 | 183 | // After the fix we can delete this else | ||
201 | 184 | tabs.selectedTabIndex= 1; | ||
202 | 185 | } | ||
203 | 186 | } // End of if about args.values | ||
204 | 187 | else { | ||
205 | 188 | tabs.selectedTabIndex= 1; | ||
206 | 189 | } | ||
207 | 190 | |||
208 | 58 | globalModel = GlobalModel.gloablModel(); | 191 | globalModel = GlobalModel.gloablModel(); |
209 | 59 | setStartEndDateToModel(); | 192 | setStartEndDateToModel(); |
211 | 60 | tabs.selectedTabIndex = 1; | 193 | } // End of Component.onCompleted: |
212 | 194 | |||
213 | 195 | // This is for wait that the app is load when newEvent is invoked by argument | ||
214 | 196 | Timer { | ||
215 | 197 | id: timer | ||
216 | 198 | interval: 200; | ||
217 | 199 | running: false; | ||
218 | 200 | repeat: false | ||
219 | 201 | onTriggered: { | ||
220 | 202 | tabPage.newEvent(); | ||
221 | 203 | } | ||
222 | 61 | } | 204 | } |
223 | 62 | 205 | ||
224 | 63 | ToolbarItems { | 206 | ToolbarItems { |
PASSED: Continuous integration, rev:123 91.189. 93.70:8080/ job/ubuntu- calendar- app-ci/ 87/ 91.189. 93.70:8080/ job/generic- mediumtests/ 507 91.189. 93.70:8080/ job/ubuntu- calendar- app-precise- amd64-ci/ 87 91.189. 93.70:8080/ job/ubuntu- calendar- app-quantal- amd64-ci/ 87 91.189. 93.70:8080/ job/ubuntu- calendar- app-raring- amd64-ci/ 87 91.189. 93.70:8080/ job/ubuntu- calendar- app-saucy- amd64-ci/ 87
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- calendar- app-ci/ 87/rebuild
http://