QmlDesigner: Add change set tracing

Change-Id: Id46b8986eadf3ff94c9b83a5f0a7b5154e133d0e
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2025-05-24 11:13:47 +02:00
parent 244ed5008e
commit d68f942242
2 changed files with 108 additions and 30 deletions

View File

@@ -11,75 +11,141 @@
namespace QmlDesigner {
ModelNode QmlModelStateOperation::target() const
static auto category = ModelTracing::category;
ModelNode QmlModelStateOperation::target(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml model state operation target",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
if (modelNode().property("target").isBindingProperty())
return modelNode().bindingProperty("target").resolveToModelNode();
else
return ModelNode(); //exception?
}
void QmlModelStateOperation::setTarget(const ModelNode &target)
void QmlModelStateOperation::setTarget(const ModelNode &target, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml model state operation set target",
category(),
keyValue("model node", *this),
keyValue("target", target),
keyValue("caller location", sl)};
modelNode().bindingProperty("target").setExpression(target.id());
}
bool QmlModelStateOperation::explicitValue() const
bool QmlModelStateOperation::explicitValue(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml model state operation explicit value",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
if (modelNode().property("explicit").isVariantProperty())
return modelNode().variantProperty("explicit").value().toBool();
return false;
}
void QmlModelStateOperation::setExplicitValue(bool value)
void QmlModelStateOperation::setExplicitValue(bool value, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml model state operation set explicit value",
category(),
keyValue("model node", *this),
keyValue("value", value),
keyValue("caller location", sl)};
modelNode().variantProperty("explicit").setValue(value);
}
bool QmlModelStateOperation::restoreEntryValues() const
bool QmlModelStateOperation::restoreEntryValues(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml model state operation restore entry values",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
if (modelNode().property("restoreEntryValues").isVariantProperty())
return modelNode().variantProperty("restoreEntryValues").value().toBool();
return false;
}
void QmlModelStateOperation::setRestoreEntryValues(bool value)
void QmlModelStateOperation::setRestoreEntryValues(bool value, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml model state operation set restore entry values",
category(),
keyValue("model node", *this),
keyValue("value", value),
keyValue("caller location", sl)};
modelNode().variantProperty("restoreEntryValues").setValue(value);
}
QList<AbstractProperty> QmlModelStateOperation::targetProperties() const
QList<AbstractProperty> QmlModelStateOperation::targetProperties(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml model state operation target properties",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
return Utils::filtered(modelNode().properties(), [](const AbstractProperty &property) {
const QList<PropertyName> ignore = {"target", "explicit", "restoreEntryValues"};
return !ignore.contains(property.name());
});
}
bool QmlPropertyChanges::isValid() const
bool QmlPropertyChanges::isValid(SL sl) const
{
return isValidQmlPropertyChanges(modelNode());
return isValidQmlPropertyChanges(modelNode(), sl);
}
bool QmlPropertyChanges::isValidQmlPropertyChanges(const ModelNode &modelNode)
bool QmlPropertyChanges::isValidQmlPropertyChanges(const ModelNode &modelNode, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"is valid qml property changes",
category(),
keyValue("model node", modelNode),
keyValue("caller location", sl)};
return isValidQmlModelNodeFacade(modelNode) && modelNode.metaInfo().isQtQuickPropertyChanges();
}
bool QmlModelStateOperation::isValid() const
bool QmlModelStateOperation::isValid(SL sl) const
{
return isValidQmlModelStateOperation(modelNode());
return isValidQmlModelStateOperation(modelNode(), sl);
}
bool QmlModelStateOperation::isValidQmlModelStateOperation(const ModelNode &modelNode)
bool QmlModelStateOperation::isValidQmlModelStateOperation(const ModelNode &modelNode, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"is valid qml model state operation",
category(),
keyValue("model node", modelNode),
keyValue("caller location", sl)};
return isValidQmlModelNodeFacade(modelNode) && modelNode.metaInfo().isQtQuickStateOperation();
}
void QmlPropertyChanges::removeProperty(PropertyNameView name)
void QmlPropertyChanges::removeProperty(PropertyNameView name, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml property changes remove property",
category(),
keyValue("model node", *this),
keyValue("property name", name),
keyValue("caller location", sl)};
RewriterTransaction transaction(view()->beginRewriterTransaction(QByteArrayLiteral("QmlPropertyChanges::removeProperty")));
if (name == "name")
return;

View File

@@ -11,29 +11,41 @@ namespace QmlDesigner {
class QMLDESIGNER_EXPORT QmlModelStateOperation : public QmlModelNodeFacade
{
public:
QmlModelStateOperation() : QmlModelNodeFacade() {}
QmlModelStateOperation(const ModelNode &modelNode) : QmlModelNodeFacade(modelNode) {}
ModelNode target() const;
void setTarget(const ModelNode &target);
bool explicitValue() const;
void setExplicitValue(bool value);
bool restoreEntryValues() const;
void setRestoreEntryValues(bool value);
QList<AbstractProperty> targetProperties() const;
bool isValid() const;
QmlModelStateOperation() : QmlModelNodeFacade()
{}
QmlModelStateOperation(const ModelNode &modelNode)
: QmlModelNodeFacade(modelNode)
{}
ModelNode target(SL sl = {}) const;
void setTarget(const ModelNode &target, SL sl = {});
bool explicitValue(SL sl = {}) const;
void setExplicitValue(bool value, SL sl = {});
bool restoreEntryValues(SL sl = {}) const;
void setRestoreEntryValues(bool value, SL sl = {});
QList<AbstractProperty> targetProperties(SL sl = {}) const;
bool isValid(SL sl = {}) const;
explicit operator bool() const { return isValid(); }
static bool isValidQmlModelStateOperation(const ModelNode &modelNode);
static bool isValidQmlModelStateOperation(const ModelNode &modelNode, SL sl = {});
};
class QMLDESIGNER_EXPORT QmlPropertyChanges : public QmlModelStateOperation
{
public:
QmlPropertyChanges() : QmlModelStateOperation() {}
QmlPropertyChanges(const ModelNode &modelNode) : QmlModelStateOperation(modelNode) {}
bool isValid() const;
QmlPropertyChanges() : QmlModelStateOperation()
{}
QmlPropertyChanges(const ModelNode &modelNode)
: QmlModelStateOperation(modelNode)
{}
bool isValid(SL sl = {}) const;
explicit operator bool() const { return isValid(); }
static bool isValidQmlPropertyChanges(const ModelNode &modelNode);
void removeProperty(PropertyNameView name);
static bool isValidQmlPropertyChanges(const ModelNode &modelNode, SL sl = {});
void removeProperty(PropertyNameView name, SL sl = {});
};
} //QmlDesigner