nodes: implementing saving/loading node positions from project file
This commit is contained in:
+12
-1
@@ -26,15 +26,25 @@
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
Node* XMLLoadNode(QXmlStreamReader* reader) {
|
||||
Node* XMLLoadNode(QXmlStreamReader* reader)
|
||||
{
|
||||
QString node_id;
|
||||
quintptr node_ptr = 0;
|
||||
QPointF node_pos;
|
||||
|
||||
XMLAttributeLoop(reader, attr) {
|
||||
if (attr.name() == QStringLiteral("id")) {
|
||||
node_id = attr.value().toString();
|
||||
} else if (attr.name() == QStringLiteral("ptr")) {
|
||||
node_ptr = attr.value().toULongLong();
|
||||
} else if (attr.name() == QStringLiteral("pos")) {
|
||||
QStringList pos = attr.value().toString().split(':');
|
||||
|
||||
// Protection in case this file has been messed with
|
||||
if (pos.size() == 2) {
|
||||
node_pos.setX(pos.at(0).toDouble());
|
||||
node_pos.setY(pos.at(1).toDouble());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +57,7 @@ Node* XMLLoadNode(QXmlStreamReader* reader) {
|
||||
|
||||
if (node) {
|
||||
node->setProperty("xml_ptr", node_ptr);
|
||||
node->SetPosition(node_pos);
|
||||
} else {
|
||||
qWarning() << "Failed to load" << node_id << "- no node with that ID is installed";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user