This commit is contained in:
Martin Marmsoler
2020-10-02 15:49:35 +02:00
parent c8691b243b
commit 9521a8aa0b
2 changed files with 14 additions and 9 deletions

View File

@@ -878,8 +878,8 @@ Terminal* findTerminal(int conductor_index, QDomElement& conductor, QHash<int, T
QString element_index = "element" + QString::number(conductor_index); QString element_index = "element" + QString::number(conductor_index);
QString terminal_index = "terminal" + QString::number(conductor_index); QString terminal_index = "terminal" + QString::number(conductor_index);
if (conductor.hasAttribute(element_index)) { QUuid element_uuid;
QUuid element_uuid = QUuid(conductor.attribute(element_index)); if (PropertiesInterface::propertyUuid(conductor, element_index, &element_uuid) == PropertiesInterface::PropertyFlags::Success) {
// element1 did not exist in the conductor part of the xml until prior 0.7 // element1 did not exist in the conductor part of the xml until prior 0.7
// It is used as an indicator that uuid's are used to identify terminals // It is used as an indicator that uuid's are used to identify terminals
bool element_found = false; bool element_found = false;
@@ -887,7 +887,8 @@ Terminal* findTerminal(int conductor_index, QDomElement& conductor, QHash<int, T
if (element->uuid() != element_uuid) if (element->uuid() != element_uuid)
continue; continue;
element_found = true; element_found = true;
QUuid terminal_uuid = QUuid(conductor.attribute(terminal_index)); QUuid terminal_uuid;
PropertiesInterface::propertyUuid(conductor, terminal_index, &terminal_uuid);
for (auto terminal: element->terminals()) { for (auto terminal: element->terminals()) {
if (terminal->uuid() != terminal_uuid) if (terminal->uuid() != terminal_uuid)
continue; continue;
@@ -901,7 +902,10 @@ Terminal* findTerminal(int conductor_index, QDomElement& conductor, QHash<int, T
qDebug() << "Diagram::fromXml() : " << element_index << ": " << element_uuid << "not found"; qDebug() << "Diagram::fromXml() : " << element_index << ": " << element_uuid << "not found";
} else { } else {
// Backward compatibility. Until version 0.7 a generated id is used to link the terminal. // Backward compatibility. Until version 0.7 a generated id is used to link the terminal.
int id_p1 = conductor.attribute(terminal_index).toInt(); int id_p1 = -1;
if (PropertiesInterface::propertyInteger(conductor, terminal_index, &id_p1) != PropertiesInterface::PropertyFlags::Success) {
qDebug() << "diagramm.cpp:findTerminal(): Reading Id was not successfull";
}
if (!table_adr_id.contains(id_p1)) { if (!table_adr_id.contains(id_p1)) {
qDebug() << "Diagram::fromXml() : terminal id " << id_p1 << " not found"; qDebug() << "Diagram::fromXml() : terminal id " << id_p1 << " not found";
} else } else
@@ -1078,14 +1082,14 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
// Load conductor // Load conductor
QList<Conductor *> added_conductors; QList<Conductor *> added_conductors;
foreach (QDomElement f, QET::findInDomElement(root, "conductors", "conductor")) foreach (QDomElement conductorElement, QET::findInDomElement(root, "conductors", "conductor"))
{ {
if (!Conductor::valideXml(f)) continue; if (!Conductor::valideXml(conductorElement)) continue;
//Check if terminal that conductor must be linked is know //Check if terminal that conductor must be linked is know
Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements); Terminal* p1 = findTerminal(1, conductorElement, table_adr_id, added_elements);
Terminal* p2 = findTerminal(2, f, table_adr_id, added_elements); Terminal* p2 = findTerminal(2, conductorElement, table_adr_id, added_elements);
if (p1 && p2 && p1 != p2) // why the condition for unequal is required? if (p1 && p2 && p1 != p2) // why the condition for unequal is required?
{ {
@@ -1093,7 +1097,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
if (c->isValid()) if (c->isValid())
{ {
addItem(c); addItem(c);
c -> fromXml(f); c -> fromXml(conductorElement);
added_conductors << c; added_conductors << c;
} }
else else

View File

@@ -734,6 +734,7 @@ QDomElement Terminal::toXml(QDomDocument &doc) const {
// Do not store terminal data in its own child // Do not store terminal data in its own child
QDomElement terminalDataElement = d->toXml(doc); QDomElement terminalDataElement = d->toXml(doc);
int y = terminalDataElement.().length(); // TODO: seems to be not correct!
for (int i=0; i < terminalDataElement.childNodes().length(); i++) { for (int i=0; i < terminalDataElement.childNodes().length(); i++) {
qdo.appendChild(terminalDataElement.childNodes().at(i)); qdo.appendChild(terminalDataElement.childNodes().at(i));
} }