forked from qt-creator/qt-creator
QmlDesigner: Inspect components for existing states
For each created items we retrieve a list of the names of all existing states. Task-number: QDS-1978 Change-Id: I8e85e439fce3c6204cb8bcf69f6be847cc8dae5c Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -34,6 +34,7 @@ enum InformationName
|
|||||||
{
|
{
|
||||||
NoName,
|
NoName,
|
||||||
NoInformationChange = NoName,
|
NoInformationChange = NoName,
|
||||||
|
AllStates,
|
||||||
Size,
|
Size,
|
||||||
BoundingRect,
|
BoundingRect,
|
||||||
Transform,
|
Transform,
|
||||||
|
|||||||
@@ -1061,6 +1061,7 @@ static QVector<InformationContainer> createInformationVector(const QList<ServerN
|
|||||||
informationVector.append(InformationContainer(instance.instanceId(), PenWidth, instance.penWidth()));
|
informationVector.append(InformationContainer(instance.instanceId(), PenWidth, instance.penWidth()));
|
||||||
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren()));
|
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren()));
|
||||||
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling()));
|
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling()));
|
||||||
|
informationVector.append(InformationContainer(instance.instanceId(), AllStates, instance.allStates()));
|
||||||
|
|
||||||
informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.fill"), instance.hasAnchor("anchors.fill")));
|
informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.fill"), instance.hasAnchor("anchors.fill")));
|
||||||
informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.centerIn"), instance.hasAnchor("anchors.centerIn")));
|
informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.centerIn"), instance.hasAnchor("anchors.centerIn")));
|
||||||
|
|||||||
@@ -871,6 +871,11 @@ void ObjectNodeInstance::deactivateState()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList ObjectNodeInstance::allStates() const
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void ObjectNodeInstance::populateResetHashes()
|
void ObjectNodeInstance::populateResetHashes()
|
||||||
{
|
{
|
||||||
QmlPrivateGate::registerCustomData(object());
|
QmlPrivateGate::registerCustomData(object());
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ public:
|
|||||||
|
|
||||||
virtual void activateState();
|
virtual void activateState();
|
||||||
virtual void deactivateState();
|
virtual void deactivateState();
|
||||||
|
virtual QStringList allStates() const;
|
||||||
|
|
||||||
void populateResetHashes();
|
void populateResetHashes();
|
||||||
bool hasValidResetBinding(const PropertyName &propertyName) const;
|
bool hasValidResetBinding(const PropertyName &propertyName) const;
|
||||||
|
|||||||
@@ -232,6 +232,20 @@ QList<QQuickItem *> QuickItemNodeInstance::allItemsRecursive() const
|
|||||||
return itemList;
|
return itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList QuickItemNodeInstance::allStates() const
|
||||||
|
{
|
||||||
|
QStringList list;
|
||||||
|
|
||||||
|
QList<QObject*> stateList = DesignerSupport::statesForItem(quickItem());
|
||||||
|
for (QObject *state : stateList) {
|
||||||
|
QQmlProperty property(state, "name");
|
||||||
|
if (property.isValid())
|
||||||
|
list.append(property.read().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
QRectF QuickItemNodeInstance::contentItemBoundingBox() const
|
QRectF QuickItemNodeInstance::contentItemBoundingBox() const
|
||||||
{
|
{
|
||||||
if (contentItem()) {
|
if (contentItem()) {
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public:
|
|||||||
void doComponentComplete() override;
|
void doComponentComplete() override;
|
||||||
|
|
||||||
QList<QQuickItem*> allItemsRecursive() const override;
|
QList<QQuickItem*> allItemsRecursive() const override;
|
||||||
|
QStringList allStates() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit QuickItemNodeInstance(QQuickItem*);
|
explicit QuickItemNodeInstance(QQuickItem*);
|
||||||
|
|||||||
@@ -661,6 +661,14 @@ QList<ServerNodeInstance> ServerNodeInstance::stateInstances() const
|
|||||||
return m_nodeInstance->stateInstances();
|
return m_nodeInstance->stateInstances();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList ServerNodeInstance::allStates() const
|
||||||
|
{
|
||||||
|
if (isValid())
|
||||||
|
return m_nodeInstance->allStates();
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
Internal::ObjectNodeInstance::Pointer ServerNodeInstance::internalInstance() const
|
Internal::ObjectNodeInstance::Pointer ServerNodeInstance::internalInstance() const
|
||||||
{
|
{
|
||||||
return m_nodeInstance;
|
return m_nodeInstance;
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ public:
|
|||||||
QSharedPointer<Internal::ObjectNodeInstance> internalInstance() const;
|
QSharedPointer<Internal::ObjectNodeInstance> internalInstance() const;
|
||||||
|
|
||||||
QList<ServerNodeInstance> stateInstances() const;
|
QList<ServerNodeInstance> stateInstances() const;
|
||||||
|
QStringList allStates() const;
|
||||||
|
|
||||||
static bool isSubclassOf(QObject *object, const QByteArray &superTypeName);
|
static bool isSubclassOf(QObject *object, const QByteArray &superTypeName);
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ public:
|
|||||||
bool hasAnchors() const;
|
bool hasAnchors() const;
|
||||||
QString error() const;
|
QString error() const;
|
||||||
bool hasError() const;
|
bool hasError() const;
|
||||||
|
QStringList allStateNames() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setProperty(const PropertyName &name, const QVariant &value);
|
void setProperty(const PropertyName &name, const QVariant &value);
|
||||||
@@ -117,6 +118,7 @@ protected:
|
|||||||
InformationName setInformationAnchor(const PropertyName &sourceAnchorLine, const PropertyName &targetAnchorLine, qint32 targetInstanceId);
|
InformationName setInformationAnchor(const PropertyName &sourceAnchorLine, const PropertyName &targetAnchorLine, qint32 targetInstanceId);
|
||||||
InformationName setInformationInstanceTypeForProperty(const PropertyName &property, const TypeName &type);
|
InformationName setInformationInstanceTypeForProperty(const PropertyName &property, const TypeName &type);
|
||||||
InformationName setInformationHasBindingForProperty(const PropertyName &property, bool hasProperty);
|
InformationName setInformationHasBindingForProperty(const PropertyName &property, bool hasProperty);
|
||||||
|
InformationName setAllStates(const QStringList &states);
|
||||||
|
|
||||||
void setParentId(qint32 instanceId);
|
void setParentId(qint32 instanceId);
|
||||||
void setRenderPixmap(const QImage &image);
|
void setRenderPixmap(const QImage &image);
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public:
|
|||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
|
|
||||||
QHash<PropertyName, QPair<PropertyName, qint32> > anchors;
|
QHash<PropertyName, QPair<PropertyName, qint32> > anchors;
|
||||||
|
QStringList allStates;
|
||||||
};
|
};
|
||||||
|
|
||||||
NodeInstance::NodeInstance() = default;
|
NodeInstance::NodeInstance() = default;
|
||||||
@@ -169,6 +170,10 @@ bool NodeInstance::hasError() const
|
|||||||
return !d->errorMessage.isEmpty();
|
return !d->errorMessage.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList NodeInstance::allStateNames() const
|
||||||
|
{
|
||||||
|
return d->allStates;
|
||||||
|
}
|
||||||
|
|
||||||
bool NodeInstance::isValid() const
|
bool NodeInstance::isValid() const
|
||||||
{
|
{
|
||||||
@@ -592,6 +597,16 @@ InformationName NodeInstance::setInformationHasBindingForProperty(const Property
|
|||||||
return NoInformationChange;
|
return NoInformationChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InformationName NodeInstance::setAllStates(const QStringList &states)
|
||||||
|
{
|
||||||
|
if (d->allStates != states) {
|
||||||
|
d->allStates = states;
|
||||||
|
return AllStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NoInformationChange;
|
||||||
|
}
|
||||||
|
|
||||||
InformationName NodeInstance::setInformation(InformationName name, const QVariant &information, const QVariant &secondInformation, const QVariant &thirdInformation)
|
InformationName NodeInstance::setInformation(InformationName name, const QVariant &information, const QVariant &secondInformation, const QVariant &thirdInformation)
|
||||||
{
|
{
|
||||||
switch (name) {
|
switch (name) {
|
||||||
@@ -614,6 +629,7 @@ InformationName NodeInstance::setInformation(InformationName name, const QVarian
|
|||||||
case Anchor: return setInformationAnchor(information.toByteArray(), secondInformation.toByteArray(), thirdInformation.value<qint32>());
|
case Anchor: return setInformationAnchor(information.toByteArray(), secondInformation.toByteArray(), thirdInformation.value<qint32>());
|
||||||
case InstanceTypeForProperty: return setInformationInstanceTypeForProperty(information.toByteArray(), secondInformation.toByteArray());
|
case InstanceTypeForProperty: return setInformationInstanceTypeForProperty(information.toByteArray(), secondInformation.toByteArray());
|
||||||
case HasBindingForProperty: return setInformationHasBindingForProperty(information.toByteArray(), secondInformation.toBool());
|
case HasBindingForProperty: return setInformationHasBindingForProperty(information.toByteArray(), secondInformation.toBool());
|
||||||
|
case AllStates: return setAllStates(information.toStringList());
|
||||||
case NoName:
|
case NoName:
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user