summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-01 21:27:18 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-08-01 21:27:18 +0200
commit053c0fb365ef09bb1736c6503b65f7272be97335 (patch)
treef472e8bf213517f59f034fbb0d66b0911a56aab2
parentd3f0e79e25e903465678c8ba3832f666ce6cb5cf (diff)
downloadkube-053c0fb365ef09bb1736c6503b65f7272be97335.tar.gz
kube-053c0fb365ef09bb1736c6503b65f7272be97335.zip
Get daylabels to start at the right date
-rw-r--r--views/calendar/qml/WeekView.qml43
1 files changed, 27 insertions, 16 deletions
diff --git a/views/calendar/qml/WeekView.qml b/views/calendar/qml/WeekView.qml
index 31e94b93..658d8e96 100644
--- a/views/calendar/qml/WeekView.qml
+++ b/views/calendar/qml/WeekView.qml
@@ -19,14 +19,14 @@
19import QtQuick 2.4 19import QtQuick 2.4
20import QtQuick.Layouts 1.1 20import QtQuick.Layouts 1.1
21import QtQuick.Controls 2.2 21import QtQuick.Controls 2.2
22import Qt.labs.calendar 1.0 as Calendar
23 22
24import org.kube.framework 1.0 as Kube 23import org.kube.framework 1.0 as Kube
25 24
26FocusScope { 25FocusScope {
27 id: root 26 id: root
28 27
29 property var dayWidth: (root.width - Kube.Units.gridUnit - Kube.Units.largeSpacing * 2) / 7 28 property int daysToShow: 7
29 property var dayWidth: (root.width - Kube.Units.gridUnit - Kube.Units.largeSpacing * 2) / root.daysToShow
30 property var hourHeight: Kube.Units.gridUnit * 2 30 property var hourHeight: Kube.Units.gridUnit * 2
31 property date currentDate 31 property date currentDate
32 32
@@ -48,6 +48,12 @@ FocusScope {
48 48
49 property date startDate: getMonday(currentDate) 49 property date startDate: getMonday(currentDate)
50 50
51 function addDaysToDate(date, days) {
52 var date = new Date(date);
53 date.setDate(date.getDate() + days);
54 return date;
55 }
56
51 Item { 57 Item {
52 anchors { 58 anchors {
53 top: parent.top 59 top: parent.top
@@ -55,25 +61,30 @@ FocusScope {
55 rightMargin: Kube.Units.largeSpacing 61 rightMargin: Kube.Units.largeSpacing
56 } 62 }
57 63
58 width: root.dayWidth * 7 + Kube.Units.gridUnit * 2 64 width: root.dayWidth * root.daysToShow + Kube.Units.gridUnit * 2
59 height: root.height 65 height: root.height
60 66
61 //BEGIN day labels 67 //BEGIN day labels
62 Calendar.DayOfWeekRow { 68 Row {
63 id: dayLabels 69 id: dayLabels
70 anchors.top: parent.top
64 anchors.right: parent.right 71 anchors.right: parent.right
65 spacing: 0 72 spacing: 0
66 locale: Qt.locale() 73 height: childrenRect.height
74 width: root.dayWidth * root.daysToShow
75 Repeater {
76 model: root.daysToShow
67 77
68 delegate: Rectangle { 78 delegate: Rectangle {
69 width: root.dayWidth 79 width: root.dayWidth
70 height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 3 80 height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 3
71 81
72 color: Kube.Colors.viewBackgroundColor 82 color: "yellow"
73 83
74 Kube.Label { 84 Kube.Label {
75 anchors.centerIn: parent 85 anchors.centerIn: parent
76 text: model.longName 86 text: addDaysToDate(root.startDate, modelData).toLocaleString(Qt.locale(), "dddd")
87 }
77 } 88 }
78 } 89 }
79 } 90 }
@@ -89,7 +100,7 @@ FocusScope {
89 } 100 }
90 101
91 height: Kube.Units.gridUnit * 3 102 height: Kube.Units.gridUnit * 3
92 width: root.dayWidth * 7 103 width: root.dayWidth * root.daysToShow
93 color: Kube.Colors.viewBackgroundColor 104 color: Kube.Colors.viewBackgroundColor
94 border.width: 1 105 border.width: 1
95 border.color: Kube.Colors.buttonColor 106 border.color: Kube.Colors.buttonColor
@@ -153,7 +164,7 @@ FocusScope {
153 164
154 Layout.fillWidth: true 165 Layout.fillWidth: true
155 height: root.height - daylong.height - dayLabels.height - Kube.Units.largeSpacing 166 height: root.height - daylong.height - dayLabels.height - Kube.Units.largeSpacing
156 width: root.dayWidth * 7 + Kube.Units.gridUnit * 2 167 width: root.dayWidth * root.daysToShow + Kube.Units.gridUnit * 2
157 168
158 contentHeight: root.hourHeight * 24 169 contentHeight: root.hourHeight * 24
159 contentWidth: width 170 contentWidth: width
@@ -165,7 +176,7 @@ FocusScope {
165 176
166 Row { 177 Row {
167 height: root.hourHeight * 24 178 height: root.hourHeight * 24
168 width: root.dayWidth * 7 + Kube.Units.gridUnit * 2 179 width: root.dayWidth * root.daysToShow + Kube.Units.gridUnit * 2
169 180
170 spacing: 0 181 spacing: 0
171 182
@@ -195,7 +206,7 @@ FocusScope {
195 Repeater { 206 Repeater {
196 model: WeekEvents { 207 model: WeekEvents {
197 start: root.startDate 208 start: root.startDate
198 length: 7 209 length: root.daysToShow
199 } 210 }
200 delegate: Rectangle { 211 delegate: Rectangle {
201 id: dayDelegate 212 id: dayDelegate