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
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import "dateExt.js" as DateExt
import "colorUtils.js" as Color
ListView {
id: diaryView
property var dayStart: new Date()
property bool expanded: false
property bool expanding: false
property bool compressing: false
signal expand()
signal compress()
clip: true
model: EventListModel {
termStart: dayStart
termLength: Date.msPerDay
}
section {
property: "category"
// labelPositioning: ViewSection.CurrentLabelAtStart // FIXME, unreliable
delegate: ListItem.Header {
text: i18n.tr(section)
MouseArea {
anchors.fill: parent
onClicked: {
if (expanded)
compress()
else
expand()
}
}
}
}
delegate: ListItem.Standard {
text: startTime.toLocaleTimeString(Qt.locale(i18n.language), Locale.ShortFormat) + " " + title
}
footer: ListItem.Standard {
text: i18n.tr("(+) New Event / Todo")
}
onContentYChanged: {
// console.log(expanded, expanding, compressing, dragging, flicking, moving, contentY)
if (expanding || compressing || !dragging) return
if (expanded) {
if (contentY < -units.gu(0.5)) {
compressing = true
expanding = false
}
}
else {
if (contentY < -units.gu(0.5)) {
expanding = true
compressing = false
}
}
}
onDraggingChanged: {
if (dragging) return
if (expanding) {
expanding = false
expand()
}
else if (compressing) {
compressing = false
compress()
}
}
}
|