[kgraphviewer-devel] [KGraphViewer/libkgraphviz] 65a7801: Clean up, drop redundant code

Kevin Funk krf at electrostorm.net
Fri Jan 14 18:01:30 CET 2011


commit 65a78014d05fd95f5e142aeaab8fbc2a76507458
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date:   Fri Jan 14 11:22:24 2011 +0100

    Clean up, drop redundant code

diff --git a/src/kgraphviz/graphedge.cpp b/src/kgraphviz/graphedge.cpp
index f42462c..20e9441 100644
--- a/src/kgraphviz/graphedge.cpp
+++ b/src/kgraphviz/graphedge.cpp
@@ -37,14 +37,10 @@
 
 namespace KGraphViz
 {
-  
-/*
- * Graph Edge
- */
 
 GraphEdge::GraphEdge() : 
-    GraphElement(),
-    m_fromNode(0),m_toNode(0),
+    m_fromNode(0),
+    m_toNode(0),
     m_dir(DOT_DEFAULT_EDGE_DIR)
 {
 //   kDebug() ;
diff --git a/src/kgraphviz/graphelement.cpp b/src/kgraphviz/graphelement.cpp
index c311f0c..0266f7f 100644
--- a/src/kgraphviz/graphelement.cpp
+++ b/src/kgraphviz/graphelement.cpp
@@ -51,7 +51,6 @@ GraphElementPrivate::GraphElementPrivate(const GraphElementPrivate& other) :
 }
 
 GraphElement::GraphElement() :
-    QObject(),
     d_ptr(new GraphElementPrivate)
 {
 /*  label("");
@@ -68,7 +67,6 @@ GraphElement::GraphElement() :
 }
 
 GraphElement::GraphElement(const GraphElement& element) :
-  QObject(),
   d_ptr(new GraphElementPrivate(*element.d_ptr))
 {
   kDebug() ;
@@ -172,7 +170,7 @@ void GraphElement::updateWithElement(const GraphElement& element)
   {
     canvasElement()->modelChanged();
   }
-  kDebug() << "done" << renderOperations().size();
+  kDebug() << "done: render operations size:" << renderOperations().size();
 }
 
 
@@ -214,7 +212,7 @@ void GraphElement::exportToGraphviz(void* element) const
         if (label != "label")
         {
           label.replace(QRegExp("\n"),"\\n");
-          //           kDebug() << it.key() << "=\"" << label << "\",";
+          kDebug() << id() << it.key() << label;
           agsafeset(element, it.key().toUtf8().data(), label.toUtf8().data(), QString().toUtf8().data());
         }
       }
@@ -223,9 +221,9 @@ void GraphElement::exportToGraphviz(void* element) const
       }
       else if (originalAttributes().isEmpty() || originalAttributes().contains(it.key()))
       {
-        kDebug() << it.key() << it.value();
-        
-        agsafeset(element, it.key().toUtf8().data(), it.value().toUtf8().data(), QString().toUtf8().data());
+        kDebug() << id() << it.key() << it.value();
+
+        agsafeset(element, it.key().toUtf8().data(), it.value().toUtf8().data(), it.value().toUtf8().data());
       }
     }
   }
@@ -245,7 +243,14 @@ void GraphElement::importFromGraphviz(void* element, QList<QString> drawingAttri
       continue;
 
     parse_renderop(value, renderOperations());
-    kDebug() << attribute << "element renderOperations size is now " << renderOperations().size();
+    kDebug() << attribute << "element renderOperations size is now" << renderOperations().size();
+  }
+
+  Agsym_t *attr = agfstattr(element);
+  while(attr) {
+    kDebug() << id() << attr->name << agxget(element, attr->index);
+    m_attributes[attr->name] = agxget(element,attr->index);
+    attr = agnxtattr(element,attr);
   }
 }
 
diff --git a/src/kgraphviz/graphnode.cpp b/src/kgraphviz/graphnode.cpp
index 2a085fa..7ef1463 100644
--- a/src/kgraphviz/graphnode.cpp
+++ b/src/kgraphviz/graphnode.cpp
@@ -24,12 +24,8 @@
    License as published by the Free Software Foundation, version 2.
 */
 
-
-/*
- * Graph Node
- */
-
 #include "canvasnode.h"
+
 #include "dotgraphview.h"
 #include "graphnode.h"
 #include "support/dotdefaults.h"
@@ -43,13 +39,8 @@
 
 namespace KGraphViz
 {
-  
-//
-// GraphNode
-//
 
-GraphNode::GraphNode() :
-    GraphElement()
+GraphNode::GraphNode()
 {
 //   kDebug() ;
 }
@@ -60,7 +51,7 @@ GraphElement(gn)
   //   kDebug() ;
 }
 
-GraphNode::GraphNode(node_t* gn) : GraphElement()
+GraphNode::GraphNode(node_t* gn)
 {
   kDebug();
 
diff --git a/src/kgraphviz/graphsubgraph.cpp b/src/kgraphviz/graphsubgraph.cpp
index 68a5f8c..7b8f7fb 100644
--- a/src/kgraphviz/graphsubgraph.cpp
+++ b/src/kgraphviz/graphsubgraph.cpp
@@ -16,10 +16,6 @@
    02110-1301, USA
 */
 
-/*
- * Graph Subgraph
- */
-
 #include "canvassubgraph.h"
 #include "graphsubgraph.h"
 #include "graphnode.h"
@@ -32,18 +28,12 @@
 
 namespace KGraphViz
 {
-  
-//
-// GraphSubgraph
-//
 
-GraphSubgraph::GraphSubgraph() :
-  GraphElement()
+GraphSubgraph::GraphSubgraph()
 {
 }
 
-GraphSubgraph::GraphSubgraph(graph_t* sg) :
-  GraphElement()
+GraphSubgraph::GraphSubgraph(graph_t* sg)
 {
   updateWithSubgraph(sg);
 }
@@ -100,10 +90,7 @@ void GraphSubgraph::updateWithSubgraph(const GraphSubgraph& subgraph)
   }
 
   if (canvasElement())
-  {
     canvasElement()->modelChanged();
-    canvasElement()->computeBoundingRect();
-  }
 //   kDebug() << "done";
 }
 
@@ -114,25 +101,9 @@ void GraphSubgraph::updateWithSubgraph(graph_t* subgraph)
   if (GD_label(subgraph))
     m_attributes["label"] = GD_label(subgraph)->text;
 
-  renderOperations().clear();
-  if (agget(subgraph, (char*)"_draw_") != NULL)
-  {
-    parse_renderop(agget(subgraph, (char*)"_draw_"), renderOperations());
-    kDebug() << "_draw_: element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(subgraph, (char*)"_ldraw_") != NULL)
-  {
-    parse_renderop(agget(subgraph, (char*)"_ldraw_"), renderOperations());
-    kDebug() << "_ldraw_: element renderOperations size is now " << renderOperations().size();
-  }
-  
-  Agsym_t *attr = agfstattr(subgraph);
-  while(attr)
-  {
-    kDebug() << subgraph->name << ":" << attr->name << agxget(subgraph,attr->index);
-    m_attributes[attr->name] = agxget(subgraph,attr->index);
-    attr = agnxtattr(subgraph,attr);
-  }
+  QList<QString> drawingAttributes;
+  drawingAttributes << "_draw_" << "_ldraw_";
+  importFromGraphviz(subgraph, drawingAttributes);
 
   for (edge_t* e = agfstout(subgraph->meta_node->graph, subgraph->meta_node); e;
       e = agnxtout(subgraph->meta_node->graph, e))


More information about the kgraphviewer-devel mailing list