[kgraphviewer-devel] [kgraphviewer/libkgraphviz] src/kgraphviz: Do not inherit from QObject in GraphElement

Kevin Funk krf at electrostorm.net
Thu Jan 27 15:10:44 CET 2011


Git commit 305cb4631057149999d10ca503ba8a9edcf25933 by Kevin Funk.
Pushed by kfunk into branch 'libkgraphviz'.

Do not inherit from QObject in GraphElement

Remove this overhead, it is not needed for the graph data structure.

M  +1    -1    src/kgraphviz/dotgraph.h     
M  +0    -2    src/kgraphviz/graphedge.cpp     
M  +0    -3    src/kgraphviz/graphedge.h     
M  +0    -4    src/kgraphviz/graphelement.cpp     
M  +2    -10   src/kgraphviz/graphelement.h     
M  +0    -2    src/kgraphviz/graphnode.cpp     
M  +0    -2    src/kgraphviz/graphnode.h     
M  +0    -2    src/kgraphviz/graphsubgraph.cpp     
M  +0    -3    src/kgraphviz/graphsubgraph.h     

http://commits.kde.org/9c7b74a4/305cb4631057149999d10ca503ba8a9edcf25933

diff --git a/src/kgraphviz/dotgraph.h b/src/kgraphviz/dotgraph.h
index 0494b27..8e81232 100644
--- a/src/kgraphviz/dotgraph.h
+++ b/src/kgraphviz/dotgraph.h
@@ -41,7 +41,7 @@ class DotGraphPrivate;
 /**
   * A class representing the model of a GraphViz dot graph
   */
-class KGRAPHVIZ_EXPORT DotGraph : public GraphElement
+class KGRAPHVIZ_EXPORT DotGraph : public QObject, public GraphElement
 {
   Q_OBJECT
 
diff --git a/src/kgraphviz/graphedge.cpp b/src/kgraphviz/graphedge.cpp
index e4d88bf..2006ebf 100644
--- a/src/kgraphviz/graphedge.cpp
+++ b/src/kgraphviz/graphedge.cpp
@@ -154,5 +154,3 @@ QTextStream& KGraphViz::operator<<(QTextStream& s, const GraphEdge& e)
 
   return s;
 }
-
-#include "graphedge.moc"
diff --git a/src/kgraphviz/graphedge.h b/src/kgraphviz/graphedge.h
index f14fe4e..9310c35 100644
--- a/src/kgraphviz/graphedge.h
+++ b/src/kgraphviz/graphedge.h
@@ -29,7 +29,6 @@
 
 #include "graphelement.h"
 
-#include <QString>
 #include <QMap>
 
 class Agedge_t;
@@ -42,8 +41,6 @@ class GraphNode;
 
 class KGRAPHVIZ_EXPORT GraphEdge : public GraphElement
 {
-  Q_OBJECT
-
 public:
   GraphEdge();
   GraphEdge(const GraphEdge& edge);
diff --git a/src/kgraphviz/graphelement.cpp b/src/kgraphviz/graphelement.cpp
index 75fff56..b7cdba6 100644
--- a/src/kgraphviz/graphelement.cpp
+++ b/src/kgraphviz/graphelement.cpp
@@ -165,7 +165,6 @@ void GraphElement::updateWithElement(const GraphElement& element)
       kDebug() << msg;
     }
     kDebug() << "modified: emiting changed";*/
-    emit changed();
   }
 
   if (canvasElement())
@@ -197,7 +196,6 @@ void GraphElement::removeAttribute(const QString& attribName)
 {
   kDebug() << attribName;
   m_attributes.remove(attribName);
-  emit changed();
 }
 
 void GraphElement::exportToGraphviz(void* element) const
@@ -292,5 +290,3 @@ QTextStream& KGraphViz::operator<<(QTextStream& s, const GraphElement& n)
   }
   return s;
 }
-
-#include "graphelement.moc"
diff --git a/src/kgraphviz/graphelement.h b/src/kgraphviz/graphelement.h
index 33ea9be..9908683 100644
--- a/src/kgraphviz/graphelement.h
+++ b/src/kgraphviz/graphelement.h
@@ -19,8 +19,6 @@
 #ifndef GRAPH_ELEMENT_H
 #define GRAPH_ELEMENT_H
 
-#include <QObject>
-
 #include "kgraphviz_export.h"
 #include "support/dotrenderop.h"
 
@@ -38,10 +36,8 @@ class GraphElementPrivate;
  * The base of all GraphViz dot graph elements (nodes, edges, subgraphs,
  * graphs). It is used to store the element attributes
  */
-class KGRAPHVIZ_EXPORT GraphElement: public QObject
+class KGRAPHVIZ_EXPORT GraphElement
 {
-  Q_OBJECT
-
 public:
   GraphElement();
   GraphElement(const GraphElement& element);
@@ -87,8 +83,7 @@ public:
   inline QMap<QString,QString>& attributes() {return m_attributes;}
   inline const QMap<QString,QString>& attributes() const {return m_attributes;}
 
-  inline QList<QString>& originalAttributes() {return m_originalAttributes;}
-  inline const QList<QString>& originalAttributes() const {return m_originalAttributes;}
+  inline QList<QString> originalAttributes() const {return m_originalAttributes;}
 
   virtual inline void storeOriginalAttributes() {m_originalAttributes = m_attributes.keys();}
 
@@ -103,9 +98,6 @@ public:
   void exportToGraphviz(void* element)  const;
   void importFromGraphviz(void* element, QList<QString> drawingAttributes);
 
-Q_SIGNALS:
-  void changed();
-
 protected:
   QMap<QString,QString> m_attributes;
   QList<QString> m_originalAttributes;
diff --git a/src/kgraphviz/graphnode.cpp b/src/kgraphviz/graphnode.cpp
index fce1fac..f49fd3d 100644
--- a/src/kgraphviz/graphnode.cpp
+++ b/src/kgraphviz/graphnode.cpp
@@ -92,5 +92,3 @@ QTextStream& KGraphViz::operator<<(QTextStream& s, const GraphNode& n)
     <<"];"<<endl;
   return s;
 }
-
-#include "graphnode.moc"
diff --git a/src/kgraphviz/graphnode.h b/src/kgraphviz/graphnode.h
index b2ba079..3cded48 100644
--- a/src/kgraphviz/graphnode.h
+++ b/src/kgraphviz/graphnode.h
@@ -49,8 +49,6 @@ class CanvasNode;
  */
 class KGRAPHVIZ_EXPORT GraphNode : public GraphElement
 {
-  Q_OBJECT
-
 public:
   GraphNode();
   GraphNode(const GraphNode& gn);
diff --git a/src/kgraphviz/graphsubgraph.cpp b/src/kgraphviz/graphsubgraph.cpp
index 7b8f7fb..8e74518 100644
--- a/src/kgraphviz/graphsubgraph.cpp
+++ b/src/kgraphviz/graphsubgraph.cpp
@@ -266,5 +266,3 @@ QTextStream& operator<<(QTextStream& s, const GraphSubgraph& sg)
 }
 
 }
-
-#include "graphsubgraph.moc"
diff --git a/src/kgraphviz/graphsubgraph.h b/src/kgraphviz/graphsubgraph.h
index 4b61d73..6735183 100644
--- a/src/kgraphviz/graphsubgraph.h
+++ b/src/kgraphviz/graphsubgraph.h
@@ -37,14 +37,11 @@ class GraphSubgraph;
 
 typedef QMap<QString, GraphSubgraph*> GraphSubgraphMap;
 
-
 /**
  * Colors and styles are dot names
  */
 class KGRAPHVIZ_EXPORT GraphSubgraph : public GraphElement
 {
-  Q_OBJECT
-
 public:
   GraphSubgraph();
   explicit GraphSubgraph(Agraph_t* sg);



More information about the kgraphviewer-devel mailing list