2
import Ubuntu.Components 0.1
4
import "dateExt.js" as DateExt
5
import "dataService.js" as DataService
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
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"))
105
anchors.top: parent.top
108
width: parent.width -timeLabel.width
111
anchors.verticalCenter: parent.verticalCenter
116
width: parent.width - units.gu(5)
119
anchors.verticalCenter: parent.verticalCenter
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);