[kgraphviewer-devel] [KGraphViewer] 23a6589: Minor cleanup of class interfaces where possible

Kevin Funk krf at electrostorm.net
Fri Dec 10 21:42:32 CET 2010


commit 23a6589882159ff5db3b092674d34895e08c6554
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date:   Fri Dec 10 21:39:31 2010 +0100

    Minor cleanup of class interfaces where possible
    
    * Add const where applicable
    * Remove overwritten methods

diff --git a/src/kgraphviz/canvassubgraph.h b/src/kgraphviz/canvassubgraph.h
index b5b6027..594d3df 100644
--- a/src/kgraphviz/canvassubgraph.h
+++ b/src/kgraphviz/canvassubgraph.h
@@ -44,8 +44,6 @@ public:
       QGraphicsScene* c,
       QGraphicsItem* parent = 0);
   virtual ~CanvasSubgraph() {}
-  
-protected:
 };
 
 }
diff --git a/src/kgraphviz/dotgraph.h b/src/kgraphviz/dotgraph.h
index 02a35e6..fa82f7c 100644
--- a/src/kgraphviz/dotgraph.h
+++ b/src/kgraphviz/dotgraph.h
@@ -111,7 +111,7 @@ public:
   GraphElement* elementNamed(const QString& id);
 
   inline void setUseLibrary(bool value) {m_useLibrary = value;}
-  inline bool useLibrary() {return m_useLibrary;}
+  inline bool useLibrary() const {return m_useLibrary;}
 
   void setGraphAttributes(QMap<QString,QString> attribs);
   void addNewNode(QMap<QString,QString> attribs);
diff --git a/src/kgraphviz/dotgraphview.cpp b/src/kgraphviz/dotgraphview.cpp
index b523ca5..46182e9 100644
--- a/src/kgraphviz/dotgraphview.cpp
+++ b/src/kgraphviz/dotgraphview.cpp
@@ -649,10 +649,9 @@ DotGraphView::~DotGraphView()
 KGraphViewerInterface::PannerPosition DotGraphView::zoomPos() const { Q_D(const DotGraphView); return d->m_zoomPosition; }
 
 double DotGraphView::zoom() const {Q_D(const DotGraphView); return d->m_zoom;}
-KSelectAction* DotGraphView::bevPopup() {Q_D(DotGraphView); return d->m_bevPopup;}
+KSelectAction* DotGraphView::bevPopup() const {Q_D(const DotGraphView); return d->m_bevPopup;}
 
-DotGraph* DotGraphView::graph() {Q_D(DotGraphView); return d->m_graph;}
-const DotGraph* DotGraphView::graph() const {Q_D(const DotGraphView); return d->m_graph;}
+DotGraph* DotGraphView::graph() const {Q_D(const DotGraphView); return d->m_graph;}
 
 const GraphElement* DotGraphView::defaultNewElement() const {Q_D(const DotGraphView); return d->m_defaultNewElement;}
 QPixmap DotGraphView::defaultNewElementPixmap() const {Q_D(const DotGraphView); return d->m_defaultNewElementPixmap;}
@@ -663,7 +662,7 @@ void DotGraphView::setDefaultNewElementPixmap(const QPixmap& pm) {Q_D(DotGraphVi
 bool DotGraphView::isReadWrite() const {Q_D(const DotGraphView); return d->m_readWrite;}
 bool DotGraphView::isReadOnly() const {Q_D(const DotGraphView); return !d->m_readWrite;}
 
-bool DotGraphView::highlighting() {Q_D(DotGraphView); return d->m_highlighting;}
+bool DotGraphView::highlighting() const {Q_D(const DotGraphView); return d->m_highlighting;}
 void DotGraphView::setHighlighting(bool highlightingValue) {Q_D(DotGraphView); d->m_highlighting = highlightingValue;}
 
 DotGraphView::EditingMode DotGraphView::editingMode() const {Q_D(const DotGraphView); return d->m_editingMode;}
diff --git a/src/kgraphviz/dotgraphview.h b/src/kgraphviz/dotgraphview.h
index a05b1f8..7930db9 100644
--- a/src/kgraphviz/dotgraphview.h
+++ b/src/kgraphviz/dotgraphview.h
@@ -128,10 +128,9 @@ public:
 
   void hideToolsWindows();
   double zoom() const;
-  KSelectAction* bevPopup();
+  KSelectAction* bevPopup() const;
 
-  DotGraph* graph();
-  const DotGraph* graph() const;
+  DotGraph* graph() const;
 
   const GraphElement* defaultNewElement() const;
   QPixmap defaultNewElementPixmap() const;
@@ -158,7 +157,7 @@ public:
   void removeSelectedSubgraphs();
   void removeSelectedElements();
   
-  bool highlighting();
+  bool highlighting() const;
   void setHighlighting(bool highlightingValue);
 
   // public so that the panner view can bubble through
diff --git a/src/kgraphviz/graphedge.cpp b/src/kgraphviz/graphedge.cpp
index aeec168..05d53a2 100644
--- a/src/kgraphviz/graphedge.cpp
+++ b/src/kgraphviz/graphedge.cpp
@@ -45,7 +45,6 @@ namespace KGraphViz
 GraphEdge::GraphEdge() : 
     GraphElement(),
     m_fromNode(0),m_toNode(0),
-    m_visible(true),
     m_colors(),
     m_dir(DOT_DEFAULT_EDGE_DIR),
     m_arrowheads()
@@ -63,7 +62,6 @@ GraphEdge::GraphEdge(const GraphEdge& edge) :
 {
     m_fromNode = 0;
     m_toNode = 0;
-    m_visible = edge.m_visible;
     m_colors = edge.m_colors;
     m_dir = edge.m_dir;
     m_arrowheads = edge.m_arrowheads;
diff --git a/src/kgraphviz/graphedge.h b/src/kgraphviz/graphedge.h
index b5c896f..c3b4dd3 100644
--- a/src/kgraphviz/graphedge.h
+++ b/src/kgraphviz/graphedge.h
@@ -60,13 +60,8 @@ public:
 
   virtual ~GraphEdge();
 
-  bool isVisible() { return m_visible; }
-  void setVisible(bool v) { m_visible = v; }
-
-  GraphElement* fromNode() { return m_fromNode; }
-  GraphElement* toNode() { return m_toNode; }
-  const GraphElement* fromNode() const { return m_fromNode; }
-  const GraphElement* toNode() const { return m_toNode; }
+  GraphElement* fromNode() const { return m_fromNode; }
+  GraphElement* toNode() const { return m_toNode; }
 
   void setFromNode(GraphElement* n) { m_fromNode = n; }
   void setToNode(GraphElement* n) { m_toNode = n; }
@@ -97,7 +92,6 @@ private:
   // we have a _ce *and* _from/_to because for collapsed edges,
   // only _to or _from will be unequal NULL
   GraphElement *m_fromNode, *m_toNode;
-  bool m_visible;
   QStringList m_colors;
   QString m_dir;
 //   QVector< QPair< float, float > > m_edgePoints;
diff --git a/src/kgraphviz/graphelement.cpp b/src/kgraphviz/graphelement.cpp
index 9e24ca1..5383c0c 100644
--- a/src/kgraphviz/graphelement.cpp
+++ b/src/kgraphviz/graphelement.cpp
@@ -35,6 +35,7 @@ GraphElement::GraphElement() :
     m_attributes(),
     m_originalAttributes(),
     m_ce(0),
+    m_visible(true),
     m_z(1.0),
     m_renderOperations(),
     m_selected(false)
@@ -57,6 +58,7 @@ GraphElement::GraphElement(const GraphElement& element) : QObject(),
   m_originalAttributes(),
   m_ce(element.m_ce),
   m_z(element.m_z),
+  m_visible(element.m_visible),
   m_renderOperations(),
   m_selected(element.m_selected)
 {
diff --git a/src/kgraphviz/graphelement.h b/src/kgraphviz/graphelement.h
index c78d134..bcdb1a7 100644
--- a/src/kgraphviz/graphelement.h
+++ b/src/kgraphviz/graphelement.h
@@ -114,6 +114,7 @@ protected:
   QList<QString> m_originalAttributes;
   
   CanvasElement* m_ce;
+
 private:
   double m_z;
   bool m_visible;
diff --git a/src/kgraphviz/pannerview.h b/src/kgraphviz/pannerview.h
index e2fc7c2..7b1ea2a 100644
--- a/src/kgraphviz/pannerview.h
+++ b/src/kgraphviz/pannerview.h
@@ -33,8 +33,6 @@
 #define PANNER_VIEW_H
 
 #include <QGraphicsView>
-#include <QWidget>
-//Added by qt3to4:
 #include <QMouseEvent>
 
 namespace KGraphViz
@@ -69,6 +67,7 @@ protected:
   virtual void drawForeground(QPainter * p, const QRectF & rect );
   virtual void contextMenuEvent(QContextMenuEvent* event);
 
+private:
   QRectF m_zoomRect;
   bool m_movingZoomRect;
   QPointF m_lastPos;


More information about the kgraphviewer-devel mailing list