diff --git a/modules/editor/grapheditor/editor/graph/abstractnodegraph.cpp b/modules/editor/grapheditor/editor/graph/abstractnodegraph.cpp index 285c9d0c0..ea37331af 100644 --- a/modules/editor/grapheditor/editor/graph/abstractnodegraph.cpp +++ b/modules/editor/grapheditor/editor/graph/abstractnodegraph.cpp @@ -432,6 +432,13 @@ void AbstractNodeGraph::loadGraphV11(const QDomElement &parent) { list.push_back(it); } values[name] = list; + } else if(type == "Color") { + QVariantList list; + list.push_back(type); + for(auto &it : valueElement.text().split(", ")) { + list.push_back(it); + } + values[name] = list; } valueElement = valueElement.nextSiblingElement(); @@ -494,19 +501,27 @@ void AbstractNodeGraph::saveGraph(QDomElement parent, QDomDocument xml) const { valueElement.setAttribute(gName, value); QVariant v = values.value(value); - if(v.type() == QVariant::List) { - QVariantList list = v.toList(); - valueElement.setAttribute(gType, list.front().toString()); - list.pop_front(); - QString pack; - for(auto &it : list) { - pack += it.toString() + ", "; - } - pack.resize(pack.size() - 2); - valueElement.appendChild(xml.createTextNode(pack)); - } else { - valueElement.setAttribute(gType, v.typeName()); - valueElement.appendChild(xml.createTextNode(v.toString())); + switch(v.type()) { + case QVariant::List: { + QVariantList list = v.toList(); + QString type = list.front().toString(); + valueElement.setAttribute(gType, type); + list.pop_front(); + QString pack; + for(auto &it : list) { + pack += it.toString() + ", "; + } + pack.resize(pack.size() - 2); + valueElement.appendChild(xml.createTextNode(pack)); + } break; + default: { + QString type = v.typeName(); + if(type == "QString") { + type = "string"; + } + valueElement.setAttribute(gType, type); + valueElement.appendChild(xml.createTextNode(v.toString())); + } break; } nodeElement.appendChild(valueElement); diff --git a/modules/editor/grapheditor/editor/graph/graphnode.cpp b/modules/editor/grapheditor/editor/graph/graphnode.cpp index 0f434191c..bc2a5975e 100644 --- a/modules/editor/grapheditor/editor/graph/graphnode.cpp +++ b/modules/editor/grapheditor/editor/graph/graphnode.cpp @@ -87,7 +87,7 @@ void GraphNode::saveUserData(QVariantMap &data) { switch(value.userType()) { case QMetaType::QColor: { QVariantList v; - v.push_back(static_cast(QVariant::Color)); + v.push_back("Color"); QColor col = value.value(); v.push_back(col.red()); v.push_back(col.green()); @@ -140,30 +140,26 @@ void GraphNode::loadUserData(const QVariantMap &data) { for(QString key : data.keys()) { if(static_cast(data[key].type()) == QMetaType::QVariantList) { QVariantList array = data[key].toList(); - switch(array.first().toInt()) { - case QVariant::Color: { - setProperty(qPrintable(key), QColor(array.at(1).toInt(), array.at(2).toInt(), - array.at(3).toInt(), array.at(4).toInt())); - } break; - default: { - QString type = array.first().toString(); - if(type == "Template") { - setProperty(qPrintable(key), QVariant::fromValue(Template(array.at(1).toString(), - array.at(2).toUInt()))); - } else if(type == "Vector2") { - setProperty(qPrintable(key), QVariant::fromValue(Vector2(array.at(1).toFloat(), - array.at(2).toFloat()))); - } else if(type == "Vector3") { - setProperty(qPrintable(key), QVariant::fromValue(Vector3(array.at(1).toFloat(), - array.at(2).toFloat(), - array.at(3).toFloat()))); - } else if(type == "Vector4") { - setProperty(qPrintable(key), QVariant::fromValue(Vector4(array.at(1).toFloat(), - array.at(2).toFloat(), - array.at(3).toFloat(), - array.at(4).toFloat() ))); - } - } break; + + QString type = array.first().toString(); + if(type == "Color") { + setProperty(qPrintable(key), QColor(array.at(1).toInt(), array.at(2).toInt(), + array.at(3).toInt(), array.at(4).toInt())); + } else if(type == "Template") { + setProperty(qPrintable(key), QVariant::fromValue(Template(array.at(1).toString(), + array.at(2).toUInt()))); + } else if(type == "Vector2") { + setProperty(qPrintable(key), QVariant::fromValue(Vector2(array.at(1).toFloat(), + array.at(2).toFloat()))); + } else if(type == "Vector3") { + setProperty(qPrintable(key), QVariant::fromValue(Vector3(array.at(1).toFloat(), + array.at(2).toFloat(), + array.at(3).toFloat()))); + } else if(type == "Vector4") { + setProperty(qPrintable(key), QVariant::fromValue(Vector4(array.at(1).toFloat(), + array.at(2).toFloat(), + array.at(3).toFloat(), + array.at(4).toFloat() ))); } } else { setProperty(qPrintable(key), data[key]);