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

« back to all changes in this revision

Viewing changes to WeekView.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:
4
4
import "dateExt.js" as DateExt
5
5
import "ViewType.js" as ViewType
6
6
 
7
 
Column {
 
7
Page{
8
8
    id: root
9
 
    objectName: "WeekView"
10
 
 
11
9
    property var dayStart: new Date();
12
10
    property var firstDay: dayStart.weekStart(Qt.locale().firstDayOfWeek);
13
11
    property bool isCurrentPage: false
14
12
 
15
 
    anchors.top: parent.top
16
 
    anchors.topMargin: units.gu(1.5)
17
 
    spacing: units.gu(1)
18
 
 
19
 
    anchors.fill: parent
20
 
 
21
 
    ViewHeader{
22
 
        id: viewHeader
23
 
        date: dayStart
24
 
    }
25
 
 
26
 
    TimeLineHeader{
27
 
        id: weekHeader
28
 
        objectName: "weekHeader"
29
 
        type: ViewType.ViewTypeWeek
30
 
        date: weekViewPath.weekStart
31
 
    }
32
 
 
33
 
    PathViewBase{
34
 
        id: weekViewPath
35
 
 
36
 
        property var visibleWeek: dayStart.weekStart(Qt.locale().firstDayOfWeek);
37
 
        property var weekStart: weekViewPath.visibleWeek
38
 
 
39
 
        width: parent.width
40
 
        height: root.height - weekViewPath.y
41
 
 
42
 
        //This is used to scroll all view together when currentItem scrolls
43
 
        property var childContentY;
44
 
 
45
 
        onNextItemHighlighted: {
46
 
            nextWeek();
47
 
            weekHeader.incrementCurrentIndex()
48
 
        }
49
 
 
50
 
        onPreviousItemHighlighted: {
51
 
            previousWeek();
52
 
            weekHeader.decrementCurrentIndex()
53
 
        }
54
 
 
55
 
        function nextWeek() {
56
 
            var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
57
 
            dayStart = weekStartDay.addDays(7);
58
 
        }
59
 
 
60
 
        function previousWeek(){
61
 
            var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
62
 
            dayStart = weekStartDay.addDays(-7);
63
 
        }
64
 
 
65
 
        delegate: TimeLineBaseComponent {
66
 
            id: timeLineView
67
 
 
68
 
            type: ViewType.ViewTypeWeek
 
13
    Column {
 
14
        objectName: "WeekView"
 
15
 
 
16
        anchors.fill: parent
 
17
        anchors.top: parent.top
 
18
        anchors.topMargin: units.gu(1.5)
 
19
        spacing: units.gu(1)
 
20
 
 
21
        ViewHeader{
 
22
            id: viewHeader
 
23
            date: dayStart
 
24
        }
 
25
 
 
26
        TimeLineHeader{
 
27
            id: weekHeader
 
28
            objectName: "weekHeader"
 
29
            type: typeWeek
 
30
            date: weekViewPath.weekStart
 
31
        }
 
32
 
 
33
        PathViewBase{
 
34
            id: weekViewPath
 
35
 
 
36
            //This is used to scroll all view together when currentItem scrolls
 
37
            property var childContentY;
 
38
 
 
39
            property var visibleWeek: root.dayStart.weekStart(Qt.locale().firstDayOfWeek);
 
40
            property var weekStart: weekViewPath.visibleWeek
69
41
 
70
42
            width: parent.width
71
 
            height: parent.height
72
 
 
73
 
            startDay: getWeekStart();
74
 
 
75
 
            Connections{
 
43
            height: root.height - weekViewPath.y
 
44
 
 
45
            onNextItemHighlighted: {
 
46
                nextWeek();
 
47
                weekHeader.incrementCurrentIndex()
 
48
            }
 
49
 
 
50
            onPreviousItemHighlighted: {
 
51
                previousWeek();
 
52
                weekHeader.decrementCurrentIndex()
 
53
            }
 
54
 
 
55
            function nextWeek() {
 
56
                var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
 
57
                dayStart = weekStartDay.addDays(7);
 
58
            }
 
59
 
 
60
            function previousWeek(){
 
61
                var weekStartDay = visibleWeek.weekStart(Qt.locale().firstDayOfWeek);
 
62
                dayStart = weekStartDay.addDays(-7);
 
63
            }
 
64
 
 
65
            delegate: TimeLineBaseComponent {
 
66
                id: timeLineView
 
67
 
 
68
                type: typeWeek
 
69
 
 
70
                width: parent.width
 
71
                height: parent.height
 
72
                startDay: getWeekStart();
 
73
 
 
74
                function getWeekStart() {
 
75
                    switch( weekViewPath.indexType(index)) {
 
76
                    case 0:
 
77
                        return weekViewPath.weekStart;
 
78
                    case -1:
 
79
                        var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
 
80
                        return weekStartDay.addDays(-7);
 
81
                    case 1:
 
82
                        var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
 
83
                        return weekStartDay.addDays(7);
 
84
                    }
 
85
                }
 
86
           } 
 
87
           Connections{
76
88
                target: root
77
89
                onIsCurrentPageChanged:{
78
90
                    if(root.isCurrentPage){
97
109
                when: timeLineView.PathView.isCurrentItem
98
110
            }
99
111
 
100
 
            function getWeekStart() {
101
 
                switch( weekViewPath.indexType(index)) {
102
 
                case 0:
103
 
                    return weekViewPath.weekStart;
104
 
                case -1:
105
 
                    var weekStartDay= weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
106
 
                    return weekStartDay.addDays(-7);
107
 
                case 1:
108
 
                    var weekStartDay = weekViewPath.weekStart.weekStart(Qt.locale().firstDayOfWeek);
109
 
                    return weekStartDay.addDays(7);
110
 
                }
111
 
            }
112
112
        }
113
113
    }
114
114
}
115
 
 
116