diff options
author | Mitch Curtis <mitch.curtis@digia.com> | 2014-01-16 17:02:25 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@digia.com> | 2014-01-17 12:24:26 +0100 |
commit | 7168dff959374e90dfba0e23c04b3756b19a7c15 (patch) | |
tree | 66808eb33beda705382b991a54917d96aabbc02c | |
parent | 0bc5e6aa56e2fbf64dde95690e5445d4d16694f6 (diff) | |
download | qtquickcontrols-7168dff959374e90dfba0e23c04b3756b19a7c15.tar.gz |
Convert headerDelegate into weekdayDelegate.
This allows us to hide CalendarHeaderModel, as we instead provide a
delegate for each weekday.
Change-Id: I246826bef5993fa5b70ad906acdf5c7854a681ba
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r-- | src/controls/Calendar.qml | 23 | ||||
-rw-r--r-- | src/controls/Private/CalendarHeaderModel.qml (renamed from src/controls/CalendarHeaderModel.qml) | 14 | ||||
-rw-r--r-- | src/controls/Private/private.pri | 1 | ||||
-rw-r--r-- | src/controls/Private/qmldir | 1 | ||||
-rw-r--r-- | src/controls/Styles/Base/CalendarStyle.qml | 24 | ||||
-rw-r--r-- | src/controls/Styles/Desktop/CalendarStyle.qml | 22 | ||||
-rw-r--r-- | src/controls/controls.pro | 1 |
7 files changed, 36 insertions, 50 deletions
diff --git a/src/controls/Calendar.qml b/src/controls/Calendar.qml index 471b88ed..2fd39594 100644 --- a/src/controls/Calendar.qml +++ b/src/controls/Calendar.qml @@ -63,8 +63,6 @@ import QtQuick.Controls.Private 1.0 Localization is supported through the \l locale property. The selected date is displayed according to \l locale, and it can be accessed through the \l selectedDateText property. - - \sa CalendarHeaderModel */ Control { @@ -340,7 +338,26 @@ Control { width: view.width height: view.cellHeight - sourceComponent: __style.headerDelegate + sourceComponent: Row { + Repeater { + id: repeater + model: CalendarHeaderModel { + locale: calendar.locale + } + Loader { + id: dayOfWeekDelegateLoader + sourceComponent: __style.weekdayDelegate + width: view.cellWidth + height: view.cellHeight + + readonly property var __dayOfWeek: dayOfWeek + + property QtObject styleData: QtObject { + readonly property alias dayOfWeek: dayOfWeekDelegateLoader.__dayOfWeek + } + } + } + } } } } diff --git a/src/controls/CalendarHeaderModel.qml b/src/controls/Private/CalendarHeaderModel.qml index 9f204cc7..1b3cd201 100644 --- a/src/controls/CalendarHeaderModel.qml +++ b/src/controls/Private/CalendarHeaderModel.qml @@ -40,14 +40,8 @@ import QtQuick 2.0 -/*! - \qmltype CalendarHeaderModel - \inqmlmodule QtQuick.Controls - \since QtQuick.Controls 1.1 - \ingroup controls - \brief A model for days of the week - - The CalendarHeaderModel model contains a list of the days of a week, +/* + CalendarHeaderModel contains a list of the days of a week, according to a \l locale. The \l locale affects which day of the week is first in the model. @@ -63,14 +57,12 @@ import QtQuick 2.0 \li \c Locale.Friday \li \c Locale.Saturday \endlist - - \sa Calendar */ ListModel { id: root - /*! + /* The locale that this model should be based on. This affects which day of the week is first in the model. */ diff --git a/src/controls/Private/private.pri b/src/controls/Private/private.pri index ffbb4f75..022fb156 100644 --- a/src/controls/Private/private.pri +++ b/src/controls/Private/private.pri @@ -34,6 +34,7 @@ PRIVATE_QML_FILES += \ $$PWD/TabBar.qml \ $$PWD/BasicButton.qml \ $$PWD/Control.qml \ + $$PWD/CalendarHeaderModel.qml \ $$PWD/DateUtils.js \ $$PWD/FastGlow.qml \ $$PWD/SourceProxy.qml\ diff --git a/src/controls/Private/qmldir b/src/controls/Private/qmldir index d2cf5f48..e80debb7 100644 --- a/src/controls/Private/qmldir +++ b/src/controls/Private/qmldir @@ -1,5 +1,6 @@ module QtQuick.Controls.Private AbstractCheckable 1.0 AbstractCheckable.qml +CalendarHeaderModel 1.0 CalendarHeaderModel.qml Control 1.0 Control.qml DateUtils 1.0 DateUtils.js FocusFrame 1.0 FocusFrame.qml diff --git a/src/controls/Styles/Base/CalendarStyle.qml b/src/controls/Styles/Base/CalendarStyle.qml index 57e9661c..326fc4ce 100644 --- a/src/controls/Styles/Base/CalendarStyle.qml +++ b/src/controls/Styles/Base/CalendarStyle.qml @@ -233,25 +233,13 @@ Style { } /*! - The delegate that styles the header of the calendar. + The delegate that styles each weekday. */ - property Component headerDelegate: Row { - id: headerRow - Repeater { - id: repeater - model: CalendarHeaderModel { locale: control.locale } - Item { - width: calendarStyle.cellWidth - height: calendarStyle.cellHeight - Rectangle { - color: "white" - anchors.fill: parent - Text { - text: control.locale.dayName(dayOfWeek, control.dayOfWeekFormat) - anchors.centerIn: parent - } - } - } + property Component weekdayDelegate: Rectangle { + color: "white" + Text { + text: control.locale.dayName(styleData.dayOfWeek, control.dayOfWeekFormat) + anchors.centerIn: parent } } diff --git a/src/controls/Styles/Desktop/CalendarStyle.qml b/src/controls/Styles/Desktop/CalendarStyle.qml index 64a5ab53..debd0ac8 100644 --- a/src/controls/Styles/Desktop/CalendarStyle.qml +++ b/src/controls/Styles/Desktop/CalendarStyle.qml @@ -124,23 +124,11 @@ Style { } } - property Component headerDelegate: Row { - id: headerRow - Repeater { - id: repeater - model: CalendarHeaderModel { locale: control.locale } - Item { - width: calendarStyle.cellWidth - height: calendarStyle.cellHeight - Rectangle { - color: __syspal.base - anchors.fill: parent - Text { - text: control.locale.dayName(dayOfWeek, control.dayOfWeekFormat) - anchors.centerIn: parent - } - } - } + property Component weekdayDelegate: Rectangle { + color: __syspal.base + Text { + text: control.locale.dayName(styleData.dayOfWeek, control.dayOfWeekFormat) + anchors.centerIn: parent } } diff --git a/src/controls/controls.pro b/src/controls/controls.pro index 211b60f9..e19d5d18 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -11,7 +11,6 @@ CONTROLS_QML_FILES = \ Button.qml \ BusyIndicator.qml \ Calendar.qml \ - CalendarHeaderModel.qml \ CheckBox.qml \ ComboBox.qml \ GroupBox.qml \ |