mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Better handling of conductors when creating from XML
The position of a conductor is determined by the two terminals the conductor connects. Therefore, it makes no sense to set the position with 'setPos()'. It is better to first load all elements (but not the conductors), position them if necessary, and only then load the conductors and assign them to the elements (terminals).
This commit is contained in:
parent
0a6efa466e
commit
96d84bf852
@ -1438,33 +1438,6 @@ bool Diagram::fromXml(QDomElement &document,
|
||||
added_shapes << dii;
|
||||
}
|
||||
|
||||
// Load conductor
|
||||
QList<Conductor *> added_conductors;
|
||||
for (auto f : QET::findInDomElement(root,
|
||||
QStringLiteral("conductors"),
|
||||
QStringLiteral("conductor")))
|
||||
{
|
||||
if (!Conductor::valideXml(f)) continue;
|
||||
|
||||
//Check if terminal that conductor must be linked is know
|
||||
|
||||
Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements);
|
||||
Terminal* p2 = findTerminal(2, f, table_adr_id, added_elements);
|
||||
|
||||
if (p1 && p2 && p1 != p2)
|
||||
{
|
||||
Conductor *c = new Conductor(p1, p2);
|
||||
if (c->isValid())
|
||||
{
|
||||
addItem(c);
|
||||
c -> fromXml(f);
|
||||
added_conductors << c;
|
||||
}
|
||||
else
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
//Load tables
|
||||
QVector<QetGraphicsTableItem *> added_tables;
|
||||
for (const auto &dom_table : QETXML::subChild(root,
|
||||
@ -1485,7 +1458,6 @@ bool Diagram::fromXml(QDomElement &document,
|
||||
{
|
||||
QVector <QGraphicsItem *> added_items;
|
||||
for (auto element : qAsConst(added_elements )) added_items << element;
|
||||
for (auto cond : qAsConst(added_conductors )) added_items << cond;
|
||||
for (auto shape : qAsConst(added_shapes )) added_items << shape;
|
||||
for (auto text : qAsConst(added_texts )) added_items << text;
|
||||
for (auto image : qAsConst(added_images )) added_items << image;
|
||||
@ -1510,6 +1482,33 @@ bool Diagram::fromXml(QDomElement &document,
|
||||
qgi->setPos(qgi->pos() += pos_);
|
||||
}
|
||||
|
||||
// Load conductor
|
||||
QList<Conductor *> added_conductors;
|
||||
for (auto f : QET::findInDomElement(root,
|
||||
QStringLiteral("conductors"),
|
||||
QStringLiteral("conductor")))
|
||||
{
|
||||
if (!Conductor::valideXml(f)) continue;
|
||||
|
||||
//Check if terminal that conductor must be linked is know
|
||||
|
||||
Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements);
|
||||
Terminal* p2 = findTerminal(2, f, table_adr_id, added_elements);
|
||||
|
||||
if (p1 && p2 && p1 != p2)
|
||||
{
|
||||
Conductor *c = new Conductor(p1, p2);
|
||||
if (c->isValid())
|
||||
{
|
||||
addItem(c);
|
||||
c -> fromXml(f);
|
||||
added_conductors << c;
|
||||
}
|
||||
else
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
//Filling of falculatory lists
|
||||
if (content_ptr) {
|
||||
content_ptr -> m_elements = added_elements;
|
||||
|
Loading…
x
Reference in New Issue
Block a user