From c75ee648a9446a37e7a4e38e891c047d23d374a2 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 4 Aug 2018 13:46:26 +0200 Subject: Cleanup --- views/calendar/qml/DateView.qml | 48 +++++++++++++++++++++++++++++++++++++ views/calendar/qml/DayLabels.qml | 52 ++++++++++++++++++++++++++++++++++++++++ views/calendar/qml/View.qml | 22 +++-------------- views/calendar/qml/WeekView.qml | 28 ++++------------------ 4 files changed, 107 insertions(+), 43 deletions(-) create mode 100644 views/calendar/qml/DateView.qml create mode 100644 views/calendar/qml/DayLabels.qml diff --git a/views/calendar/qml/DateView.qml b/views/calendar/qml/DateView.qml new file mode 100644 index 00000000..c42b35fe --- /dev/null +++ b/views/calendar/qml/DateView.qml @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2018 Christian Mollekopf, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import QtQuick 2.4 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.2 + +import org.kube.framework 1.0 as Kube + +Row { + id: root + property date date: null + + spacing: Kube.Units.smallSpacing + + Kube.Label { + anchors.verticalCenter: parent.verticalCenter + text: root.date.getDate() + color: Kube.Colors.highlightedTextColor + font.pointSize: Kube.Units.defaultFontSize * 3 + } + Column { + anchors.verticalCenter: parent.verticalCenter + Kube.Label { + text: root.date.toLocaleString(Qt.locale(), "dddd") + color: Kube.Colors.highlightedTextColor + } + Kube.Label { + text: root.date.toLocaleString(Qt.locale(), "MMMM yyyy") + color: Kube.Colors.highlightedTextColor + font.pointSize: Kube.Units.smallFontSize + } + } +} diff --git a/views/calendar/qml/DayLabels.qml b/views/calendar/qml/DayLabels.qml new file mode 100644 index 00000000..cd961068 --- /dev/null +++ b/views/calendar/qml/DayLabels.qml @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 Christian Mollekopf, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import QtQuick 2.4 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.2 + +import org.kube.framework 1.0 as Kube + +Row { + id: root + property date startDate + property int dayWidth + property int daysToShow + + height: childrenRect.height + width: dayWidth * daysToShow + + spacing: 0 + Repeater { + model: root.daysToShow + delegate: Item { + width: root.dayWidth + height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 3 + Kube.Label { + function addDaysToDate(date, days) { + var date = new Date(date); + date.setDate(date.getDate() + days); + return date; + } + font.bold: true + + anchors.centerIn: parent + text: addDaysToDate(root.startDate, modelData).toLocaleString(Qt.locale(), "dddd") + } + } + } +} diff --git a/views/calendar/qml/View.qml b/views/calendar/qml/View.qml index 2a819ab6..917d0c80 100644 --- a/views/calendar/qml/View.qml +++ b/views/calendar/qml/View.qml @@ -69,27 +69,11 @@ RowLayout { width: parent.width spacing: Kube.Units.smallSpacing - Row { - spacing: Kube.Units.smallSpacing - Kube.Label { - anchors.verticalCenter: parent.verticalCenter - text: root.currentDate.getDate() + DateView { + date: root.currentDate + } color: Kube.Colors.highlightedTextColor - font.pointSize: Kube.Units.defaultFontSize * 3 } - Column { - anchors.verticalCenter: parent.verticalCenter - Kube.Label { - text: root.currentDate.toLocaleString(Qt.locale(), "dddd") - color: Kube.Colors.highlightedTextColor - } - Kube.Label { - text: root.currentDate.toLocaleString(Qt.locale(), "MMMM yyyy") - color: Kube.Colors.highlightedTextColor - font.pointSize: Kube.Units.smallFontSize - } - } - } } diff --git a/views/calendar/qml/WeekView.qml b/views/calendar/qml/WeekView.qml index f78a4a8d..484a151f 100644 --- a/views/calendar/qml/WeekView.qml +++ b/views/calendar/qml/WeekView.qml @@ -59,34 +59,14 @@ FocusScope { width: root.dayWidth * root.daysToShow + Kube.Units.gridUnit * 2 height: root.height - //BEGIN day labels - Row { + DayLabels { id: dayLabels anchors.top: parent.top anchors.right: parent.right - spacing: 0 - height: childrenRect.height - width: root.dayWidth * root.daysToShow - Repeater { - model: root.daysToShow - delegate: Item { - width: root.dayWidth - height: Kube.Units.gridUnit + Kube.Units.smallSpacing * 3 - Kube.Label { - function addDaysToDate(date, days) { - var date = new Date(date); - date.setDate(date.getDate() + days); - return date; - } - font.bold: true - - anchors.centerIn: parent - text: addDaysToDate(root.startDate, modelData).toLocaleString(Qt.locale(), "dddd") - } - } - } + startDate: root.startDate + dayWidth: root.dayWidth + daysToShow: root.daysToShow } - //END day labels //BEGIN daylong events Rectangle { -- cgit v1.2.3