diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-06-30 13:39:43 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-06-30 20:54:05 +0000 |
commit | 5e226b8426a3366515dfdf791ea75e063f029afb (patch) | |
tree | 3df257b53ab00b9d567003415a718171d178f4b6 /src | |
parent | a775baf6163cf02886dfb2e598e9a09c1bc05838 (diff) |
Add missing StackView::view attached property
Change-Id: Ie2e5e09e906b2886525a986bccbd1b2722a0a795
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/qquickstackview.cpp | 16 | ||||
-rw-r--r-- | src/controls/qquickstackview_p.cpp | 12 | ||||
-rw-r--r-- | src/controls/qquickstackview_p.h | 3 | ||||
-rw-r--r-- | src/controls/qquickstackview_p_p.h | 1 |
4 files changed, 31 insertions, 1 deletions
diff --git a/src/controls/qquickstackview.cpp b/src/controls/qquickstackview.cpp index 663253a4..baf98434 100644 --- a/src/controls/qquickstackview.cpp +++ b/src/controls/qquickstackview.cpp @@ -520,12 +520,15 @@ void QQuickStackAttachedPrivate::reset() { Q_Q(QQuickStackAttached); int oldIndex = element ? element->index : -1; + QQuickStackView *oldView = element ? element->view : Q_NULLPTR; QQuickStackView::Status oldStatus = element ? element->status : QQuickStackView::Inactive; element = Q_NULLPTR; if (oldIndex != -1) emit q->indexChanged(); + if (oldView) + emit q->viewChanged(); if (oldStatus != QQuickStackView::Inactive) emit q->statusChanged(); } @@ -549,6 +552,19 @@ int QQuickStackAttached::index() const } /*! + \qmlattachedproperty StackView QtQuickControls2::StackView::view + + TODO +*/ +QQuickStackView *QQuickStackAttached::view() const +{ + Q_D(const QQuickStackAttached); + if (!d->initialized) + const_cast<QQuickStackAttachedPrivate *>(d)->init(); + return d->element ? d->element->view : Q_NULLPTR; +} + +/*! \qmlattachedproperty enumeration QtQuickControls2::StackView::status TODO diff --git a/src/controls/qquickstackview_p.cpp b/src/controls/qquickstackview_p.cpp index 8e5be7e4..3c6bb38c 100644 --- a/src/controls/qquickstackview_p.cpp +++ b/src/controls/qquickstackview_p.cpp @@ -124,7 +124,7 @@ QQuickStackElement *QQuickStackElement::fromObject(QObject *object, QQuickStackV bool QQuickStackElement::load(QQuickStackView *parent) { - view = parent; + setView(parent); if (!item) { ownItem = true; @@ -186,6 +186,16 @@ void QQuickStackElement::setIndex(int value) } } +void QQuickStackElement::setView(QQuickStackView *value) +{ + if (view != value) { + view = value; + QQuickStackAttached *attached = attachedStackObject(item); + if (attached) + emit attached->viewChanged(); + } +} + void QQuickStackElement::setStatus(QQuickStackView::Status value) { if (status != value) { diff --git a/src/controls/qquickstackview_p.h b/src/controls/qquickstackview_p.h index a4e719c2..f5180c08 100644 --- a/src/controls/qquickstackview_p.h +++ b/src/controls/qquickstackview_p.h @@ -150,16 +150,19 @@ class Q_QUICKCONTROLS_EXPORT QQuickStackAttached : public QObject { Q_OBJECT Q_PROPERTY(int index READ index NOTIFY indexChanged FINAL) + Q_PROPERTY(QQuickStackView *view READ view NOTIFY viewChanged FINAL) Q_PROPERTY(QQuickStackView::Status status READ status NOTIFY statusChanged FINAL) public: explicit QQuickStackAttached(QQuickItem *parent = Q_NULLPTR); int index() const; + QQuickStackView *view() const; QQuickStackView::Status status() const; Q_SIGNALS: void indexChanged(); + void viewChanged(); void statusChanged(); private: diff --git a/src/controls/qquickstackview_p_p.h b/src/controls/qquickstackview_p_p.h index 753950e6..857876e9 100644 --- a/src/controls/qquickstackview_p_p.h +++ b/src/controls/qquickstackview_p_p.h @@ -75,6 +75,7 @@ public: void initProperties(); void setIndex(int index); + void setView(QQuickStackView *view); void setStatus(QQuickStackView::Status status); void transitionNextReposition(QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, bool asTarget); |