diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-03-24 07:48:40 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-04-04 09:03:08 +0000 |
commit | f249c3d30de43e6f0e4f8905f8a4090a912b0a08 (patch) | |
tree | df67d9ca7f3628dfe288621c1a990419347ce0d9 | |
parent | 5e6b1e2950aa96b53c2fe77185f8d3bf420d27e9 (diff) |
Use Q_PRIVATE_PROPERTY for QQmlListProperty
Hide QQmlListProperty, which is close to unusable in C++, from the
templates C++ API.
Change-Id: I9720fc3297fc625076a8a7553245852b641bc65a
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickapplicationwindow.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickapplicationwindow_p.h | 3 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenubar.cpp | 12 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenubar_p.h | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenubar_p_p.h | 3 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpane.cpp | 12 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpane_p.h | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpane_p_p.h | 3 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 12 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup_p.h | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup_p_p.h | 3 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollview.cpp | 17 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollview_p.h | 7 |
13 files changed, 55 insertions, 45 deletions
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index 4e062b33..b2ca40f4 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -141,6 +141,8 @@ public: return window->d_func(); } + QQmlListProperty<QObject> contentData(); + void relayout(); void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override; @@ -561,9 +563,10 @@ void QQuickApplicationWindow::setFooter(QQuickItem *footer) \sa contentItem */ -QQmlListProperty<QObject> QQuickApplicationWindow::contentData() +QQmlListProperty<QObject> QQuickApplicationWindowPrivate::contentData() { - return QQmlListProperty<QObject>(contentItem(), this, + Q_Q(QQuickApplicationWindow); + return QQmlListProperty<QObject>(q->contentItem(), q, QQuickApplicationWindowPrivate::contentData_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, diff --git a/src/quicktemplates2/qquickapplicationwindow_p.h b/src/quicktemplates2/qquickapplicationwindow_p.h index d74d3c9d..c004ee3a 100644 --- a/src/quicktemplates2/qquickapplicationwindow_p.h +++ b/src/quicktemplates2/qquickapplicationwindow_p.h @@ -66,7 +66,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickApplicationWindow : public QQuickWi Q_OBJECT Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) Q_PROPERTY(QQuickItem *contentItem READ contentItem CONSTANT FINAL) - Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL) + Q_PRIVATE_PROPERTY(QQuickApplicationWindow::d_func(), QQmlListProperty<QObject> contentData READ contentData FINAL) Q_PROPERTY(QQuickItem *activeFocusControl READ activeFocusControl NOTIFY activeFocusControlChanged FINAL) Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL) Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL) @@ -89,7 +89,6 @@ public: void setBackground(QQuickItem *background); QQuickItem *contentItem() const; - QQmlListProperty<QObject> contentData(); QQuickItem *activeFocusControl() const; diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp index 9bd0ea9a..dcd2244d 100644 --- a/src/quicktemplates2/qquickmenubar.cpp +++ b/src/quicktemplates2/qquickmenubar.cpp @@ -502,18 +502,20 @@ void QQuickMenuBar::resetContentHeight() of the menu bar, and also menus that have been dynamically added or inserted using the \l addMenu() and \l insertMenu() methods, respectively. */ -QQmlListProperty<QQuickMenu> QQuickMenuBar::menus() +QQmlListProperty<QQuickMenu> QQuickMenuBarPrivate::menus() { - return QQmlListProperty<QQuickMenu>(this, nullptr, + Q_Q(QQuickMenuBar); + return QQmlListProperty<QQuickMenu>(q, nullptr, QQuickMenuBarPrivate::menus_append, QQuickMenuBarPrivate::menus_count, QQuickMenuBarPrivate::menus_at, QQuickMenuBarPrivate::menus_clear); } -QQmlListProperty<QObject> QQuickMenuBar::contentData() +QQmlListProperty<QObject> QQuickMenuBarPrivate::contentData() { - return QQmlListProperty<QObject>(this, nullptr, + Q_Q(QQuickMenuBar); + return QQmlListProperty<QObject>(q, nullptr, QQuickMenuBarPrivate::contentData_append, QQuickContainerPrivate::contentData_count, QQuickContainerPrivate::contentData_at, @@ -659,3 +661,5 @@ QAccessible::Role QQuickMenuBar::accessibleRole() const #endif QT_END_NAMESPACE + +#include "moc_qquickmenubar_p.cpp" diff --git a/src/quicktemplates2/qquickmenubar_p.h b/src/quicktemplates2/qquickmenubar_p.h index 8c703f25..9f03076e 100644 --- a/src/quicktemplates2/qquickmenubar_p.h +++ b/src/quicktemplates2/qquickmenubar_p.h @@ -61,8 +61,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenuBar : public QQuickContainer Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth RESET resetContentWidth NOTIFY contentWidthChanged FINAL) Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight RESET resetContentHeight NOTIFY contentHeightChanged FINAL) - Q_PROPERTY(QQmlListProperty<QQuickMenu> menus READ menus NOTIFY menusChanged FINAL) - Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL) + Q_PRIVATE_PROPERTY(QQuickMenuBar::d_func(), QQmlListProperty<QQuickMenu> menus READ menus NOTIFY menusChanged FINAL) + Q_PRIVATE_PROPERTY(QQuickMenuBar::d_func(), QQmlListProperty<QObject> contentData READ contentData FINAL) public: explicit QQuickMenuBar(QQuickItem *parent = nullptr); @@ -84,9 +84,6 @@ public: void setContentHeight(qreal height); void resetContentHeight(); - QQmlListProperty<QQuickMenu> menus(); - QQmlListProperty<QObject> contentData(); - Q_SIGNALS: void delegateChanged(); void contentWidthChanged(); diff --git a/src/quicktemplates2/qquickmenubar_p_p.h b/src/quicktemplates2/qquickmenubar_p_p.h index 161806fb..77625257 100644 --- a/src/quicktemplates2/qquickmenubar_p_p.h +++ b/src/quicktemplates2/qquickmenubar_p_p.h @@ -68,6 +68,9 @@ public: return menuBar->d_func(); } + QQmlListProperty<QQuickMenu> menus(); + QQmlListProperty<QObject> contentData(); + QQuickItem *beginCreateItem(); void completeCreateItem(); diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp index e1d8d7bb..96481c54 100644 --- a/src/quicktemplates2/qquickpane.cpp +++ b/src/quicktemplates2/qquickpane.cpp @@ -359,9 +359,10 @@ void QQuickPane::resetContentHeight() \sa Item::data, contentChildren */ -QQmlListProperty<QObject> QQuickPane::contentData() +QQmlListProperty<QObject> QQuickPanePrivate::contentData() { - return QQmlListProperty<QObject>(contentItem(), nullptr, + Q_Q(QQuickPane); + return QQmlListProperty<QObject>(q->contentItem(), nullptr, QQuickItemPrivate::data_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, @@ -381,9 +382,10 @@ QQmlListProperty<QObject> QQuickPane::contentData() \sa Item::children, contentData */ -QQmlListProperty<QQuickItem> QQuickPane::contentChildren() +QQmlListProperty<QQuickItem> QQuickPanePrivate::contentChildren() { - return QQmlListProperty<QQuickItem>(contentItem(), nullptr, + Q_Q(QQuickPane); + return QQmlListProperty<QQuickItem>(q->contentItem(), nullptr, QQuickItemPrivate::children_append, QQuickItemPrivate::children_count, QQuickItemPrivate::children_at, @@ -421,3 +423,5 @@ QAccessible::Role QQuickPane::accessibleRole() const #endif QT_END_NAMESPACE + +#include "moc_qquickpane_p.cpp" diff --git a/src/quicktemplates2/qquickpane_p.h b/src/quicktemplates2/qquickpane_p.h index 53bf7067..55ddf200 100644 --- a/src/quicktemplates2/qquickpane_p.h +++ b/src/quicktemplates2/qquickpane_p.h @@ -60,8 +60,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPane : public QQuickControl Q_OBJECT Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth RESET resetContentWidth NOTIFY contentWidthChanged FINAL) Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight RESET resetContentHeight NOTIFY contentHeightChanged FINAL) - Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL) - Q_PROPERTY(QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL) + Q_PRIVATE_PROPERTY(QQuickPane::d_func(), QQmlListProperty<QObject> contentData READ contentData FINAL) + Q_PRIVATE_PROPERTY(QQuickPane::d_func(), QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL) Q_CLASSINFO("DefaultProperty", "contentData") public: @@ -76,9 +76,6 @@ public: void setContentHeight(qreal height); void resetContentHeight(); - QQmlListProperty<QObject> contentData(); - QQmlListProperty<QQuickItem> contentChildren(); - Q_SIGNALS: void contentWidthChanged(); void contentHeightChanged(); diff --git a/src/quicktemplates2/qquickpane_p_p.h b/src/quicktemplates2/qquickpane_p_p.h index 9d091792..f6092de1 100644 --- a/src/quicktemplates2/qquickpane_p_p.h +++ b/src/quicktemplates2/qquickpane_p_p.h @@ -62,6 +62,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPanePrivate : public QQuickControlP public: QQuickPanePrivate(); + QQmlListProperty<QObject> contentData(); + QQmlListProperty<QQuickItem> contentChildren(); + QQuickItem *getContentItem() override; void addImplicitSizeListener(QQuickItem *item); diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 03dd3dd0..f7baae9b 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -1718,13 +1718,12 @@ void QQuickPopup::setContentItem(QQuickItem *item) \sa Item::data, contentChildren */ -QQmlListProperty<QObject> QQuickPopup::contentData() +QQmlListProperty<QObject> QQuickPopupPrivate::contentData() { - Q_D(QQuickPopup); - QQuickControlPrivate *p = QQuickControlPrivate::get(d->popupItem); + QQuickControlPrivate *p = QQuickControlPrivate::get(popupItem); if (!p->contentItem) p->executeContentItem(); - return QQmlListProperty<QObject>(d->popupItem->contentItem(), nullptr, + return QQmlListProperty<QObject>(popupItem->contentItem(), nullptr, QQuickItemPrivate::data_append, QQuickItemPrivate::data_count, QQuickItemPrivate::data_at, @@ -1744,10 +1743,9 @@ QQmlListProperty<QObject> QQuickPopup::contentData() \sa Item::children, contentData */ -QQmlListProperty<QQuickItem> QQuickPopup::contentChildren() +QQmlListProperty<QQuickItem> QQuickPopupPrivate::contentChildren() { - Q_D(QQuickPopup); - return QQmlListProperty<QQuickItem>(d->popupItem->contentItem(), nullptr, + return QQmlListProperty<QQuickItem>(popupItem->contentItem(), nullptr, QQuickItemPrivate::children_append, QQuickItemPrivate::children_count, QQuickItemPrivate::children_at, diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h index 07ac664e..1a9439d6 100644 --- a/src/quicktemplates2/qquickpopup_p.h +++ b/src/quicktemplates2/qquickpopup_p.h @@ -101,8 +101,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopup : public QObject, public QQml Q_PROPERTY(QQuickItem *parent READ parentItem WRITE setParentItem RESET resetParentItem NOTIFY parentChanged FINAL) Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) - Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL) - Q_PROPERTY(QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL) + Q_PRIVATE_PROPERTY(QQuickPopup::d_func(), QQmlListProperty<QObject> contentData READ contentData FINAL) + Q_PRIVATE_PROPERTY(QQuickPopup::d_func(), QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL) Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged FINAL) Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) @@ -229,9 +229,6 @@ public: QQuickItem *contentItem() const; void setContentItem(QQuickItem *item); - QQmlListProperty<QObject> contentData(); - QQmlListProperty<QQuickItem> contentChildren(); - bool clip() const; void setClip(bool clip); diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index 64362ada..1688b808 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -94,6 +94,9 @@ public: return popup->d_func(); } + QQmlListProperty<QObject> contentData(); + QQmlListProperty<QQuickItem> contentChildren(); + void init(); void closeOrReject(); bool tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags); diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index 30750aa8..1c81eb70 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -108,6 +108,9 @@ class QQuickScrollViewPrivate : public QQuickControlPrivate public: QQuickScrollViewPrivate(); + QQmlListProperty<QObject> contentData(); + QQmlListProperty<QQuickItem> contentChildren(); + QQuickItem *getContentItem() override; QQuickFlickable *ensureFlickable(bool content); @@ -433,10 +436,10 @@ void QQuickScrollView::setContentHeight(qreal height) \sa Item::data, contentChildren */ -QQmlListProperty<QObject> QQuickScrollView::contentData() +QQmlListProperty<QObject> QQuickScrollViewPrivate::contentData() { - Q_D(QQuickScrollView); - return QQmlListProperty<QObject>(this, d, + Q_Q(QQuickScrollView); + return QQmlListProperty<QObject>(q, this, QQuickScrollViewPrivate::contentData_append, QQuickScrollViewPrivate::contentData_count, QQuickScrollViewPrivate::contentData_at, @@ -454,10 +457,10 @@ QQmlListProperty<QObject> QQuickScrollView::contentData() \sa Item::children, contentData */ -QQmlListProperty<QQuickItem> QQuickScrollView::contentChildren() +QQmlListProperty<QQuickItem> QQuickScrollViewPrivate::contentChildren() { - Q_D(QQuickScrollView); - return QQmlListProperty<QQuickItem>(this, d, + Q_Q(QQuickScrollView); + return QQmlListProperty<QQuickItem>(q, this, QQuickScrollViewPrivate::contentChildren_append, QQuickScrollViewPrivate::contentChildren_count, QQuickScrollViewPrivate::contentChildren_at, @@ -580,3 +583,5 @@ QAccessible::Role QQuickScrollView::accessibleRole() const #endif QT_END_NAMESPACE + +#include "moc_qquickscrollview_p.cpp" diff --git a/src/quicktemplates2/qquickscrollview_p.h b/src/quicktemplates2/qquickscrollview_p.h index 136260c2..2e8f19db 100644 --- a/src/quicktemplates2/qquickscrollview_p.h +++ b/src/quicktemplates2/qquickscrollview_p.h @@ -60,8 +60,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickScrollView : public QQuickControl Q_OBJECT Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged FINAL) Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL) - Q_PROPERTY(QQmlListProperty<QObject> contentData READ contentData FINAL) - Q_PROPERTY(QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL) + Q_PRIVATE_PROPERTY(QQuickScrollView::d_func(), QQmlListProperty<QObject> contentData READ contentData FINAL) + Q_PRIVATE_PROPERTY(QQuickScrollView::d_func(), QQmlListProperty<QQuickItem> contentChildren READ contentChildren NOTIFY contentChildrenChanged FINAL) Q_CLASSINFO("DefaultProperty", "contentData") public: @@ -73,9 +73,6 @@ public: qreal contentHeight() const; void setContentHeight(qreal height); - QQmlListProperty<QObject> contentData(); - QQmlListProperty<QQuickItem> contentChildren(); - Q_SIGNALS: void contentWidthChanged(); void contentHeightChanged(); |