summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-11 07:28:04 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-11 07:37:02 +0200
commit2525b7cb66877479df393b84bba1bd4a76146b45 (patch)
tree483cd784b6a0ea5da9db8436e113de9b00d8a70c
parent9d17b3dc4628215cb2fb9c83fe71874f262d057d (diff)
downloadkube-2525b7cb66877479df393b84bba1bd4a76146b45.tar.gz
kube-2525b7cb66877479df393b84bba1bd4a76146b45.zip
Make the calendar work with the current time
-rw-r--r--views/calendar/main.qml1
-rw-r--r--views/calendar/qml/View.qml8
-rw-r--r--views/calendar/qml/WeekEvents.qml2
-rw-r--r--views/calendar/qml/WeekView.qml26
4 files changed, 31 insertions, 6 deletions
diff --git a/views/calendar/main.qml b/views/calendar/main.qml
index e3915e74..e8cd9c4d 100644
--- a/views/calendar/main.qml
+++ b/views/calendar/main.qml
@@ -143,5 +143,6 @@ ApplicationWindow {
143 143
144 View { 144 View {
145 anchors.fill: parent 145 anchors.fill: parent
146 currentDate: "2018-04-09"
146 } 147 }
147} 148}
diff --git a/views/calendar/qml/View.qml b/views/calendar/qml/View.qml
index 434c92d1..f870a850 100644
--- a/views/calendar/qml/View.qml
+++ b/views/calendar/qml/View.qml
@@ -26,6 +26,9 @@ import org.kube.framework 1.0 as Kube
26RowLayout { 26RowLayout {
27 id: root 27 id: root
28 28
29 //TODO update every second
30 property date currentDate: new Date()
31
29 anchors.fill: parent 32 anchors.fill: parent
30 33
31 Rectangle { 34 Rectangle {
@@ -100,7 +103,8 @@ RowLayout {
100 } 103 }
101 104
102 WeekView { 105 WeekView {
103 Layout.fillHeight: parent.height 106 Layout.fillHeight: true
104 Layout.fillWidth: parent.height 107 Layout.fillWidth: true
108 currentDate: root.currentDate
105 } 109 }
106} 110}
diff --git a/views/calendar/qml/WeekEvents.qml b/views/calendar/qml/WeekEvents.qml
index 774f254e..73774b27 100644
--- a/views/calendar/qml/WeekEvents.qml
+++ b/views/calendar/qml/WeekEvents.qml
@@ -3,6 +3,4 @@ import QtQuick 2.7
3import org.kube.framework 1.0 as Kube 3import org.kube.framework 1.0 as Kube
4 4
5Kube.PeriodDayEventModel { 5Kube.PeriodDayEventModel {
6 start: "2018-04-09"
7 length: 7
8} 6}
diff --git a/views/calendar/qml/WeekView.qml b/views/calendar/qml/WeekView.qml
index 08a15ccf..781aefa5 100644
--- a/views/calendar/qml/WeekView.qml
+++ b/views/calendar/qml/WeekView.qml
@@ -28,6 +28,25 @@ FocusScope {
28 28
29 property var dayWidth: (root.width - Kube.Units.gridUnit - Kube.Units.largeSpacing * 2) / 7 29 property var dayWidth: (root.width - Kube.Units.gridUnit - Kube.Units.largeSpacing * 2) / 7
30 property var hourHeight: Kube.Units.gridUnit * 2 30 property var hourHeight: Kube.Units.gridUnit * 2
31 property date currentDate
32
33 function getMonday(date) {
34 var year = date.getFullYear()
35 var month = date.getMonth()
36 //Jup, getDate returns the day of the month
37 var day = date.getDate()
38
39 while (true) {
40 if (date.getDay() === Locale.Monday) {
41 return date
42 }
43 day = day - 1
44 date = new Date(year, month, day)
45 }
46 return date
47 }
48
49 property date startDate: getMonday(currentDate)
31 50
32 Item { 51 Item {
33 anchors { 52 anchors {
@@ -167,7 +186,10 @@ FocusScope {
167 //END time labels 186 //END time labels
168 187
169 Repeater { 188 Repeater {
170 model: WeekEvents{} 189 model: WeekEvents {
190 start: root.startDate
191 length: 7
192 }
171 delegate: Rectangle { 193 delegate: Rectangle {
172 id: day 194 id: day
173 195
@@ -219,7 +241,7 @@ FocusScope {
219 rightMargin: Kube.Units.smallSpacing 241 rightMargin: Kube.Units.smallSpacing
220 } 242 }
221 width: root.dayWidth - Kube.Units.smallSpacing * 2 - Kube.Units.gridUnit * model.modelData.indention 243 width: root.dayWidth - Kube.Units.smallSpacing * 2 - Kube.Units.gridUnit * model.modelData.indention
222 height: root.hourHeight * model.modelData.duration 244 height: Math.max(root.hourHeight * 0.5, root.hourHeight * model.modelData.duration)
223 y: root.hourHeight * model.modelData.starts 245 y: root.hourHeight * model.modelData.starts
224 x: Kube.Units.gridUnit * model.modelData.indention 246 x: Kube.Units.gridUnit * model.modelData.indention
225 247