summaryrefslogtreecommitdiff
path: root/src/diagramconnection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/diagramconnection.cpp')
-rw-r--r--src/diagramconnection.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/diagramconnection.cpp b/src/diagramconnection.cpp
index 1b1865a..545f9bf 100644
--- a/src/diagramconnection.cpp
+++ b/src/diagramconnection.cpp
@@ -15,6 +15,8 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#include "diagramconnection.h"
+#include "diagramdocument.h"
+#include "diagramobject.h"
DiagramConnection::DiagramConnection(DiagramItem *parent)
: DiagramItem(parent)
@@ -42,3 +44,32 @@ void
DiagramConnection::updatePositions()
{
}
+
+#include "domutils.h"
+
+void
+DiagramConnection::loadFromXml(QDomElement element, DiagramDocument *document)
+{
+ DiagramItem::loadFromXml(element, document);
+ QDomElement connectionElement = element.firstChildElement("connection");
+ if (!connectionElement.isNull()) {
+ QString sourceId = readStringElement(connectionElement, "source");
+ QString targetId = readStringElement(connectionElement, "target");
+ if (document) {
+ setSource(qobject_cast<DiagramObject *>(document->itemById(sourceId)));
+ setTarget(qobject_cast<DiagramObject *>(document->itemById(targetId)));
+ }
+ }
+}
+
+void
+DiagramConnection::saveToXml(QDomDocument doc, QDomElement element)
+{
+ DiagramItem::saveToXml(doc, element);
+ QDomElement connectionElement = doc.createElement("connection");
+ element.appendChild(connectionElement);
+ if (m_objects[0] != NULL)
+ appendStringElement(doc, connectionElement, "source", m_objects[0]->id());
+ if (m_objects[1] != NULL)
+ appendStringElement(doc, connectionElement, "target", m_objects[1]->id());
+}