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
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import "dateExt.js" as DateExt
Item {
id: root
property var startDay: DateExt.today();
property int type: typeWeek
readonly property int typeWeek: 0
readonly property int typeDay: 1
onStartDayChanged: {
timeLineView.scroll();
}
//scroll in case content height changed
onHeightChanged: {
timeLineView.scroll()
}
Flickable{
id: timeLineView
anchors.top: parent.top
width: parent.width
height: parent.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 == typeWeek ? 7 : 1
delegate: TimeLineBase {
property int idx: index
anchors.top: parent.top
width: {
if( type == typeWeek ) {
parent.width/7
} else {
(parent.width)
}
}
height: parent.height
delegate: comp
day: startDay.addDays(index)
}
}
}
}
Component{
id: comp
EventBubble{
type: {
if( root.type == typeWeek ) {
narrowType
} else {
wideType
}
}
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: units.gu(0.1)
anchors.rightMargin: units.gu(0.1)
}
}
}
|