diff options
author | Dan Cape <dcape@qnx.com> | 2015-08-25 13:34:43 -0400 |
---|---|---|
committer | Dan Cape <dcape@qnx.com> | 2015-09-09 12:52:05 +0000 |
commit | 49c359dd88f962ec04cc7ede8cfa4ae2173e55f7 (patch) | |
tree | c7f5570b55c4885af3cf3c774624b705acaa7ec2 /src/qml/types/qqmlconnections.cpp | |
parent | 68607aeeeb6ba84b843a0e3d848a5438a36f55a7 (diff) |
Add enabled property to the QML Connections element
Now allows a quick way to enable/disable the signal handlers in the
QML Connections element. Updated test file to have objectName and added
test for this new functionality. Set to be available as of QtQml2.3.
[ChangeLog][QML Elements] Allow enabling/disabling of connections established using a Connections element
Change-Id: Ib0de2b3c78bb529ef74d5b4bb4ccb0f335cc50de
Task-number: QTBUG-36350
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/qml/types/qqmlconnections.cpp')
-rw-r--r-- | src/qml/types/qqmlconnections.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp index 6a93410ecb..5f69bf5f94 100644 --- a/src/qml/types/qqmlconnections.cpp +++ b/src/qml/types/qqmlconnections.cpp @@ -51,11 +51,12 @@ QT_BEGIN_NAMESPACE class QQmlConnectionsPrivate : public QObjectPrivate { public: - QQmlConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} + QQmlConnectionsPrivate() : target(0), enabled(true), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} QList<QQmlBoundSignal*> boundsignals; QObject *target; + bool enabled; bool targetSet; bool ignoreUnknownSignals; bool componentcomplete; @@ -177,6 +178,34 @@ void QQmlConnections::setTarget(QObject *obj) } /*! + \qmlproperty bool QtQml::Connections::enabled + \since 5.7 + + This property holds whether the item accepts change events. + + By default, this property is \c true. +*/ +bool QQmlConnections::isEnabled() const +{ + Q_D(const QQmlConnections); + return d->enabled; +} + +void QQmlConnections::setEnabled(bool enabled) +{ + Q_D(QQmlConnections); + if (d->enabled == enabled) + return; + + d->enabled = enabled; + + foreach (QQmlBoundSignal *s, d->boundsignals) + s->setEnabled(d->enabled); + + emit enabledChanged(); +} + +/*! \qmlproperty bool QtQml::Connections::ignoreUnknownSignals Normally, a connection to a non-existent signal produces runtime errors. |