[kgraphviewer-devel] [KGraphViewer/libkgraphviz] 9fa25b4: Remove context menu logic from CanvasEdge

Kevin Funk krf at electrostorm.net
Wed Dec 15 15:41:51 CET 2010


commit 9fa25b48e4382c578125811ffd5bc5541a9a19fa
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date:   Wed Dec 15 14:12:59 2010 +0100

    Remove context menu logic from CanvasEdge
    
    This should be handled in QGraphicsView subclass (=> DotGraphView)

diff --git a/src/kgraphviz/canvasedge.cpp b/src/kgraphviz/canvasedge.cpp
index 0e7f7cd..877ef07 100644
--- a/src/kgraphviz/canvasedge.cpp
+++ b/src/kgraphviz/canvasedge.cpp
@@ -33,13 +33,10 @@
 #include "support/dot2qtconsts.h"
 #include "support/fontscache.h"
 
-#include <KAction>
 #include <KDebug>
 #include <KLocale>
 
 #include <QPainter>
-#include <QGraphicsSceneMouseEvent>
-#include <QMenu>
 
 #include <math.h>
 #include <iostream>
@@ -57,7 +54,7 @@ CanvasEdge::CanvasEdge(DotGraphView* view,
     m_scaleX(scaleX), m_scaleY(scaleY),
     m_xMargin(xMargin), m_yMargin(yMargin),
     m_gh(/*gh*/0), m_wdhcf(wdhcf), m_hdvcf(hdvcf), m_edge(e),
-    m_font(0), m_view(view), m_popup(new QMenu())
+    m_font(0), m_view(view)
 {
   kDebug() << "edge "  << edge()->fromNode()->id() << "->"  << edge()->toNode()->id() << m_gh;
   setBoundingRegionGranularity(0.9);
@@ -69,19 +66,12 @@ CanvasEdge::CanvasEdge(DotGraphView* view,
   QString tipStr = i18n("%1 -> %2\nlabel='%3'",
       edge()->fromNode()->id(),edge()->toNode()->id(),e->label());
   setToolTip(tipStr);
-
-  // the message should be given (or possible to be given) by the part user
-  KAction* removeEdgeAction = new KAction(i18n("Remove selected edge(s)"), this);
-  m_popup->addAction(removeEdgeAction);
-  connect(removeEdgeAction,SIGNAL(triggered(bool)),this,SLOT(slotRemoveEdge()));
 } 
 
 CanvasEdge::~CanvasEdge()
 {
-  delete m_popup;
 }
 
-
 QRectF CanvasEdge::boundingRect() const
 {
   return m_boundingRect;
@@ -510,10 +500,4 @@ qreal CanvasEdge::distance(const QPointF& point1, const QPointF& point2)
   return sqrt(pow(point1.x()-point2.x(),2)+pow(point1.y()-point2.y(),2));
 }
 
-void CanvasEdge::slotRemoveEdge()
-{
-  kDebug();
-  m_view->removeSelectedElements();
-}
-
 #include "canvasedge.moc"
diff --git a/src/kgraphviz/canvasedge.h b/src/kgraphviz/canvasedge.h
index 9ce46e8..f8f5a8d 100644
--- a/src/kgraphviz/canvasedge.h
+++ b/src/kgraphviz/canvasedge.h
@@ -34,7 +34,6 @@
 
 class QGraphicsScene;
 class QFont;
-class QMenu;
 
 /*
  * Canvas Items:
@@ -80,9 +79,6 @@ public:
   inline void setGh(qreal gh) {m_gh = gh;}
   
   void computeBoundingRect();
-
-public Q_SLOTS:
-  void slotRemoveEdge();
   
 private:
   qreal distance(const QPointF& point1, const QPointF& point2);
@@ -93,7 +89,6 @@ private:
   QRectF m_boundingRect;
   QFont* m_font;
   DotGraphView* m_view;
-  QMenu* m_popup;
   mutable QPainterPath m_boundingRegion;
 };
 


More information about the kgraphviewer-devel mailing list