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

« back to all changes in this revision

Viewing changes to calendar.qml

  • Committer: Kunal Parmar
  • Date: 2014-04-05 07:10:36 UTC
  • Revision ID: pkunal.parmar@gmail.com-20140405071036-9bvzjav3j46h52pk
Unnecessary Top Page removed

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    PageStack {
63
63
        id: pageStack
64
64
 
65
 
        Component.onCompleted: push(tabPage)
 
65
        Component.onCompleted: push(tabs)
66
66
 
67
 
        Page{
68
 
            id: tabPage
 
67
        Tabs{
 
68
            id: tabs
69
69
 
70
70
            property var currentDay: DateExt.today();
71
71
            property var globalModel;
77
77
 
78
78
            onCurrentDayChanged: {
79
79
                if( yearView.currentYear !== currentDay.getFullYear() ) {
80
 
                    yearView.currentYear = tabPage.currentDay.getFullYear();
 
80
                    yearView.currentYear = tabs.currentDay.getFullYear();
81
81
                }
82
82
 
83
83
                if( monthView.currentMonth !== undefined && !monthView.currentMonth.isSameDay(currentDay))
137
137
                var difference = endTime - startTime;
138
138
 
139
139
                if (difference > month)
140
 
                    return 0;   // Year view
 
140
                    return yearTab.index;   // Year view
141
141
                else if (difference > 7 * day)
142
 
                    return 1;   // Month view}
 
142
                    return monthTab.index;   // Month view}
143
143
                else if (difference > day)
144
 
                    return 2;   // Week view
 
144
                    return weekTab.index;   // Week view
145
145
                else
146
 
                    return 3;   // Day view
 
146
                    return dayTab.index;   // Day view
147
147
            }
148
148
 
149
149
            // This function parse the argument
166
166
                // If an url has been set
167
167
                if (args.defaultArgument.at(0)) {
168
168
                    parseArguments(args.defaultArgument.at(0))
169
 
                    tabPage.currentDay = new Date()
 
169
                    tabs.currentDay = new Date()
170
170
                    // If newevent has been called on startup
171
171
                    if (newevent) {
172
172
                        timer.running = true;
173
173
                    }
174
174
                    else if (starttime !== -1) { // If no newevent has been setted, but starttime
175
175
                        var startTime = parseInt(starttime);
176
 
                        tabPage.currentDay = new Date(startTime);
 
176
                        tabs.currentDay = new Date(startTime);
177
177
 
178
178
                        // If also endtime has been settend
179
179
                        if (endtime !== -1) {
206
206
                running: false;
207
207
                repeat: false
208
208
                onTriggered: {
209
 
                    tabPage.newEvent();
 
209
                    tabs.newEvent();
210
210
                }
211
211
            }
212
212
 
219
219
                        iconSource: Qt.resolvedUrl("calendar-today.svg");
220
220
                        text: i18n.tr("Today");
221
221
                        onTriggered: {
222
 
                            tabPage.currentDay = (new Date()).midnight();
 
222
                            tabs.currentDay = (new Date()).midnight();
223
223
                        }
224
224
                    }
225
225
                }
229
229
                        iconSource: Qt.resolvedUrl("new-event.svg");
230
230
                        text: i18n.tr("New Event");
231
231
                        onTriggered: {
232
 
                            pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date":tabPage.currentDay});
 
232
                            pageStack.push(Qt.resolvedUrl("NewEvent.qml"),{"date":tabs.currentDay});
233
233
                        }
234
234
                    }
235
235
                }
236
236
            }
237
237
 
238
 
            Tabs{
239
 
                id: tabs
240
 
 
241
 
                Tab{
242
 
                    objectName: "yearTab"
243
 
                    title: i18n.tr("Year")
244
 
                    page: Page{
245
 
                        objectName: "yearPage"
246
 
                        anchors.fill: parent
247
 
                        tools: commonToolBar
248
 
                        YearView{
249
 
                            id: yearView
250
 
                            onMonthSelected: {
251
 
                                tabs.selectedTabIndex = 1
252
 
                                var now = DateExt.today();
253
 
                                if( date.getMonth() === now.getMonth()
254
 
                                        && date.getFullYear() === now.getFullYear()) {
255
 
                                    monthView.currentMonth = now
256
 
                                } else {
257
 
                                    monthView.currentMonth = date.midnight();
258
 
                                }
 
238
            Tab{
 
239
                id: yearTab
 
240
                objectName: "yearTab"
 
241
                title: i18n.tr("Year")
 
242
                page: Page{
 
243
                    objectName: "yearPage"
 
244
                    tools: commonToolBar
 
245
                    YearView{
 
246
                        id: yearView
 
247
                        onMonthSelected: {
 
248
                            tabs.selectedTabIndex = monthTab.index;
 
249
                            var now = DateExt.today();
 
250
                            if( date.getMonth() === now.getMonth()
 
251
                                    && date.getFullYear() === now.getFullYear()) {
 
252
                                monthView.currentMonth = now
 
253
                            } else {
 
254
                                monthView.currentMonth = date.midnight();
259
255
                            }
260
256
                        }
261
257
                    }
262
258
                }
263
 
                Tab {
264
 
                    id: monthTab
265
 
                    objectName: "monthTab"
266
 
                    title: i18n.tr("Month")
267
 
                    page: MonthView{
 
259
            }
 
260
            Tab {
 
261
                id: monthTab
 
262
                objectName: "monthTab"
 
263
                title: i18n.tr("Month")
 
264
                page: MonthView{
 
265
                    tools: commonToolBar
 
266
                    id: monthView
 
267
 
 
268
                    onDateSelected: {
 
269
                        tabs.selectedTabIndex  = dayTab.index;
 
270
                        tabs.currentDay = date;
 
271
                    }
 
272
                }
 
273
            }
 
274
            Tab{
 
275
                id: weekTab
 
276
                objectName: "weekTab"
 
277
                title: i18n.tr("Week")
 
278
                page: Page{
 
279
                    tools: commonToolBar
 
280
                    WeekView{
 
281
                        id: weekView
268
282
                        anchors.fill: parent
269
 
                        tools: commonToolBar
270
 
                        id: monthView
 
283
                        isCurrentPage: tabs.selectedTab == weekTab
 
284
 
 
285
                        onDayStartChanged: {
 
286
                            tabs.currentDay = dayStart;
 
287
                        }
271
288
 
272
289
                        onDateSelected: {
273
 
                            tabs.selectedTabIndex  = 3
274
 
                            tabPage.currentDay = date;
275
 
                        }
276
 
                    }
277
 
                }
278
 
                Tab{
279
 
                    id: weekTab
280
 
                    objectName: "weekTab"
281
 
                    title: i18n.tr("Week")
282
 
                    page: Page{
283
 
                        anchors.fill: parent
284
 
                        tools: commonToolBar
285
 
                        WeekView{
286
 
                            id: weekView
287
 
                            anchors.fill: parent
288
 
                            isCurrentPage: tabs.selectedTab == weekTab
289
 
 
290
 
                            onDayStartChanged: {
291
 
                                tabPage.currentDay = dayStart;
292
 
                            }
293
 
 
294
 
                            onDateSelected: {
295
 
                                tabs.selectedTabIndex = 3;
296
 
                                tabPage.currentDay = date;
297
 
                            }
298
 
                        }
299
 
                    }
300
 
                }
301
 
 
302
 
                Tab{
303
 
                    id: dayTab
304
 
                    objectName: "dayTab"
305
 
                    title: i18n.tr("Day")
306
 
                    page: Page{
307
 
                        anchors.fill: parent
308
 
                        tools: commonToolBar
309
 
                        DayView{
310
 
                            id: dayView
311
 
                            anchors.fill: parent
312
 
                            isCurrentPage: tabs.selectedTab == dayTab
313
 
 
314
 
                            onCurrentDayChanged: {
315
 
                                tabPage.currentDay = currentDay;
316
 
                            }
 
290
                            tabs.selectedTabIndex = dayTab.index;
 
291
                            tabs.currentDay = date;
 
292
                        }
 
293
                    }
 
294
                }
 
295
            }
 
296
 
 
297
            Tab{
 
298
                id: dayTab
 
299
                objectName: "dayTab"
 
300
                title: i18n.tr("Day")
 
301
                page: Page{
 
302
                    tools: commonToolBar
 
303
                    DayView{
 
304
                        id: dayView
 
305
                        anchors.fill: parent
 
306
                        isCurrentPage: tabs.selectedTab == dayTab
 
307
 
 
308
                        onCurrentDayChanged: {
 
309
                            tabs.currentDay = currentDay;
317
310
                        }
318
311
                    }
319
312
                }
321
314
        }
322
315
    }
323
316
}
 
317