removed Node::addEdge call from Edge ctor, called it at Edge creation

master
Denes Matetelki 14 years ago
parent c9fb8b7c85
commit da74ca1a3e

@ -12,7 +12,9 @@ const double Edge::m_twoPi = 2.0 * Edge::m_pi;
const qreal Edge::m_arrowSize = 7; const qreal Edge::m_arrowSize = 7;
Edge::Edge(Node *sourceNode, Node *destNode) Edge::Edge(Node *sourceNode, Node *destNode)
: m_angle(-1) : m_sourceNode(sourceNode)
, m_destNode(destNode)
, m_angle(-1)
, m_color(0,0,0) , m_color(0,0,0)
, m_width(1) , m_width(1)
, m_secondary(false) , m_secondary(false)
@ -21,10 +23,6 @@ Edge::Edge(Node *sourceNode, Node *destNode)
setAcceptedMouseButtons(0); setAcceptedMouseButtons(0);
setZValue(1); setZValue(1);
m_sourceNode = sourceNode;
m_destNode = destNode;
m_sourceNode->addEdge(this,true);
m_destNode->addEdge(this,false);
adjust(); adjust();
} }

@ -131,9 +131,13 @@ bool GraphWidget::readContentFromXmlFile(const QString &fileName)
QDomElement e = edges.item(i).toElement(); QDomElement e = edges.item(i).toElement();
if(!e.isNull()) if(!e.isNull())
{ {
Edge *edge = new Edge( Node *source = m_nodeList[e.attribute("source").toInt()];
m_nodeList[e.attribute("source").toInt()], Node *destination = m_nodeList[e.attribute("destination").toInt()];
m_nodeList[e.attribute("destination").toInt()]);
Edge *edge = new Edge(source, destination);
source->addEdge(edge, true);
destination->addEdge(edge, false);
edge->setColor(QColor(e.attribute("red").toFloat(), edge->setColor(QColor(e.attribute("red").toFloat(),
e.attribute("green").toFloat(), e.attribute("green").toFloat(),
e.attribute("blue").toFloat())); e.attribute("blue").toFloat()));
@ -829,6 +833,9 @@ void GraphWidget::addEdge(Node *source, Node *destination)
sec = true; sec = true;
} }
Edge *edge = new Edge(source, destination); Edge *edge = new Edge(source, destination);
source->addEdge(edge, true);
destination->addEdge(edge, false);
edge->setColor(destination->color()); edge->setColor(destination->color());
edge->setWidth(destination->scale()*2 + 1); edge->setWidth(destination->scale()*2 + 1);

Loading…
Cancel
Save