2
import Ubuntu.Components 0.1
3
import "dateExt.js" as DateExt
8
property var currentDayStart: (new Date()).midnight()
9
property string eventViewType: "DiaryView.qml";
11
signal incrementCurrentDay
12
signal decrementCurrentDay
18
property int currentIndexSaved: 0
19
property int currentIndex: 0
20
property var currentDayStart: (new Date()).midnight()
23
onCurrentIndexChanged: {
24
var delta = currentIndex - intern.currentIndexSaved
25
if (intern.currentIndexSaved == count - 1 && currentIndex == 0) delta = 1
26
if (intern.currentIndexSaved == 0 && currentIndex == count - 1) delta = -1
27
intern.currentIndexSaved = currentIndex
28
if (delta > 0) incrementCurrentDay()
29
else decrementCurrentDay()
32
onCurrentDayStartChanged: {
33
if (!moving) intern.currentDayStart = currentDayStart
37
intern.currentDayStart = currentDayStart
38
intern.currentIndex = currentIndex
41
preferredHighlightBegin: 0.5
42
preferredHighlightEnd: 0.5
43
highlightRangeMode: PathView.StrictlyEnforceRange
46
startX: -eventView.width; startY: eventView.height / 2
47
PathLine { relativeX: eventView.width; relativeY: 0 }
48
PathLine { relativeX: eventView.width; relativeY: 0 }
49
PathLine { relativeX: eventView.width; relativeY: 0 }
52
snapMode: PathView.SnapOneItem
59
width: eventView.width
60
height: eventView.height
61
source: eventView.eventViewType
63
property var dayStart: {
64
if (index == intern.currentIndex) return intern.currentDayStart
65
var previousIndex = intern.currentIndex > 0 ? intern.currentIndex - 1 : 2
66
if (index === previousIndex) return intern.currentDayStart.addDays(-1)
67
return intern.currentDayStart.addDays(1)
71
item.newEvent.connect(eventView.newEvent);
77
value: eventViewDelegate.dayStart
80
//share state from delegate to eventView, if state change is from current delegate
84
value: eventViewDelegate.item.state;
85
when: index == eventView.currentIndex
88
//share state from eventview to delegate, so that all delegate share the same state
90
target: eventViewDelegate.item
92
value: eventView.state