summaryrefslogtreecommitdiffstats
path: root/views/calendar/qml/WeekView.qml
diff options
context:
space:
mode:
authorMichael Bohlender <michael.bohlender@kdemail.net>2018-03-15 08:55:54 +0100
committerMichael Bohlender <michael.bohlender@kdemail.net>2018-03-15 08:56:18 +0100
commitfb8c18b8f86bca090a52fee08cd25116fe66ebb5 (patch)
treea8519b356d9ecbbca892ccdd5acb5e60a54fb6aa /views/calendar/qml/WeekView.qml
parenta728bb2e3c970183a86fa92fe5d24cdfe95e7812 (diff)
downloadkube-fb8c18b8f86bca090a52fee08cd25116fe66ebb5.tar.gz
kube-fb8c18b8f86bca090a52fee08cd25116fe66ebb5.zip
initial month view
Diffstat (limited to 'views/calendar/qml/WeekView.qml')
-rw-r--r--views/calendar/qml/WeekView.qml273
1 files changed, 273 insertions, 0 deletions
diff --git a/views/calendar/qml/WeekView.qml b/views/calendar/qml/WeekView.qml
new file mode 100644
index 00000000..8eef3a92
--- /dev/null
+++ b/views/calendar/qml/WeekView.qml
@@ -0,0 +1,273 @@
1/*
2 * Copyright (C) 2018 Michael Bohlender, <bohlender@kolabsys.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19import QtQuick 2.4
20import QtQuick.Layouts 1.1
21import QtQuick.Controls 2.3
22import Qt.labs.calendar 1.0
23
24import org.kube.framework 1.0 as Kube
25
26FocusScope {
27 id: root
28
29 Item {
30 anchors {
31 top: parent.top
32 topMargin: Kube.Units.largeSpacing
33 horizontalCenter: parent.horizontalCenter
34 }
35
36 width: Kube.Units.gridUnit * 7 * 7 + Kube.Units.gridUnit * 2
37 height: Kube.Units.gridUnit * 27
38
39 //BEGIN day labels
40 DayOfWeekRow {
41 id: dayLabels
42 anchors.right: parent.right
43 spacing: 0
44 locale: Qt.locale("en_GB")
45
46 delegate: Rectangle {
47 width: Kube.Units.gridUnit * 7
48 height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 3
49
50 border.width: 1
51 border.color: "lightgrey"
52 color: Kube.Colors.viewBackgroundColor
53
54 Kube.Label {
55 anchors {
56 top: parent.top
57 left: parent.left
58 margins: Kube.Units.smallSpacing
59 }
60 text: model.shortName
61 }
62 }
63 }
64 //END day labels
65
66 //BEGIN daylong events
67 Rectangle {
68 id: daylong
69
70 anchors {
71 top: dayLabels.bottom
72 right: parent.right
73 }
74
75 height: Kube.Units.gridUnit * 3
76 width: Kube.Units.gridUnit * 7 * 7
77 color: Kube.Colors.viewBackgroundColor
78 border.width: 1
79 border.color: Kube.Colors.buttonColor
80
81 ListView {
82
83 anchors {
84 fill: parent
85 margins: 1
86 }
87
88 model: DaylongEvents {}
89
90 delegate: Item {
91 height: Kube.Units.gridUnit + 2 // +2 to make good for the white border
92 width: daylong.width
93
94 Rectangle {
95 width: Kube.Units.gridUnit * 7 * model.duration
96 height: parent.height
97 x: Kube.Units.gridUnit * 7 * model.starts
98 color: model.color
99 border.width: 1
100 border.color: Kube.Colors.viewBackgroundColor
101
102 Kube.Label {
103 anchors {
104 left: parent.left
105 leftMargin: Kube.Units.smallSpacing
106 }
107 color: Kube.Colors.highlightedTextColor
108 text: model.text
109 }
110 }
111 }
112 }
113 }
114 //END daylong events
115
116 Flickable {
117 id: mainWeekViewer
118
119 anchors {
120 top: daylong.bottom
121 }
122
123 height: Kube.Units.gridUnit * 24
124 width: Kube.Units.gridUnit * 7 * 7 + Kube.Units.gridUnit * 2
125
126 contentHeight: Kube.Units.gridUnit * 24 * 2
127 contentWidth: width
128
129 clip: true
130 boundsBehavior: Flickable.StopAtBounds
131
132 ScrollBar.vertical: Kube.ScrollBar {}
133
134 Row {
135
136 height: Kube.Units.gridUnit * 24 * 2
137 width: Kube.Units.gridUnit * 7 * 7 + Kube.Units.gridUnit * 2
138
139 spacing: 0
140
141 //BEGIN time labels
142 Column {
143 anchors.bottom: parent.bottom
144 Repeater {
145 model: ["1:00","2:00","3:00","4:00","5:00","6:00","7:00","8:00","9:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00","0:00"]
146 delegate: Item {
147 height: Kube.Units.gridUnit * 2
148 width: Kube.Units.gridUnit * 2
149
150 Kube.Label {
151 anchors {
152 right: parent.right
153 rightMargin: Kube.Units.smallSpacing
154 bottom: parent.bottom
155 }
156 text: model.modelData
157 }
158 }
159 }
160 }
161 //END time labels
162
163 Repeater {
164 model: WeekEvents{}
165 delegate: Rectangle {
166 id: day
167
168 property var events: model.events
169
170 width: Kube.Units.gridUnit * 7
171 height: Kube.Units.gridUnit * 24 * 2
172
173 border.width: 1
174 border.color: "lightgrey"
175 color: Kube.Colors.viewBackgroundColor
176
177 Column {
178 anchors.fill: parent
179 Repeater {
180 model: 24
181 delegate: Rectangle {
182 height: Kube.Units.gridUnit * 4
183 width: parent.width
184 color: "transparent"
185 border.width:1
186 border.color: "lightgrey"
187 }
188 }
189 }
190
191 Repeater {
192 model: parent.events
193
194 delegate: Rectangle {
195 id: eventDelegate
196
197 states: [
198 State {
199 name: "dnd"
200 when: mouseArea.drag.active
201
202 PropertyChanges {target: mouseArea; cursorShape: Qt.ClosedHandCursor}
203 PropertyChanges {target: eventDelegate; x: x; y: y}
204 PropertyChanges {target: eventDelegate; parent: root}
205 PropertyChanges {target: eventDelegate; opacity: 0.7}
206 PropertyChanges {target: eventDelegate; anchors.right: ""}
207 PropertyChanges {target: eventDelegate; width: Kube.Units.gridUnit * 7 - Kube.Units.smallSpacing * 2}
208 }
209 ]
210
211 anchors {
212 right: parent.right
213 rightMargin: Kube.Units.smallSpacing
214 }
215 width: Kube.Units.gridUnit * 7 - Kube.Units.smallSpacing * 2 - Kube.Units.gridUnit * model.indention
216 height: Kube.Units.gridUnit * model.duration
217 y: Kube.Units.gridUnit * model.starts
218 x: Kube.Units.gridUnit * model.indention
219
220 color: model.color
221 border.width: 1
222 border.color: Kube.Colors.viewBackgroundColor
223
224 Kube.Label {
225 anchors {
226 left: parent.left
227 leftMargin: Kube.Units.smallSpacing
228 }
229 text: model.text
230 color: Kube.Colors.highlightedTextColor
231 }
232
233 Drag.active: mouseArea.drag.active
234 Drag.hotSpot.x: mouseArea.mouseX
235 Drag.hotSpot.y: mouseArea.mouseY
236 Drag.source: eventDelegate
237
238 MouseArea {
239 id: mouseArea
240 anchors.fill: parent
241
242 hoverEnabled: true
243 drag.target: parent
244
245 onEntered: {
246 eventDelegate.z = eventDelegate.z + 100
247 }
248 onExited: {
249 eventDelegate.z = eventDelegate.z - 100
250
251 }
252
253 onReleased: eventDelegate.Drag.drop()
254 }
255 }
256 }
257
258 DropArea {
259 anchors.fill: parent
260
261 onDropped: {
262 console.log("DROP")
263 drop.accept(Qt.MoveAction)
264 drop.source.visible = false
265 console.log((drop.source.y - mainWeekViewer.y + mainWeekViewer.contentY) / Kube.Units.gridUnit)
266 }
267 }
268 }
269 }
270 }
271 }
272 }
273}