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

« back to all changes in this revision

Viewing changes to DayView.qml

  • Committer: Tarmac
  • Author(s): Kunal Parmar
  • Date: 2013-09-05 14:07:36 UTC
  • mfrom: (96.2.8 ubuntu-calendar-app)
  • Revision ID: tarmac-20130905140736-oy4uj5uy5fpcujve
New day view and week view created,
Theme applied according to UDS presentation
Removed unused files.

Approved by Olivier Tilloy, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
    property var currentDay: new Date()
14
14
 
15
 
    onCurrentDayChanged:{
16
 
        weekRibbon.visibleWeek = currentDay.weekStart(Qt.locale().firstDayOfWeek);
17
 
        weekRibbon.setSelectedDay(currentDay);
18
 
    }
19
 
 
20
 
    Label{
21
 
        id: todayLabel
22
 
        text: Qt.formatDateTime( new Date(),"d MMMM yyyy");
23
 
        fontSize: "large"
24
 
        width: parent.width
25
 
    }
26
 
 
27
 
    Label{
28
 
        id: timeLabel;visible: false
29
 
        text: new Date(0, 0, 0, 0).toLocaleTimeString(Qt.locale(), i18n.tr("HH"))
30
 
    }
31
 
 
32
 
    WeekRibbon{
33
 
        id: weekRibbon
34
 
        visibleWeek: currentDay.weekStart(Qt.locale().firstDayOfWeek);
35
 
        anchors.top: todayLabel.bottom
36
 
        anchors.left: timeLabel.right
37
 
        width: parent.width
38
 
        height: units.gu(10)
39
 
        //removing timeLabel.width from front and back of ribbon
40
 
        weekWidth: ((width - 2* timeLabel.width )/ 7 )
41
 
 
42
 
        onWeekChanged: {
43
 
            currentDay = visibleWeek
44
 
        }
45
 
 
46
 
        onDaySelected: {
47
 
            currentDay = day;
48
 
        }
49
 
    }
50
 
 
51
15
    PathViewBase{
52
 
        id: weekViewPath
53
 
        objectName:"DayViewPathBase"
54
 
 
55
 
        property var visibleDay: currentDay;
56
 
 
57
 
        QtObject{
58
 
            id: intern
59
 
            property var startDay: weekViewPath.visibleDay.addDays(-1)
60
 
        }
61
 
 
62
 
        anchors.top: weekRibbon.bottom
 
16
        id: dayViewPath
 
17
        objectName: "DayViewPathBase"
 
18
 
 
19
        property var startDay: currentDay.addDays(-1)
 
20
 
 
21
        anchors.top: parent.top
 
22
        anchors.topMargin: units.gu(1.5)
 
23
 
63
24
        width: parent.width
64
 
        height: parent.height - weekRibbon.height - units.gu(3)
 
25
        height: parent.height - units.gu(3)
65
26
 
66
27
        onNextItemHighlighted: {
67
 
            nextDay();
 
28
            //next day
 
29
            currentDay = currentDay.addDays(1);
68
30
        }
69
31
 
70
32
        onPreviousItemHighlighted: {
71
 
            previousDay();
72
 
        }
73
 
 
74
 
        function nextDay() {
75
 
            currentDay = visibleDay.addDays(1);
76
 
        }
77
 
 
78
 
        function previousDay(){
79
 
            currentDay = visibleDay.addDays(-1);
80
 
        }
81
 
 
82
 
        delegate: DayComponent {
 
33
            //previous day
 
34
            currentDay = currentDay.addDays(-1);
 
35
        }
 
36
 
 
37
        delegate: TimeLineBaseComponent {
83
38
            id: timeLineView
84
39
            objectName: "DayComponent-"+index
85
40
 
 
41
            type: typeDay
 
42
 
86
43
            width: parent.width
87
44
            height: parent.height
88
 
            weekWidth: weekRibbon.weekWidth
89
 
            day: getStartDay();
 
45
 
 
46
            startDay: getStartDay().addDays(-1);
90
47
 
91
48
            function getStartDay() {
92
49
                //previous page
93
 
                if (index === weekViewPath.currentIndex) {
94
 
                    return intern.startDay;
 
50
                if (index === dayViewPath.currentIndex) {
 
51
                    return dayViewPath.startDay;
95
52
                }
96
53
 
97
54
                //next page
98
 
                var previousIndex = weekViewPath.currentIndex > 0 ? weekViewPath.currentIndex - 1 : 2
 
55
                var previousIndex = dayViewPath.currentIndex > 0 ? dayViewPath.currentIndex - 1 : 2
99
56
                if ( index === previousIndex ) {
100
 
                    return intern.startDay.addDays(2);
 
57
                    return dayViewPath.startDay.addDays(2);
101
58
                }
102
59
 
103
60
                //current page
104
 
                return intern.startDay.addDays(1);
 
61
                return dayViewPath.startDay.addDays(1);
105
62
            }
106
63
        }
107
64
    }