forked from qt-creator/qt-creator
QmlDesigner: Implement new functions in QmlObjectNode and QmlTimelineKeyframeGroup
* QmlObjectNode::allInvalidStateOperations * QmlTimelineKeyframeGroup::allInvalidTimelineKeyframeGroups These functions make it easy to find dangling/invalid PropertyChanges and KeyFrameGroups. Change-Id: I201a6561a51aba53405e8a8fc92821c467fecb1b Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
committed by
Thomas Hartmann
parent
50557abd03
commit
8f974cd1c5
@@ -128,14 +128,13 @@ public:
|
||||
virtual bool isBlocked(const PropertyName &propName) const;
|
||||
|
||||
friend auto qHash(const QmlObjectNode &node) { return qHash(node.modelNode()); }
|
||||
QList<QmlModelState> allDefinedStates() const;
|
||||
QList<QmlModelStateOperation> allInvalidStateOperations() const;
|
||||
|
||||
protected:
|
||||
NodeInstance nodeInstance() const;
|
||||
QmlObjectNode nodeForInstance(const NodeInstance &instance) const;
|
||||
QmlItemNode itemForInstance(const NodeInstance &instance) const;
|
||||
|
||||
protected:
|
||||
QList<QmlModelState> allDefinedStates() const;
|
||||
};
|
||||
|
||||
QMLDESIGNERCORE_EXPORT QList<ModelNode> toModelNodeList(const QList<QmlObjectNode> &fxObjectNodeList);
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
QList<QmlModelStateOperation> stateOperations(const ModelNode &node) const;
|
||||
QList<QmlPropertyChanges> propertyChanges() const;
|
||||
QList<QmlModelStateOperation> stateOperations() const;
|
||||
QList<QmlModelStateOperation> allInvalidStateOperations() const;
|
||||
|
||||
bool hasPropertyChanges(const ModelNode &node) const;
|
||||
|
||||
|
@@ -72,6 +72,7 @@ public:
|
||||
static bool isValidKeyframe(const ModelNode &node);
|
||||
static bool checkKeyframesType(const ModelNode &node);
|
||||
static QmlTimelineKeyframeGroup keyframeGroupForKeyframe(const ModelNode &node);
|
||||
static QList<QmlTimelineKeyframeGroup> allInvalidTimelineKeyframeGroups(AbstractView *view);
|
||||
|
||||
void moveAllKeyframes(qreal offset);
|
||||
void scaleAllKeyframes(qreal factor);
|
||||
@@ -84,6 +85,8 @@ public:
|
||||
void toogleRecording(bool b) const;
|
||||
|
||||
QmlTimeline timeline() const;
|
||||
|
||||
bool isDangling() const;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -523,6 +523,16 @@ QList<QmlModelState> QmlObjectNode::allDefinedStates() const
|
||||
return returnList;
|
||||
}
|
||||
|
||||
QList<QmlModelStateOperation> QmlObjectNode::allInvalidStateOperations() const
|
||||
{
|
||||
QList<QmlModelStateOperation> result;
|
||||
|
||||
const auto allStates = allDefinedStates();
|
||||
for (const auto &state : allStates)
|
||||
result.append(state.allInvalidStateOperations());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Removes a variant property of the object specified by \a name from the
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include "qmlitemnode.h"
|
||||
#include "annotation.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -136,6 +137,12 @@ QList<QmlModelStateOperation> QmlModelState::stateOperations() const
|
||||
return returnList;
|
||||
}
|
||||
|
||||
QList<QmlModelStateOperation> QmlModelState::allInvalidStateOperations() const
|
||||
{
|
||||
return Utils::filtered(stateOperations(), [](const QmlModelStateOperation &operation) {
|
||||
return !operation.target().isValid();
|
||||
});
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds a change set for \a node to this state, but only if it does not
|
||||
|
@@ -153,6 +153,13 @@ QmlTimeline QmlTimelineKeyframeGroup::timeline() const
|
||||
return {};
|
||||
}
|
||||
|
||||
bool QmlTimelineKeyframeGroup::isDangling() const
|
||||
{
|
||||
QTC_ASSERT(isValid(), return false);
|
||||
|
||||
return !target().isValid() || keyframes().isEmpty();
|
||||
}
|
||||
|
||||
void QmlTimelineKeyframeGroup::setValue(const QVariant &value, qreal currentFrame)
|
||||
{
|
||||
QTC_ASSERT(isValid(), return );
|
||||
@@ -294,6 +301,22 @@ QmlTimelineKeyframeGroup QmlTimelineKeyframeGroup::keyframeGroupForKeyframe(cons
|
||||
return QmlTimelineKeyframeGroup();
|
||||
}
|
||||
|
||||
QList<QmlTimelineKeyframeGroup> QmlTimelineKeyframeGroup::allInvalidTimelineKeyframeGroups(AbstractView *view)
|
||||
{
|
||||
QList<QmlTimelineKeyframeGroup> ret;
|
||||
|
||||
QTC_ASSERT(view, return ret);
|
||||
QTC_ASSERT(view->model(), return ret);
|
||||
QTC_ASSERT(view->rootModelNode().isValid(), return ret);
|
||||
|
||||
const auto groups = view->rootModelNode().subModelNodesOfType("QtQuick.Timeline.KeyframeGroup");
|
||||
for (const QmlTimelineKeyframeGroup &group : groups) {
|
||||
if (group.isDangling())
|
||||
ret.append(group);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void QmlTimelineKeyframeGroup::moveAllKeyframes(qreal offset)
|
||||
{
|
||||
for (const ModelNode &childNode : modelNode().defaultNodeListProperty().toModelNodeList()) {
|
||||
|
Reference in New Issue
Block a user