From 0cf95269987931e0315fa902cc467eaf314a8a6d Mon Sep 17 00:00:00 2001 From: Lukáš Lalinský Date: Tue, 30 Dec 2008 10:47:25 +0100 Subject: Rename DiagramConnection to Line --- src/boxsidehub.cpp | 4 +- src/commands.cpp | 6 +-- src/commands.h | 4 +- src/connector.cpp | 8 ++-- src/connector.h | 8 ++-- src/diagramconnection.cpp | 69 ----------------------------- src/diagramconnection.h | 51 --------------------- src/diagramdocument.cpp | 12 ++--- src/diagramdocument.h | 4 +- src/diagramobject.h | 2 +- src/items/database/databasecommands.cpp | 2 +- src/items/database/databaserelationship.cpp | 6 +-- src/items/database/databaserelationship.h | 4 +- src/line.cpp | 69 +++++++++++++++++++++++++++++ src/line.h | 48 ++++++++++++++++++++ src/src.pri | 4 +- 16 files changed, 149 insertions(+), 152 deletions(-) delete mode 100644 src/diagramconnection.cpp delete mode 100644 src/diagramconnection.h create mode 100644 src/line.cpp create mode 100644 src/line.h diff --git a/src/boxsidehub.cpp b/src/boxsidehub.cpp index 28728f8..1cba872 100644 --- a/src/boxsidehub.cpp +++ b/src/boxsidehub.cpp @@ -19,7 +19,7 @@ #include #include "connector.h" #include "diagramobject.h" -#include "diagramconnection.h" +#include "line.h" #include "boxsidehub.h" BoxSideHub::BoxSideHub(DiagramObject *owner) @@ -72,7 +72,7 @@ BoxSideHub::update() QRectF rect = item->boundingRect().translated(item->pos()); qDebug() << this; foreach (Connector *connector, connectors()) { - DiagramConnection *connection = connector->owner(); + Line *connection = connector->owner(); Connector *connector1 = connection->connector(0); Connector *connector2 = connection->connector(1); DiagramObject *item1, *item2; diff --git a/src/commands.cpp b/src/commands.cpp index 4d6a5bb..70f0f94 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -16,7 +16,7 @@ #include #include "commands.h" -#include "diagramconnection.h" +#include "line.h" #include "diagramdocument.h" #include "diagramitem.h" #include "diagramobject.h" @@ -145,7 +145,7 @@ RemoveObjectCommand::~RemoveObjectCommand() void RemoveObjectCommand::redo() { - foreach (DiagramConnection *connection, m_connections) + foreach (Line *connection, m_connections) m_document->removeItem(connection); m_document->removeItem(m_object); m_owner = true; @@ -155,7 +155,7 @@ void RemoveObjectCommand::undo() { m_document->addItem(m_object); - foreach (DiagramConnection *connection, m_connections) { + foreach (Line *connection, m_connections) { m_document->addItem(connection); } m_owner = false; diff --git a/src/commands.h b/src/commands.h index a763236..76dbbf5 100644 --- a/src/commands.h +++ b/src/commands.h @@ -23,7 +23,7 @@ #include #include -class DiagramConnection; +class Line; class DiagramDocument; class DiagramItem; class DiagramObject; @@ -95,7 +95,7 @@ public: protected: DiagramDocument *m_document; DiagramObject *m_object; - QList m_connections; + QList m_connections; bool m_owner; }; diff --git a/src/connector.cpp b/src/connector.cpp index 62159a6..123971d 100644 --- a/src/connector.cpp +++ b/src/connector.cpp @@ -16,14 +16,14 @@ #include "connector.h" #include "hub.h" -#include "diagramconnection.h" +#include "line.h" -Connector::Connector(DiagramConnection *owner) +Connector::Connector(Line *owner) : m_owner(owner), m_hub(NULL) { } -DiagramConnection * +Line * Connector::owner() const { return m_owner; @@ -91,7 +91,7 @@ Connector::connectedObject() const Connector * Connector::otherEnd() const { - DiagramConnection *conn = owner(); + Line *conn = owner(); if (conn->connector(0) == this) { return conn->connector(1); } diff --git a/src/connector.h b/src/connector.h index f1b6b74..0d2ede2 100644 --- a/src/connector.h +++ b/src/connector.h @@ -18,15 +18,15 @@ #define CONNECTOR_H #include -class DiagramConnection; +class Line; class DiagramObject; class Hub; class Connector { public: - Connector(DiagramConnection *owner); - DiagramConnection *owner() const; + Connector(Line *owner); + Line *owner() const; QPointF pos() const; void setPos(const QPointF &pos); @@ -45,7 +45,7 @@ public: private: QPointF m_pos; qreal m_angle; - DiagramConnection *m_owner; + Line *m_owner; Hub *m_hub; }; diff --git a/src/diagramconnection.cpp b/src/diagramconnection.cpp deleted file mode 100644 index 1c8d73b..0000000 --- a/src/diagramconnection.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2008 Lukas Lalinsky -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -#include "diagramconnection.h" -#include "diagramdocument.h" -#include "diagramobject.h" -#include "connector.h" - -DiagramConnection::DiagramConnection(DiagramItem *parent) - : DiagramItem(parent) -{ - m_connectors[0] = new Connector(this); - m_connectors[1] = new Connector(this); - setZValue(1.0); -} - -Connector * -DiagramConnection::connector(int index) const -{ - Q_ASSERT(index == 0 || index == 1); - return m_connectors[index]; -} - -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(document->itemById(sourceId))); - setTarget(qobject_cast(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());*/ -} diff --git a/src/diagramconnection.h b/src/diagramconnection.h deleted file mode 100644 index 66ad706..0000000 --- a/src/diagramconnection.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2008 Lukas Lalinsky -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -#ifndef DIAGRAMCONNECTION_H -#define DIAGRAMCONNECTION_H - -#include "diagramitem.h" -class Connector; -class DiagramObject; - -class DiagramConnection : public DiagramItem -{ - Q_OBJECT - -public: - DiagramConnection(DiagramItem *parent = 0); - - enum LineLayout - { - StraightLineLayout, - OrthogonalLineLayout - }; - - Connector *connector(int index) const; - - virtual void updatePositions(); - - virtual void loadFromXml(QDomElement element, DiagramDocument *document = 0); - void saveToXml(QDomDocument doc, QDomElement element); - -signals: - void endPointChanged(); - -private: - Connector *m_connectors[2]; -}; - -#endif diff --git a/src/diagramdocument.cpp b/src/diagramdocument.cpp index ea73abe..4074f00 100644 --- a/src/diagramdocument.cpp +++ b/src/diagramdocument.cpp @@ -18,7 +18,7 @@ #include "hub.h" #include "diagramdocument.h" #include "diagramobject.h" -#include "diagramconnection.h" +#include "line.h" #include "items/database/databasetable.h" #include "items/database/databaserelationship.h" #include "items/database/column.h" @@ -142,7 +142,7 @@ void DiagramDocument::updatePositions(DiagramObject *object) { Connector *connector; - foreach (DiagramConnection *connection, findConnections(object)) { + foreach (Line *connection, findConnections(object)) { connector = connection->connector(0); if (connector->isConnected()) connector->hub()->update(); @@ -294,11 +294,11 @@ DiagramDocument::deleteSelectedItems() } } -QList +QList DiagramDocument::findConnections(DiagramObject *object) { - QList result; - foreach (DiagramConnection *connection, itemsByType()) + QList result; + foreach (Line *connection, itemsByType()) if (connection->connector(0)->connectedObject() == object || connection->connector(1)->connectedObject() == object) result.append(connection); return result; @@ -329,7 +329,7 @@ DiagramDocument::save(const QString &fileName) item->saveToXml(doc, element); } - foreach (DiagramConnection *item, itemsByType()) { + foreach (Line *item, itemsByType()) { QDomElement element = doc.createElement("item"); itemList.appendChild(element); item->saveToXml(doc, element); diff --git a/src/diagramdocument.h b/src/diagramdocument.h index 47d1294..c0a63c0 100644 --- a/src/diagramdocument.h +++ b/src/diagramdocument.h @@ -27,7 +27,7 @@ class DatabaseTable; class DatabaseRelationship; -class DiagramConnection; +class Line; class DiagramItem; class DiagramObject; @@ -81,7 +81,7 @@ public: void itemMoved(DiagramItem *table); void itemHasMoved(DiagramItem *table); - QList findConnections(DiagramObject *object); + QList findConnections(DiagramObject *object); template QList itemsByType(); int gridSize() const; diff --git a/src/diagramobject.h b/src/diagramobject.h index 96b027c..5ef107b 100644 --- a/src/diagramobject.h +++ b/src/diagramobject.h @@ -19,7 +19,7 @@ #include "diagramitem.h" class Hub; -class DiagramConnection; +class Line; class DiagramObject : public DiagramItem { diff --git a/src/items/database/databasecommands.cpp b/src/items/database/databasecommands.cpp index eae59db..1d9a63e 100644 --- a/src/items/database/databasecommands.cpp +++ b/src/items/database/databasecommands.cpp @@ -17,7 +17,7 @@ #include #include "databasecommands.h" #include "diagramdocument.h" -#include "diagramconnection.h" +#include "line.h" #include "diagramitem.h" #include "databasetable.h" #include "column.h" diff --git a/src/items/database/databaserelationship.cpp b/src/items/database/databaserelationship.cpp index a95ac6e..39c9d25 100644 --- a/src/items/database/databaserelationship.cpp +++ b/src/items/database/databaserelationship.cpp @@ -107,7 +107,7 @@ bool DatabaseRelationship::PrivateData::pathsInitialized = false; QPainterPath DatabaseRelationship::PrivateData::paths[5]; DatabaseRelationship::DatabaseRelationship(DiagramItem *parent) - : DiagramConnection(parent), d(new PrivateData) + : Line(parent), d(new PrivateData) { setFlag(ItemIsSelectable); connect(this, SIGNAL(endPointChanged()), this, SLOT(updateLayout())); @@ -421,7 +421,7 @@ DatabaseRelationship::updateLayout() void DatabaseRelationship::loadFromXml(QDomElement element, DiagramDocument *document) { - DiagramConnection::loadFromXml(element, document); + Line::loadFromXml(element, document); QDomElement relationshipeElement = element.firstChildElement("relationship"); if (!relationshipeElement.isNull()) { setCardinality(readEnumElement(relationshipeElement, "cardinality", OneToMany, this, "Cardinality")); @@ -436,7 +436,7 @@ DatabaseRelationship::loadFromXml(QDomElement element, DiagramDocument *document void DatabaseRelationship::saveToXml(QDomDocument doc, QDomElement element) { - DiagramConnection::saveToXml(doc, element); + Line::saveToXml(doc, element); QDomElement relationshipeElement = doc.createElement("relationship"); element.appendChild(relationshipeElement); appendEnumElement(doc, relationshipeElement, "cardinality", d->cardinality, this, "Cardinality"); diff --git a/src/items/database/databaserelationship.h b/src/items/database/databaserelationship.h index f8f381e..5d90053 100644 --- a/src/items/database/databaserelationship.h +++ b/src/items/database/databaserelationship.h @@ -20,11 +20,11 @@ #include #include #include -#include "diagramconnection.h" +#include "line.h" #include "databasetable.h" #include "connector.h" -class DatabaseRelationship : public DiagramConnection +class DatabaseRelationship : public Line { Q_OBJECT Q_ENUMS(Cardinality Action) diff --git a/src/line.cpp b/src/line.cpp new file mode 100644 index 0000000..1ca27af --- /dev/null +++ b/src/line.cpp @@ -0,0 +1,69 @@ +// Copyright (C) 2008 Lukas Lalinsky +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +#include "line.h" +#include "diagramdocument.h" +#include "diagramobject.h" +#include "connector.h" + +Line::Line(DiagramItem *parent) + : DiagramItem(parent) +{ + m_connectors[0] = new Connector(this); + m_connectors[1] = new Connector(this); + setZValue(1.0); +} + +Connector * +Line::connector(int index) const +{ + Q_ASSERT(index == 0 || index == 1); + return m_connectors[index]; +} + +void +Line::updatePositions() +{ +} + +#include "domutils.h" + +void +Line::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(document->itemById(sourceId))); + setTarget(qobject_cast(document->itemById(targetId)));*/ + } + } +} + +void +Line::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());*/ +} diff --git a/src/line.h b/src/line.h new file mode 100644 index 0000000..ff71d82 --- /dev/null +++ b/src/line.h @@ -0,0 +1,48 @@ +// Copyright (C) 2008 Lukas Lalinsky +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +#ifndef DIAGRAMCONNECTION_H +#define DIAGRAMCONNECTION_H + +#include "diagramitem.h" +class Connector; +class DiagramObject; + +class Line : public DiagramItem +{ + Q_OBJECT + +public: + Line(DiagramItem *parent = 0); + + enum LineLayout + { + StraightLineLayout, + OrthogonalLineLayout + }; + + Connector *connector(int index) const; + + virtual void updatePositions(); + + virtual void loadFromXml(QDomElement element, DiagramDocument *document = 0); + void saveToXml(QDomDocument doc, QDomElement element); + +private: + Connector *m_connectors[2]; +}; + +#endif diff --git a/src/src.pri b/src/src.pri index 5a96c1f..fee3021 100644 --- a/src/src.pri +++ b/src/src.pri @@ -10,7 +10,7 @@ SOURCES = \ mainwindow.cpp \ diagramview.cpp \ diagramdocument.cpp \ - diagramconnection.cpp \ + line.cpp \ diagramitem.cpp \ diagramitemfactory.cpp \ diagramitemproperties.cpp \ @@ -25,7 +25,7 @@ HEADERS = \ mainwindow.h \ diagramview.h \ diagramdocument.h \ - diagramconnection.h \ + line.h \ diagramitem.h \ diagramitemfactory.h \ diagramitemproperties.h \ -- cgit v1.2.3-54-g00ecf