QmlDesigner: Add QmlTimelineKeyframeGroup tracing

Change-Id: I6677896f6f55c5ee71d05b2d6b932404c2ab443e
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2025-05-24 00:40:42 +02:00
parent 337bdfb65e
commit 18d65b4546
2 changed files with 260 additions and 68 deletions

View File

@@ -18,51 +18,98 @@
namespace QmlDesigner {
QmlTimelineKeyframeGroup::QmlTimelineKeyframeGroup() = default;
static auto category = ModelTracing::category;
QmlTimelineKeyframeGroup::QmlTimelineKeyframeGroup(const ModelNode &modelNode)
: QmlModelNodeFacade(modelNode)
{}
bool QmlTimelineKeyframeGroup::isValid() const
bool QmlTimelineKeyframeGroup::isValid(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group is valid",
category(),
keyValue("mode node", *this),
keyValue("caller location", sl)};
return isValidQmlTimelineKeyframeGroup(modelNode());
}
bool QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(const ModelNode &modelNode)
bool QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(const ModelNode &modelNode, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group is valid",
category(),
keyValue("model node", modelNode),
keyValue("caller location", sl)};
return modelNode.isValid() && modelNode.metaInfo().isQtQuickTimelineKeyframeGroup();
}
void QmlTimelineKeyframeGroup::destroy()
void QmlTimelineKeyframeGroup::destroy(SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group destroy",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
modelNode().destroy();
}
ModelNode QmlTimelineKeyframeGroup::target() const
ModelNode QmlTimelineKeyframeGroup::target(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group target",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
return modelNode().bindingProperty("target").resolveToModelNode();
}
void QmlTimelineKeyframeGroup::setTarget(const ModelNode &target)
void QmlTimelineKeyframeGroup::setTarget(const ModelNode &target, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group target",
category(),
keyValue("model node", *this),
keyValue("target", target),
keyValue("caller location", sl)};
ModelNode nonConstTarget = target;
modelNode().bindingProperty("target").setExpression(nonConstTarget.validId());
}
PropertyName QmlTimelineKeyframeGroup::propertyName() const
PropertyName QmlTimelineKeyframeGroup::propertyName(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group property name",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
return modelNode().variantProperty("property").value().toString().toUtf8();
}
void QmlTimelineKeyframeGroup::setPropertyName(PropertyNameView propertyName)
void QmlTimelineKeyframeGroup::setPropertyName(PropertyNameView propertyName, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group property name",
category(),
keyValue("model node", *this),
keyValue("property name", propertyName),
keyValue("caller location", sl)};
modelNode().variantProperty("property").setValue(QString::fromUtf8(propertyName));
}
int QmlTimelineKeyframeGroup::getSupposedTargetIndex(qreal newFrame) const
int QmlTimelineKeyframeGroup::getSupposedTargetIndex(qreal newFrame, SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group target index",
category(),
keyValue("model node", *this),
keyValue("new frame", newFrame),
keyValue("caller location", sl)};
const NodeListProperty nodeListProperty = modelNode().defaultNodeListProperty();
int i = 0;
for (const auto &node : nodeListProperty.toModelNodeList()) {
@@ -79,32 +126,56 @@ int QmlTimelineKeyframeGroup::getSupposedTargetIndex(qreal newFrame) const
return nodeListProperty.count();
}
int QmlTimelineKeyframeGroup::indexOfKeyframe(const ModelNode &frame) const
int QmlTimelineKeyframeGroup::indexOfKeyframe(const ModelNode &frame, SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group index of key frame",
category(),
keyValue("model node", *this),
keyValue("frame", frame),
keyValue("caller location", sl)};
if (!isValid())
return -1;
return modelNode().defaultNodeListProperty().indexOf(frame);
}
void QmlTimelineKeyframeGroup::slideKeyframe(int /*sourceIndex*/, int /*targetIndex*/)
void QmlTimelineKeyframeGroup::slideKeyframe(int /*sourceIndex*/, int /*targetIndex*/, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group slide key frame",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
/*
if (targetIndex != sourceIndex)
modelNode().defaultNodeListProperty().slide(sourceIndex, targetIndex);
*/
}
bool QmlTimelineKeyframeGroup::isRecording() const
bool QmlTimelineKeyframeGroup::isRecording(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group is recording",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
if (!isValid())
return false;
return modelNode().hasAuxiliaryData(recordProperty);
}
void QmlTimelineKeyframeGroup::toogleRecording(bool record) const
void QmlTimelineKeyframeGroup::toogleRecording(bool record, SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group toggle recording",
category(),
keyValue("model node", *this),
keyValue("record", record),
keyValue("caller location", sl)};
QTC_CHECK(isValid());
if (!record) {
@@ -115,26 +186,52 @@ void QmlTimelineKeyframeGroup::toogleRecording(bool record) const
}
}
QmlTimeline QmlTimelineKeyframeGroup::timeline() const
QmlTimeline QmlTimelineKeyframeGroup::timeline(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group timeline",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
QTC_CHECK(isValid());
return modelNode().parentProperty().parentModelNode();
}
bool QmlTimelineKeyframeGroup::isDangling(const ModelNode &node)
bool QmlTimelineKeyframeGroup::isDangling(const ModelNode &node, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group is dangling",
category(),
keyValue("model node", node),
keyValue("caller location", sl)};
QmlTimelineKeyframeGroup group{node};
return group.isDangling();
}
bool QmlTimelineKeyframeGroup::isDangling() const
bool QmlTimelineKeyframeGroup::isDangling(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group is dangling",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
return !target().isValid() || keyframes().isEmpty();
}
void QmlTimelineKeyframeGroup::setValue(const QVariant &value, qreal currentFrame)
void QmlTimelineKeyframeGroup::setValue(const QVariant &value, qreal currentFrame, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group set value",
category(),
keyValue("model node", *this),
keyValue("value", value),
keyValue("current frame", currentFrame),
keyValue("caller location", sl)};
if (!isValid())
return;
@@ -163,8 +260,15 @@ void QmlTimelineKeyframeGroup::setValue(const QVariant &value, qreal currentFram
slideKeyframe(sourceIndex, targetIndex);
}
QVariant QmlTimelineKeyframeGroup::value(qreal frame) const
QVariant QmlTimelineKeyframeGroup::value(qreal frame, SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group value",
category(),
keyValue("model node", *this),
keyValue("frame", frame),
keyValue("caller location", sl)};
QTC_CHECK(isValid());
for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) {
@@ -176,8 +280,14 @@ QVariant QmlTimelineKeyframeGroup::value(qreal frame) const
return QVariant();
}
NodeMetaInfo QmlTimelineKeyframeGroup::valueType() const
NodeMetaInfo QmlTimelineKeyframeGroup::valueType(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group value type",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
QTC_CHECK(isValid());
const ModelNode targetNode = target();
@@ -188,8 +298,15 @@ NodeMetaInfo QmlTimelineKeyframeGroup::valueType() const
return {};
}
bool QmlTimelineKeyframeGroup::hasKeyframe(qreal frame)
bool QmlTimelineKeyframeGroup::hasKeyframe(qreal frame, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group has key frame",
category(),
keyValue("model node", *this),
keyValue("frame", frame),
keyValue("caller location", sl)};
for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) {
if (qFuzzyCompare(childNode.variantProperty("frame").value().toReal(), frame))
return true;
@@ -198,8 +315,15 @@ bool QmlTimelineKeyframeGroup::hasKeyframe(qreal frame)
return false;
}
ModelNode QmlTimelineKeyframeGroup::keyframe(qreal frame) const
ModelNode QmlTimelineKeyframeGroup::keyframe(qreal frame, SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group key frame",
category(),
keyValue("model node", *this),
keyValue("frame", frame),
keyValue("caller location", sl)};
for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) {
if (qFuzzyCompare(childNode.variantProperty("frame").value().toReal(), frame))
return childNode;
@@ -208,8 +332,14 @@ ModelNode QmlTimelineKeyframeGroup::keyframe(qreal frame) const
return ModelNode();
}
qreal QmlTimelineKeyframeGroup::minActualKeyframe() const
qreal QmlTimelineKeyframeGroup::minActualKeyframe(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group min actual key frame",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
QTC_CHECK(isValid());
qreal min = std::numeric_limits<double>::max();
@@ -222,8 +352,14 @@ qreal QmlTimelineKeyframeGroup::minActualKeyframe() const
return min;
}
qreal QmlTimelineKeyframeGroup::maxActualKeyframe() const
qreal QmlTimelineKeyframeGroup::maxActualKeyframe(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group max actual key frame",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
QTC_CHECK(isValid());
qreal max = std::numeric_limits<double>::lowest();
@@ -236,30 +372,61 @@ qreal QmlTimelineKeyframeGroup::maxActualKeyframe() const
return max;
}
QList<ModelNode> QmlTimelineKeyframeGroup::keyframes() const
QList<ModelNode> QmlTimelineKeyframeGroup::keyframes(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group key frames",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
return modelNode().defaultNodeListProperty().toModelNodeList();
}
QList<ModelNode> QmlTimelineKeyframeGroup::keyframePositions() const
QList<ModelNode> QmlTimelineKeyframeGroup::keyframePositions(SL sl) const
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group key frame positions",
category(),
keyValue("model node", *this),
keyValue("caller location", sl)};
return Utils::filtered(modelNode().defaultNodeListProperty().toModelNodeList(), [](auto &&node) {
return node.variantProperty("frame").value().isValid();
});
}
bool QmlTimelineKeyframeGroup::isValidKeyframe(const ModelNode &node)
bool QmlTimelineKeyframeGroup::isValidKeyframe(const ModelNode &node, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group is valid key frame",
category(),
keyValue("model node", node),
keyValue("caller location", sl)};
return isValidQmlModelNodeFacade(node) && node.metaInfo().isQtQuickTimelineKeyframe();
}
bool QmlTimelineKeyframeGroup::checkKeyframesType(const ModelNode &node)
bool QmlTimelineKeyframeGroup::checkKeyframesType(const ModelNode &node, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group check keyframes type",
category(),
keyValue("model node", node),
keyValue("caller location", sl)};
return node.isValid() && node.type() == "QtQuick.Timeline.KeyframeGroup";
}
QmlTimelineKeyframeGroup QmlTimelineKeyframeGroup::keyframeGroupForKeyframe(const ModelNode &node)
QmlTimelineKeyframeGroup QmlTimelineKeyframeGroup::keyframeGroupForKeyframe(const ModelNode &node,
SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group for key frame",
category(),
keyValue("model node", node),
keyValue("caller location", sl)};
if (isValidKeyframe(node) && node.hasParentProperty()) {
const QmlTimelineKeyframeGroup timeline(node.parentProperty().parentModelNode());
if (timeline.isValid())
@@ -270,8 +437,14 @@ QmlTimelineKeyframeGroup QmlTimelineKeyframeGroup::keyframeGroupForKeyframe(cons
}
QList<QmlTimelineKeyframeGroup> QmlTimelineKeyframeGroup::allInvalidTimelineKeyframeGroups(
AbstractView *view)
AbstractView *view, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group all invalid timeline key frame groups",
category(),
keyValue("view", view),
keyValue("caller location", sl)};
QTC_CHECK(view);
QTC_CHECK(view->model());
@@ -286,8 +459,15 @@ QList<QmlTimelineKeyframeGroup> QmlTimelineKeyframeGroup::allInvalidTimelineKeyf
});
}
void QmlTimelineKeyframeGroup::moveAllKeyframes(qreal offset)
void QmlTimelineKeyframeGroup::moveAllKeyframes(qreal offset, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group move all key frames",
category(),
keyValue("model node", *this),
keyValue("offset", offset),
keyValue("caller location", sl)};
for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) {
auto property = childNode.variantProperty("frame");
if (property.isValid())
@@ -295,8 +475,15 @@ void QmlTimelineKeyframeGroup::moveAllKeyframes(qreal offset)
}
}
void QmlTimelineKeyframeGroup::scaleAllKeyframes(qreal factor)
void QmlTimelineKeyframeGroup::scaleAllKeyframes(qreal factor, SL sl)
{
using NanotraceHR::keyValue;
NanotraceHR::Tracer tracer{"qml timeline key frame group scale all key frames",
category(),
keyValue("model node", *this),
keyValue("factor", factor),
keyValue("caller location", sl)};
for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) {
auto property = childNode.variantProperty("frame");

View File

@@ -15,57 +15,62 @@ class QmlTimeline;
class QMLDESIGNER_EXPORT QmlTimelineKeyframeGroup final : public QmlModelNodeFacade
{
public:
QmlTimelineKeyframeGroup();
QmlTimelineKeyframeGroup(const ModelNode &modelNode);
QmlTimelineKeyframeGroup() = default;
bool isValid() const;
QmlTimelineKeyframeGroup(const ModelNode &modelNode)
: QmlModelNodeFacade(modelNode)
{}
bool isValid(SL sl = {}) const;
explicit operator bool() const { return isValid(); }
static bool isValidQmlTimelineKeyframeGroup(const ModelNode &modelNode);
void destroy();
ModelNode target() const;
void setTarget(const ModelNode &target);
static bool isValidQmlTimelineKeyframeGroup(const ModelNode &modelNode, SL sl = {});
void destroy(SL sl = {});
PropertyName propertyName() const;
void setPropertyName(PropertyNameView propertyName);
ModelNode target(SL sl = {}) const;
void setTarget(const ModelNode &target, SL sl = {});
void setValue(const QVariant &value, qreal frame);
QVariant value(qreal frame) const;
PropertyName propertyName(SL sl = {}) const;
void setPropertyName(PropertyNameView propertyName, SL sl = {});
NodeMetaInfo valueType() const;
void setValue(const QVariant &value, qreal frame, SL sl = {});
QVariant value(qreal frame, SL sl = {}) const;
qreal currentFrame() const;
NodeMetaInfo valueType(SL sl = {}) const;
bool hasKeyframe(qreal frame);
qreal currentFrame(SL sl = {}) const;
qreal minActualKeyframe() const;
qreal maxActualKeyframe() const;
bool hasKeyframe(qreal frame, SL sl = {});
ModelNode keyframe(qreal position) const;
qreal minActualKeyframe(SL sl = {}) const;
qreal maxActualKeyframe(SL sl = {}) const;
QList<ModelNode> keyframes() const;
ModelNode keyframe(qreal position, SL sl = {}) const;
QList<ModelNode> keyframePositions() const;
QList<ModelNode> keyframes(SL sl = {}) const;
static bool isValidKeyframe(const ModelNode &node);
static bool checkKeyframesType(const ModelNode &node);
static QmlTimelineKeyframeGroup keyframeGroupForKeyframe(const ModelNode &node);
static QList<QmlTimelineKeyframeGroup> allInvalidTimelineKeyframeGroups(AbstractView *view);
QList<ModelNode> keyframePositions(SL sl = {}) const;
void moveAllKeyframes(qreal offset);
void scaleAllKeyframes(qreal factor);
int getSupposedTargetIndex(qreal newFrame) const;
static bool isValidKeyframe(const ModelNode &node, SL sl = {});
static bool checkKeyframesType(const ModelNode &node, SL sl = {});
static QmlTimelineKeyframeGroup keyframeGroupForKeyframe(const ModelNode &node, SL sl = {});
static QList<QmlTimelineKeyframeGroup> allInvalidTimelineKeyframeGroups(AbstractView *view,
SL sl = {});
int indexOfKeyframe(const ModelNode &frame) const;
void slideKeyframe(int sourceIndex, int targetIndex);
void moveAllKeyframes(qreal offset, SL sl = {});
void scaleAllKeyframes(qreal factor, SL sl = {});
int getSupposedTargetIndex(qreal newFrame, SL sl = {}) const;
bool isRecording() const;
void toogleRecording(bool b) const;
int indexOfKeyframe(const ModelNode &frame, SL sl = {}) const;
void slideKeyframe(int sourceIndex, int targetIndex, SL sl = {});
QmlTimeline timeline() const;
bool isRecording(SL sl = {}) const;
void toogleRecording(bool b, SL sl = {}) const;
static bool isDangling(const ModelNode &node);
bool isDangling() const;
QmlTimeline timeline(SL sl = {}) const;
static bool isDangling(const ModelNode &node, SL sl = {});
bool isDangling(SL sl = {}) const;
};
} // namespace QmlDesigner