forked from qt-creator/qt-creator
Use qt new state api
This commit is contained in:
committed by
Thomas Hartmann
parent
d6057ae600
commit
0fe36330e8
@@ -632,7 +632,7 @@ bool NodeInstance::resetStateProperty(const NodeInstance &target, const QString
|
||||
*/
|
||||
void NodeInstance::registerDeclarativeTypes()
|
||||
{
|
||||
qmlRegisterType<QmlDesigner::Internal::QmlPropertyChangesObject>();
|
||||
// qmlRegisterType<QmlDesigner::Internal::QmlPropertyChangesObject>();
|
||||
}
|
||||
|
||||
#ifdef QTCREATOR_TEST
|
||||
|
||||
@@ -186,7 +186,7 @@ void NodeInstanceView::resetInstanceProperty(const AbstractProperty &property)
|
||||
NodeInstance instance = instanceForNode(property.parentModelNode());
|
||||
Q_ASSERT(instance.isValid());
|
||||
const QString name = property.name();
|
||||
if (activeStateInstance().isValid()) {
|
||||
if (activeStateInstance().isValid() && !property.parentModelNode().metaInfo().isSubclassOf("PropertyChange", 4, 7)) {
|
||||
bool statePropertyWasReseted = activeStateInstance().resetStateProperty(instance, name, instance.resetVariant(name));
|
||||
if (!statePropertyWasReseted)
|
||||
instance.resetProperty(name);
|
||||
@@ -204,7 +204,7 @@ void NodeInstanceView::setInstancePropertyBinding(const BindingProperty &propert
|
||||
const QString expression = property.expression();
|
||||
|
||||
|
||||
if (activeStateInstance().isValid()) {
|
||||
if (activeStateInstance().isValid() && !property.parentModelNode().metaInfo().isSubclassOf("PropertyChange", 4, 7)) {
|
||||
bool stateBindingWasUpdated = activeStateInstance().updateStateBinding(instance, name, expression);
|
||||
if (!stateBindingWasUpdated) {
|
||||
if (property.isDynamic())
|
||||
@@ -240,7 +240,7 @@ void NodeInstanceView::setInstancePropertyVariant(const VariantProperty &propert
|
||||
const QVariant value = property.value();
|
||||
|
||||
|
||||
if (activeStateInstance().isValid()) {
|
||||
if (activeStateInstance().isValid() && !property.parentModelNode().metaInfo().isSubclassOf("PropertyChange", 4, 7)) {
|
||||
bool stateValueWasUpdated = activeStateInstance().updateStateVariant(instance, name, value);
|
||||
if (!stateValueWasUpdated) {
|
||||
if (property.isDynamic())
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "objectnodeinstance.h"
|
||||
#include <private/qdeclarativestateoperations_p.h>
|
||||
#include <private/qdeclarativepropertychanges_p.h>
|
||||
|
||||
#include <QPair>
|
||||
#include <QWeakPointer>
|
||||
@@ -48,74 +49,74 @@ class QmlPropertyChangesNodeInstance;
|
||||
|
||||
// Original QmlPropertyChanges class requires a custom parser
|
||||
// work around this by writing a replacement class
|
||||
class QmlPropertyChangesObject : public QDeclarativeStateOperation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QObject *target READ targetObject WRITE setTargetObject)
|
||||
Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
|
||||
Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
|
||||
//class QmlPropertyChangesObject : public QDeclarativeStateOperation
|
||||
//{
|
||||
// Q_OBJECT
|
||||
// Q_PROPERTY(QObject *target READ targetObject WRITE setTargetObject)
|
||||
// Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
|
||||
// Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
|
||||
|
||||
typedef QPair<QString, QWeakPointer<QDeclarativeBinding> > ExpressionPair;
|
||||
public:
|
||||
~QmlPropertyChangesObject();
|
||||
QObject *targetObject() const;
|
||||
void setTargetObject(QObject *object);
|
||||
// typedef QPair<QString, QWeakPointer<QDeclarativeBinding> > ExpressionPair;
|
||||
//public:
|
||||
// ~QmlPropertyChangesObject();
|
||||
// QObject *targetObject() const;
|
||||
// void setTargetObject(QObject *object);
|
||||
|
||||
bool restoreEntryValues() const;
|
||||
void setRestoreEntryValues(bool restore);
|
||||
// bool restoreEntryValues() const;
|
||||
// void setRestoreEntryValues(bool restore);
|
||||
|
||||
bool isExplicit() const;
|
||||
void setIsExplicit(bool isExplicit);
|
||||
// bool isExplicit() const;
|
||||
// void setIsExplicit(bool isExplicit);
|
||||
|
||||
virtual ActionList actions();
|
||||
// virtual ActionList actions();
|
||||
|
||||
void setVariantValue(const QString &name, const QVariant & value);
|
||||
void setExpression(const QString &name, const QString &expression);
|
||||
void removeVariantValue(const QString &name);
|
||||
void removeExpression(const QString &name);
|
||||
// void setVariantValue(const QString &name, const QVariant & value);
|
||||
// void setExpression(const QString &name, const QString &expression);
|
||||
// void removeVariantValue(const QString &name);
|
||||
// void removeExpression(const QString &name);
|
||||
|
||||
void resetProperty(const QString &name);
|
||||
// void resetProperty(const QString &name);
|
||||
|
||||
QVariant variantValue(const QString &name) const;
|
||||
QString expression(const QString &name) const;
|
||||
// QVariant variantValue(const QString &name) const;
|
||||
// QString expression(const QString &name) const;
|
||||
|
||||
bool hasVariantValue(const QString &name) const;
|
||||
bool hasExpression(const QString &name) const;
|
||||
// bool hasVariantValue(const QString &name) const;
|
||||
// bool hasExpression(const QString &name) const;
|
||||
|
||||
QmlPropertyChangesObject();
|
||||
// QmlPropertyChangesObject();
|
||||
|
||||
bool updateStateVariant(const QString &propertyName, const QVariant &value);
|
||||
bool updateStateBinding(const QString &propertyName, const QString &expression);
|
||||
bool resetStateProperty(const QString &propertyName, const QVariant &resetValue);
|
||||
// bool updateStateVariant(const QString &propertyName, const QVariant &value);
|
||||
// bool updateStateBinding(const QString &propertyName, const QString &expression);
|
||||
// bool resetStateProperty(const QString &propertyName, const QVariant &resetValue);
|
||||
|
||||
QDeclarativeState *state() const;
|
||||
void updateRevertValueAndBinding(const QString &name);
|
||||
// QDeclarativeState *state() const;
|
||||
// void updateRevertValueAndBinding(const QString &name);
|
||||
|
||||
void removeFromStateRevertList();
|
||||
void addToStateRevertList();
|
||||
// void removeFromStateRevertList();
|
||||
// void addToStateRevertList();
|
||||
|
||||
private: // functions
|
||||
bool isActive() const;
|
||||
//private: // functions
|
||||
// bool isActive() const;
|
||||
|
||||
QDeclarativeStatePrivate *statePrivate() const;
|
||||
// QDeclarativeStatePrivate *statePrivate() const;
|
||||
|
||||
QDeclarativeStateGroup *stateGroup() const;
|
||||
QDeclarativeProperty createMetaProperty(const QString &property);
|
||||
// QDeclarativeStateGroup *stateGroup() const;
|
||||
// QDeclarativeProperty createMetaProperty(const QString &property);
|
||||
|
||||
QDeclarativeAction &qmlActionForProperty(const QString &propertyName) const;
|
||||
bool hasActionForProperty(const QString &propertyName) const;
|
||||
void removeActionForProperty(const QString &propertyName);
|
||||
// QDeclarativeAction &qmlActionForProperty(const QString &propertyName) const;
|
||||
// bool hasActionForProperty(const QString &propertyName) const;
|
||||
// void removeActionForProperty(const QString &propertyName);
|
||||
|
||||
QDeclarativeAction createQDeclarativeAction(const QString &propertyName);
|
||||
// QDeclarativeAction createQDeclarativeAction(const QString &propertyName);
|
||||
|
||||
private: // variables
|
||||
QWeakPointer<QObject> m_targetObject;
|
||||
bool m_restoreEntryValues;
|
||||
bool m_isExplicit;
|
||||
//private: // variables
|
||||
// QWeakPointer<QObject> m_targetObject;
|
||||
// bool m_restoreEntryValues;
|
||||
// bool m_isExplicit;
|
||||
|
||||
mutable ActionList m_qmlActionList;
|
||||
QHash<QString, ExpressionPair> m_expressionHash;
|
||||
};
|
||||
// mutable ActionList m_qmlActionList;
|
||||
// QHash<QString, ExpressionPair> m_expressionHash;
|
||||
//};
|
||||
|
||||
class QmlPropertyChangesNodeInstance : public ObjectNodeInstance
|
||||
{
|
||||
@@ -133,13 +134,13 @@ public:
|
||||
void reparent(const NodeInstance &oldParentInstance, const QString &oldParentProperty, const NodeInstance &newParentInstance, const QString &newParentProperty);
|
||||
|
||||
protected:
|
||||
QmlPropertyChangesNodeInstance(QmlPropertyChangesObject *object);
|
||||
QmlPropertyChangesObject *changesObject() const;
|
||||
QmlPropertyChangesNodeInstance(QDeclarativePropertyChanges *object);
|
||||
QDeclarativePropertyChanges *changesObject() const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlDesigner
|
||||
|
||||
QML_DECLARE_TYPE(QmlDesigner::Internal::QmlPropertyChangesObject)
|
||||
//QML_DECLARE_TYPE(QmlDesigner::Internal::QmlPropertyChangesObject)
|
||||
|
||||
#endif // QMLPROPERTYCHANGESNODEINSTANCE_H
|
||||
|
||||
@@ -127,42 +127,17 @@ void QmlStateNodeInstance::setPropertyBinding(const QString &name, const QString
|
||||
|
||||
bool QmlStateNodeInstance::updateStateVariant(const NodeInstance &target, const QString &propertyName, const QVariant &value)
|
||||
{
|
||||
// iterate over propertychange object and update values
|
||||
QDeclarativeListReference listReference(stateObject(), "changes");
|
||||
for (int i = 0; i < listReference.count(); i++) {
|
||||
//We also have parent and anchor changes
|
||||
QmlPropertyChangesObject *changeObject = qobject_cast<QmlPropertyChangesObject*>(listReference.at(i));
|
||||
if (changeObject && target.isWrappingThisObject(changeObject->targetObject()))
|
||||
return changeObject->updateStateVariant(propertyName, value);
|
||||
}
|
||||
|
||||
return false;
|
||||
return stateObject()->changeValueInRevertList(target.internalObject(), propertyName.toLatin1(), value);
|
||||
}
|
||||
|
||||
bool QmlStateNodeInstance::updateStateBinding(const NodeInstance &target, const QString &propertyName, const QString &expression)
|
||||
{
|
||||
// iterate over propertychange object and update binding
|
||||
QDeclarativeListReference listReference(stateObject(), "changes");
|
||||
for (int i = 0; i < listReference.count(); i++) {
|
||||
QmlPropertyChangesObject *changeObject = qobject_cast<QmlPropertyChangesObject*>(listReference.at(i));
|
||||
if (changeObject && target.isWrappingThisObject(changeObject->targetObject()))
|
||||
return changeObject->updateStateBinding(propertyName, expression);
|
||||
}
|
||||
|
||||
return false;
|
||||
return stateObject()->changeValueInRevertList(target.internalObject(), propertyName.toLatin1(), expression);
|
||||
}
|
||||
|
||||
bool QmlStateNodeInstance::resetStateProperty(const NodeInstance &target, const QString &propertyName, const QVariant &resetValue)
|
||||
{
|
||||
// iterate over propertychange object and reset propertry
|
||||
QDeclarativeListReference listReference(stateObject(), "changes");
|
||||
for (int i = 0; i < listReference.count(); i++) {
|
||||
QmlPropertyChangesObject *changeObject = qobject_cast<QmlPropertyChangesObject*>(listReference.at(i));
|
||||
if (changeObject && target.isWrappingThisObject(changeObject->targetObject()))
|
||||
return changeObject->resetStateProperty(propertyName, resetValue);
|
||||
}
|
||||
|
||||
return false;
|
||||
return stateObject()->removeEntryInRevertList(target.internalObject(), propertyName.toLatin1());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user