aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2016-08-26 12:46:42 +0200
committerMitch Curtis <mitch.curtis@qt.io>2016-09-02 08:23:49 +0000
commit58326f2bc3bceafc0054e790832e0a77db340606 (patch)
tree596cd37c11aab8077980e7e6db9f65e200e1bf82 /src
parent67f67f2cc6de160ddea4aa76afc56e86415ed99b (diff)
StackView: add removed() attached signal
This provides an opportunity for users to destroy items that StackView doesn't, like objects that are pushed as Items. [ChangeLog][Controls][StackView] Added StackView.removed() attached signal to provide a way to delete items that StackView won't. Task-number: QTBUG-55405 Change-Id: I59096efaf1a95d36451fbf1f46b8f68ee96c20de Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquickstackview.cpp17
-rw-r--r--src/quicktemplates2/qquickstackview_p.cpp5
-rw-r--r--src/quicktemplates2/qquickstackview_p.h1
3 files changed, 22 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index df163089..040eff1b 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -1092,4 +1092,21 @@ QQuickStackView::Status QQuickStackAttached::status() const
\sa status
*/
+/*!
+ \qmlattachedsignal QtQuick.Controls::StackView::removed()
+ \since QtQuick.Controls 2.1
+
+ This attached signal is emitted when the item it's attached to has been
+ removed from the stack. It can be used to safely destroy an Item that was
+ pushed onto the stack, for example:
+
+ \code
+ Item {
+ StackView.onRemoved: destroy() // Will be destroyed sometime after this call.
+ }
+ \endcode
+
+ \sa status
+*/
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp
index 0f5674c2..438b4269 100644
--- a/src/quicktemplates2/qquickstackview_p.cpp
+++ b/src/quicktemplates2/qquickstackview_p.cpp
@@ -85,6 +85,7 @@ QQuickStackElement::~QQuickStackElement()
if (ownComponent)
delete component;
+ QQuickStackAttached *attached = attachedStackObject(this);
if (item) {
if (ownItem) {
item->setParentItem(nullptr);
@@ -99,13 +100,15 @@ QQuickStackElement::~QQuickStackElement()
if (item->parentItem() != originalParent) {
item->setParentItem(originalParent);
} else {
- QQuickStackAttached *attached = attachedStackObject(this);
if (attached)
QQuickStackAttachedPrivate::get(attached)->itemParentChanged(item, nullptr);
}
}
}
+ if (attached)
+ emit attached->removed();
+
delete context;
}
diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h
index d8b6ce7c..9bf60183 100644
--- a/src/quicktemplates2/qquickstackview_p.h
+++ b/src/quicktemplates2/qquickstackview_p.h
@@ -182,6 +182,7 @@ Q_SIGNALS:
/*Q_REVISION(1)*/ void activating();
/*Q_REVISION(1)*/ void deactivated();
/*Q_REVISION(1)*/ void deactivating();
+ /*Q_REVISION(1)*/ void removed();
private:
Q_DISABLE_COPY(QQuickStackAttached)