~timo-jyrinki/ubuntu-calendar-app/revert_213_that_reverted_212

« back to all changes in this revision

Viewing changes to calendar.qml

  • Committer: Timo Jyrinki
  • Date: 2014-03-24 13:56:27 UTC
  • Revision ID: timo.jyrinki@canonical.com-20140324135627-l1kr11f5avrabstp
Revert bzr213 that reverted bzr212, taking into accound conflicts in calendar.qml and WeekView.qml.

Show diffs side-by-side

added added

removed removed

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