Permalink
Browse files

Removal and preserving of RHS edges

  • Loading branch information...
aelliott committed Apr 26, 2013
1 parent f275213 commit 7c9976b73158a931a3a54e09b6bf0705b025fd1f
@@ -100,6 +100,22 @@ void EdgeItem::setTo(NodeItem *edgeTo)
connect(_to, SIGNAL(shapeChanged()), this, SLOT(nodeMoved()));
}
void EdgeItem::deleteEdge()
{
setItemState(GraphItem::GraphItem_Deleted);
if(_edge != 0)
_edge->setPhantom(true);
}
void EdgeItem::preserveEdge()
{
setItemState(GraphItem::GraphItem_Normal);
if(_edge != 0)
_edge->setPhantom(false);
}
QLineF EdgeItem::line() const
{
QLineF initial = QLineF(_from->centerPos(), _to->centerPos());
@@ -31,6 +31,9 @@ class EdgeItem : public GraphItem
void setFrom(NodeItem *edgeFrom);
void setTo(NodeItem *edgeTo);
void preserveEdge();
void deleteEdge();
QLineF line() const;
QPolygonF polygon(double polygonWidth = -1.0) const;
@@ -731,8 +731,6 @@ EdgeItem *GraphScene::edge(const QString &id) const
void GraphScene::removeEdge(EdgeItem *edge)
{
qDebug() << "Removing edge.";
qDebug() << "Edge: " << edge->id();
if(edge == 0)
{
qDebug() << "GraphScene::removeEdge() passed null pointer, ignoring";
@@ -918,8 +916,21 @@ void GraphScene::keyPressEvent(QKeyEvent *event)
EdgeItem *edge = *iter;
if(edge == item)
{
removeEdge(edge);
found = true;
if(_linkedGraph != 0)
{
if(edge->itemState() == GraphItem::GraphItem_Normal)
{
edge->deleteEdge();
edge->setSelected(false);
}
else if(edge->itemState() == GraphItem::GraphItem_New)
removeEdge(edge);
}
else
{
removeEdge(edge);
}
break;
}
}
@@ -1122,6 +1133,16 @@ void GraphScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
EdgeItem *edge = *iter;
if(edge->edgePolygon().containsPoint(event->scenePos(), Qt::OddEvenFill))
{
if(_linkedGraph != 0)
{
if(edge->itemState() == GraphItem::GraphItem_Deleted)
{
edge->preserveEdge();
edge->setSelected(false);
}
return;
}
QGraphicsScene::mouseDoubleClickEvent(event);
return;
}

0 comments on commit 7c9976b

Please sign in to comment.