4 import
Qt.labs.calendar 1.0
31 property date firstDate:
new Date(1970, 0, 1)
43 property date lastDate: new Date(9999, 11, 31)
55 property date date: _p.today();
60 property bool _skipNextFocus:
false 63 var cDate =
new Date();
64 cDate.setHours(0, 0, 0, 0, 0);
68 function focusDate() {
70 _skipNextFocus =
false;
72 _calenderList.currentIndex = calendarModel.indexOf(_calenderList.date);
73 _calenderList.positionViewAtIndex(_calenderList.currentIndex, ListView.SnapPosition);
78 Component.onCompleted: _p.focusDate()
79 onDateChanged: _p.focusDate()
85 keyNavigationWraps:
true 86 snapMode: ListView.SnapOneItem
87 orientation: ListView.Horizontal
88 highlightRangeMode: ListView.StrictlyEnforceRange
91 model: CalendarModel {
93 from: _calenderList.firstDate
94 to: _calenderList.lastDate
97 delegate: GridLayout {
98 width: _calenderList.width
99 height: _calenderList.height
104 Layout.fillHeight:
true 105 Layout.preferredWidth: 36
108 icon.name:
"go-previous" 109 icon.source:
"qrc:/de/skycoder42/qtmvvm/quick/icons/ic_navigate_before.svg" 113 onClicked: _calenderList.decrementCurrentIndex()
118 Layout.fillWidth:
true 119 horizontalAlignment: Text.AlignHCenter
126 Layout.fillHeight:
true 127 Layout.preferredWidth: 36
131 icon.source:
"qrc:/de/skycoder42/qtmvvm/quick/icons/ic_navigate_next.svg" 135 onClicked: _calenderList.incrementCurrentIndex()
139 Layout.fillWidth:
true 143 Layout.fillWidth:
true 145 text: model.shortName
146 horizontalAlignment: Text.AlignHCenter
147 verticalAlignment: Text.AlignVCenter
154 Layout.fillHeight:
true 156 text: model.weekNumber
157 horizontalAlignment: Text.AlignHCenter
158 verticalAlignment: Text.AlignVCenter
166 Layout.fillWidth:
true 167 Layout.fillHeight:
true 176 readonly
property bool isCurrent: model.day === _calenderList.date.getDate() && model.month === _calenderList.date.getMonth()
177 readonly
property alias highlightColor: helper.
highlight 179 horizontalAlignment: Text.AlignHCenter
180 verticalAlignment: Text.AlignVCenter
181 opacity: model.month === grid.month ? 1 : 0.5
186 background: Rectangle {
187 readonly
property double size: Math.max(dayDelegate.width, dayDelegate.height) * 1.2
189 anchors.centerIn: parent
193 color: dayDelegate.highlightColor
194 opacity: dayDelegate.isCurrent ? 1 : 0
197 Behavior on opacity {
200 easing.type: Easing.OutBack
209 if(model.month < grid.month) {
210 _calenderList.decrementCurrentIndex();
211 _p._skipNextFocus =
true;
212 }
else if(model.month > grid.month) {
213 _calenderList.incrementCurrentIndex();
214 _p._skipNextFocus =
true;
216 _calenderList.date = model.date;
223 Layout.fillWidth:
true 225 Layout.minimumHeight: 0
226 Layout.maximumHeight: 0
color highlight
The color to use to highlight stuff.
A helper class to get style-dependant colors.
QTMVVM_REVISION_1 static Q_INVOKABLE QColor accentTextColor(const QColor &accentColor, const QColor &baseColor) const
Calculates the optimal text color based on the background color.
The QML import for the QtMvvmQuick QML module.
A QML singleton to access common presenter methods globally.