~pkunal-parmar/ubuntu-calendar-app/CustomSwipeArea

« back to all changes in this revision

Viewing changes to calendar.qml

  • Committer: Tarmac
  • Author(s): nskaggs
  • Date: 2014-03-20 14:56:32 UTC
  • mfrom: (212.1.7 revert-212)
  • Revision ID: tarmac-20140320145632-hul9eb00eot702ed
Revert rev 212. Fixes: https://bugs.launchpad.net/bugs/1294181.

Approved by Timo Jyrinki, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
            property int endtime: -1;
77
77
 
78
78
            onCurrentDayChanged: {
79
 
                if( monthPage.item
80
 
                        && monthPage.item.currentMonth !== undefined
81
 
                        && !monthPage.item.currentMonth.isSameDay(currentDay))
82
 
                    monthPage.item.currentMonth = currentDay.midnight();
83
 
 
84
 
                if( dayPage.item && !dayPage.item.currentDay.isSameDay(currentDay))
85
 
                    dayPage.item.currentDay = currentDay
86
 
 
87
 
                if( weekPage.item && !weekPage.item.dayStart.isSameDay(currentDay))
88
 
                    weekPage.item.dayStart = currentDay
 
79
                if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay))
 
80
                    monthView.currentMonth = currentDay.midnight();
 
81
 
 
82
                if( !dayView.currentDay.isSameDay(currentDay))
 
83
                    dayView.currentDay = currentDay
 
84
 
 
85
                if( !weekView.dayStart.isSameDay(currentDay))
 
86
                    weekView.dayStart = currentDay
89
87
 
90
88
                setStartEndDateToModel();
91
89
            }
135
133
                var difference = endTime - startTime;
136
134
 
137
135
                if (difference > month)
138
 
                    return yearTab.index;   // Year view
 
136
                    return 0;   // Year view
139
137
                else if (difference > 7 * day)
140
 
                    return monthTab.index;   // Month view}
 
138
                    return 1;   // Month view}
141
139
                else if (difference > day)
142
 
                    return weekTab.index;   // Week view
 
140
                    return 2;   // Week view
143
141
                else
144
 
                    return dayTab.index;   // Day view
 
142
                    return 3;   // Day view
145
143
            }
146
144
 
147
145
            // This function parse the argument
180
178
                        }
181
179
                        else {
182
180
                            // If no endtime has been setted, open the starttime date in day view
183
 
                            tabs.selectedTabIndex = dayTab.index;
 
181
                            tabs.selectedTabIndex = 3;
184
182
                        }
185
183
                    } // End of else if (starttime)
186
184
                    else {
187
185
                        // Due to bug #1231558 {if (args.defaultArgument.at(0))} is always true
188
186
                        // After the fix we can delete this else
189
 
                        tabs.selectedTabIndex = monthTab.index;
 
187
                        tabs.selectedTabIndex= 1;
190
188
                    }
191
189
                } // End of if about args.values
192
190
                else {
193
 
                    tabs.selectedTabIndex = monthTab.index;
 
191
                    tabs.selectedTabIndex= 1;
194
192
                }
195
193
 
196
194
                globalModel = GlobalModel.globalModel();
235
233
 
236
234
            Tabs{
237
235
                id: tabs
238
 
 
239
236
                Tab{
240
 
                    id: yearTab
241
237
                    objectName: "yearTab"
242
238
                    title: i18n.tr("Year")
243
 
                    page: Loader{
244
 
                        id: yearPage
 
239
                    page: Page{
245
240
                        objectName: "yearPage"
246
 
                        anchors {
247
 
                            top: parent.top
248
 
                            left: parent.left
249
 
                            right: parent.right
250
 
                            bottom: parent.bottom
251
 
                        }
252
 
                        source: (tabs.selectedTab === yearTab) ? Qt.resolvedUrl("YearView.qml") : ""
253
 
 
254
 
                        onLoaded:{
255
 
                            item.tools = commonToolBar
256
 
                        }
257
 
 
258
 
                        Connections{
259
 
                            target: yearPage.item
 
241
                        anchors.fill: parent
 
242
                        tools: commonToolBar
 
243
                        YearView{
260
244
                            onMonthSelected: {
261
 
                                tabs.selectedTabIndex = monthTab.index
 
245
                                tabs.selectedTabIndex = 1
262
246
                                var now = DateExt.today();
263
247
                                if( date.getMonth() === now.getMonth()
264
248
                                        && date.getFullYear() === now.getFullYear()) {
265
 
                                    tabPage.currentDay = now;
 
249
                                    monthView.currentMonth = now
266
250
                                } else {
267
 
                                    tabPage.currentDay = date.midnight();
 
251
                                    monthView.currentMonth = date.midnight();
268
252
                                }
269
253
                            }
270
254
                        }
271
255
                    }
272
256
                }
273
 
 
274
257
                Tab {
275
258
                    id: monthTab
276
259
                    objectName: "monthTab"
277
260
                    title: i18n.tr("Month")
278
 
 
279
 
                    page: Loader{
280
 
                        id: monthPage
281
 
                        anchors {
282
 
                            top: parent.top
283
 
                            left: parent.left
284
 
                            right: parent.right
285
 
                            bottom: parent.bottom
286
 
                        }
287
 
 
288
 
                        source: (tabs.selectedTab === monthTab) ? Qt.resolvedUrl("MonthView.qml") : ""
289
 
 
290
 
                        onLoaded: {
291
 
                            item.currentMonth = tabPage.currentDay.midnight();
292
 
                            item.tools = commonToolBar
293
 
                        }
294
 
 
295
 
                        Connections{
296
 
                            target: monthPage.item
297
 
                            onDateSelected: {
298
 
                                tabs.selectedTabIndex = dayTab.index
299
 
                                tabPage.currentDay = date;
300
 
                            }
 
261
                    page: MonthView{
 
262
                        anchors.fill: parent
 
263
                        tools: commonToolBar
 
264
                        id: monthView
 
265
 
 
266
                        onDateSelected: {
 
267
                            tabs.selectedTabIndex  = 3
 
268
                            tabPage.currentDay = date;
301
269
                        }
302
270
                    }
303
271
                }
304
 
 
305
272
                Tab{
306
 
                    id: weekTab
307
273
                    objectName: "weekTab"
308
274
                    title: i18n.tr("Week")
309
 
                    page: Loader{
310
 
                        id: weekPage
311
 
                        anchors {
312
 
                            top: parent.top
313
 
                            left: parent.left
314
 
                            right: parent.right
315
 
                            bottom: parent.bottom
316
 
                        }
317
 
                        source: (tabs.selectedTab === weekTab) ? Qt.resolvedUrl("WeekView.qml") : ""
318
 
 
319
 
                        onLoaded: {
320
 
                            item.dayStart = tabPage.currentDay;
321
 
                            item.tools = commonToolBar
322
 
                        }
323
 
 
324
 
                        Connections{
325
 
                            target: weekPage.item
 
275
                    page: Page{
 
276
                        anchors.fill: parent
 
277
                        tools: commonToolBar
 
278
                        WeekView{
 
279
                            id: weekView
 
280
                            anchors.fill: parent
 
281
 
326
282
                            onDayStartChanged: {
327
 
                                tabPage.currentDay = weekPage.item.dayStart;
 
283
                                tabPage.currentDay = dayStart;
328
284
                            }
329
285
                        }
330
286
                    }
331
287
                }
332
288
 
333
289
                Tab{
334
 
                    id: dayTab
335
290
                    objectName: "dayTab"
336
291
                    title: i18n.tr("Day")
337
 
                    page: Loader{
338
 
                        id: dayPage
339
 
                        anchors {
340
 
                            top: parent.top
341
 
                            left: parent.left
342
 
                            right: parent.right
343
 
                            bottom: parent.bottom
344
 
                        }
345
 
                        source: (tabs.selectedTab === dayTab) ? Qt.resolvedUrl("DayView.qml") : ""
346
 
 
347
 
                        onLoaded: {
348
 
                            item.currentDay = tabPage.currentDay;
349
 
                            item.tools = commonToolBar
350
 
                        }
351
 
 
352
 
                        Connections{
353
 
                            target: dayPage.item
 
292
                    page: Page{
 
293
                        anchors.fill: parent
 
294
                        tools: commonToolBar
 
295
                        DayView{
 
296
                            id: dayView
 
297
                            anchors.fill: parent
 
298
 
354
299
                            onCurrentDayChanged: {
355
 
                                tabPage.currentDay = dayPage.item.currentDay;
 
300
                                tabPage.currentDay = currentDay;
356
301
                            }
357
302
                        }
358
303
                    }