mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Fix issue that conductors where connected wrong. This was, because instead of reusing the id's stored in the Terminal, new id's where created
This commit is contained in:
parent
52f886e34b
commit
0cc6558281
@ -750,12 +750,11 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
||||
}
|
||||
|
||||
// table de correspondance entre les adresses des bornes et leurs ids
|
||||
QHash<Terminal *, int> table_adr_id;
|
||||
|
||||
if (!list_elements.isEmpty()) {
|
||||
auto dom_elements = document.createElement("elements");
|
||||
for (auto elmt : list_elements) {
|
||||
dom_elements.appendChild(elmt->toXml(document, table_adr_id));
|
||||
dom_elements.appendChild(elmt->toXml(document));
|
||||
}
|
||||
dom_root.appendChild(dom_elements);
|
||||
}
|
||||
@ -763,7 +762,6 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
||||
if (!list_conductors.isEmpty()) {
|
||||
auto dom_conductors = document.createElement("conductors");
|
||||
for (auto cond : list_conductors) {
|
||||
//dom_conductors.appendChild(cond->toXml(document, table_adr_id));
|
||||
dom_conductors.appendChild(cond->toXml(document));
|
||||
}
|
||||
dom_root.appendChild(dom_conductors);
|
||||
|
@ -108,8 +108,7 @@ QDomDocument ExportElementTextPattern::xmlConf() const
|
||||
root.setAttribute("name", m_name);
|
||||
doc.appendChild(root);
|
||||
|
||||
QHash<Terminal *, int> H;
|
||||
QDomElement elmt = m_element->toXml(doc, H);
|
||||
QDomElement elmt = m_element->toXml(doc);
|
||||
QDomElement texts = elmt.firstChildElement("dynamic_texts");
|
||||
QDomElement groups = elmt.firstChildElement("texts_groups");
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
methode
|
||||
@return L'element XML representant cet element electrique
|
||||
*/
|
||||
QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table_adr_id) const
|
||||
QDomElement Element::toXml(QDomDocument &document) const
|
||||
{
|
||||
QDomElement element = document.createElement("element");
|
||||
|
||||
@ -1050,25 +1050,16 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
element.setAttribute("z", QString::number(this->zValue()));
|
||||
element.setAttribute("orientation", QString::number(orientation()));
|
||||
|
||||
/* recupere le premier id a utiliser pour les bornes de cet element */
|
||||
int id_terminal = 0;
|
||||
if (!table_adr_id.isEmpty()) {
|
||||
// trouve le plus grand id
|
||||
int max_id_t = -1;
|
||||
foreach (int id_t, table_adr_id.values()) {
|
||||
if (id_t > max_id_t) max_id_t = id_t;
|
||||
}
|
||||
id_terminal = max_id_t + 1;
|
||||
}
|
||||
|
||||
// enregistrement des bornes de l'appareil
|
||||
QDomElement xml_terminals = document.createElement("terminals");
|
||||
// pour chaque enfant de l'element
|
||||
foreach(Terminal *t, terminals()) {
|
||||
// alors on enregistre la borne
|
||||
QDomElement terminal = t -> toXml(document);
|
||||
terminal.setAttribute("id", id_terminal); // for backward compatibility
|
||||
table_adr_id.insert(t, id_terminal ++);
|
||||
if (t->ID() > 0) {
|
||||
// for backward compatibility
|
||||
terminal.setAttribute("id", t->ID()); // for backward compatibility
|
||||
}
|
||||
xml_terminals.appendChild(terminal);
|
||||
}
|
||||
element.appendChild(xml_terminals);
|
||||
|
@ -113,7 +113,7 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
|
||||
void editProperty() override;
|
||||
static bool valideXml(QDomElement &);
|
||||
virtual bool fromXml(QDomElement &, QHash<int, Terminal *> &, bool = false);
|
||||
virtual QDomElement toXml(QDomDocument &, QHash<Terminal *, int> &) const;
|
||||
virtual QDomElement toXml(QDomDocument &) const;
|
||||
QUuid uuid() const;
|
||||
int orientation() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user