diff options
Diffstat (limited to 'views/calendar/qml/WeekView.qml')
-rw-r--r-- | views/calendar/qml/WeekView.qml | 43 |
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 @@ | |||
19 | import QtQuick 2.4 | 19 | import QtQuick 2.4 |
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 |
21 | import QtQuick.Controls 2.2 | 21 | import QtQuick.Controls 2.2 |
22 | import Qt.labs.calendar 1.0 as Calendar | ||
23 | 22 | ||
24 | import org.kube.framework 1.0 as Kube | 23 | import org.kube.framework 1.0 as Kube |
25 | 24 | ||
26 | FocusScope { | 25 | FocusScope { |
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 |