aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2020-08-17 14:24:01 +0200
committerMarco Bubke <marco.bubke@qt.io>2020-08-17 14:45:22 +0000
commitfcabab7b5f232c48c13cd36062517cc8f60da761 (patch)
treebffb25a96dbd0ea937938fa697f63ae00bcdacd6 /share
parent96f0d2517f4da4fb0e5564ec59adc89153e614bf (diff)
QmlDesigner: Extend captured data
Change-Id: I780815e6f42be4f3aceb1d784a685cc330572832 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h39
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp18
2 files changed, 45 insertions, 12 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h b/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h
index c7950e278b..c9d626e434 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h
+++ b/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h
@@ -29,11 +29,41 @@
#include "imagecontainer.h"
+#include <utils/smallstringio.h>
+
namespace QmlDesigner {
class CapturedDataCommand
{
public:
+ struct Property
+ {
+ Property() = default;
+ Property(QString key, QVariant value)
+ : key(std::move(key))
+ , value(std::move(value))
+ {}
+
+ friend QDataStream &operator<<(QDataStream &out, const Property &property)
+ {
+ out << property.key;
+ out << property.value;
+
+ return out;
+ }
+
+ friend QDataStream &operator>>(QDataStream &in, Property &property)
+ {
+ in >> property.key;
+ in >> property.value;
+
+ return in;
+ }
+
+ QString key;
+ QVariant value;
+ };
+
struct NodeData
{
friend QDataStream &operator<<(QDataStream &out, const NodeData &data)
@@ -41,7 +71,7 @@ public:
out << data.nodeId;
out << data.contentRect;
out << data.sceneTransform;
- out << data.text;
+ out << data.properties;
return out;
}
@@ -51,7 +81,7 @@ public:
in >> data.nodeId;
in >> data.contentRect;
in >> data.sceneTransform;
- in >> data.text;
+ in >> data.properties;
return in;
}
@@ -59,7 +89,7 @@ public:
qint32 nodeId = -1;
QRectF contentRect;
QTransform sceneTransform;
- QString text;
+ std::vector<Property> properties;
};
struct StateData
@@ -81,7 +111,8 @@ public:
}
ImageContainer image;
- QVector<NodeData> nodeData;
+ std::vector<NodeData> nodeData;
+ qint32 nodeId = -1;
};
friend QDataStream &operator<<(QDataStream &out, const CapturedDataCommand &command)
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp
index aea75a76c7..f1e2a3a475 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturenodeinstanceserver.cpp
@@ -56,17 +56,19 @@ CapturedDataCommand::StateData collectStateData(ServerNodeInstance rootNodeInsta
stateData.image = ImageContainer(stateInstanceId,
QmlDesigner::renderPreviewImage(rootNodeInstance),
stateInstanceId);
+ stateData.nodeId = stateInstanceId;
for (const ServerNodeInstance &instance : nodeInstances) {
+ CapturedDataCommand::NodeData nodeData;
+
+ nodeData.nodeId = instance.instanceId();
+ nodeData.contentRect = instance.contentItemBoundingRect();
+ nodeData.sceneTransform = instance.sceneTransform();
auto textProperty = instance.property("text");
- if (!textProperty.isNull() && instance.holdsGraphical()) {
- CapturedDataCommand::NodeData nodeData;
- nodeData.nodeId = instance.instanceId();
- nodeData.contentRect = instance.contentItemBoundingRect();
- nodeData.sceneTransform = instance.sceneTransform();
- nodeData.text = textProperty.toString();
- stateData.nodeData.push_back(std::move(nodeData));
- }
+ if (!textProperty.isNull() && instance.holdsGraphical())
+ nodeData.properties.emplace_back(QString{"text"}, textProperty.toString());
+
+ stateData.nodeData.push_back(std::move(nodeData));
}
return stateData;