aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/calendar/qquickcalendarview.cpp18
-rw-r--r--src/calendar/qquickcalendarview_p.h6
-rw-r--r--src/calendar/qquickdayofweekrow.cpp18
-rw-r--r--src/calendar/qquickdayofweekrow_p.h6
-rw-r--r--src/calendar/qquickweeknumbercolumn.cpp18
-rw-r--r--src/calendar/qquickweeknumbercolumn_p.h6
-rw-r--r--src/imports/calendar/CalendarView.qml18
-rw-r--r--src/imports/calendar/DayOfWeekRow.qml20
-rw-r--r--src/imports/calendar/WeekNumberColumn.qml20
9 files changed, 103 insertions, 27 deletions
diff --git a/src/calendar/qquickcalendarview.cpp b/src/calendar/qquickcalendarview.cpp
index c5c6f9e3..5a597a64 100644
--- a/src/calendar/qquickcalendarview.cpp
+++ b/src/calendar/qquickcalendarview.cpp
@@ -48,7 +48,7 @@ class QQuickCalendarViewPrivate : public QQuickControlPrivate
Q_DECLARE_PUBLIC(QQuickCalendarView)
public:
- QQuickCalendarViewPrivate() : pressTimer(0), pressedItem(Q_NULLPTR), model(Q_NULLPTR) { }
+ QQuickCalendarViewPrivate() : pressTimer(0), pressedItem(Q_NULLPTR), model(Q_NULLPTR), delegate(Q_NULLPTR) { }
QQuickItem *cellAt(const QPoint &pos) const;
QDate dateOf(QQuickItem *cell) const;
@@ -64,6 +64,7 @@ public:
int pressTimer;
QQuickItem *pressedItem;
QQuickMonthModel *model;
+ QQmlComponent *delegate;
};
QQuickItem *QQuickCalendarViewPrivate::cellAt(const QPoint &pos) const
@@ -201,6 +202,21 @@ void QQuickCalendarView::setTitle(const QString &title)
}
}
+QQmlComponent *QQuickCalendarView::delegate() const
+{
+ Q_D(const QQuickCalendarView);
+ return d->delegate;
+}
+
+void QQuickCalendarView::setDelegate(QQmlComponent *delegate)
+{
+ Q_D(QQuickCalendarView);
+ if (d->delegate != delegate) {
+ d->delegate = delegate;
+ emit delegateChanged();
+ }
+}
+
void QQuickCalendarView::componentComplete()
{
Q_D(QQuickCalendarView);
diff --git a/src/calendar/qquickcalendarview_p.h b/src/calendar/qquickcalendarview_p.h
index 5b26f8e6..23a582a1 100644
--- a/src/calendar/qquickcalendarview_p.h
+++ b/src/calendar/qquickcalendarview_p.h
@@ -53,6 +53,7 @@
QT_BEGIN_NAMESPACE
+class QQmlComponent;
class QQuickCalendarViewPrivate;
class Q_QUICKCALENDAR_EXPORT QQuickCalendarView : public QQuickControl
@@ -63,6 +64,7 @@ class Q_QUICKCALENDAR_EXPORT QQuickCalendarView : public QQuickControl
Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL)
Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL)
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
public:
explicit QQuickCalendarView(QQuickItem *parent = Q_NULLPTR);
@@ -82,12 +84,16 @@ public:
QString title() const;
void setTitle(const QString &title);
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *delegate);
+
Q_SIGNALS:
void monthChanged();
void yearChanged();
void localeChanged();
void sourceChanged();
void titleChanged();
+ void delegateChanged();
void pressed(const QDate &date);
void released(const QDate &date);
diff --git a/src/calendar/qquickdayofweekrow.cpp b/src/calendar/qquickdayofweekrow.cpp
index fc880817..e6f84f2f 100644
--- a/src/calendar/qquickdayofweekrow.cpp
+++ b/src/calendar/qquickdayofweekrow.cpp
@@ -44,7 +44,10 @@ QT_BEGIN_NAMESPACE
class QQuickDayOfWeekRowPrivate : public QQuickControlPrivate
{
public:
+ QQuickDayOfWeekRowPrivate() : delegate(Q_NULLPTR), model(Q_NULLPTR) { }
+
QVariant source;
+ QQmlComponent *delegate;
QQuickDayOfWeekModel *model;
};
@@ -84,4 +87,19 @@ void QQuickDayOfWeekRow::setSource(const QVariant &source)
}
}
+QQmlComponent *QQuickDayOfWeekRow::delegate() const
+{
+ Q_D(const QQuickDayOfWeekRow);
+ return d->delegate;
+}
+
+void QQuickDayOfWeekRow::setDelegate(QQmlComponent *delegate)
+{
+ Q_D(QQuickDayOfWeekRow);
+ if (d->delegate != delegate) {
+ d->delegate = delegate;
+ emit delegateChanged();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/calendar/qquickdayofweekrow_p.h b/src/calendar/qquickdayofweekrow_p.h
index d0d2fc1c..73bb2e83 100644
--- a/src/calendar/qquickdayofweekrow_p.h
+++ b/src/calendar/qquickdayofweekrow_p.h
@@ -53,6 +53,7 @@
QT_BEGIN_NAMESPACE
+class QQmlComponent;
class QQuickDayOfWeekRowPrivate;
class Q_QUICKCALENDAR_EXPORT QQuickDayOfWeekRow : public QQuickControl
@@ -60,6 +61,7 @@ class Q_QUICKCALENDAR_EXPORT QQuickDayOfWeekRow : public QQuickControl
Q_OBJECT
Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL)
Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
public:
explicit QQuickDayOfWeekRow(QQuickItem *parent = Q_NULLPTR);
@@ -70,9 +72,13 @@ public:
QVariant source() const;
void setSource(const QVariant &source);
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *delegate);
+
Q_SIGNALS:
void localeChanged();
void sourceChanged();
+ void delegateChanged();
private:
Q_DISABLE_COPY(QQuickDayOfWeekRow)
diff --git a/src/calendar/qquickweeknumbercolumn.cpp b/src/calendar/qquickweeknumbercolumn.cpp
index d4d764a2..feb88301 100644
--- a/src/calendar/qquickweeknumbercolumn.cpp
+++ b/src/calendar/qquickweeknumbercolumn.cpp
@@ -44,7 +44,10 @@ QT_BEGIN_NAMESPACE
class QQuickWeekNumberColumnPrivate : public QQuickControlPrivate
{
public:
+ QQuickWeekNumberColumnPrivate() : delegate(Q_NULLPTR), model(Q_NULLPTR) { }
+
QVariant source;
+ QQmlComponent *delegate;
QQuickWeekNumberModel *model;
};
@@ -110,4 +113,19 @@ void QQuickWeekNumberColumn::setSource(const QVariant &source)
}
}
+QQmlComponent *QQuickWeekNumberColumn::delegate() const
+{
+ Q_D(const QQuickWeekNumberColumn);
+ return d->delegate;
+}
+
+void QQuickWeekNumberColumn::setDelegate(QQmlComponent *delegate)
+{
+ Q_D(QQuickWeekNumberColumn);
+ if (d->delegate != delegate) {
+ d->delegate = delegate;
+ emit delegateChanged();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/calendar/qquickweeknumbercolumn_p.h b/src/calendar/qquickweeknumbercolumn_p.h
index 3da37ac7..7873e81f 100644
--- a/src/calendar/qquickweeknumbercolumn_p.h
+++ b/src/calendar/qquickweeknumbercolumn_p.h
@@ -53,6 +53,7 @@
QT_BEGIN_NAMESPACE
+class QQmlComponent;
class QQuickWeekNumberColumnPrivate;
class Q_QUICKCALENDAR_EXPORT QQuickWeekNumberColumn : public QQuickControl
@@ -62,6 +63,7 @@ class Q_QUICKCALENDAR_EXPORT QQuickWeekNumberColumn : public QQuickControl
Q_PROPERTY(int year READ year WRITE setYear NOTIFY yearChanged FINAL)
Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged FINAL)
Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged FINAL)
+ Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
public:
explicit QQuickWeekNumberColumn(QQuickItem *parent = Q_NULLPTR);
@@ -78,11 +80,15 @@ public:
QVariant source() const;
void setSource(const QVariant &source);
+ QQmlComponent *delegate() const;
+ void setDelegate(QQmlComponent *delegate);
+
Q_SIGNALS:
void monthChanged();
void yearChanged();
void localeChanged();
void sourceChanged();
+ void delegateChanged();
private:
Q_DISABLE_COPY(QQuickWeekNumberColumn)
diff --git a/src/imports/calendar/CalendarView.qml b/src/imports/calendar/CalendarView.qml
index aac2ec9c..6bf11b8f 100644
--- a/src/imports/calendar/CalendarView.qml
+++ b/src/imports/calendar/CalendarView.qml
@@ -41,7 +41,15 @@ import QtQuick.Calendar 2.0
AbstractCalendarView {
id: control
- property Component delegate: CalendarDelegate {
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+
+ Accessible.name: title
+
+ //! [delegate]
+ delegate: CalendarDelegate {
width: grid.width ? grid.width / 7 : implicitWidth
height: grid.height ? grid.height / 6 : implicitHeight
opacity: model.month === control.month ? 1 : 0
@@ -49,13 +57,7 @@ AbstractCalendarView {
text: model.day
padding: control.Theme.padding
}
-
- implicitWidth: Math.max(background ? background.implicitWidth : 0,
- contentItem.implicitWidth + leftPadding + rightPadding)
- implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentItem.implicitHeight + topPadding + bottomPadding)
-
- Accessible.name: title
+ //! [delegate]
//! [contentItem]
contentItem: Grid {
diff --git a/src/imports/calendar/DayOfWeekRow.qml b/src/imports/calendar/DayOfWeekRow.qml
index e4cb2b91..8f88def4 100644
--- a/src/imports/calendar/DayOfWeekRow.qml
+++ b/src/imports/calendar/DayOfWeekRow.qml
@@ -41,7 +41,16 @@ import QtQuick.Calendar 2.0
AbstractDayOfWeekRow {
id: control
- property Component delegate: Text {
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+
+ topPadding: Theme.padding
+ bottomPadding: Theme.padding
+
+ //! [delegate]
+ delegate: Text {
text: model.shortName
font.bold: true
color: control.Theme.textColor
@@ -50,14 +59,7 @@ AbstractDayOfWeekRow {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
-
- implicitWidth: Math.max(background ? background.implicitWidth : 0,
- contentItem.implicitWidth + leftPadding + rightPadding)
- implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentItem.implicitHeight + topPadding + bottomPadding)
-
- topPadding: Theme.padding
- bottomPadding: Theme.padding
+ //! [delegate]
//! [contentItem]
contentItem: Row {
diff --git a/src/imports/calendar/WeekNumberColumn.qml b/src/imports/calendar/WeekNumberColumn.qml
index 0e2dd505..0fb8a87b 100644
--- a/src/imports/calendar/WeekNumberColumn.qml
+++ b/src/imports/calendar/WeekNumberColumn.qml
@@ -41,7 +41,16 @@ import QtQuick.Calendar 2.0
AbstractWeekNumberColumn {
id: control
- property Component delegate: Text {
+ implicitWidth: Math.max(background ? background.implicitWidth : 0,
+ contentItem.implicitWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(background ? background.implicitHeight : 0,
+ contentItem.implicitHeight + topPadding + bottomPadding)
+
+ leftPadding: Theme.padding
+ rightPadding: Theme.padding
+
+ //! [delegate]
+ delegate: Text {
text: model.weekNumber
font.bold: true
color: control.Theme.textColor
@@ -50,14 +59,7 @@ AbstractWeekNumberColumn {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
-
- implicitWidth: Math.max(background ? background.implicitWidth : 0,
- contentItem.implicitWidth + leftPadding + rightPadding)
- implicitHeight: Math.max(background ? background.implicitHeight : 0,
- contentItem.implicitHeight + topPadding + bottomPadding)
-
- leftPadding: Theme.padding
- rightPadding: Theme.padding
+ //! [delegate]
//! [contentItem]
contentItem: Column {