forked from qt-creator/qt-creator
QmlPuppet: Clean up private API usage in QmlStateNodeInstance
Change-Id: If1c8cee81cbdd6f90808a824c2b4d023dd8a3e12 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -30,10 +30,9 @@
|
||||
|
||||
#include "qmlstatenodeinstance.h"
|
||||
|
||||
#include <private/qquickstategroup_p.h>
|
||||
#include <qmlprivategate.h>
|
||||
|
||||
#include "qmlpropertychangesnodeinstance.h"
|
||||
#include <private/qquickstateoperations_p.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
namespace Internal {
|
||||
@@ -44,7 +43,7 @@ namespace Internal {
|
||||
QmlStateNodeInstance manages a QQuickState object.
|
||||
*/
|
||||
|
||||
QmlStateNodeInstance::QmlStateNodeInstance(QQuickState *object) :
|
||||
QmlStateNodeInstance::QmlStateNodeInstance(QObject *object) :
|
||||
ObjectNodeInstance(object)
|
||||
{
|
||||
}
|
||||
@@ -52,11 +51,7 @@ QmlStateNodeInstance::QmlStateNodeInstance(QQuickState *object) :
|
||||
QmlStateNodeInstance::Pointer
|
||||
QmlStateNodeInstance::create(QObject *object)
|
||||
{
|
||||
QQuickState *stateObject = qobject_cast<QQuickState*>(object);
|
||||
|
||||
Q_ASSERT(stateObject);
|
||||
|
||||
Pointer instance(new QmlStateNodeInstance(stateObject));
|
||||
Pointer instance(new QmlStateNodeInstance(object));
|
||||
|
||||
instance->populateResetHashes();
|
||||
|
||||
@@ -65,42 +60,21 @@ QmlStateNodeInstance::Pointer
|
||||
|
||||
void QmlStateNodeInstance::activateState()
|
||||
{
|
||||
if (stateGroup()
|
||||
&& !isStateActive()
|
||||
if (!QmlPrivateGate::States::isStateActive(object(), context())
|
||||
&& nodeInstanceServer()->hasInstanceForObject(object())) {
|
||||
nodeInstanceServer()->setStateInstance(nodeInstanceServer()->instanceForObject(object()));
|
||||
stateGroup()->setState(property("name").toString());
|
||||
QmlPrivateGate::States::activateState(object(), context());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QmlStateNodeInstance::deactivateState()
|
||||
{
|
||||
if (stateGroup()) {
|
||||
if (isStateActive()) {
|
||||
nodeInstanceServer()->clearStateInstance();
|
||||
stateGroup()->setState(QString());
|
||||
}
|
||||
if (QmlPrivateGate::States::isStateActive(object(), context())) {
|
||||
nodeInstanceServer()->clearStateInstance();
|
||||
QmlPrivateGate::States::deactivateState(object());
|
||||
}
|
||||
}
|
||||
|
||||
QQuickState *QmlStateNodeInstance::stateObject() const
|
||||
{
|
||||
Q_ASSERT(object());
|
||||
Q_ASSERT(qobject_cast<QQuickState*>(object()));
|
||||
return static_cast<QQuickState*>(object());
|
||||
}
|
||||
|
||||
QQuickStateGroup *QmlStateNodeInstance::stateGroup() const
|
||||
{
|
||||
return stateObject()->stateGroup();
|
||||
}
|
||||
|
||||
bool QmlStateNodeInstance::isStateActive() const
|
||||
{
|
||||
return stateObject() && stateGroup() && stateGroup()->state() == property("name");
|
||||
}
|
||||
|
||||
void QmlStateNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
|
||||
{
|
||||
bool hasParent = parent();
|
||||
@@ -123,17 +97,17 @@ void QmlStateNodeInstance::setPropertyBinding(const PropertyName &name, const QS
|
||||
|
||||
bool QmlStateNodeInstance::updateStateVariant(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant &value)
|
||||
{
|
||||
return stateObject()->changeValueInRevertList(target->object(), QString::fromUtf8(propertyName), value);
|
||||
return QmlPrivateGate::States::changeValueInRevertList(object(), target->object(), propertyName, value);
|
||||
}
|
||||
|
||||
bool QmlStateNodeInstance::updateStateBinding(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QString &expression)
|
||||
{
|
||||
return stateObject()->changeValueInRevertList(target->object(), QString::fromUtf8(propertyName), expression);
|
||||
return QmlPrivateGate::States::updateStateBinding(object(), target->object(), propertyName, expression);
|
||||
}
|
||||
|
||||
bool QmlStateNodeInstance::resetStateProperty(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant & /* resetValue */)
|
||||
bool QmlStateNodeInstance::resetStateProperty(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant & resetValue)
|
||||
{
|
||||
return stateObject()->removeEntryFromRevertList(target->object(), QString::fromUtf8(propertyName));
|
||||
return QmlPrivateGate::States::resetStateProperty(object(), target->object(), propertyName, resetValue);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user