69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
1 |
import QtQuick 2.0 |
2 |
import Ubuntu.Components 0.1 |
|
3 |
import "dateExt.js" as DateExt |
|
233.1.1
by Kunal Parmar
EventView performance improvement |
4 |
|
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
5 |
Item { |
6 |
id: bubbleOverLay
|
|
7 |
||
8 |
property var delegate; |
|
9 |
property var day; |
|
257.1.2
by Mihir Soni
Description will be visible only if is fit to event bubble |
10 |
property int hourHeight: units.gu(10) |
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
11 |
|
233.1.1
by Kunal Parmar
EventView performance improvement |
12 |
property var model; |
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
13 |
|
222.3.9
by Bartosz Kosiorek
Move MouseArea into TimeLineBase |
14 |
MouseArea { |
15 |
anchors.fill: parent |
|
16 |
objectName: "mouseArea" |
|
17 |
onPressAndHold: { |
|
18 |
var selectedDate = new Date(day); |
|
19 |
var hour = parseInt(mouseY / hourHeight); |
|
20 |
selectedDate.setHours(hour) |
|
21 |
pageStack.push(Qt.resolvedUrl("NewEvent.qml"), {"date":selectedDate, "model":eventModel}); |
|
22 |
}
|
|
23 |
}
|
|
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
24 |
|
222.3.6
by Bartosz Kosiorek
Fix remarks after review |
25 |
TimeSeparator { |
69.1.16
by Kunal Parmar
WeekView currenttime issue fixed |
26 |
id: separator
|
27 |
objectName: "separator" |
|
28 |
width: bubbleOverLay.width |
|
233.1.1
by Kunal Parmar
EventView performance improvement |
29 |
visible: false |
72.2.8
by Kunal Parmar
minor changes |
30 |
z:1 |
69.1.16
by Kunal Parmar
WeekView currenttime issue fixed |
31 |
}
|
32 |
||
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
33 |
QtObject { |
34 |
id: intern
|
|
35 |
property var now : new Date(); |
|
238.1.7
by Kunal Parmar
Second attempt |
36 |
property var eventMap; |
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
37 |
}
|
38 |
||
98.1.1
by Kunal Parmar
eventmap removed |
39 |
function showEventDetails(event) { |
222.3.9
by Bartosz Kosiorek
Move MouseArea into TimeLineBase |
40 |
pageStack.push(Qt.resolvedUrl("EventDetails.qml"), {"event":event,"model":model}); |
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
41 |
}
|
42 |
||
238.1.7
by Kunal Parmar
Second attempt |
43 |
WorkerScript { |
44 |
id: eventLayoutHelper
|
|
45 |
source: "EventLayoutHelper.js" |
|
46 |
||
47 |
onMessage: { |
|
238.1.8
by Kunal Parmar
merge from trunk |
48 |
layoutEvents(messageObject.schedules,messageObject.maxDepth); |
238.1.7
by Kunal Parmar
Second attempt |
49 |
}
|
50 |
}
|
|
51 |
||
238.1.8
by Kunal Parmar
merge from trunk |
52 |
function layoutEvents(array, depth) { |
238.1.7
by Kunal Parmar
Second attempt |
53 |
var width = bubbleOverLay.width; |
54 |
var offset = width/(depth+1); |
|
55 |
for(var i=0; i < array.length ; ++i) { |
|
56 |
var schedule = array[i]; |
|
57 |
var x = (schedule.depth) * offset |
|
58 |
var w = width - x; |
|
59 |
var event = intern.eventMap[schedule.id]; |
|
60 |
bubbleOverLay.createEvent(event , x, w); |
|
61 |
}
|
|
62 |
}
|
|
63 |
||
98.1.1
by Kunal Parmar
eventmap removed |
64 |
function createEvents() { |
199.1.11
by Kunal Parmar
Some warning removed |
65 |
if(!bubbleOverLay || bubbleOverLay == undefined) { |
66 |
return; |
|
67 |
}
|
|
233.1.1
by Kunal Parmar
EventView performance improvement |
68 |
destroyAllChildren(); |
98.1.1
by Kunal Parmar
eventmap removed |
69 |
|
238.1.6
by Kunal Parmar
Code format |
70 |
var eventMap = {}; |
238.1.7
by Kunal Parmar
Second attempt |
71 |
var allSchs = []; |
72 |
||
209.1.1
by Yohan Boniface
Use proper end of day value |
73 |
var startDate = new Date(day).midnight(); |
74 |
var endDate = new Date(day).endOfDay(); |
|
233.1.1
by Kunal Parmar
EventView performance improvement |
75 |
var items = model.getItems(startDate,endDate); |
222.3.10
by Bartosz Kosiorek
Fix indentation |
76 |
for(var i = 0; i < items.length; ++i) { |
233.1.1
by Kunal Parmar
EventView performance improvement |
77 |
var event = items[i]; |
238.1.8
by Kunal Parmar
merge from trunk |
78 |
|
238.1.7
by Kunal Parmar
Second attempt |
79 |
if(event.allDay) { |
80 |
continue; |
|
69.1.12
by Kunal Parmar
scrolling changed |
81 |
}
|
238.1.7
by Kunal Parmar
Second attempt |
82 |
|
238.1.17
by Kunal Parmar
moved duration calculation to Workerscript |
83 |
var schedule = {"startDateTime": event.startDateTime, "endDateTime": event.endDateTime,"id":event.itemId }; |
238.1.7
by Kunal Parmar
Second attempt |
84 |
allSchs.push(schedule); |
85 |
eventMap[event.itemId] = event; |
|
98.1.2
by Kunal Parmar
current time fix |
86 |
}
|
69.1.12
by Kunal Parmar
scrolling changed |
87 |
|
238.1.7
by Kunal Parmar
Second attempt |
88 |
intern.eventMap = eventMap; |
89 |
eventLayoutHelper.sendMessage(allSchs); |
|
90 |
||
98.1.2
by Kunal Parmar
current time fix |
91 |
if( intern.now.isSameDay( bubbleOverLay.day ) ) { |
92 |
bubbleOverLay.showSeparator(intern.now.getHours()); |
|
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
93 |
}
|
94 |
}
|
|
95 |
||
96 |
function destroyAllChildren() { |
|
238.1.5
by Kunal Parmar
revert space change |
97 |
for( var i = children.length - 1; i >= 0; --i ) { |
238.1.8
by Kunal Parmar
merge from trunk |
98 |
if( children[i].objectName === "mouseArea" ) { |
222.3.9
by Bartosz Kosiorek
Move MouseArea into TimeLineBase |
99 |
continue; |
100 |
}
|
|
233.1.1
by Kunal Parmar
EventView performance improvement |
101 |
children[i].visible = false; |
102 |
if( children[i].objectName !== "separator") { |
|
69.1.16
by Kunal Parmar
WeekView currenttime issue fixed |
103 |
children[i].destroy(); |
104 |
}
|
|
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
105 |
}
|
106 |
}
|
|
107 |
||
238.1.7
by Kunal Parmar
Second attempt |
108 |
function createEvent( event, x, width ) { |
109 |
var hour = event.startDateTime.getHours(); |
|
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
110 |
var eventBubble = delegate.createObject(bubbleOverLay); |
233.1.1
by Kunal Parmar
EventView performance improvement |
111 |
|
124.3.3
by Kunal Parmar
TimeLineBase changed to QtOrganizerModel |
112 |
var yPos = (( event.startDateTime.getMinutes() * hourHeight) / 60) + hour * hourHeight |
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
113 |
eventBubble.y = yPos; |
114 |
||
124.3.3
by Kunal Parmar
TimeLineBase changed to QtOrganizerModel |
115 |
var durationMin = (event.endDateTime.getHours() - event.startDateTime.getHours()) * 60; |
116 |
durationMin += (event.endDateTime.getMinutes() - event.startDateTime.getMinutes()); |
|
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
117 |
var height = (durationMin * hourHeight )/ 60; |
212.2.3
by Kunal Parmar
show details as per height |
118 |
eventBubble.height = (height > eventBubble.minimumHeight) ? height:eventBubble.minimumHeight ; |
119 |
||
238.1.1
by Kunal Parmar
MutipleEventOnsametime |
120 |
eventBubble.x = x; |
121 |
eventBubble.width = width; |
|
212.2.3
by Kunal Parmar
show details as per height |
122 |
eventBubble.event = event |
238.1.7
by Kunal Parmar
Second attempt |
123 |
eventBubble.clicked.connect( bubbleOverLay.showEventDetails ); |
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
124 |
}
|
125 |
||
69.1.17
by Kunal Parmar
createSeparator -> showSeparator |
126 |
function showSeparator(hour) { |
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
127 |
var y = ((intern.now.getMinutes() * hourHeight) / 60) + hour * hourHeight; |
69.1.16
by Kunal Parmar
WeekView currenttime issue fixed |
128 |
separator.y = y; |
129 |
separator.visible = true; |
|
69.1.1
by Kunal Parmar
Initial WeekRibbon and WeekView implementation |
130 |
}
|
131 |
}
|