From 0fbadc727dcfb0e7524a3fd60e51ecf325999674 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sun, 14 Mar 2021 08:29:26 +0100 Subject: [PATCH] store terminalData in the terminal tag. Fixes the drag problem from the collection into the diagram. The problem was that some tags missed and therefore the creation of the element for dragging was unsuccessful --- sources/editor/graphicspart/partterminal.cpp | 12 +++++++++++- sources/properties/terminaldata.h | 6 ++++-- sources/qetgraphicsitem/terminal.cpp | 12 +++++++++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/sources/editor/graphicspart/partterminal.cpp b/sources/editor/graphicspart/partterminal.cpp index c5830eb8e..873468414 100644 --- a/sources/editor/graphicspart/partterminal.cpp +++ b/sources/editor/graphicspart/partterminal.cpp @@ -78,7 +78,17 @@ void PartTerminal::toXmlPriv(QDomElement& e) const { d->m_pos = pos(); QDomDocument doc = e.ownerDocument(); - e.appendChild(d -> toXml(doc)); + QDomElement terminalData = d -> toXml(doc); + + // Copy everything from terminalData to terminal + for (int i=0; i < terminalData.attributes().count(); i++) { + QDomAttr attr = terminalData.attributes().item(i).toAttr(); + e.setAttribute(attr.name(), attr.value()); + } +// for (int i=0; i < terminalData.childNodes().count(); i++) { +// e.appendChild(terminalData.childNodes().at(i)); +// } + } diff --git a/sources/properties/terminaldata.h b/sources/properties/terminaldata.h index 6690c9c78..753d1b8bd 100644 --- a/sources/properties/terminaldata.h +++ b/sources/properties/terminaldata.h @@ -56,14 +56,16 @@ class TerminalData : public PropertiesInterface const QString& prefix = QString()) const override; void fromSettings(QSettings &settings, const QString& = QString()) override; - void toXmlPriv(QDomElement &xml_element) const override; - bool fromXmlPriv(const QDomElement &xml_element) override; static bool valideXml(const QDomElement &xml_element); static QString typeToString(TerminalData::Type type); static TerminalData::Type typeFromString(const QString &string); +private: + void toXmlPriv(QDomElement &xml_element) const override; + bool fromXmlPriv(const QDomElement &xml_element) override; + // must be public, because this class is a private member // of PartTerminal/Terminal and they must access this data public: diff --git a/sources/qetgraphicsitem/terminal.cpp b/sources/qetgraphicsitem/terminal.cpp index d6484524d..7bdc29933 100644 --- a/sources/qetgraphicsitem/terminal.cpp +++ b/sources/qetgraphicsitem/terminal.cpp @@ -771,8 +771,18 @@ void Terminal::toXmlPriv(QDomElement &qdo) const // Bad hack. The problem is that in the diagrams the terminal is described by the position and in the Collection by the dock. QPointF tempPos = d->m_pos; d->m_pos = dock_elmt_; - d->toXmlPriv(qdo); // TerminalData + QDomDocument doc = qdo.ownerDocument(); + QDomElement terminalData = d->toXml(doc); // TerminalData d->m_pos = tempPos; + + // Copy everything from terminalData to terminal + for (int i=0; i < terminalData.attributes().count(); i++) { + QDomAttr attr = terminalData.attributes().item(i).toAttr(); + qdo.setAttribute(attr.name(), attr.value()); + } +// for (int i=0; i < terminalData.childNodes().count(); i++) { +// qdo.appendChild(terminalData.childNodes().at(i)); +// } } /**