QmlDesigner: Add and dispatch ValuesModifiedCommand

We already have valuesChanged() which notifies that a
property of the C++ QObject has changed.

This patch adds valuesModified() which notifies that values
in the data model should be changed.

While valuesChanged() only changes the so called instance value,
valuesModified() does change the internal data model and as
a result the QML code.
This is done in NodeInstanceView::valuesModified().

This enabled the qml2puppet to acutally change values,
like a property editor would.

Change-Id: I2493b9e626c4b194e332a7a096de3dbf2195514a
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Thomas Hartmann
2019-10-18 16:55:08 +02:00
parent b4bc204a7d
commit 49379bfda7
9 changed files with 58 additions and 6 deletions

View File

@@ -42,7 +42,7 @@ public:
ValuesChangedCommand();
explicit ValuesChangedCommand(const QVector<PropertyValueContainer> &valueChangeVector);
QVector<PropertyValueContainer> valueChanges() const;
const QVector<PropertyValueContainer> valueChanges() const;
quint32 keyNumber() const;
static void removeSharedMemorys(const QVector<qint32> &keyNumberVector);
@@ -59,6 +59,26 @@ QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command);
bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second);
QDebug operator <<(QDebug debug, const ValuesChangedCommand &instance);
/* ValuesChangedCommand is used to notify that the values of a specific instatiated
* QObject changed.
* The ValuesModifiedCommand is used to notify that a user changed a QML property and
* that this property should be changed in the data model.
*/
class ValuesModifiedCommand : public ValuesChangedCommand
{
public:
ValuesModifiedCommand()
{}
explicit ValuesModifiedCommand(const QVector<PropertyValueContainer> &valueChangeVector)
: ValuesChangedCommand(valueChangeVector)
{}
};
} // namespace QmlDesigner
Q_DECLARE_METATYPE(QmlDesigner::ValuesModifiedCommand)
Q_DECLARE_METATYPE(QmlDesigner::ValuesChangedCommand)