4
4
import "dateExt.js" as DateExt
5
5
import "dataService.js" as DataService
11
property var dayStart : new Date();
13
property bool expanded: false
14
property bool expanding: false
15
property bool compressing: false
22
//scroll to first event or current hour
23
var hour = intern.now.getHours();
24
if(eventListModel.count > 0) {
25
hour = eventListModel.get(0).startTime.getHours();
28
timeLineView.contentY = hour * units.gu(10);
30
if(timeLineView.contentY >= timeLineView.contentHeight - timeLineView.height) {
31
timeLineView.contentY = timeLineView.contentHeight - timeLineView.height
35
function createEventMap() {
37
for(var i = 0 ; i < eventListModel.count ; ++i) {
38
var event = eventListModel.get(i);
39
eventMap[event.startTime.getHours()] = event
44
function createEvents() {
45
intern.eventMap = createEventMap();
47
bubbleOverLay.destroyAllChildren();
49
for( var i=0; i < 24; ++i ) {
50
var event = intern.eventMap[i];
52
bubbleOverLay.createEvent(event,i);
53
} else if( i === intern.now.getHours()
54
&& intern.now.isSameDay( timeLineView.dayStart )) {
55
bubbleOverLay.createSeparator(i);
62
function showEventDetails(hour) {
63
var event = intern.eventMap[hour];
64
pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":event});
68
// console.log(expanded, expanding, compressing, dragging, flicking, moving, contentY)
69
if (expanding || compressing || !dragging) return
72
if (contentY < -units.gu(0.5)) {
78
if (contentY < -units.gu(0.5)) {
92
else if (compressing) {
100
contentHeight: timeLineColumn.height + units.gu(3)
105
property var eventMap;
106
property var now : new Date();
107
property var hourHeight : units.gu(10)
112
termStart: timeLineView.dayStart
113
termLength: Date.msPerDay
121
id: background; anchors.fill: parent
128
anchors.top: parent.top
129
anchors.topMargin: units.gu(3)
133
model: 24 // hour in a day
138
height: intern.hourHeight
10
flickableChild: timeLineView
13
timeLineView.createEvents();
21
//scroll to first event or current hour
22
var hour = intern.now.getHours();
23
if( eventModel.count > 0) {
24
hour = eventModel.get(0).startTime.getHours();
27
timeLineView.contentY = hour * intern.hourHeight;
29
if(timeLineView.contentY >= timeLineView.contentHeight - timeLineView.height) {
30
timeLineView.contentY = timeLineView.contentHeight - timeLineView.height
34
function createEventMap() {
36
for(var i = 0 ; i < eventModel.count ; ++i) {
37
var event = eventModel.get(i);
38
eventMap[event.startTime.getHours()] = event
43
function createEvents() {
44
intern.eventMap = createEventMap();
46
bubbleOverLay.destroyAllChildren();
48
for( var i=0; i < 24; ++i ) {
49
var event = intern.eventMap[i];
51
bubbleOverLay.createEvent(event,i);
52
} else if( i === intern.now.getHours()
53
&& intern.now.isSameDay( root.dayStart )) {
54
bubbleOverLay.createSeparator(i);
61
function showEventDetails(hour) {
62
var event = intern.eventMap[hour];
63
pageStack.push(Qt.resolvedUrl("EventDetails.qml"),{"event":event});
66
contentHeight: timeLineColumn.height + units.gu(3)
71
property var eventMap;
72
property var now : new Date();
73
property var hourHeight : units.gu(10)
77
id: background; anchors.fill: parent
84
anchors.top: parent.top
85
anchors.topMargin: units.gu(3)
89
model: 24 // hour in a day
141
93
width: parent.width
142
y: -timeLabel.height/2
145
// TRANSLATORS: this is a time formatting string,
146
// see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
147
text: new Date(0, 0, 0, index).toLocaleTimeString(Qt.locale(), i18n.tr("HH:mm"))
149
anchors.top: parent.top
94
height: intern.hourHeight
98
y: -timeLabel.height/2
101
// TRANSLATORS: this is a time formatting string,
102
// see http://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-date.html#details for valid expressions
103
text: new Date(0, 0, 0, index).toLocaleTimeString(Qt.locale(), i18n.tr("HH:mm"))
105
anchors.top: parent.top
108
width: parent.width -timeLabel.width
111
anchors.verticalCenter: parent.verticalCenter
152
width: parent.width -timeLabel.width
116
width: parent.width - units.gu(5)
153
117
height:units.dp(1)
155
119
anchors.verticalCenter: parent.verticalCenter
160
width: parent.width - units.gu(5)
163
anchors.verticalCenter: parent.verticalCenter
164
anchors.horizontalCenter: parent.horizontalCenter
173
width: timeLineColumn.width
174
height: timeLineColumn.height
175
anchors.top: parent.top
176
anchors.topMargin: units.gu(3)
178
function destroyAllChildren() {
179
for( var i = children.length - 1; i >= 0; --i ) {
180
children[i].destroy();
184
function createEvent( event ,hour) {
185
var eventBubble = infoBubbleComponent.createObject(bubbleOverLay);
186
eventBubble.title = event.title;
187
eventBubble.location = "test";
188
eventBubble.hour = hour;
190
var yPos = (( event.startTime.getMinutes() * intern.hourHeight) / 60) + hour * intern.hourHeight
191
eventBubble.y = yPos;
193
var durationMin = (event.endTime.getHours() - event.startTime.getHours()) * 60;
194
durationMin += (event.endTime.getMinutes() - event.startTime.getMinutes());
195
var height = (durationMin * intern.hourHeight )/ 60;
196
eventBubble.height = height;
199
function createSeparator(hour) {
200
var separator = separatorComponent.createObject(bubbleOverLay);
201
var yPos = ((intern.now.getMinutes() * intern.hourHeight) / 60) + hour * intern.hourHeight
202
separator.visible = true;
204
separator.x = (parent.width - separator.width)/2
209
id: infoBubbleComponent
213
property string title;
214
property string location;
218
width: timeLineView.width - units.gu(8)
221
border.color: "#f4d690"
230
leftMargin: units.gu(1)
231
rightMargin: units.gu(1)
232
topMargin: units.gu(1)
235
Label{text:infoBubble.title;fontSize:"medium";color:"black"}
236
Label{text:infoBubble.location; fontSize:"small"; color:"black"}
242
timeLineView.showEventDetails(hour);
249
id: separatorComponent
252
height: units.gu(0.5)
253
width: timeLineView.width - units.gu(2)
120
anchors.horizontalCenter: parent.horizontalCenter
129
width: timeLineColumn.width
130
height: timeLineColumn.height
131
anchors.top: parent.top
132
anchors.topMargin: units.gu(3)
134
function destroyAllChildren() {
135
for( var i = children.length - 1; i >= 0; --i ) {
136
children[i].destroy();
140
function createEvent( event ,hour) {
141
var eventBubble = infoBubbleComponent.createObject(bubbleOverLay);
142
eventBubble.title = event.title;
143
eventBubble.location = "test";
144
eventBubble.hour = hour;
146
var yPos = (( event.startTime.getMinutes() * intern.hourHeight) / 60) + hour * intern.hourHeight
147
eventBubble.y = yPos;
149
var durationMin = (event.endTime.getHours() - event.startTime.getHours()) * 60;
150
durationMin += (event.endTime.getMinutes() - event.startTime.getMinutes());
151
var height = (durationMin * intern.hourHeight )/ 60;
152
eventBubble.height = height;
155
function createSeparator(hour) {
156
var w = timeLineView.width - units.gu(2);
157
var y = ((intern.now.getMinutes() * intern.hourHeight) / 60) + hour * intern.hourHeight;
158
var x = (parent.width - w)/ 2;
159
var properties = {"x": x, "y": y, "width": w}
161
var component = Qt.createComponent("TimeSeparator.qml");
162
var separator = component.createObject(bubbleOverLay, properties);
167
id: infoBubbleComponent
171
property string title;
172
property string location;
176
width: timeLineView.width - units.gu(8)
179
border.color: "#f4d690"
188
leftMargin: units.gu(1)
189
rightMargin: units.gu(1)
190
topMargin: units.gu(1)
193
Label{text:infoBubble.title;fontSize:"medium";color:"black"}
194
Label{text:infoBubble.location; fontSize:"small"; color:"black"}
200
timeLineView.showEventDetails(hour);