~nskaggs/ubuntu-calendar-app/standalone-ap-for-1293489

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1
import QtOrganizer 5.0

import "dateExt.js" as DateExt
import "ViewType.js" as ViewType

Item {
    id: root

    property var startDay: DateExt.today();
    property alias contentY: timeLineView.contentY
    property alias contentInteractive: timeLineView.interactive

    property int type: ViewType.ViewTypeWeek

    onStartDayChanged: {
        timeLineView.scroll();
    }

    //scroll in case content height changed
    onHeightChanged: {
        timeLineView.scroll()
    }

    Column {
        anchors.top: parent.top

        width: parent.width
        height: parent.height

        AllDayEventComponent{
            id: allDayContainer
            type: root.type
            startDay: root.startDay
        }

        Flickable{
            id: timeLineView

            width: parent.width
            height: parent.height - allDayContainer.height

            contentHeight: units.gu(10) * 24
            contentWidth: width

            clip: true

            function scroll() {
                //scroll to 9 o'clock
                var hour = 9

                timeLineView.contentY = hour * units.gu(10);
                if(timeLineView.contentY >= timeLineView.contentHeight - timeLineView.height) {
                    timeLineView.contentY = timeLineView.contentHeight - timeLineView.height
                }
            }

            TimeLineBackground{
            }

            Row{
                id: week
                width: parent.width
                height: parent.height
                anchors.top: parent.top

                Repeater{
                    model: type == ViewType.ViewTypeWeek ? 7 : 1

                    delegate: TimeLineBase {
                        property int idx: index
                        anchors.top: parent.top
                        width: {
                            if( type == ViewType.ViewTypeWeek ) {
                                 parent.width/7
                            } else {
                                (parent.width)
                            }
                        }
                        height: parent.height
                        delegate: comp
                        day: startDay.addDays(index)
                    }
                }
            }
        }
    }

    Component{
        id: comp
        EventBubble{
            type: {
                if( root.type == ViewType.ViewTypeWeek ) {
                    narrowType
                } else {
                    wideType
                }
            }
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.leftMargin: units.gu(0.1)
            anchors.rightMargin: units.gu(0.1)
            clip: true
        }
    }
}