[kgraphviewer-devel] [KGraphViewer] 9ff0506: Introduce kgraphviz library

Kevin Funk krf at electrostorm.net
Fri Dec 10 15:13:47 CET 2010


	A	 src/shared/kgraphviewer_interface.h	 [License: UNKNOWN]


	A	 src/shared/kgraphviewer_export.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/loadagraphthread.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/loadagraphthread.cpp	 [License: Trivialfile.]


	A	 src/kgraphviz/support/layoutagraphthread.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/layoutagraphthread.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/support/dotrenderop.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/dotgrammar.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/dotgrammar.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/support/dotdefaults.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/dot2qtconsts.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/dot2qtconsts.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/support/FontsCache.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/FontsCache.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/support/DotGraphParsingHelper.h	 [License: UNKNOWN]


	A	 src/kgraphviz/support/DotGraphParsingHelper.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/pannerview.h	 [License: UNKNOWN]


	A	 src/kgraphviz/pannerview.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/graphsubgraph.h	 [License: UNKNOWN]


	A	 src/kgraphviz/graphsubgraph.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/graphnode.h	 [License: UNKNOWN]


	A	 src/kgraphviz/graphnode.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/graphexporter.h	 [License: UNKNOWN]


	A	 src/kgraphviz/graphexporter.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/graphelement.h	 [License: UNKNOWN]


	A	 src/kgraphviz/graphelement.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/graphedge.h	 [License: UNKNOWN]


	A	 src/kgraphviz/graphedge.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/dotgraphview.h	 [License: UNKNOWN]


	A	 src/kgraphviz/dotgraphview.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/dotgraph.h	 [License: UNKNOWN]


	A	 src/kgraphviz/dotgraph.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/canvassubgraph.h	 [License: UNKNOWN]


	A	 src/kgraphviz/canvassubgraph.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/canvasnode.h	 [License: UNKNOWN]


	A	 src/kgraphviz/canvasnode.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/canvaselement.h	 [License: UNKNOWN]


	A	 src/kgraphviz/canvaselement.cpp	 [License: UNKNOWN]


	A	 src/kgraphviz/canvasedge.h	 [License: UNKNOWN]


	A	 src/kgraphviz/canvasedge.cpp	 [License: UNKNOWN]

commit 9ff050614b43dac79aa3304efd7807b60822a7fe
Author: Kevin Funk <krf at electrostorm.net>
Date:   Fri Dec 10 10:39:48 2010 +0100

    Introduce kgraphviz library
    
    Changes:
    * Put all graph specific classes in src/kgraphviz
      * Most important: Graph, Node, Edge, SubGraph, all canvas elements
      * Dependencies as DotGrammer, DotRenderOp, etc.
    * Update references of kgraphviewer/kgrapheditor UI code to sync with
      latest changes
    
    TODO (fixing regressions):
    * Re-enable printing support of DotGraph
    * Re-enable optional activation of birds eye view
    
    TODO:
    * Export API, hide implementation details
    * Install development headers

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3359d15..bb50e63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,4 +37,3 @@ configure_file (config-kgraphviewer.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-k
 
 add_subdirectory(src)
 add_subdirectory(doc)
-
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0863ee2..0af4892 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,4 +1,6 @@
-add_subdirectory( part )
+add_subdirectory(kgraphviz)
+add_subdirectory(part)
+add_subdirectory(shared)
 
 include_directories( part ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${graphviz_INCLUDE_DIRECTORIES} )
 
@@ -59,5 +61,4 @@ install( FILES kgrapheditor.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
 
 
 
-#add_subdirectory(plasmaapplet)
-
+#add_subdirectory(plasmaapplet)
\ No newline at end of file
diff --git a/src/kgrapheditor.cpp b/src/kgrapheditor.cpp
index 6a8edce..e3d3251 100644
--- a/src/kgrapheditor.cpp
+++ b/src/kgrapheditor.cpp
@@ -26,8 +26,9 @@
 #include "ui_preferencesParsing.h"
 #include "ui_preferencesOpenInExistingWindow.h"
 #include "ui_preferencesReopenPreviouslyOpenedFiles.h"
-#include "part/dotgraph.h"
-#include "part/dotgraphview.h"
+
+#include <kgraphviz/dotgraph.h>
+#include <kgraphviz/dotgraphview.h>
 
 #include <kshortcutsdialog.h>
 #include <kfiledialog.h>
diff --git a/src/kgraphviewer.cpp b/src/kgraphviewer.cpp
index 3ee711a..6b038c7 100644
--- a/src/kgraphviewer.cpp
+++ b/src/kgraphviewer.cpp
@@ -18,7 +18,7 @@
 
 
 #include "kgraphviewer.h"
-#include "part/kgraphviewer_interface.h"
+#include "shared/kgraphviewer_interface.h"
 #include "kgraphviewerConfigDialog.h"
 #include "kgraphviewersettings.h"
 #include "ui_preferencesParsing.h"
@@ -36,6 +36,7 @@
 #include <kdebug.h>
 #include <kstandarddirs.h>
 #include <kstandardaction.h>
+#include <ktabwidget.h>
 #include <ktoggleaction.h>
 #include <klibloader.h>
 #include <kmessagebox.h>
diff --git a/src/kgraphviz/canvasedge.cpp b/src/kgraphviz/canvasedge.cpp
new file mode 100644
index 0000000..3e7ac0d
--- /dev/null
+++ b/src/kgraphviz/canvasedge.cpp
@@ -0,0 +1,591 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.cpp, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+#include "canvasedge.h"
+#include "canvaselement.h"
+#include "dotgraphview.h"
+#include "graphedge.h"
+#include "graphnode.h"
+#include "support/dotdefaults.h"
+#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>
+
+//
+// CanvasEdge
+//
+
+namespace KGraphViewer
+{
+
+CanvasEdge::CanvasEdge(DotGraphView* view, GraphEdge* e,
+                       qreal scaleX, qreal scaleY,
+                       qreal xMargin, qreal yMargin, qreal gh,
+                       qreal wdhcf, qreal hdvcf,
+                       QGraphicsItem* parent)
+                       : QAbstractGraphicsShapeItem(parent),
+    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())
+{
+  kDebug() << "edge "  << edge()->fromNode()->id() << "->"  << edge()->toNode()->id() << m_gh;
+  setBoundingRegionGranularity(0.9);
+  m_font = FontsCache::changeable().fromName(e->fontName());
+
+  computeBoundingRect();
+//   kDebug() << "boundingRect computed: " << m_boundingRect;
+  
+  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()));
+  
+  
+  connect(e,SIGNAL(changed()),this,SLOT(modelChanged()));
+  connect(this, SIGNAL(selected(CanvasEdge*, Qt::KeyboardModifiers)), view, SLOT(slotEdgeSelected(CanvasEdge*, Qt::KeyboardModifiers)));
+  
+  connect(this, SIGNAL(edgeContextMenuEvent(const QString&, const QPoint&)), view, SLOT(slotContextMenuEvent(const QString&, const QPoint&)));
+
+  setAcceptHoverEvents ( true );
+
+  kDebug() << "connect slotElementHoverEnter";
+  connect(this, SIGNAL(hoverEnter(CanvasEdge*)), view, SLOT(slotElementHoverEnter(CanvasEdge*)));
+  connect(this, SIGNAL(hoverLeave(CanvasEdge*)), view, SLOT(slotElementHoverLeave(CanvasEdge*)));
+  
+} 
+
+CanvasEdge::~CanvasEdge()
+{
+  delete m_popup;
+}
+
+
+QRectF CanvasEdge::boundingRect() const
+{
+  return m_boundingRect;
+}
+
+QPainterPath CanvasEdge::shape () const
+{
+//   kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id();
+  if (m_boundingRegion.isEmpty()) {
+    m_boundingRegion.addRegion(boundingRegion(QTransform()));
+  }
+  return m_boundingRegion;
+  /*
+  foreach (const DotRenderOp& dro, edge()->renderOperations())
+  {
+    if ( dro.renderop == "B" )
+    {
+      for (int splineNum = 0; splineNum < edge()->colors().count() || (splineNum==0 && edge()->colors().count()==0); splineNum++)
+      {
+        QPolygonF points(dro.integers[0]);
+        for (int i = 0; i < dro.integers[0]; i++)
+        {
+          qreal nom = (dro.integers[2*dro.integers[0]]-dro.integers[2]);
+          qreal denom = (dro.integers[2*dro.integers[0]-1]-dro.integers[1]);
+          qreal diffX, diffY;
+          if (nom == 0)
+          {
+            diffX = 0;
+            diffY = 2*(edge()->colors().count()/2 - splineNum);
+          }
+          else if (denom ==0)
+          {
+            diffX = 2*(edge()->colors().count()/2 - splineNum);
+            diffY = 0;
+          }
+          else
+          {
+            double pente = nom/denom;
+            if (pente < 0)
+            {
+              diffX = 2*(edge()->colors().count()/2 - splineNum);
+              diffY = edge()->colors().count()/2 + splineNum;
+            }
+            else
+            {
+              diffX = 2*(edge()->colors().count()/2 - splineNum);
+              diffY = 2*(edge()->colors().count()/2 - splineNum);
+            }
+          }
+          QPointF p(
+              //NOTE: when uncommenting, fix nested comments in here:
+              (dro.integers[2*i+1]/ *%m_wdhcf* /*m_scaleX) +m_xMargin + diffX,
+              (m_gh-dro.integers[2*i+2]/ *%m_hdvcf* /)*m_scaleY + m_yMargin + diffY
+                  );
+          points[i] = p;
+        }
+        path.moveTo(points[0]);
+        for (int j = 0; j < (points.size()-1)/3; j++)
+        {
+          path.cubicTo(points[3*j + 1],points[3*j+1 + 1], points[3*j+2 + 1]);
+        }
+        for (int j = (points.size()-1)/3-3; j >= 0 ; j--)
+        {
+          path.cubicTo(points[3*j + 1],points[3*j+1 + 1], points[3*j+2 + 1]);
+        }
+      }
+    }
+  }
+  return path;
+  */
+}
+
+
+
+void CanvasEdge::paint(QPainter* p, const QStyleOptionGraphicsItem* option,
+                   QWidget* widget)
+{
+//   kDebug();
+Q_UNUSED(option)
+Q_UNUSED(widget)
+  if (m_boundingRect == QRectF())
+  {
+    return;
+  }
+  /// computes the scaling of line width
+  qreal widthScaleFactor = (m_scaleX+m_scaleY)/2;
+  if (widthScaleFactor < 1)
+  {
+    widthScaleFactor = 1;
+  }
+
+  if (edge()->style()=="invis")
+  {
+    return;
+  }
+  if (edge()->renderOperations().isEmpty())
+  {
+    if ((edge()->fromNode()->canvasElement()!=0)
+      && (edge()->toNode()->canvasElement()!=0))
+    {
+      p->drawLine(
+        edge()->fromNode()->canvasElement()->boundingRect().center()+edge()->fromNode()->canvasElement()->pos(),
+        edge()->toNode()->canvasElement()->boundingRect().center()+edge()->toNode()->canvasElement()->pos());
+    }
+    return;
+  }
+
+  QColor lineColor = Dot2QtConsts::componentData().qtColor(edge()->color(0));
+  QColor backColor;
+  
+  QList<QPointF> allPoints;
+  foreach (const DotRenderOp& dro, edge()->renderOperations())
+  {
+    //     kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "renderop" << dro.renderop << "; selected:" << edge()->isSelected();
+    if (dro.renderop == "c")
+    {
+      QColor c(dro.str.mid(0,7));
+      bool ok;
+      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
+      lineColor = c;
+//       kDebug() << "c" << dro.str.mid(0,7) << lineColor;
+    }
+    else if (dro.renderop == "C")
+    {
+      QColor c(dro.str.mid(0,7));
+      bool ok;
+      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
+/*      if (m_hovered && m_view->highlighting())
+      {
+        c = c.lighter();
+      }*/
+      backColor = c;
+//       kDebug() << "C" << dro.str.mid(0,7) << backColor;
+    }
+    else if ( dro.renderop == "T" )
+    {
+      const QString& str = dro.str;
+    
+      qreal stringWidthGoal = dro.integers[3] * m_scaleX;
+      int fontSize = edge()->fontSize();
+      m_font->setPointSize(fontSize);
+      QFontMetrics fm(*m_font);
+      while (fm.width(str) > stringWidthGoal && fontSize > 1)
+      {
+        fontSize--;
+        m_font->setPointSize(fontSize);
+        fm = QFontMetrics(*m_font);
+      }
+      p->save();
+      p->setFont(*m_font);
+      
+      p->setPen(Dot2QtConsts::componentData().qtColor(edge()->fontColor()));
+
+      qreal x = (m_scaleX *
+                       (
+                         (dro.integers[0])
+                         + (((-dro.integers[2])*(fm.width(dro.str)))/2)
+                         - ( (fm.width(dro.str))/2 )
+                       )
+                      )
+                      + m_xMargin;
+      qreal y = ((m_gh - (dro.integers[1]))*m_scaleY)+ m_yMargin;
+      QPointF point(x,y);
+//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawText" << edge()->fontColor() << point;
+
+      p->drawText(point,str);
+      p->restore();
+    }      
+    else if (( dro.renderop == "p" ) || (dro.renderop == "P" ))
+    {
+      QPolygonF polygon(dro.integers[0]);
+      for (int i = 0; i < dro.integers[0]; i++)
+      {
+        QPointF point(
+            (int(dro.integers[2*i+1])/*%m_wdhcf*/)*m_scaleX +m_xMargin,
+            (int(m_gh-dro.integers[2*i+2])/*%m_hdvcf*/)*m_scaleY + m_yMargin
+                );
+        polygon[i] = point;
+//         kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id()  << point;
+        allPoints.append(point);
+      }
+      if (dro.renderop == "P" )
+      {
+        p->save();
+        p->setBrush(lineColor);
+        p->drawPolygon(polygon);
+//         kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawPolygon" << edge()->color(0) << polygon;
+        p->restore();
+      }
+      else
+      {
+        p->setBrush(Dot2QtConsts::componentData().qtColor("white"));
+      }
+      QPen pen(lineColor);
+      if (edge()->style() == "bold")
+      {
+        pen.setStyle(Qt::SolidLine);
+        pen.setWidth((int)(2 * widthScaleFactor));
+      }
+      else
+      {
+        pen.setWidth((int)(1 * widthScaleFactor));
+        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(edge()->style()));
+      }
+      p->save();
+      p->setPen(pen);
+//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawPolyline" << edge()->color(0) << polygon;
+      p->drawPolyline(polygon);
+      p->restore();
+    }
+    else if (( dro.renderop == "e" ) || (dro.renderop == "E" ))
+    {
+      qreal w = m_scaleX * dro.integers[2] * 2;
+      qreal h = m_scaleY *  dro.integers[3] * 2;
+      qreal x = (m_xMargin + (dro.integers[0]/*%m_wdhcf*/)*m_scaleX) - w/2;
+      qreal y = ((m_gh -  dro.integers[1]/*%m_hdvcf*/)*m_scaleY + m_yMargin) - h/2;
+      p->save();
+      if (dro.renderop == "E" )
+      {
+        p->setBrush(lineColor);
+      }
+      else
+      {
+        p->setBrush(Dot2QtConsts::componentData().qtColor("white"));
+      }
+      QPen pen(lineColor);
+      if (edge()->style() == "bold")
+      {
+        pen.setStyle(Qt::SolidLine);
+        pen.setWidth(int(2 * widthScaleFactor));
+      }
+      else
+      {
+        pen.setWidth(int(1 * widthScaleFactor));
+        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(edge()->style()));
+      }
+      p->setPen(pen);
+      QRectF rect(x,y,w,h);
+//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawEllipse" << edge()->color(0) << rect;
+      p->drawEllipse(rect);
+      p->restore();
+    }
+    else if ( dro.renderop == "B" )
+    {
+      uint lineWidth = 1;
+      QPen pen;
+      if (edge()->style() == "bold")
+      {
+        pen.setStyle(Qt::SolidLine);
+        pen.setWidth(int(2 * widthScaleFactor));
+      }
+      else if (edge()->style() != "filled")
+      {
+        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(edge()->style()));
+      }
+      if (edge()->style().left(12) == "setlinewidth")
+      {
+        bool ok;
+        lineWidth = edge()->style().mid(12, edge()->style().length()-1-12).toInt(&ok);
+        pen.setWidth(int(lineWidth * widthScaleFactor));
+      }
+      if (edge()->attributes().contains("penwidth"))
+      {
+        bool ok;
+        lineWidth = edge()->attributes()["penwidth"].toInt(&ok);
+        pen.setWidth(int(lineWidth * widthScaleFactor));
+      }
+      if (edge()->attributes().contains("color"))
+      {
+        kDebug() << "set edge color to " << QColor(edge()->attributes()["color"]).name();
+        lineColor = QColor(edge()->attributes()["color"]);
+      }
+      for (int splineNum = 0; splineNum < edge()->colors().count() || (splineNum==0 && edge()->colors().count()==0); splineNum++)
+      {
+        QPolygonF points(dro.integers[0]);
+        for (int i = 0; i < dro.integers[0]; i++)
+        {
+          // computing of diffX and diffY to draw parallel edges
+          // when asked through the corresponding GraphViz feature
+          qreal nom = (dro.integers[2*dro.integers[0]]-dro.integers[2]);
+          qreal denom = (dro.integers[2*dro.integers[0]-1]-dro.integers[1]);
+          qreal diffX, diffY;
+          if (nom == 0)
+          {
+            diffX = 0;
+            diffY = 2*(edge()->colors().count()/2 - splineNum);
+          }
+          else if (denom ==0)
+          {
+            diffX = 2*(edge()->colors().count()/2 - splineNum);
+            diffY = 0;
+          }
+          else
+          {
+            double pente = nom/denom;
+            if (pente < 0)
+            {
+              diffX = 2*(edge()->colors().count()/2 - splineNum);
+              diffY = edge()->colors().count()/2 + splineNum;
+            }
+            else
+            {
+              diffX = 2*(edge()->colors().count()/2 - splineNum);
+              diffY = 2*(edge()->colors().count()/2 - splineNum);
+            }
+          }
+          QPointF p(
+              (dro.integers[2*i+1]/*%m_wdhcf*/*m_scaleX) +m_xMargin + diffX,
+              (m_gh-dro.integers[2*i+2]/*%m_hdvcf*/)*m_scaleY + m_yMargin + diffY
+                  );
+          points[i] = p;
+//           kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id()  << p;
+          allPoints.append(p);
+        }
+        kDebug() << "Setting pen color to " << edge()->color(splineNum);
+        if (splineNum != 0)
+          lineColor = Dot2QtConsts::componentData().qtColor(edge()->color(splineNum));
+        pen.setColor(lineColor);
+        p->save();
+//         p->setBrush(Dot2QtConsts::componentData().qtColor(edge()->color(0)));
+        p->setBrush(Qt::NoBrush);
+        p->setPen(pen);
+        QPainterPath path;
+        path.moveTo(points[0]);
+        for (int j = 0; j < (points.size()-1)/3; j++)
+        {
+          path.cubicTo(points[3*j + 1],points[3*j+1 + 1], points[3*j+2 + 1]);
+        }
+//         kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawPath" << edge()->color(splineNum) << points.first() << points.last();
+        p->drawPath(path);
+        p->restore();
+      }
+    }
+  }
+  if (edge()->isSelected())
+  {
+//     kDebug() << "draw square";
+//     p->drawRect(m_boundingRect);
+    qreal maxDist = 0;
+    QPair<QPointF,QPointF> pointsPair;
+    foreach(const QPointF& point1, allPoints)
+    {
+      foreach(const QPointF& point2, allPoints)
+      {
+        if (distance(point1, point2) > maxDist)
+        {
+          maxDist = distance(point1, point2);
+          pointsPair = qMakePair(point1, point2);
+        }
+      }
+    }
+    if (maxDist>0)
+    {
+      p->save();
+      //         p->setBrush(Dot2QtConsts::componentData().qtColor(edge()->color(0)));
+      p->setBrush(Qt::black);
+      p->setPen(Qt::black);
+      p->drawRect(QRectF(pointsPair.first-QPointF(3,3),QSizeF(6,6)));
+      p->drawRect(QRectF(pointsPair.second-QPointF(3,3),QSizeF(6,6)));
+      p->restore();
+    }
+  }
+}
+
+void CanvasEdge::modelChanged()
+{
+//   kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id();
+  prepareGeometryChange();
+  computeBoundingRect();
+}
+
+void CanvasEdge::computeBoundingRect()
+{
+//   kDebug();
+  //invalidate bounding region cache
+  m_boundingRegion = QPainterPath();
+  if (edge()->renderOperations().isEmpty())
+  {
+    if ((edge()->fromNode()->canvasElement()==0)
+      || (edge()->toNode()->canvasElement()==0)
+      || edge()->style()=="invis")
+    {
+      m_boundingRect = QRectF();
+    }
+    else
+    {
+      QRectF br(
+      edge()->fromNode()->canvasElement()->boundingRect().center()+edge()->fromNode()->canvasElement()->pos(),
+                edge()->toNode()->canvasElement()->boundingRect().center()+edge()->toNode()->canvasElement()->pos());
+//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() <<br;
+      m_boundingRect = br;
+    }
+  }
+  else
+  {
+    QPolygonF points;
+    foreach (const DotRenderOp& dro, edge()->renderOperations())
+    {
+//       kDebug() << dro.renderop  << ", ";
+      if ( (dro.renderop != "B") && (dro.renderop != "p") &&  (dro.renderop != "P") ) continue;
+      uint previousSize = points.size();
+      points.resize(previousSize+dro.integers[0]);
+      for (int i = 0; i < dro.integers[0]; i++)
+      {
+        QPointF p(
+            ((dro.integers[2*i+1]/*%m_wdhcf*/)*m_scaleX) +m_xMargin,
+            ((m_gh-dro.integers[2*i+2]/*%m_hdvcf*/)*m_scaleY) + m_yMargin
+                );
+        points[previousSize+i] = p;
+      }
+    }
+//     kDebug() << points.size() << "points";
+    if (points.size() == 0) return;
+
+    int len = points.count();
+    QPolygonF a = points,  b = points;
+    a.translate(-1, -1);
+    b.translate(1, 1);
+    a.resize(2*len);
+    for (int i=0;i<len;i++)
+    {
+      a[len+i] = b[i];
+    }
+//     kDebug() << a.size() << "points";
+
+    m_boundingRect = a.boundingRect();
+  }
+  kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "New bounding rect is:" << m_boundingRect;
+}
+
+void CanvasEdge::mousePressEvent(QGraphicsSceneMouseEvent * event)
+{
+  kDebug() << event;
+  if (m_view->isReadOnly())
+  {
+    return;
+  }
+  if (event->button() == Qt::LeftButton)
+  {
+    edge()->setSelected(!edge()->isSelected());
+    if (edge()->isSelected())
+    {
+      emit(selected(this,event->modifiers()));
+    }
+    update();
+  }
+  else if (event->button() == Qt::RightButton)
+  {
+    if (!edge()->isSelected())
+    {
+      edge()->setSelected(true);
+      emit(selected(this,event->modifiers()));
+      update();
+    }
+    kDebug() << "emiting edgeContextMenuEvent("<<m_edge->id()<<","<<event->screenPos()<<")";
+    emit(edgeContextMenuEvent(m_edge->id(), event->screenPos() ));
+// opens the selected edge contextual menu and if necessary select the edge
+/*    kDebug() << "opens the contextual menu";
+    m_popup->exec(event->screenPos());*/
+  }
+}
+
+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();
+}
+
+void CanvasEdge::hoverEnterEvent( QGraphicsSceneHoverEvent * event )
+{
+  Q_UNUSED(event)
+  kDebug() << edge()->id();
+  emit hoverEnter(this);
+}
+
+void CanvasEdge::hoverLeaveEvent( QGraphicsSceneHoverEvent * event )
+{
+  Q_UNUSED(event)
+  kDebug() << edge()->id();
+  emit hoverLeave(this);
+}
+
+}
+
+#include "canvasedge.moc"
diff --git a/src/kgraphviz/canvasedge.h b/src/kgraphviz/canvasedge.h
new file mode 100644
index 0000000..4efe8e3
--- /dev/null
+++ b/src/kgraphviz/canvasedge.h
@@ -0,0 +1,117 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+#ifndef CANVAS_EDGE_H
+#define CANVAS_EDGE_H
+
+#include <QGraphicsScene>
+#include <QGraphicsPathItem>
+#include <QAbstractGraphicsShapeItem>
+#include <QWidget>
+#include <QMap>
+#include <QFont>
+
+#include "graphexporter.h"
+
+
+class QMenu;
+
+/*
+ * Canvas Items:
+ * - CanvasNode       (Rectangular Area)
+ * - CanvasEdge       (Spline curve)
+ * - CanvasEdgeLabel  (Label for edges)
+ * - CanvasEdgeArrow  (Arrows at the end of the edge spline)
+ */
+namespace KGraphViewer
+{
+
+class CanvasNode;
+class CanvasEdge;
+class GraphEdge;
+class DotGraphView;
+
+
+class CanvasEdge : public QObject, public QAbstractGraphicsShapeItem
+{
+Q_OBJECT
+public:
+  explicit CanvasEdge(DotGraphView* v, GraphEdge*,
+             qreal scaleX, qreal scaleY,
+             qreal xMargin, qreal yMargin, qreal gh,
+             qreal wdhcf, qreal hdvcf, QGraphicsItem* parent = 0);
+
+  virtual ~CanvasEdge();
+  
+  QRectF boundingRect() const;
+
+  QPainterPath shape () const;
+
+  void paint(QPainter* p, const QStyleOptionGraphicsItem *option,
+        QWidget *widget);
+
+  inline GraphEdge* edge() { return m_edge; }
+  inline const GraphEdge* edge() const { return m_edge; }
+
+  inline void setGh(qreal gh) {m_gh = gh;}
+  
+  void computeBoundingRect();
+
+Q_SIGNALS:
+  void selected(CanvasEdge*, Qt::KeyboardModifiers);
+  void edgeContextMenuEvent(const QString&, const QPoint&);
+  void hoverEnter(CanvasEdge*);
+  void hoverLeave(CanvasEdge*);
+  
+public Q_SLOTS:
+  void modelChanged();
+  void slotRemoveEdge();
+
+protected:
+  virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
+  virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
+  virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
+  
+private:
+  qreal distance(const QPointF& point1, const QPointF& point2);
+  
+  qreal m_scaleX, m_scaleY;
+  qreal m_xMargin, m_yMargin, m_gh, m_wdhcf, m_hdvcf;
+  GraphEdge* m_edge;
+  QRectF m_boundingRect;
+  QFont* m_font;
+  DotGraphView* m_view;
+  QMenu* m_popup;
+  mutable QPainterPath m_boundingRegion;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/canvaselement.cpp b/src/kgraphviz/canvaselement.cpp
new file mode 100644
index 0000000..94c6eb3
--- /dev/null
+++ b/src/kgraphviz/canvaselement.cpp
@@ -0,0 +1,575 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+
+#include "canvaselement.h"
+#include "dotgraphview.h"
+#include "graphelement.h"
+#include "support/dotdefaults.h"
+#include "support/dot2qtconsts.h"
+#include "support/FontsCache.h"
+
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+
+#include <QPainter>
+#include <QGraphicsScene>
+#include <QGraphicsSceneMouseEvent>
+#include <QMenu>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <KAction>
+
+namespace KGraphViewer
+{
+  
+  
+CanvasElement::CanvasElement(
+                              DotGraphView* v,
+                              GraphElement* gelement,
+                              QGraphicsScene* c,
+                              QGraphicsItem* parent
+                            )
+  : QObject(), QAbstractGraphicsShapeItem(parent),
+    m_scaleX(0), m_scaleY(0),
+    m_xMargin(0), m_yMargin(0), m_gh(0), m_wdhcf(0), m_hdvcf(0),
+    m_element(gelement), m_view(v),
+    m_font(0),
+    m_pen(Dot2QtConsts::componentData().qtColor(gelement->fontColor())),
+    m_popup(new QMenu()),
+    m_hovered(false)
+{
+//   kDebug();
+  m_font = FontsCache::changeable().fromName(gelement->fontName());
+/*  kDebug() << "Creating CanvasElement for "<<gelement->id();
+  kDebug() << "    data: " << wdhcf << "," << hdvcf << "," << gh << "," 
+    << scaleX << "," << scaleY << "," << xMargin << "," << yMargin << endl;*/
+  
+  if (element()->style() == "bold")
+  {
+    m_pen.setStyle(Qt::SolidLine);
+    m_pen.setWidth(int(2*((m_scaleX+m_scaleY)/2)));
+  }
+  else if (element()->style() != "filled")
+  {
+    m_pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(m_element->style()));
+    m_pen.setWidth(int((m_scaleX+m_scaleY)/2));
+    if (element()->style().left(12) == "setlinewidth")
+    {
+      bool ok;
+      uint lineWidth = element()->style().mid(13, m_element->style().length()-1-13).toInt(&ok);
+      m_pen.setWidth(lineWidth * int((m_scaleX+m_scaleY)/2));
+    }
+  }
+  if (m_element->style() == "filled")
+  {
+    m_brush = Dot2QtConsts::componentData().qtColor(element()->backColor());
+//     QCanvasPolygon::drawShape(p);
+  }
+  else
+  {
+    m_brush = c->backgroundBrush();
+  }
+  
+  // the message should be given (or possible to be given) by the part user
+  KAction* removeElementAction = new KAction(i18n("Remove selected element(s)"), this);
+  m_popup->addAction(removeElementAction);
+  connect(removeElementAction,SIGNAL(triggered(bool)),this,SLOT(slotRemoveElement()));
+
+  connect(this, SIGNAL(selected(CanvasElement*, Qt::KeyboardModifiers)), v, SLOT(slotElementSelected(CanvasElement*, Qt::KeyboardModifiers)));
+
+  connect(this, SIGNAL(elementContextMenuEvent(const QString&, const QPoint&)), v, SLOT(slotContextMenuEvent(const QString&, const QPoint&)));
+
+  setAcceptHoverEvents ( true );
+
+  connect(this, SIGNAL(hoverEnter(CanvasElement*)), v, SLOT(slotElementHoverEnter(CanvasElement*)));
+  connect(this, SIGNAL(hoverLeave(CanvasElement*)), v, SLOT(slotElementHoverLeave(CanvasElement*)));
+  
+}
+
+CanvasElement::~CanvasElement()
+{
+  delete m_popup;
+}
+
+void CanvasElement::modelChanged()
+{
+  kDebug() ;//<< id();
+  m_pen = QPen(Dot2QtConsts::componentData().qtColor(m_element->fontColor()));
+  m_font = FontsCache::changeable().fromName(m_element->fontName());
+  prepareGeometryChange();
+  computeBoundingRect();
+}
+
+void CanvasElement::initialize(qreal scaleX, qreal scaleY,
+                            qreal xMargin, qreal yMargin, qreal gh,
+                            qreal wdhcf, qreal hdvcf)
+{
+//   kDebug();
+  setFlag(QGraphicsItem::ItemIsMovable, true);
+  setFlag(QGraphicsItem::ItemIsSelectable, true);
+
+  m_scaleX = scaleX; m_scaleY = scaleY;
+  m_xMargin = xMargin; m_yMargin = yMargin;
+//   m_gh = gh;
+  m_wdhcf = wdhcf; m_hdvcf = hdvcf;
+
+  setZValue(m_element->z());
+
+  computeBoundingRect();
+}
+
+QRectF CanvasElement::boundingRect () const
+{
+  return m_boundingRect;
+}
+
+void CanvasElement::computeBoundingRect()
+{
+//   kDebug() << element();
+  kDebug() << element()->id() << zValue();
+  
+  qreal adjust = 0.5;
+  QRectF rect;
+  if (element()->renderOperations().isEmpty())
+  {
+    kDebug() << "no render operation";
+    rect = QRectF(0,0,(m_view->defaultNewElementPixmap().size().width())*m_scaleX,(m_view->defaultNewElementPixmap().size().height())*m_scaleY);
+    m_boundingRect = rect;
+  }
+  else
+  {
+    DotRenderOpVec::const_iterator it, it_end;
+    it = element()->renderOperations().constBegin(); it_end = element()->renderOperations().constEnd();
+    for (; it != it_end; it++)
+    {
+//       QString msg;
+//       QTextStream dd(&msg);
+//       dd << element()->id() << " an op: " << (*it).renderop << " ";
+//       foreach (int i, (*it).integers)
+//       {
+//         dd << i << " ";
+//       }
+//       dd << (*it).str;
+//       kDebug() << msg;
+
+      if ((*it).renderop == "e" || (*it).renderop == "E")
+      {
+//         kDebug() << "integers[0]=" << (*it).integers[0] << "; m_wdhcf=" << m_wdhcf
+//             << "(*it).integers[0]/*%m_wdhcf*/=" << (*it).integers[0]/*%m_wdhcf*/;
+        qreal w = m_scaleX * (*it).integers[2] * 2;
+        qreal h = m_scaleY * (*it).integers[3] * 2;
+        qreal x = m_xMargin + (((*it).integers[0]/*%m_wdhcf*/)*m_scaleX) - w/2;
+        qreal y = ((m_gh - (*it).integers[1]/*%m_hdvcf*/)*m_scaleY) + m_yMargin - h/2;
+        m_boundingRect = QRectF(x - adjust,y - adjust, w + adjust, h + adjust);
+//         kDebug() << "'" << element()->id() << "' set rect for ellipse to " << rect;
+      }
+      else if  ((*it).renderop == "p" || (*it).renderop == "P")
+      {
+        QPolygonF polygon((*it).integers[0]);
+        for (int i = 0; i < (*it).integers[0]; i++)
+        {
+          qreal x,y;
+          x = ((*it).integers[2*i+1] == m_wdhcf)?(*it).integers[2*i+1]:(*it).integers[2*i+1]/*%m_wdhcf*/;
+          y = ((*it).integers[2*i+2] == m_hdvcf)?(*it).integers[2*i+2]:(*it).integers[2*i+2]/*%m_hdvcf*/;
+          {
+
+          }
+          QPointF p(
+                    x*m_scaleX +m_xMargin,
+                    (m_gh-y)*m_scaleY + m_yMargin
+                  );
+          polygon[i] = p;
+        }
+        m_boundingRect = polygon.boundingRect();
+//         kDebug() << "'" << element()->id() << "' set rect for polygon to " << rect;
+      }
+    }
+  }
+  setPos(0,0);
+}
+
+void CanvasElement::paint(QPainter* p, const QStyleOptionGraphicsItem *option,
+QWidget *widget)
+{
+  Q_UNUSED(option)
+  Q_UNUSED(widget)
+  /// computes the scaling of line width
+  qreal widthScaleFactor = (m_scaleX+m_scaleY)/2;
+  if (widthScaleFactor < 1)
+  {
+    widthScaleFactor = 1;
+  }
+  
+  QString msg;
+  QTextStream dd(&msg);
+  foreach (const DotRenderOp &op, element()->renderOperations())
+  {
+    dd << element()->id() << " an op: " << op.renderop << " ";
+    foreach (int i, op.integers)
+    {
+      dd << i << " ";
+    }
+    dd << op.str << endl;
+  }
+//   kDebug() << msg;
+
+  if (element()->renderOperations().isEmpty() && m_view->isReadWrite())
+  {
+    kError() << element()->id() << ": no render operation. This should not happen.";
+    return;
+  }
+
+  QListIterator<DotRenderOp> it(element()->renderOperations());
+//   it.toBack();
+
+  QColor lineColor = Dot2QtConsts::componentData().qtColor(element()->lineColor());
+  QColor backColor = Dot2QtConsts::componentData().qtColor(element()->backColor());
+  if (m_hovered && m_view->highlighting())
+  {
+    backColor = backColor.lighter();
+  }
+  
+  while (it.hasNext())
+  {
+    const DotRenderOp& dro = it.next();
+    if (dro.renderop == "c")
+    {
+      QColor c(dro.str.mid(0,7));
+      bool ok;
+      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
+      lineColor = c;
+//       kDebug() << "c" << dro.str.mid(0,7) << lineColor;
+    }
+    else if (dro.renderop == "C")
+    {
+      QColor c(dro.str.mid(0,7));
+      bool ok;
+      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
+      if (m_hovered && m_view->highlighting())
+      {
+        c = c.lighter();
+      }
+      backColor = c;
+//       kDebug() << "C" << dro.str.mid(0,7) << backColor;
+    }
+    else if (dro.renderop == "e" || dro.renderop == "E")
+    {
+      QPen pen = p->pen();
+      qreal w = m_scaleX * dro.integers[2] * 2;
+      qreal h = m_scaleY * dro.integers[3] * 2;
+      qreal x = m_xMargin + ((dro.integers[0]/*%m_wdhcf*/)*m_scaleX) - w/2;
+      qreal y = ((m_gh - dro.integers[1]/*%m_hdvcf*/)*m_scaleY) + m_yMargin - h/2;
+      QRectF rect(x,y,w,h);
+      p->save();
+      p->setBrush(backColor);
+      pen.setColor(lineColor);
+      if (element()->attributes().contains("penwidth"))
+      {
+        bool ok;
+        int lineWidth = element()->attributes()["penwidth"].toInt(&ok);
+        pen.setWidth(int(lineWidth * widthScaleFactor));
+      }
+      p->setPen(pen);
+      
+//       kDebug() << element()->id() << "drawEllipse" << lineColor << backColor << rect;
+//       rect = QRectF(0,0,100,100);
+      p->drawEllipse(rect);
+      p->restore();
+    }
+    else if(dro.renderop == "p" || dro.renderop == "P")
+    {
+//       std::cerr << "Drawing polygon for node '"<<element()->id()<<"': ";
+      QPolygonF points(dro.integers[0]);
+      for (int i = 0; i < dro.integers[0]; i++)
+      {
+        qreal x,y;
+        x = (dro.integers[2*i+1] == m_wdhcf)?dro.integers[2*i+1]:dro.integers[2*i+1]/*%m_wdhcf*/;
+        y = (dro.integers[2*i+2] == m_hdvcf)?dro.integers[2*i+2]:dro.integers[2*i+2]/*%m_hdvcf*/;
+        QPointF p(
+                  (x*m_scaleX) + m_xMargin,
+                  ((m_gh-y)*m_scaleY) + m_yMargin
+                );
+/*        kDebug() << "    point: (" << dro.integers[2*i+1] << ","
+                  << dro.integers[2*i+2] << ") " << m_wdhcf << "/" << m_hdvcf;*/
+        points[i] = p;
+      }
+      p->save();
+
+      QPen pen = p->pen();
+      pen.setColor(lineColor);
+      if (element()->style() == "bold")
+      {
+        pen.setStyle(Qt::SolidLine);
+        pen.setWidth(2);
+      }
+      if (element()->attributes().contains("penwidth"))
+      {
+        bool ok;
+        int lineWidth = element()->attributes()["penwidth"].toInt(&ok);
+        pen.setWidth(int(lineWidth * widthScaleFactor));
+      }
+      else if (element()->style() != "filled")
+      {
+        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(element()->style()));
+      }
+      if (element()->style().left(12) == "setlinewidth")
+      {
+        bool ok;
+        uint lineWidth = element()->style().mid(12, element()->style().length()-1-12).toInt(&ok);
+        pen.setWidth(lineWidth);
+      }
+      p->setPen(pen);
+      p->setBrush(backColor);
+/*      if (element()->style() == "filled")
+      {
+        p->setBrush(Dot2QtConsts::componentData().qtColor(element()->backColor()));
+    //     QCanvasPolygon::paint(p);
+      }
+      else
+      {
+        p->setBrush(canvas()->backgroundColor());
+      }*/
+//       kDebug() << element()->id() << "drawPolygon" << points;
+      p->drawPolygon(points);
+      p->restore();
+      if (!element()->shapeFile().isEmpty())
+      {
+        QPixmap pix(element()->shapeFile());
+        if (!pix.isNull())
+        {
+          p->drawPixmap(int(points.boundingRect().left()), int(points.boundingRect().top()), pix);
+        }
+      }
+    }
+
+  }
+
+  it.toFront();
+  while (it.hasNext())
+  {
+    const DotRenderOp& dro = it.next();
+    if (dro.renderop == "c")
+    {
+      QColor c(dro.str.mid(0,7));
+      bool ok;
+      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
+      lineColor = c;
+//       kDebug() << "c" << dro.str.mid(0,7) << lineColor;
+    }
+    else if (dro.renderop == "C")
+    {
+      QColor c(dro.str.mid(0,7));
+      bool ok;
+      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
+      if (m_hovered && m_view->highlighting())
+      {
+        c = c.lighter();
+      }
+      backColor = c;
+//       kDebug() << "C" << dro.str.mid(0,7) << backColor;
+    }
+    else if ( dro.renderop == "L" )
+    {
+//       kDebug() << "Label";
+      QPolygonF points(dro.integers[0]);
+      for (int i = 0; i < dro.integers[0]; i++)
+      {
+        qreal x,y;
+        x = (dro.integers[2*i+1] == m_wdhcf)?dro.integers[2*i+1]:dro.integers[2*i+1]/*%m_wdhcf*/;
+        y = (dro.integers[2*i+2] == m_hdvcf)?dro.integers[2*i+2]:dro.integers[2*i+2]/*%m_hdvcf*/;
+        QPointF p(
+                  (x*m_scaleX) +m_xMargin,
+                  ((m_gh-y)*m_scaleY) + m_yMargin
+                );
+        points[i] = p;
+      }
+      p->save();
+      QPen pen(lineColor);
+      if (element()->style() == "bold")
+      {
+        pen.setStyle(Qt::SolidLine);
+        pen.setWidth(2);
+      }
+      else if (element()->style() != "filled")
+      {
+        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(element()->style()));
+      }
+      p->setPen(pen);
+//       kDebug() << element()->id() << "drawPolyline" << points;
+      p->drawPolyline(points);
+      p->restore();
+    }
+  }
+
+//   kDebug() << "Drawing" << element()->id() << "labels";
+  QString color = lineColor.name();
+  it.toFront();
+  while (it.hasNext())
+  {
+    const DotRenderOp& dro = it.next();
+    if (dro.renderop == "c" || dro.renderop == "C")
+    {
+      color = dro.str.mid(0,7);
+//       kDebug() << dro.renderop << color;
+    }
+    else if (dro.renderop == "F")
+    {
+      element()->setFontName(dro.str);
+      element()->setFontSize(dro.integers[0]);
+//       kDebug() << "F" << element()->fontName() << element()->fontColor() << element()->fontSize();
+    }
+    else if ( dro.renderop == "T" )
+    {
+      // we suppose here that the color has been set just before
+      element()->setFontColor(color);
+      // draw a label
+//       kDebug() << "Drawing a label " << dro.integers[0]
+//       << " " << dro.integers[1] << " " << dro.integers[2]
+//       << " " << dro.integers[3] << " " << dro.str
+//         << " (" << element()->fontName() << ", " << element()->fontSize()
+//         << ", " << element()->fontColor() << ")";
+
+      int stringWidthGoal = int(dro.integers[3] * m_scaleX);
+      int fontSize = element()->fontSize();
+//       kDebug() << element()->id() << " initial fontSize " << fontSize;
+      m_font->setPointSize(fontSize);
+      QFontMetrics fm(*m_font);
+      while (fm.width(dro.str) > stringWidthGoal && fontSize > 1)
+      {
+        fontSize--;
+        m_font->setPointSize(fontSize);
+        fm = QFontMetrics(*m_font);
+      }
+      p->save();
+      p->setFont(*m_font);
+      QPen pen(m_pen);
+      pen.setColor(element()->fontColor());
+      p->setPen(pen);
+      qreal x = (m_scaleX *
+                       (
+                         (dro.integers[0])
+                         + (((-dro.integers[2])*(fm.width(dro.str)))/2)
+                         - ( (fm.width(dro.str))/2 )
+                       )
+                      )
+                      + m_xMargin;
+      qreal y = ((m_gh - (dro.integers[1]))*m_scaleY)+ m_yMargin;
+      QPointF point(x,y);
+//       kDebug() << element()->id() << "drawText" << point << " " << fontSize;
+      p->drawText(point, dro.str);
+      p->restore();
+    }
+  }
+  if (element()->isSelected())
+  {
+//     kDebug() << "element is selected: draw selection marks";
+    p->save();
+    p->setBrush(Qt::black);
+    p->setPen(Qt::black);
+    p->drawRect(QRectF(m_boundingRect.topLeft(),QSizeF(6,6)));
+    p->drawRect(QRectF(m_boundingRect.topRight()-QPointF(6,0),QSizeF(6,6)));
+    p->drawRect(QRectF(m_boundingRect.bottomLeft()-QPointF(0,6),QSizeF(6,6)));
+    p->drawRect(QRectF(m_boundingRect.bottomRight()-QPointF(6,6),QSizeF(6,6)));
+    p->restore();
+  }
+}
+
+void CanvasElement::mousePressEvent(QGraphicsSceneMouseEvent* event)
+{
+  kDebug() << m_element->id() << boundingRect();
+  if (m_view->isReadOnly())
+  {
+    return;
+  }
+  if (m_view->editingMode() == DotGraphView::AddNewEdge)
+  {
+    m_view->createNewEdgeDraftFrom(this);
+    return;
+  }
+  else if (m_view->editingMode() == DotGraphView::DrawNewEdge)
+  {
+    m_view->finishNewEdgeTo(this);
+    return;
+  }
+  if (event->button() == Qt::LeftButton)
+  {
+    m_element->setSelected(!m_element->isSelected());
+    if (m_element->isSelected())
+    {
+      emit(selected(this,event->modifiers()));
+    }
+    update();
+  }
+  else if (event->button() == Qt::RightButton)
+  {
+    // opens the selected edge contextual menu and if necessary select the edge
+    if (!m_element->isSelected())
+    {
+      m_element->setSelected(true);
+      emit(selected(this,event->modifiers()));
+      update();
+    }
+    
+//     kDebug() << "opens the contextual menu";
+//     m_popup->exec(event->screenPos());
+    emit(elementContextMenuEvent(m_element->id(), event->screenPos() ));
+  }
+}
+
+void CanvasElement::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
+{
+  Q_UNUSED(event)
+//   kDebug() ;
+}
+
+void CanvasElement::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
+{
+  Q_UNUSED(event)
+//   kDebug() ;
+}
+
+void CanvasElement::slotRemoveElement()
+{
+  kDebug();
+  m_view->removeSelectedElements();
+}
+
+void CanvasElement::hoverEnterEvent( QGraphicsSceneHoverEvent * event )
+{
+  Q_UNUSED(event)
+//   kDebug();
+  m_hovered = true;
+  update();
+  emit hoverEnter(this);
+}
+
+void CanvasElement::hoverLeaveEvent( QGraphicsSceneHoverEvent * event )
+{
+  Q_UNUSED(event)
+//   kDebug();
+  m_hovered = false;
+  update();
+  emit hoverLeave(this);
+}
+
+}
+
+#include "canvaselement.moc"
diff --git a/src/kgraphviz/canvaselement.h b/src/kgraphviz/canvaselement.h
new file mode 100644
index 0000000..d37a208
--- /dev/null
+++ b/src/kgraphviz/canvaselement.h
@@ -0,0 +1,101 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/*
+ * Canvas Subgraph (subgraph node view)
+ */
+
+#ifndef CANVAS_ELEMENT_H
+#define CANVAS_ELEMENT_H
+
+#include <QAbstractGraphicsShapeItem>
+#include <QPen>
+#include <QBrush>
+
+class QMenu;
+class QGraphicsScene;
+
+
+namespace KGraphViewer
+{
+class GraphElement;
+class DotGraphView;
+
+class CanvasElement: public QObject, public QAbstractGraphicsShapeItem
+{
+Q_OBJECT
+public:
+  CanvasElement(
+      DotGraphView* v, 
+      GraphElement* s,
+      QGraphicsScene* c,
+      QGraphicsItem* parent = 0);
+      
+  virtual ~CanvasElement();
+  
+  GraphElement* element() { return m_element; }
+
+  virtual void paint(QPainter* p, const QStyleOptionGraphicsItem *option,
+        QWidget *widget = 0 );
+
+  virtual QRectF boundingRect () const;
+
+  void computeBoundingRect();
+  
+  void initialize(qreal scaleX, qreal scaleY,
+                  qreal xMargin, qreal yMargin, qreal gh,
+                  qreal wdhcf, qreal hdvcf);
+
+  inline void setGh(qreal gh) {m_gh = gh;}
+  
+  protected:
+  virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
+  virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
+  virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
+  virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
+  virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent * event );
+
+  qreal m_scaleX, m_scaleY;
+  qreal m_xMargin, m_yMargin, m_gh, m_wdhcf, m_hdvcf;
+  GraphElement* m_element;
+  DotGraphView* m_view;
+  QFont* m_font;
+  QPen m_pen;
+  QBrush m_brush;
+  QRectF m_boundingRect;
+  QMenu* m_popup;
+
+  bool m_hovered;
+  
+Q_SIGNALS:
+  void selected(CanvasElement*, Qt::KeyboardModifiers);
+  void elementContextMenuEvent(const QString&, const QPoint&);
+  void hoverEnter(CanvasElement*);
+  void hoverLeave(CanvasElement*);
+  
+public Q_SLOTS:
+  void modelChanged();
+  void slotRemoveElement();
+};
+
+}
+
+#endif // CANVAS_ELEMENT_H
+
+
+
diff --git a/src/kgraphviz/canvasnode.cpp b/src/kgraphviz/canvasnode.cpp
new file mode 100644
index 0000000..ab37cc4
--- /dev/null
+++ b/src/kgraphviz/canvasnode.cpp
@@ -0,0 +1,148 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.cpp, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+/*
+ * Callgraph View
+ */
+
+#include "canvasnode.h"
+#include "dotgraphview.h"
+#include "graphnode.h"
+#include "support/dotdefaults.h"
+#include "support/dot2qtconsts.h"
+#include "support/FontsCache.h"
+
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+
+#include <QGraphicsScene>
+#include <QMatrix>
+#include <QPainter>
+#include <QStyle>
+#include <QPolygonF>
+#include <QPixmap>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+namespace KGraphViewer
+{
+  
+CanvasNode::CanvasNode(DotGraphView* v,
+                        GraphNode* s,
+                        QGraphicsScene* c,
+                        QGraphicsItem* parent)
+: CanvasElement(v,(GraphElement*)s, c, parent)
+
+{
+  kDebug() << s->id();
+  connect(s,SIGNAL(changed()),this,SLOT(modelChanged()));
+
+  QString tipStr;
+  QString id = s->id();
+  QString label = s->label();
+  tipStr = i18n("id='%1'\nlabel='%2'",id,label);
+//   kDebug() << "CanvasEllipseNode setToolTip " << tipStr;
+  setToolTip(tipStr);
+}
+
+// CanvasHtmlNode::CanvasHtmlNode(
+//                                           DotGraphView* v, 
+//                                           GraphNode* n,
+//                                           const DotRenderOp& dro,
+//                                           const DotRenderOpVec& dros,
+//                                           QGraphicsScene* c,
+//                                           double scaleX, double scaleY, 
+//                                           int xMargin, int yMargin, int gh,
+//                                           int wdhcf, int hdvcf
+//                                         )
+// : KHTMLPart(v->viewport()), CanvasNode(v, n)
+// {
+//   m_renderOperations = dros;
+// //   kDebug() << "Creating "<<node()->id()<<" CanvasHtmlNode for" << n
+// //     << " with label '" << n->label() << "'";
+// 
+//   QString myHTMLCode = n->label();
+//   myHTMLCode = myHTMLCode.mid(1, myHTMLCode.length() - 2);
+// //   kDebug() << "HTML = " << myHTMLCode;
+//   begin(KUrl(QString("file:") + QDir::currentPath() + "/index.html"));
+//   setAutoloadImages(true);
+//   write(myHTMLCode);
+//   kDebug() << "HTML written.";
+//   end();
+//   setStatusMessagesEnabled (false);
+// //   view()->setFrameShape ( QFrame::NoFrame );
+// //   view()->setFrameShadow ( QFrame::Plain );
+// //   view()->setLineWidth ( 0 );
+// //   view()->setMidLineWidth ( 0 );
+// //   view()->setHScrollBarMode ( Q3ScrollView::AlwaysOff );
+// //   view()->setVScrollBarMode ( Q3ScrollView::AlwaysOff );
+//   view()->setMarginWidth(0);
+//   view()->setMarginHeight(0);
+//   m_zoomFactor = m_view->zoom();
+//   view()->part()->setZoomFactor(int(m_zoomFactor*100));
+//   view()->move(int(n->x()*scaleX*m_zoomFactor), int((gh-n->y())*scaleY*m_zoomFactor));
+//   view()->setMinimumSize(int(n->w()*scaleX),int(n->h()*scaleY*m_zoomFactor));
+//   view()->setMaximumSize(int(n->w()*scaleX),int(n->h()*scaleY*m_zoomFactor));
+//   view()->adjustSize();
+//   KHTMLPart::show();
+//   CanvasHtmlNode::connect(v, SIGNAL(contentsMoving ( int, int)), this, SLOT(move(int, int)));
+//   CanvasHtmlNode::connect(v, SIGNAL(zoomed (double)), this, SLOT(zoomed(double)));
+// }
+// 
+// CanvasHtmlNode::~CanvasHtmlNode() 
+// {
+//   KHTMLPart::hide();
+// }
+// 
+// // void CanvasHtmlNode::paint(QPainter& p)
+// // {
+// //   view()->drawContents(&p);
+// // }
+// 
+// void CanvasHtmlNode::move(int x, int y)
+// {
+// //   kDebug() << "CanvasHtmlNode::move("<<x<<", "<<y<<")";
+//   m_xMovedTo = x; m_yMovedTo = y;
+//   view()->move(int((node()->x())*m_scaleX*m_zoomFactor - m_xMovedTo), int((m_gh-node()->y())*m_scaleY*m_zoomFactor) - m_yMovedTo);
+// //   view()->move(int(x*m_scaleX), int((m_gh-y)*m_scaleY));
+// }
+// 
+// void CanvasHtmlNode::zoomed(double factor)
+// {
+//   m_zoomFactor = factor;
+//   view()->part()->setZoomFactor(int(factor*100));
+//   view()->move(int(node()->x()*m_scaleX*m_zoomFactor - m_xMovedTo), int((m_gh-node()->y())*m_scaleY*m_zoomFactor - m_yMovedTo));
+//   view()->setMinimumSize(int(node()->w()*m_scaleX*m_zoomFactor),int(node()->h()*m_scaleY*m_zoomFactor));
+//   view()->setMaximumSize(int(node()->w()*m_scaleX*m_zoomFactor),int(node()->h()*m_scaleY*m_zoomFactor));
+//   view()->adjustSize();
+// }
+
+}
+
+#include "canvasnode.moc"
diff --git a/src/kgraphviz/canvasnode.h b/src/kgraphviz/canvasnode.h
new file mode 100644
index 0000000..fdb8436
--- /dev/null
+++ b/src/kgraphviz/canvasnode.h
@@ -0,0 +1,86 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+/*
+ * Canvas Node (graph node view)
+ */
+
+#ifndef CANVAS_NODE_H
+#define CANVAS_NODE_H
+
+#include "canvaselement.h"
+
+namespace KGraphViewer
+{
+  
+class GraphNode;
+
+class CanvasNode : public CanvasElement
+{
+  Q_OBJECT
+public:
+  CanvasNode(DotGraphView* v,
+            GraphNode* s,
+            QGraphicsScene* c,
+            QGraphicsItem* parent = 0);
+  
+  virtual ~CanvasNode() {}
+  
+};
+
+// class CanvasHtmlNode: public KHTMLPart, public CanvasNode
+// {
+//   Q_OBJECT
+// public:
+//   CanvasHtmlNode(
+//                      DotGraphView* v, 
+//                      GraphNode* n,
+//                      const DotRenderOp& dro,
+//                      const DotRenderOpVec& dros,
+//                      QGraphicsScene* c,
+//                      double scaleX, double scaleY, int xMargin, int yMargin, int gh,
+//                      int wdhcf, int hdvcf);
+//   virtual ~CanvasHtmlNode();
+//   
+//   QRect rect() {return view()->contentsRect();}
+//   
+// protected:
+// //   virtual void paint(QPainter&);
+// 
+// public slots:
+//   void move(int x, int y);
+//   void zoomed(double factor);
+// 
+// private:
+//   double m_zoomFactor;
+//   int m_xMovedTo, m_yMovedTo;
+// };
+
+}
+#endif
+
+
+
diff --git a/src/kgraphviz/canvassubgraph.cpp b/src/kgraphviz/canvassubgraph.cpp
new file mode 100644
index 0000000..a0ea4b4
--- /dev/null
+++ b/src/kgraphviz/canvassubgraph.cpp
@@ -0,0 +1,37 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+
+#include "canvassubgraph.h"
+
+namespace KGraphViewer
+{
+  
+  
+CanvasSubgraph::CanvasSubgraph(
+                              DotGraphView* v,
+                              GraphSubgraph* gsubgraph,
+                              QGraphicsScene* c,
+                              QGraphicsItem* parent
+                            ) : CanvasElement(v,(GraphElement*)gsubgraph,c,parent)
+{
+}
+
+}
+
+#include "canvassubgraph.moc"
diff --git a/src/kgraphviz/canvassubgraph.h b/src/kgraphviz/canvassubgraph.h
new file mode 100644
index 0000000..868a516
--- /dev/null
+++ b/src/kgraphviz/canvassubgraph.h
@@ -0,0 +1,56 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/*
+ * Canvas Subgraph (subgraph node view)
+ */
+
+#ifndef CANVAS_SUBGRAPH_H
+#define CANVAS_SUBGRAPH_H
+
+#include "canvaselement.h"
+
+class QGraphicsScene;
+
+namespace KGraphViewer
+{
+  
+class GraphSubgraph;
+class DotGraphView;
+
+class CanvasSubgraph: public CanvasElement
+{
+  Q_OBJECT
+
+public:
+  CanvasSubgraph(
+      DotGraphView* v, 
+      GraphSubgraph* s,
+      QGraphicsScene* c,
+      QGraphicsItem* parent = 0);
+  virtual ~CanvasSubgraph() {}
+  
+protected:
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/dotgraph.cpp b/src/kgraphviz/dotgraph.cpp
new file mode 100644
index 0000000..59696e0
--- /dev/null
+++ b/src/kgraphviz/dotgraph.cpp
@@ -0,0 +1,1020 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#include "dotgraph.h"
+
+#include "graphexporter.h"
+#include "canvasedge.h"
+#include "canvasnode.h"
+#include "canvassubgraph.h"
+#include "support/dotgrammar.h"
+#include "support/DotGraphParsingHelper.h"
+
+#include <math.h>
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "part/fdstream.hpp"
+#include <boost/spirit/include/classic_assign_actor.hpp>
+#include <boost/spirit/include/classic_confix.hpp>
+#include <boost/spirit/include/classic_distinct.hpp>
+
+#include <graphviz/gvc.h>
+
+#include <KDebug>
+#include <KLocale>
+#include <KMessageBox>
+
+#include <QFile>
+#include <QPair>
+#include <QByteArray>
+#include <QProcess>
+#include <QMutexLocker>
+#include <QUuid>
+
+using namespace boost;
+using namespace boost::spirit::classic;
+
+extern KGraphViewer::DotGraphParsingHelper* phelper;
+
+
+namespace KGraphViewer
+{
+
+const distinct_parser<> keyword_p("0-9a-zA-Z_");
+
+DotGraph::DotGraph() :
+  GraphElement(),
+  m_dotFileName(""),m_width(0.0), m_height(0.0),m_scale(1.0),
+  m_directed(true),m_strict(false),
+  m_layoutCommand(""),
+  m_horizCellFactor(0), m_vertCellFactor(0),
+  m_wdhcf(0), m_hdvcf(0),
+  m_readWrite(false),
+  m_dot(0),
+  m_phase(Initial),
+  m_useLibrary(false)
+{
+  setId("unnamed");
+}
+
+DotGraph::DotGraph(const QString& command, const QString& fileName) :
+  GraphElement(),
+  m_dotFileName(fileName),m_width(0.0), m_height(0.0),m_scale(1.0),
+  m_directed(true),m_strict(false),
+  m_layoutCommand(command),
+  m_horizCellFactor(0), m_vertCellFactor(0),
+  m_wdhcf(0), m_hdvcf(0),
+  m_readWrite(false),
+  m_dot(0),
+  m_phase(Initial),
+  m_useLibrary(false)
+{
+  setId("unnamed");
+}
+
+DotGraph::~DotGraph()  
+{
+  GraphNodeMap::iterator itn, itn_end;
+  itn = m_nodesMap.begin(); itn_end = m_nodesMap.end();
+  for (; itn != itn_end; itn++)
+  {
+    delete *itn;
+  }
+
+  GraphEdgeMap::iterator ite, ite_end;
+  ite = m_edgesMap.begin(); ite_end = m_edgesMap.end();
+  for (; ite != ite_end; ite++)
+  {
+    delete (*ite);
+  }
+}
+
+QString DotGraph::chooseLayoutProgramForFile(const QString& str)
+{
+  QFile iFILE(str);
+
+  if (!iFILE.open(QIODevice::ReadOnly))
+  {
+    kError() << "Can't test dot file. Will try to use the dot command on the file: '" << str << "'" << endl;
+    return "dot";// -Txdot";
+  }
+
+  QByteArray fileContent = iFILE.readAll();
+  if (fileContent.isEmpty()) return "";
+  std::string s =  fileContent.data();
+  std::string cmd = "dot";
+  parse(s.c_str(),
+        (
+          !(keyword_p("strict")) >> (keyword_p("graph")[assign_a(cmd,"neato")])
+        ), (space_p|comment_p("/*", "*/")) );
+
+  return  QString::fromStdString(cmd);// + " -Txdot" ;
+}
+
+bool DotGraph::parseDot(const QString& str)
+{
+  kDebug() << str;
+  m_useLibrary = false;
+  if (m_layoutCommand.isEmpty())
+  {
+    m_layoutCommand = chooseLayoutProgramForFile(str);
+    if (m_layoutCommand.isEmpty())
+    {
+      m_layoutCommand = chooseLayoutProgramForFile(str);
+      return false;
+    }
+  }
+
+  kDebug() << "Running " << m_layoutCommand  << str;
+  QStringList options;
+  /// @TODO handle the non-dot commands that could don't know the -T option
+//  if (m_readWrite && m_phase == Initial)
+//  {
+//    options << "-Tdot";
+//  }
+//  else
+//  {
+    options << "-Txdot";
+//   }
+  options << str;
+
+  kDebug() << "m_dot is " << m_dot  << ". Acquiring mutex";
+  QMutexLocker locker(&m_dotProcessMutex);
+  kDebug() << "mutex acquired ";
+  if (m_dot != 0)
+  {
+    disconnect(m_dot,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotDotRunningDone(int,QProcess::ExitStatus)));
+    disconnect(m_dot,SIGNAL(error(QProcess::ProcessError)),this,SLOT(slotDotRunningError(QProcess::ProcessError)));
+    m_dot->kill();
+    delete m_dot;
+  }
+  m_dot = new QProcess();
+  connect(m_dot,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotDotRunningDone(int,QProcess::ExitStatus)));
+  connect(m_dot,SIGNAL(error(QProcess::ProcessError)),this,SLOT(slotDotRunningError(QProcess::ProcessError)));
+  m_dot->start(m_layoutCommand, options);
+  kDebug() << "process started";
+ return true;
+}
+
+bool DotGraph::update()
+{
+  GraphExporter exporter;
+  if (!m_useLibrary)
+  {
+    kDebug() << "command";
+    QString str = exporter.writeDot(this);
+    return parseDot(str);
+  }
+  else
+  {
+    kDebug() << "library";
+    graph_t* graph = exporter.exportToGraphviz(this);
+
+    GVC_t* gvc = gvContext();
+    gvLayout(gvc, graph, m_layoutCommand.toUtf8().data());
+    gvRender (gvc, graph, "xdot", NULL);
+
+    updateWithGraph(graph);
+    
+    gvFreeLayout(gvc, graph);
+    agclose(graph);
+    bool result = (gvFreeContext(gvc) == 0);
+    return result;
+  }
+}
+
+QByteArray DotGraph::getDotResult(int , QProcess::ExitStatus )
+{
+  kDebug();
+
+  QMutexLocker locker(&m_dotProcessMutex);
+  if (m_dot == 0)
+  {
+    return QByteArray();
+  }
+  QByteArray result = m_dot->readAll();
+  delete m_dot;
+  m_dot = 0;
+  return result;
+}
+
+void DotGraph::slotDotRunningDone(int exitCode, QProcess::ExitStatus exitStatus)
+{
+  kDebug();
+  
+  QByteArray result = getDotResult(exitCode, exitStatus);
+  result.replace("\\\n","");
+
+  kDebug() << "string content is:" << endl << result << endl << "=====================" << result.size();
+  std::string s =  result.data();
+  //   std::cerr << "stdstring content is:" << std::endl << s << std::endl << "===================== " << s.size() << std::endl;
+  if (phelper != 0)
+  {
+    phelper->graph = 0;
+    delete phelper;
+  }
+//   if (parsingResult)
+//   {
+//     if (m_readWrite)
+//     {
+//       storeOriginalAttributes();
+//       update();
+//     }
+//     computeCells();
+//   }
+
+  DotGraph newGraph(m_layoutCommand, m_dotFileName);
+  phelper = new DotGraphParsingHelper;
+  phelper->graph = &newGraph;
+  phelper->z = 1;
+  phelper->maxZ = 1;
+  phelper->uniq = 0;
+
+  kDebug() << "parsing new dot";
+  bool parsingResult = parse(s);
+  delete phelper;
+  phelper = 0;
+  kDebug() << "phelper deleted";
+
+  if (parsingResult)
+  {
+    kDebug() << "calling updateWithGraph";
+    updateWithGraph(newGraph);
+  }
+  else
+  {
+    kDebug() << "parsing failed";
+    kError() << "parsing failed";
+  }
+//   return parsingResult;
+//   if (m_readWrite && m_phase == Initial)
+//   {
+//     m_phase = Final;
+//     update();
+//   }
+//   else
+//   {
+    kDebug() << "emiting readyToDisplay";
+    emit(readyToDisplay());
+//   }
+}
+
+void DotGraph::slotDotRunningError(QProcess::ProcessError error)
+{
+  kError() << "DotGraph::slotDotRunningError" << error;
+  switch (error)
+  {
+    case QProcess::FailedToStart:
+      KMessageBox::error(0, i18n("Unable to start %1.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
+    break;
+    case QProcess::Crashed:
+      KMessageBox::error(0, i18n("%1 crashed.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
+    break;
+    case QProcess::Timedout:
+      KMessageBox::error(0, i18n("%1 timed out.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
+    break;
+    case QProcess::WriteError:
+      KMessageBox::error(0, i18n("Was not able to write data to the %1 process.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
+    break;
+    case QProcess::ReadError:
+      KMessageBox::error(0, i18n("Was not able to read data from the %1 process.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
+    break;
+    default:
+      KMessageBox::error(0, i18n("Unknown error running %1.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
+  }
+}
+
+unsigned int DotGraph::cellNumber(int x, int y)
+{
+/*  kDebug() << "x= " << x << ", y= " << y << ", m_width= " << m_width << ", m_height= " << m_height << ", m_horizCellFactor= " << m_horizCellFactor << ", m_vertCellFactor= " << m_vertCellFactor  << ", m_wdhcf= " << m_wdhcf << ", m_hdvcf= " << m_hdvcf;*/
+  
+  unsigned int nx = (unsigned int)(( x - ( x % int(m_wdhcf) ) ) / m_wdhcf);
+  unsigned int ny = (unsigned int)(( y - ( y % int(m_hdvcf) ) ) / m_hdvcf);
+/*  kDebug() << "nx = " << (unsigned int)(( x - ( x % int(m_wdhcf) ) ) / m_wdhcf);
+  kDebug() << "ny = " << (unsigned int)(( y - ( y % int(m_hdvcf) ) ) / m_hdvcf);
+  kDebug() << "res = " << ny * m_horizCellFactor + nx;*/
+  
+  unsigned int res = ny * m_horizCellFactor + nx;
+  return res;
+}
+
+#define MAXCELLWEIGHT 800
+
+void DotGraph::computeCells()
+{
+  return;
+  kDebug() << m_width << m_height << endl;
+  m_horizCellFactor = m_vertCellFactor = 1;
+  m_wdhcf = (int)ceil(((double)m_width) / m_horizCellFactor)+1;
+  m_hdvcf = (int)ceil(((double)m_height) / m_vertCellFactor)+1;
+  bool stop = true;
+  do
+  {
+    stop = true;
+    m_cells.clear();
+//     m_cells.resize(m_horizCellFactor * m_vertCellFactor);
+    
+    GraphNodeMap::iterator it, it_end;
+    it = m_nodesMap.begin(); it_end = m_nodesMap.end();
+    for (; it != it_end; it++)
+    {
+      GraphNode* gn = *it;
+//       int cellNum = cellNumber(int(gn->x()), int(gn->y()));
+      int cellNum = cellNumber(0,0);
+      kDebug() << "Found cell number " << cellNum;
+
+      if (m_cells.size() <= cellNum)
+      {
+        m_cells.resize(cellNum+1);
+      }
+      m_cells[cellNum].insert(gn);
+      
+      kDebug() << "after insert";
+      if ( m_cells[cellNum].size() > MAXCELLWEIGHT )
+      {
+        kDebug() << "cell number " << cellNum  << " contains " << m_cells[cellNum].size() << " nodes";
+        if ((m_width/m_horizCellFactor) > (m_height/m_vertCellFactor))
+        {
+          m_horizCellFactor++;
+          m_wdhcf = m_width / m_horizCellFactor;
+        }
+        else
+        {
+          m_vertCellFactor++;
+          m_hdvcf = m_height / m_vertCellFactor;
+        }
+        kDebug() << "cell factor is now " << m_horizCellFactor << " / " << m_vertCellFactor;
+        stop = false;
+        break;
+      }
+    }
+  } while (!stop);
+  kDebug() << "m_wdhcf=" << m_wdhcf << "; m_hdvcf=" << m_hdvcf << endl;
+  kDebug() << "finished" << endl;
+}
+
+QSet< GraphNode* >& DotGraph::nodesOfCell(unsigned int id)
+{
+  return m_cells[id];
+}
+
+void DotGraph::storeOriginalAttributes()
+{
+  foreach (GraphNode* node, nodes())
+  {
+    node->storeOriginalAttributes();
+  }
+  foreach (GraphEdge* edge, edges())
+  {
+    edge->storeOriginalAttributes();
+  }
+  foreach (GraphSubgraph* subgraph, subgraphs())
+  {
+    subgraph->storeOriginalAttributes();
+  }
+  GraphElement::storeOriginalAttributes();
+}
+
+void DotGraph::saveTo(const QString& fileName)
+{
+  kDebug() << fileName;
+  m_dotFileName = fileName;
+  GraphExporter exporter;
+  exporter.writeDot(this, fileName);
+}
+
+void DotGraph::updateWithGraph(graph_t* newGraph)
+{
+  kDebug();
+
+  // copy global graph render operations and attributes
+  renderOperations().clear();
+  if (agget(newGraph, (char*)"_draw_") != NULL)
+  {
+    parse_renderop(agget(newGraph, (char*)"_draw_"), renderOperations());
+    kDebug() << "_draw_: element renderOperations size is now " << renderOperations().size();
+  }
+  if (agget(newGraph, (char*)"_ldraw_") != NULL)
+  {
+    parse_renderop(agget(newGraph, (char*)"_ldraw_"), renderOperations());
+    kDebug() << "_ldraw_: element renderOperations size is now " << renderOperations().size();
+  }
+  
+  Agsym_t *attr = agfstattr(newGraph);
+  while(attr)
+  {
+    kDebug() << newGraph->name << ":" << attr->name << agxget(newGraph,attr->index);
+    m_attributes[attr->name] = agxget(newGraph,attr->index);
+    attr = agnxtattr(newGraph,attr);
+  }
+  
+  // copy subgraphs
+  for (edge_t* e = agfstout(newGraph->meta_node->graph, newGraph->meta_node); e;
+      e = agnxtout(newGraph->meta_node->graph, e))
+  {
+    graph_t* sg = agusergraph(e->head);
+    kDebug() << "subgraph:" << sg->name;
+    if (subgraphs().contains(sg->name))
+    {
+      kDebug() << "known";
+      // ???
+      //       nodes()[ngn->name]->setZ(ngn->z());
+      subgraphs()[sg->name]->updateWithSubgraph(sg);
+      if (subgraphs()[sg->name]->canvasElement()!=0)
+      {
+        //         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
+      }
+    }
+    else
+    {
+      kDebug() << "new";
+      GraphSubgraph* newsg = new GraphSubgraph(sg);
+      //       kDebug() << "new created";
+      subgraphs().insert(sg->name, newsg);
+      //       kDebug() << "new inserted";
+    }
+
+  }
+
+  // copy nodes
+  node_t* ngn = agfstnode(newGraph);
+  kDebug() << "first node:" << (void*)ngn;
+  
+  while (ngn != NULL)
+//   foreach (GraphNode* ngn, newGraph.nodes())
+  {
+    kDebug() << "node " << ngn->name;
+    if (nodes().contains(ngn->name))
+    {
+      kDebug() << "known";
+// ???
+//       nodes()[ngn->name]->setZ(ngn->z());
+      nodes()[ngn->name]->updateWithNode(ngn);
+      if (nodes()[ngn->name]->canvasElement()!=0)
+      {
+        //         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
+      }
+    }
+    else
+    {
+      kDebug() << "new";
+      GraphNode* newgn = new GraphNode(ngn);
+      //       kDebug() << "new created";
+      nodes().insert(ngn->name, newgn);
+      //       kDebug() << "new inserted";
+    }
+
+    // copy node edges
+    edge_t* nge = agfstout(newGraph, ngn);
+    while (nge != NULL)
+    {
+      kDebug() << "edge " << nge->id;
+      QString edgeName = QString(nge->head->name) + nge->tail->name;
+      if (edges().contains(edgeName))
+      {
+        kDebug() << "edge known" << nge->id;
+//         edges()[nge->name]->setZ(nge->z());
+        edges()[edgeName]->updateWithEdge(nge);
+        if (edges()[edgeName]->canvasEdge()!=0)
+        {
+          //         edges()[nge->id()]->canvasEdge()->setGh(m_height);
+        }
+      }
+      else
+      {
+        kDebug() << "new edge" << edgeName;
+        {
+          GraphEdge* newEdge = new GraphEdge();
+          newEdge->setId(edgeName);
+          newEdge->updateWithEdge(nge);
+          if (elementNamed(nge->tail->name) == 0)
+          {
+            GraphNode* newgn = new GraphNode();
+            //       kDebug() << "new created";
+            nodes().insert(nge->tail->name, newgn);
+          }
+          newEdge->setFromNode(elementNamed(nge->tail->name));
+          if (elementNamed(nge->head->name) == 0)
+          {
+            GraphNode* newgn = new GraphNode();
+            //       kDebug() << "new created";
+            nodes().insert(nge->head->name, newgn);
+          }
+          newEdge->setToNode(elementNamed(nge->head->name));
+          edges().insert(edgeName, newEdge);
+        }
+      }
+      nge = agnxtedge(newGraph, nge, ngn);
+    }
+    ngn = agnxtnode(newGraph, ngn);
+  }
+  kDebug() << "Done";
+  emit readyToDisplay();
+  computeCells();
+}
+
+void DotGraph::updateWithGraph(const DotGraph& newGraph)
+{
+  kDebug();
+  GraphElement::updateWithElement(newGraph);
+  m_width=newGraph.width();
+  m_height=newGraph.height();
+  m_scale=newGraph.scale();
+  m_directed=newGraph.directed();
+  m_strict=newGraph.strict();
+  computeCells();
+  foreach (GraphSubgraph* nsg, newGraph.subgraphs())
+  {
+    kDebug() << "subgraph" << nsg->id();
+    if (subgraphs().contains(nsg->id()))
+    {
+      kDebug() << "subgraph known" << nsg->id();
+      subgraphs().value(nsg->id())->updateWithSubgraph(*nsg);
+      if (subgraphs().value(nsg->id())->canvasElement()!=0)
+      {
+//         subgraphs().value(nsg->id())->canvasElement()->setGh(m_height);
+      }
+    }
+    else
+    {
+      kDebug() << "new subgraph" << nsg->id();
+      GraphSubgraph* newSubgraph = new GraphSubgraph();
+      newSubgraph->updateWithSubgraph(*nsg);
+      newSubgraph->setZ(0);
+      subgraphs().insert(nsg->id(), newSubgraph);
+    }
+  }
+  foreach (GraphNode* ngn, newGraph.nodes())
+  {
+    kDebug() << "node " << ngn->id();
+    if (nodes().contains(ngn->id()))
+    {
+      kDebug() << "known";
+      nodes()[ngn->id()]->setZ(ngn->z());
+      nodes()[ngn->id()]->updateWithNode(*ngn);
+      if (nodes()[ngn->id()]->canvasElement()!=0)
+      {
+//         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
+      }
+    }
+    else
+    {
+      kDebug() << "new";
+      GraphNode* newgn = new GraphNode(*ngn);
+//       kDebug() << "new created";
+      nodes().insert(ngn->id(), newgn);
+//       kDebug() << "new inserted";
+    }
+  }
+  foreach (GraphEdge* nge, newGraph.edges())
+  {
+    kDebug() << "edge " << nge->id();
+    if (edges().contains(nge->id()))
+    {
+      kDebug() << "edge known" << nge->id();
+      edges()[nge->id()]->setZ(nge->z());
+      edges()[nge->id()]->updateWithEdge(*nge);
+      if (edges()[nge->id()]->canvasEdge()!=0)
+      {
+//         edges()[nge->id()]->canvasEdge()->setGh(m_height);
+      }
+    }
+    else
+    {
+      kDebug() << "new edge" << nge->id();
+      {
+        GraphEdge* newEdge = new GraphEdge();
+        newEdge->setId(nge->id());
+        newEdge->updateWithEdge(*nge);
+        newEdge->setFromNode(elementNamed(nge->fromNode()->id()));
+        newEdge->setToNode(elementNamed(nge->toNode()->id()));
+        edges().insert(nge->id(), newEdge);
+      }
+    }
+  }
+  kDebug() << "Done";
+  computeCells();
+}
+
+void DotGraph::removeNodeNamed(const QString& nodeName)
+{
+  kDebug() << nodeName;
+  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(nodeName));
+  if (node == 0)
+  {
+    kError() << "No such node " << nodeName;
+    return;
+  }
+  
+  GraphEdgeMap::iterator it, it_end;
+  it = m_edgesMap.begin(); it_end = m_edgesMap.end();
+  while (it != it_end)
+  {
+    if ( it.value()->fromNode() == node
+        || it.value()->toNode() == node )
+    {
+      GraphEdge* edge = it.value();
+      if (edge->canvasEdge() != 0)
+      {
+        edge->canvasEdge()->hide();
+        delete edge->canvasEdge();
+        delete edge;
+      }
+      it = edges().erase(it);
+    }
+    else
+    {
+      ++it;
+    }
+  }
+
+  if (node->canvasNode() != 0)
+  {
+    node->canvasNode()->hide();
+    delete node->canvasNode();
+    node->setCanvasNode(0);
+  }
+  nodes().remove(nodeName);
+  delete node;
+
+}
+
+void DotGraph::removeNodeFromSubgraph(
+    const QString& nodeName,
+    const QString& subgraphName)
+{
+  kDebug() << nodeName << subgraphName;
+  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(nodeName));
+  if (node == 0)
+  {
+    kError() << "No such node " << nodeName;
+    return;
+  }
+
+  GraphSubgraph* subgraph = subgraphs()[subgraphName];
+  if (subgraph == 0)
+  {
+    kError() << "No such subgraph " << subgraphName;
+    return;
+  }
+  
+  subgraph->removeElement(node);
+  if (subgraph->content().isEmpty())
+  {
+    removeSubgraphNamed(subgraphName);
+  }
+}
+
+void DotGraph::removeSubgraphNamed(const QString& subgraphName)
+{
+  kDebug() << subgraphName << " from " << subgraphs().keys();
+  GraphSubgraph* subgraph = subgraphs()[subgraphName];
+
+  if (subgraph == 0)
+  {
+    kError() << "Subgraph" << subgraphName << "not found";
+    return;
+  }
+  GraphEdgeMap::iterator it, it_end;
+  it = m_edgesMap.begin(); it_end = m_edgesMap.end();
+  while (it != it_end)
+  {
+    if ( it.value()->fromNode() == subgraph
+        || it.value()->toNode() == subgraph )
+    {
+      GraphEdge* edge = it.value();
+      if (edge->canvasEdge() != 0)
+      {
+        edge->canvasEdge()->hide();
+        delete edge->canvasEdge();
+        delete edge;
+      }
+      it = edges().erase(it);
+    }
+    else
+    {
+      ++it;
+    }
+  }
+
+  if (subgraph->canvasSubgraph() != 0)
+  {
+    subgraph->canvasSubgraph()->hide();
+    delete subgraph->canvasSubgraph();
+    subgraph->setCanvasSubgraph(0);
+  }
+  foreach(GraphElement* element, subgraph->content())
+  {
+    if (dynamic_cast<GraphNode*>(element) != 0)
+    {
+      kDebug() << "Adding" << element->id() << "to main graph";
+      nodes()[element->id()] = dynamic_cast<GraphNode*>(element);
+    }
+    else if (dynamic_cast<GraphSubgraph*>(element) != 0)
+    {
+      subgraphs()[element->id()] = dynamic_cast<GraphSubgraph*>(element);
+    }
+    else
+    {
+      kError() << "Don't know how to handle" << element->id();
+    }
+  }
+  subgraph->content().clear();
+  subgraphs().remove(subgraphName);
+  delete subgraph;
+}
+
+void DotGraph::removeEdge(const QString& id)
+{
+  kDebug() << id;
+  GraphEdgeMap::iterator it = edges().begin();
+  for (; it != edges().end(); it++)
+  {
+    GraphEdge* edge = it.value();
+    if (edge->id() ==id)
+    {
+      if (edge->canvasEdge() != 0)
+      {
+        edge->canvasEdge()->hide();
+        delete edge->canvasEdge();
+        delete edge;
+      }
+      edges().remove(id);
+      break;
+    }
+  }
+}
+
+void DotGraph::removeElement(const QString& id)
+{
+  kDebug() << id;
+  GraphNodeMap::const_iterator itN = nodes().constBegin();
+  for (; itN != nodes().constEnd(); itN++)
+  {
+    const GraphNode* node = itN.value();
+    if (node->id() == id)
+    {
+      removeNodeNamed(id);
+      return;
+    }
+  }
+  GraphEdgeMap::const_iterator itE = edges().constBegin();
+  for (; itE != edges().constEnd(); itE++)
+  {
+    const GraphEdge* edge = itE.value();
+    if (edge->id() == id)
+    {
+      removeEdge(id);
+      return;
+    }
+  }
+  GraphSubgraphMap::const_iterator itS = subgraphs().constBegin();
+  for (; itS != subgraphs().constEnd(); itS++)
+  {
+    const GraphSubgraph* subgraph = itS.value();
+    if (subgraph->id() == id)
+    {
+      removeSubgraphNamed(id);
+      return;
+    }
+  }
+}
+
+void DotGraph::setAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue)
+{
+  if (nodes().contains(elementId))
+  {
+    nodes()[elementId]->attributes()[attributeName] = attributeValue;
+  }
+  else if (edges().contains(elementId))
+  {
+    edges()[elementId]->attributes()[attributeName] = attributeValue;
+  }
+  else if (subgraphs().contains(elementId))
+  {
+    subgraphs()[elementId]->attributes()[attributeName] = attributeValue;
+  }
+}
+
+GraphElement* DotGraph::elementNamed(const QString& id)
+{
+  GraphElement* ret = 0;
+  if ((ret = m_nodesMap.value(id, 0))) {
+    return ret;
+  }
+  if ((ret = m_edgesMap.value(id, 0))) {
+    return ret;
+  }
+  foreach(GraphSubgraph* subGraph, m_subgraphsMap) {
+    if ((ret = subGraph->elementNamed(id))) {
+      return ret;
+    }
+  }
+  return 0;
+}
+
+void DotGraph::setGraphAttributes(QMap<QString,QString> attribs)
+{
+  kDebug() << attribs;
+  attributes() = attribs;
+}
+
+
+void DotGraph::addNewNode(QMap<QString,QString> attribs)
+{
+  kDebug() << attribs;
+  GraphNode* newNode = new GraphNode();
+  newNode->attributes() = attribs;
+  nodes().insert(newNode->id(), newNode);
+  kDebug() << "node added as" << newNode->id();
+}
+
+void DotGraph::addNewSubgraph(QMap<QString,QString> attribs)
+{
+  kDebug() << attribs;
+  GraphSubgraph* newSG = new GraphSubgraph();
+  newSG->attributes() = attribs;
+  subgraphs()[newSG->id()] = newSG;
+  kDebug() << "subgraph added as" << newSG->id();
+}
+
+void DotGraph::addNewNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph)
+{
+  kDebug() << attribs << "to" << subgraph;
+  GraphNode* newNode = new GraphNode();
+  newNode->attributes() = attribs;
+  subgraphs()[subgraph]->content().push_back(newNode);
+
+  kDebug() << "node added as" << newNode->id() << "in" << subgraph;
+}
+
+void DotGraph::addExistingNodeToSubgraph(QMap<QString,QString> attribs,QString subgraph)
+{
+  kDebug() << attribs << "to" << subgraph;
+  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(attribs["id"]));
+  if (node == 0)
+  {
+    kError() << "No such node" << attribs["id"];
+    return;
+  }
+  if (nodes().contains(attribs["id"]))
+  {
+    nodes().remove(attribs["id"]);
+    node->attributes() = attribs;
+    subgraphs()[subgraph]->content().push_back(node);
+    kDebug() << "node " << node->id() << " added in " << subgraph;
+  }
+  else
+  {
+    foreach(GraphSubgraph* gs, subgraphs())
+    {
+      GraphElement* elt = 0;
+      foreach(GraphElement* element, gs->content())
+      {
+        if (element == node)
+        {
+          elt = element;
+          break;
+        }
+      }
+      if (elt != 0)
+      {
+        kDebug() << "removing node " << elt->id() << " from " << gs->id();
+        gs->removeElement(elt);
+        subgraphs()[subgraph]->content().push_back(elt);
+        kDebug() << "node " << elt->id() << " added in " << subgraph;
+        break;
+      }
+    }
+  }
+}
+
+void DotGraph::moveExistingNodeToMainGraph(QMap<QString,QString> attribs)
+{
+  kDebug() << attribs;
+  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(attribs["id"]));
+  if (node == 0)
+  {
+    kError() << "No such node" << attribs["id"];
+    return;
+  }
+  else if (nodes().contains(attribs["id"]))
+  {
+    kError() << "Node" << attribs["id"] << "already in main graph";
+    return;
+  }
+  else
+  {
+    foreach(GraphSubgraph* gs, subgraphs())
+    {
+      bool found = false;
+      foreach(GraphElement* element, gs->content())
+      {
+        if (element == node)
+        {
+          found = true;
+          break;
+        }
+      }
+      if (found)
+      {
+        kDebug() << "removing node " << node->id() << " from " << gs->id();
+        gs->removeElement(node);
+        nodes()[node->id()] = node;
+        kDebug() << "node " << node->id() << " moved to main graph";
+        break;
+      }
+    }
+  }
+}
+
+void DotGraph::addNewEdge(QString src, QString tgt, QMap<QString,QString> attribs)
+{
+  kDebug() << src << tgt << attribs;
+  GraphEdge* newEdge = new GraphEdge();
+  newEdge->attributes() = attribs;
+  GraphElement* srcElement = elementNamed(src);
+  if (srcElement == 0)
+  {
+    srcElement = elementNamed(QString("cluster_")+src);
+  }
+  GraphElement* tgtElement = elementNamed(tgt);
+  if (tgtElement == 0)
+  {
+    tgtElement = elementNamed(QString("cluster_")+tgt);
+  }
+  
+  if (srcElement == 0 || tgtElement == 0)
+  {
+    kError() << src << "or" << tgt << "missing";
+    return;
+  }
+  if (attribs.contains("id"))
+  {
+    newEdge->setId(attribs["id"]);
+  }
+  else
+  {
+    newEdge->setId(src+tgt+QUuid::createUuid().toString().remove('{').remove('}').remove('-'));
+  }
+  newEdge->setFromNode(srcElement);
+  newEdge->setToNode(tgtElement);
+  edges().insert(newEdge->id(), newEdge);
+}
+
+void DotGraph::removeAttribute(const QString& nodeName, const QString& attribName)
+{
+  kDebug();
+  GraphElement* element = elementNamed(nodeName);
+  if (element != 0)
+  {
+    element->removeAttribute(attribName);
+  }
+}
+
+void DotGraph::renameNode(const QString& oldNodeName, const QString& newNodeName)
+{
+  if (oldNodeName != newNodeName)
+  {
+    kDebug() << "Renaming " << oldNodeName << " into " << newNodeName;
+    GraphNode* node = nodes()[oldNodeName];
+    nodes().remove(oldNodeName);
+    node->setId(newNodeName);
+    nodes()[newNodeName] = node;
+  }
+}
+
+QString DotGraph::backColor() const
+{
+  kDebug();
+  if (m_attributes.find("bgcolor") != m_attributes.end())
+  {
+    return m_attributes["bgcolor"];
+  }
+  else
+  {
+    return QString();
+  }
+}
+
+
+}
+
+#include "dotgraph.moc"
diff --git a/src/kgraphviz/dotgraph.h b/src/kgraphviz/dotgraph.h
new file mode 100644
index 0000000..4a52afc
--- /dev/null
+++ b/src/kgraphviz/dotgraph.h
@@ -0,0 +1,173 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/*
+ * GraphViz dot Graph model
+ */
+
+#ifndef DOT_GRAPH_H
+#define DOT_GRAPH_H
+
+#include <QList>
+#include <QSet>
+#include <QString>
+#include <QProcess>
+#include <QMutex>
+
+#include "graphelement.h"
+#include "graphsubgraph.h"
+#include "graphnode.h"
+#include "graphedge.h"
+#include "shared/kgraphviewer_export.h"
+#include "support/dotdefaults.h"
+
+class Agraph_t;
+
+namespace KGraphViewer
+{
+  
+/**
+  * A class representing the model of a GraphViz dot graph
+  */
+class DotGraph : public GraphElement
+{
+  Q_OBJECT
+public:
+  enum ParsePhase {Initial, Final};
+  
+  DotGraph();
+  DotGraph(const QString& command, const QString& fileName);
+
+  virtual ~DotGraph();
+  
+  QString chooseLayoutProgramForFile(const QString& str);
+  bool parseDot(const QString& str);
+  
+  /** Constant accessor to the nodes of this graph */
+  inline const GraphNodeMap& nodes() const {return m_nodesMap;}
+  /** Constant accessor to the edges of this graph */
+  inline const GraphEdgeMap& edges() const {return m_edgesMap;}
+  inline const GraphSubgraphMap& subgraphs() const {return m_subgraphsMap;}
+  /** Accessor to the nodes of this graph */
+  inline GraphNodeMap& nodes() {return m_nodesMap;}
+  /** Accessor to the edges of this graph */
+  inline GraphEdgeMap& edges() {return m_edgesMap;}
+  inline GraphSubgraphMap& subgraphs() {return m_subgraphsMap;}
+  double width() const {return m_width;}
+  double height() const {return m_height;}
+  double scale() const {return m_scale;}
+  void width(double w) {m_width = w;}
+  void height(double h) {m_height = h;}
+  void scale(double s) {m_scale = s;}
+  virtual QString backColor() const;
+  
+  inline void strict(bool s) {m_strict = s;}
+  inline void directed(bool d) {m_directed = d;}
+  inline bool strict() const {return m_strict;}
+  inline bool directed() const {return m_directed;}
+
+  QSet< GraphNode* >& nodesOfCell(unsigned int id);
+  
+  inline unsigned int horizCellFactor() const {return m_horizCellFactor;}
+  inline unsigned int vertCellFactor() const {return m_vertCellFactor;}
+  inline double wdhcf() const {return m_wdhcf;}
+  inline double hdvcf() const {return m_hdvcf;}
+  
+  inline void layoutCommand(const QString& command) {m_layoutCommand = command;}
+  inline const QString& layoutCommand() {return m_layoutCommand;}
+  
+  inline void dotFileName(const QString& fileName) {m_dotFileName = fileName;}
+  inline const QString& dotFileName() const {return m_dotFileName;}
+
+  bool update();
+
+  inline void setReadWrite() {m_readWrite = true;}
+  inline void setReadOnly() {m_readWrite = false;}
+
+  virtual void storeOriginalAttributes();
+
+  void KGRAPHVIEWER_EXPORT saveTo(const QString& fileName);
+
+  virtual void updateWithGraph(Agraph_t* newGraph);
+  virtual void updateWithGraph(const DotGraph& graph);
+
+  void KGRAPHVIEWER_EXPORT setAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue);
+
+  GraphElement* elementNamed(const QString& id);
+
+  inline void setUseLibrary(bool value) {m_useLibrary = value;}
+  inline bool useLibrary() {return m_useLibrary;}
+
+  void KGRAPHVIEWER_EXPORT setGraphAttributes(QMap<QString,QString> attribs);
+  void KGRAPHVIEWER_EXPORT addNewNode(QMap<QString,QString> attribs);
+  void KGRAPHVIEWER_EXPORT addNewSubgraph(QMap<QString,QString> attribs);
+  void KGRAPHVIEWER_EXPORT addNewNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph);
+  void KGRAPHVIEWER_EXPORT addExistingNodeToSubgraph(QMap<QString,QString> attribs,QString subgraph);
+  void KGRAPHVIEWER_EXPORT moveExistingNodeToMainGraph(QMap<QString,QString> attribs);
+  void KGRAPHVIEWER_EXPORT addNewEdge(QString src, QString tgt, QMap<QString,QString> attribs);
+  void KGRAPHVIEWER_EXPORT removeAttribute(const QString& nodeName, const QString& attribName);
+  void KGRAPHVIEWER_EXPORT renameNode(const QString& oldNodeName, const QString& newNodeName);
+  void KGRAPHVIEWER_EXPORT removeNodeNamed(const QString& nodeName);
+  void KGRAPHVIEWER_EXPORT removeNodeFromSubgraph(const QString& nodeName, const QString& subgraphName);
+  void KGRAPHVIEWER_EXPORT removeSubgraphNamed(const QString& subgraphName);
+  void KGRAPHVIEWER_EXPORT removeEdge(const QString& id);
+  void KGRAPHVIEWER_EXPORT removeElement(const QString& id);
+
+Q_SIGNALS:
+  void readyToDisplay();
+
+private Q_SLOTS:
+  void slotDotRunningDone(int,QProcess::ExitStatus);
+  void slotDotRunningError(QProcess::ProcessError);
+  
+private:
+  unsigned int cellNumber(int x, int y);
+  void computeCells();
+  QByteArray getDotResult(int exitCode, QProcess::ExitStatus exitStatus);
+    
+  QString m_dotFileName;
+  GraphSubgraphMap m_subgraphsMap;
+  GraphNodeMap m_nodesMap;
+  GraphEdgeMap m_edgesMap;
+  double m_width, m_height;
+  double m_scale;
+  bool m_directed;
+  bool m_strict;
+  QString m_layoutCommand;
+  
+  unsigned int m_horizCellFactor, m_vertCellFactor;
+  QVector< QSet< GraphNode* > > m_cells;
+  
+  double m_wdhcf, m_hdvcf;
+
+  bool m_readWrite;
+  QProcess* m_dot;
+
+  ParsePhase m_phase;
+
+  QMutex m_dotProcessMutex;
+
+  bool m_useLibrary;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/dotgraphview.cpp b/src/kgraphviz/dotgraphview.cpp
new file mode 100644
index 0000000..014c18e
--- /dev/null
+++ b/src/kgraphviz/dotgraphview.cpp
@@ -0,0 +1,2273 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.cpp, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+/*
+ * Callgraph View
+ */
+
+#include "dotgraphview.h"
+
+#include "dotgraph.h"
+#include "graphelement.h"
+#include "canvassubgraph.h"
+#include "canvasedge.h"
+#include "graphnode.h"
+#include "canvasnode.h"
+#include "graphedge.h"
+#include "pannerview.h"
+
+// TODO: Re-enable
+//#include "part/simpleprintingcommand.h"
+
+#include "graphexporter.h"
+#include "support/dot2qtconsts.h"
+#include "support/FontsCache.h"
+#include "support/loadagraphthread.h"
+#include "support/layoutagraphthread.h"
+
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+#include <limits>
+
+#include <graphviz/types.h>
+
+#include <QMatrix>
+#include <QPainter>
+#include <QStyle>
+#include <QImage>
+#include <QContextMenuEvent>
+#include <QKeyEvent>
+#include <QPixmap>
+#include <QBitmap>
+#include <QResizeEvent>
+#include <QFocusEvent>
+#include <QMouseEvent>
+#include <QWheelEvent>
+#include <QMenu>
+#include <QGraphicsSimpleTextItem>
+#include <QScrollBar>
+#include <QUuid>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kfiledialog.h>
+#include <kmessagebox.h>
+#include <kinputdialog.h>
+#include <kselectaction.h>
+#include <ktoggleaction.h>
+#include <kstandarddirs.h>
+#include <kactionmenu.h>
+    
+// DotGraphView defaults
+
+#define DEFAULT_ZOOMPOS      KGraphViewerInterface::Auto
+#define KGV_MAX_PANNER_NODES 100
+
+namespace KGraphViewer
+{
+
+class DotGraphViewPrivate
+{
+
+public:
+  DotGraphViewPrivate(KActionCollection* actions, DotGraphView* parent) : 
+   m_labelViews(),
+    m_popup(0),
+    m_zoom(1),
+    m_isMoving(false),
+    m_exporter(),
+    m_zoomPosition(DEFAULT_ZOOMPOS),
+    m_lastAutoPosition(KGraphViewerInterface::TopLeft),
+    m_graph(0),
+    m_printCommand(0),
+    m_actions(actions),
+    m_detailLevel(DEFAULT_DETAILLEVEL),
+    m_defaultNewElement(0),
+    m_defaultNewElementPixmap(KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-newnode.png")),
+    m_editingMode(DotGraphView::None),
+    m_newEdgeSource(0),
+    m_newEdgeDraft(0),
+    m_readWrite(false),
+    m_leavedTimer(std::numeric_limits<int>::max()),
+    m_highlighting(false),
+    m_loadThread(),
+    m_layoutThread(),
+    m_backgroundColor(QColor("white")),
+    q_ptr( parent )
+  {
+    
+  }
+  virtual ~DotGraphViewPrivate()
+  {
+    delete m_birdEyeView;
+    m_birdEyeView = 0;
+    if (m_popup != 0)
+    {
+      delete m_popup;
+    }
+    if (m_canvas)
+    {
+      Q_Q(DotGraphView);
+      q->setScene(0);
+      delete m_canvas;
+    }
+    if (m_graph != 0)
+    {
+      delete m_graph;
+    }
+  }
+  
+
+  void updateSizes(QSizeF s = QSizeF(0,0));
+  void updateBirdEyeView();
+  void setupPopup();
+  void exportToImage();
+  KActionCollection* actionCollection() {return m_actions;}
+  int displaySubgraph(GraphSubgraph* gsubgraph, int zValue, CanvasElement* parent = 0);
+
+
+  QSet<QGraphicsSimpleTextItem*> m_labelViews;
+  QGraphicsScene* m_canvas;
+  QMenu* m_popup;
+  KSelectAction* m_bevPopup;
+  KSelectAction* m_layoutAlgoSelectAction;
+  int m_xMargin, m_yMargin;
+  PannerView *m_birdEyeView;
+  double m_cvZoom;
+  double m_zoom;
+  bool m_isMoving;
+  QPoint m_lastPos;
+
+  GraphExporter m_exporter;
+
+  // widget options
+  KGraphViewerInterface::PannerPosition m_zoomPosition, m_lastAutoPosition;
+
+  DotGraph* m_graph;
+
+  KGVSimplePrintingCommand* m_printCommand;
+
+  KToggleAction* m_bevEnabledAction;
+  KActionCollection* m_actions;
+
+  int m_detailLevel;
+
+  GraphElement* m_defaultNewElement;
+
+  /** image used for a new node just added in an edited graph because this new node has
+    *  still no attribute and thus no render operation */
+  QPixmap m_defaultNewElementPixmap;
+  DotGraphView::EditingMode m_editingMode;
+
+  CanvasElement* m_newEdgeSource;
+  QGraphicsLineItem* m_newEdgeDraft;
+
+  bool m_readWrite;
+
+  QMap<QString, QString> m_newElementAttributes;
+
+  /// identifier of the timer started when the mouse leaves the view during
+  /// edge drawing
+  int m_leavedTimer;
+
+  DotGraphView::ScrollDirection m_scrollDirection;
+
+  QPoint m_pressPos;
+  QPoint m_pressScrollBarsPos;
+
+  /// true if elements should be highlighted on hover; false otherwise
+  bool m_highlighting;
+
+  /// A thread to load graphviz agraph files
+  LoadAGraphThread m_loadThread;
+
+  /// A thread to layout graphviz agraph files
+  LayoutAGraphThread m_layoutThread;
+
+  /// The graph background color
+  QColor m_backgroundColor;
+
+  DotGraphView * const q_ptr;
+  Q_DECLARE_PUBLIC(DotGraphView);
+};
+  
+void DotGraphViewPrivate::updateSizes(QSizeF s)
+{
+  kDebug() ;
+  Q_Q(DotGraphView);
+  if (m_canvas == 0)
+    return;
+  if (s == QSizeF(0,0)) s = q->size();
+  
+  // the part of the canvas that should be visible
+  qreal cWidth  = m_canvas->width()  - 2*m_xMargin + 100;
+  qreal cHeight = m_canvas->height() - 2*m_yMargin + 100;
+
+  // TODO: Re-enable
+  // hide birds eye view if no overview needed
+//   if (//!_data || !_activeItem ||
+//       !KGraphViewerPartSettings::birdsEyeViewEnabled() ||
+//       (((cWidth * m_zoom) < s.width()) && (cHeight * m_zoom) < s.height()))
+//   {
+//     m_birdEyeView->hide();
+//     return;
+//   }
+//   m_birdEyeView->hide();
+  
+  // first, assume use of 1/3 of width/height (possible larger)
+  double zoom = .33 * s.width() / cWidth;
+  if (zoom * cHeight < .33 * s.height()) zoom = .33 * s.height() / cHeight;
+  
+  // fit to widget size
+  if (cWidth  * zoom  > s.width())   zoom = s.width() / (double)cWidth;
+  if (cHeight * zoom  > s.height())  zoom = s.height() / (double)cHeight;
+  
+  // scale to never use full height/width
+  zoom = zoom * 3/4;
+  
+  // at most a zoom of 1/3
+  if (zoom > .33) zoom = .33;
+  
+  if (zoom != m_cvZoom)
+  {
+    m_cvZoom = zoom;
+    
+    QMatrix wm;
+    wm.scale( zoom, zoom );
+    m_birdEyeView->setMatrix(wm);
+    
+    // make it a little bigger to compensate for widget frame
+    m_birdEyeView->resize((cWidth * zoom) + 4,
+                          (cHeight * zoom) + 4);
+    
+  }
+  updateBirdEyeView();
+  m_birdEyeView->setZoomRect(q->mapToScene(q->viewport()->rect()).boundingRect());
+  m_birdEyeView->show();
+  QSizeF newCanvasSize = m_canvas->sceneRect().size();
+  if (newCanvasSize.width() < q->viewport()->width())
+  {
+    newCanvasSize.setWidth(q->viewport()->width());
+  }
+  else if (q->viewport()->width() < m_canvas->sceneRect().size().width())
+  {
+    newCanvasSize.setWidth(m_canvas->sceneRect().size().width());
+  }
+  if (newCanvasSize.height() < q->viewport()->height())
+  {
+    newCanvasSize.setHeight(q->viewport()->height());
+  }
+  else if (q->viewport()->height() < m_canvas->sceneRect().size().height())
+  {
+    newCanvasSize.setHeight(m_canvas->sceneRect().size().height());
+  }
+  //   std::cerr << "done." << std::endl;
+}
+
+void DotGraphViewPrivate::updateBirdEyeView()
+{
+  Q_Q(DotGraphView);
+  qreal cvW = m_birdEyeView->width();
+  qreal cvH = m_birdEyeView->height();
+  qreal x = q->width()- cvW - q->verticalScrollBar()->width()    -2;
+  qreal y = q->height()-cvH - q->horizontalScrollBar()->height() -2;
+  QPoint oldZoomPos = m_birdEyeView->pos();
+  QPoint newZoomPos = QPoint(0,0);
+  KGraphViewerInterface::PannerPosition zp = m_zoomPosition;
+  if (zp == KGraphViewerInterface::Auto)
+  {
+    QPointF tl1Pos = q->mapToScene(QPoint(0,0));
+    QPointF tl2Pos = q->mapToScene(QPoint(cvW,cvH));
+    QPointF tr1Pos = q->mapToScene(QPoint(x,0));
+    QPointF tr2Pos = q->mapToScene(QPoint(x+cvW,cvH));
+    QPointF bl1Pos = q->mapToScene(QPoint(0,y));
+    QPointF bl2Pos = q->mapToScene(QPoint(cvW,y+cvH));
+    QPointF br1Pos = q->mapToScene(QPoint(x,y));
+    QPointF br2Pos = q->mapToScene(QPoint(x+cvW,y+cvH));
+    int tlCols = m_canvas->items(QRectF(tl1Pos.x(),tl1Pos.y(),tl2Pos.x(),tl2Pos.y())).count();
+    kDebug() << tr1Pos.x() << tr1Pos.y() << tr2Pos.x() << tr2Pos.y();
+    int trCols = m_canvas->items(QRectF(tr1Pos.x(),tr1Pos.y(),tr2Pos.x(),tr2Pos.y())).count();
+    int blCols = m_canvas->items(QRectF(bl1Pos.x(),bl1Pos.y(),bl2Pos.x(),bl2Pos.y())).count();
+    int brCols = m_canvas->items(QRectF(br1Pos.x(),br1Pos.y(),br2Pos.x(),br2Pos.y())).count();
+    int minCols = tlCols;
+    zp = m_lastAutoPosition;
+    switch(zp)
+    {
+      case KGraphViewerInterface::TopRight:    minCols = trCols; break;
+      case KGraphViewerInterface::BottomLeft:  minCols = blCols; break;
+      case KGraphViewerInterface::BottomRight: minCols = brCols; break;
+      default:
+      case KGraphViewerInterface::TopLeft:     minCols = tlCols; break;
+    }
+    if (minCols > tlCols) { minCols = tlCols; zp = KGraphViewerInterface::TopLeft; }
+    if (minCols > trCols) { minCols = trCols; zp = KGraphViewerInterface::TopRight; }
+    if (minCols > blCols) { minCols = blCols; zp = KGraphViewerInterface::BottomLeft; }
+    if (minCols > brCols) { minCols = brCols; zp = KGraphViewerInterface::BottomRight; }
+    
+    m_lastAutoPosition = zp;
+  }
+  
+  switch(zp)
+  {
+    case KGraphViewerInterface::TopRight:
+      newZoomPos = QPoint(x,0);
+      break;
+    case KGraphViewerInterface::BottomLeft:
+      newZoomPos = QPoint(0,y);
+      break;
+    case KGraphViewerInterface::BottomRight:
+      newZoomPos = QPoint(x,y);
+      break;
+    default:
+      break;
+  }
+  if (newZoomPos != oldZoomPos)
+    m_birdEyeView->move(newZoomPos);
+}
+
+int DotGraphViewPrivate::displaySubgraph(GraphSubgraph* gsubgraph, int zValue, CanvasElement* parent)
+{
+  kDebug();
+  Q_Q(DotGraphView);
+  double scaleX = 1.0, scaleY = 1.0;
+  
+  if (m_detailLevel == 0)      { scaleX = m_graph->scale() * 0.7; scaleY = m_graph->scale() * 0.7; }
+  else if (m_detailLevel == 1) { scaleX = m_graph->scale() * 1.0; scaleY = m_graph->scale() * 1.0; }
+  else if (m_detailLevel == 2) { scaleX = m_graph->scale() * 1.3; scaleY = m_graph->scale() * 1.3; }
+  else                        { scaleX = m_graph->scale() * 1.0; scaleY = m_graph->scale() * 1.0; }
+  
+  qreal gh = m_graph->height();
+  
+  if (gsubgraph->canvasSubgraph() == 0)
+  {
+    kDebug() << "Creating canvas subgraph for" << gsubgraph->id();
+    CanvasSubgraph* csubgraph = new CanvasSubgraph(q, gsubgraph, m_canvas, parent);
+    csubgraph->initialize(
+      scaleX, scaleY, m_xMargin, m_yMargin, gh,
+      m_graph->wdhcf(), m_graph->hdvcf());
+    gsubgraph->setCanvasSubgraph(csubgraph);
+    //       csubgraph->setZValue(gsubgraph->z());
+    csubgraph->setZValue(zValue+=2);
+    csubgraph->show();
+    m_canvas->addItem(csubgraph);
+    kDebug() << " one CanvasSubgraph... Done";
+  }
+  foreach (GraphElement* element, gsubgraph->content())
+  {
+    GraphNode* gnode = dynamic_cast<GraphNode*>(element);
+    if (gnode->canvasNode()==0)
+    {
+      kDebug() << "Creating canvas node for:" << gnode->id();
+      CanvasNode *cnode = new CanvasNode(q, gnode, m_canvas);
+      if (cnode == 0) continue;
+      cnode->initialize(
+        scaleX, scaleY, m_xMargin, m_yMargin, gh,
+        m_graph->wdhcf(), m_graph->hdvcf());
+      gnode->setCanvasNode(cnode);
+      m_canvas->addItem(cnode);
+      //       cnode->setZValue(gnode->z());
+      cnode->setZValue(zValue+1);
+      cnode->show();
+    }
+    gnode->canvasNode()->computeBoundingRect();
+  }
+  gsubgraph->canvasSubgraph()->computeBoundingRect();
+  
+  int newZvalue = zValue;
+  foreach(GraphSubgraph* ssg, gsubgraph->subgraphs())
+  {
+    int hereZvalue = displaySubgraph(ssg, zValue, gsubgraph->canvasSubgraph());
+    if (hereZvalue > newZvalue)
+      newZvalue = hereZvalue;
+  }
+  return newZvalue;
+}
+
+void DotGraphViewPrivate::setupPopup()
+{
+  Q_Q(DotGraphView);
+  if (m_popup != 0)
+  {
+    return;
+  }
+  kDebug() << "DotGraphView::setupPopup";
+  m_popup = new QMenu();
+  
+  m_layoutAlgoSelectAction = new KSelectAction(i18n("Select Layout Algo"),q);
+  actionCollection()->addAction("view_layout_algo",m_layoutAlgoSelectAction);
+  
+  QStringList layoutAlgos;
+  KAction* lea = new KAction(i18n(" "), q);
+  lea->setWhatsThis(i18n("Specify yourself the layout command to use. Given a dot file, it should produce an xdot file on its standard output."));
+  actionCollection()->addAction("layout_specifiy",lea);
+  lea->setCheckable(false);
+  
+  KAction* lda = new KAction(i18n("Dot"), q);
+  lda->setWhatsThis(i18n("Layout the graph using the dot program."));
+  actionCollection()->addAction("layout_dot",lda);
+  lda->setCheckable(false);
+  
+  KAction* lna = new KAction(i18n("Neato"), q);
+  lna->setWhatsThis(i18n("Layout the graph using the neato program."));
+  actionCollection()->addAction("layout_neato",lna);
+  lna->setCheckable(false);
+  
+  KAction* lta = new KAction(i18n("Twopi"), q);
+  lta->setWhatsThis(i18n("Layout the graph using the twopi program."));
+  actionCollection()->addAction("layout_twopi",lta);
+  lta->setCheckable(false);
+  
+  KAction* lfa = new KAction(i18n("Fdp"), q);
+  lfa->setWhatsThis(i18n("Layout the graph using the fdp program."));
+  actionCollection()->addAction("layout_fdp",lfa);
+  lfa->setCheckable(false);
+  
+  KAction* lca = new KAction(i18n("Circo"), q);
+  lca->setWhatsThis(i18n("Layout the graph using the circo program."));
+  actionCollection()->addAction("layout_c",lca);
+  lca->setCheckable(false);
+  
+  m_layoutAlgoSelectAction->addAction(lea);
+  m_layoutAlgoSelectAction->addAction(lda);
+  m_layoutAlgoSelectAction->addAction(lna);
+  m_layoutAlgoSelectAction->addAction(lta);
+  m_layoutAlgoSelectAction->addAction(lfa);
+  m_layoutAlgoSelectAction->addAction(lca);
+  
+  m_layoutAlgoSelectAction->setCurrentItem(1);
+  m_layoutAlgoSelectAction->setEditable(true);
+  m_layoutAlgoSelectAction->setToolTip(i18n("Choose a GraphViz layout algorithm or edit your own one."));
+  m_layoutAlgoSelectAction->setWhatsThis(i18n(
+    "Choose a GraphViz layout algorithm or type in your own command that will "
+    "generate a graph in the xdot format on its standard output. For example, to "
+    "manually specify the <tt>G</tt> option to the dot command, type in: "
+    "<tt>dot -Gname=MyGraphName -Txdot </tt>"));
+  QObject::connect(m_layoutAlgoSelectAction, SIGNAL(triggered (const QString &)),
+          q, SLOT(slotSelectLayoutAlgo(const QString&)));
+  
+  
+  QMenu* layoutPopup = m_popup->addMenu(i18n("Layout"));
+  layoutPopup->addAction(m_layoutAlgoSelectAction);
+  QAction* slc = layoutPopup->addAction(i18n("Specify layout command"), q, SLOT(slotLayoutSpecify()));
+  slc->setWhatsThis(i18n("Specify yourself the layout command to use. Given a dot file, it should produce an xdot file on its standard output."));
+  QAction* rlc = layoutPopup->addAction(i18n("Reset layout command to default"), q, SLOT(slotLayoutReset()));
+  rlc->setWhatsThis(i18n("Resets the layout command to use to the default depending on the graph type (directed or not)."));
+  
+  m_popup->addAction(KIcon("zoom-in"), i18n("Zoom In"), q, SLOT(zoomIn()));
+  m_popup->addAction(KIcon("zoom-out"), i18n("Zoom Out"), q, SLOT(zoomOut()));
+  
+  m_popup->insertSeparator();
+  
+  KActionMenu* file_exportMenu = new KActionMenu(i18n("Export Graph"), q);
+  actionCollection()->addAction("file_export",file_exportMenu);
+  file_exportMenu->setToolTip(i18n("Allows the graph to be exported in another format."));
+  file_exportMenu->setWhatsThis(i18n(
+    "Use the Export Graph menu to export the graph in another format. "
+    "There is currently only one export format supported: as a PNG image."));
+  
+  
+  m_popup->addAction(file_exportMenu);
+  KAction* exportToImageAction = new KAction(i18n("As Image..."),q);
+  exportToImageAction->setWhatsThis(i18n("Export the graph to an image file (currently PNG only.)"));
+  actionCollection()->addAction("export_image", exportToImageAction);
+  QObject::connect(exportToImageAction,SIGNAL(triggered(bool)), q, SLOT(slotExportImage()));
+  
+  file_exportMenu->addAction(exportToImageAction);
+  
+  
+  m_popup->insertSeparator();
+  
+  m_bevEnabledAction = new KToggleAction(
+    KIcon(KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-bev.png")),
+                                        i18n("Enable Bird's-eye View"), q);
+    actionCollection()->addAction("view_bev_enabled",m_bevEnabledAction);
+    m_bevEnabledAction->setShortcut(Qt::CTRL+Qt::Key_B);
+    m_bevEnabledAction->setWhatsThis(i18n("Enables or disables the Bird's-eye View"));
+    QObject::connect(m_bevEnabledAction,
+            SIGNAL(toggled(bool)),
+            q,
+            SLOT(slotBevToggled()));
+    m_bevEnabledAction->setCheckable(true);
+    m_popup->addAction(m_bevEnabledAction);
+    
+    m_bevPopup = new KSelectAction(i18n("Birds-eye View"), q);
+  m_bevPopup->setWhatsThis(i18n("Allows the Bird's-eye View to be setup."));
+  m_popup->addAction(m_bevPopup);
+  actionCollection()->addAction("view_bev",m_bevPopup);
+  
+  KAction* btla = new KAction(i18n("Top Left"), q);
+  btla->setWhatsThis(i18n("Puts the Bird's-eye View in the top-left corner."));
+  btla->setCheckable(true);
+  actionCollection()->addAction("bev_top_left",btla);
+  QObject::connect(btla, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
+          q, SLOT(slotBevTopLeft()));
+  KAction* btra = new KAction(i18n("Top Right"), q);
+  btra->setWhatsThis(i18n("Puts the Bird's-eye View in the top-right corner."));
+  btra->setCheckable(true);
+  actionCollection()->addAction("bev_top_right",btra);
+  QObject::connect(btra, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
+          q, SLOT(slotBevTopRight()));
+  KAction* bbla = new KAction(i18n("Bottom Left"), q);
+  bbla->setWhatsThis(i18n("Puts the Bird's-eye View in the bottom-left corner."));
+  bbla->setCheckable(true);
+  actionCollection()->addAction("bev_bottom_left",bbla);
+  QObject::connect(bbla, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
+          q, SLOT(slotBevBottomLeft()));
+  KAction* bbra = new KAction(i18n("Bottom Right"), q);
+  bbra->setWhatsThis(i18n("Puts the Bird's-eye View in the bottom-right corner."));
+  bbra->setCheckable(true);
+  actionCollection()->addAction("bev_bottom_right",bbra);
+  QObject::connect(bbra, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
+          q, SLOT(slotBevBottomRight()));
+  KAction* bba = new KAction(i18n("Automatic"), q);
+  bba->setWhatsThis(i18n("Let KGraphViewer automatically choose the position of the Bird's-eye View."));
+  bba->setCheckable(true);
+  actionCollection()->addAction("bev_automatic",bba);
+  QObject::connect(bba, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
+          q, SLOT(slotBevAutomatic()));
+  m_bevPopup->addAction(btla);
+  m_bevPopup->addAction(btra);
+  m_bevPopup->addAction(bbla);
+  m_bevPopup->addAction(bbra);
+  m_bevPopup->addAction(bba);
+  switch (m_zoomPosition)
+  {
+    case KGraphViewerInterface::TopLeft:
+      btla->setChecked(true);
+      break;
+    case KGraphViewerInterface::TopRight:
+      btra->setChecked(true);
+      break;
+    case KGraphViewerInterface::BottomLeft:
+      bbla->setChecked(true);
+      break;
+    case KGraphViewerInterface::BottomRight:
+      bbra->setChecked(true);
+      break;
+    case KGraphViewerInterface::Auto:
+      bba->setChecked(true);
+      break;
+  }
+
+  // TODO: Re-enable
+//   kDebug() << "    m_bevEnabledAction setting checked to : " << KGraphViewerPartSettings::birdsEyeViewEnabled();
+//   m_bevEnabledAction->setChecked(KGraphViewerPartSettings::birdsEyeViewEnabled());
+//   m_bevPopup->setEnabled(KGraphViewerPartSettings::birdsEyeViewEnabled());
+}
+
+void DotGraphViewPrivate::exportToImage()
+{
+  // write current content of canvas as image to file
+  if (!m_canvas) return;
+  
+  QString fn = KFileDialog::getSaveFileName(KUrl(":"),QString("*.png"),0,QString(""));
+  
+  if (!fn.isEmpty())
+  {
+    QPixmap pix(m_canvas->sceneRect().size().toSize());
+    QPainter p(&pix);
+    m_canvas->render( &p );
+    pix.save(fn,"PNG");
+  }
+}
+
+
+//
+// DotGraphView
+//
+DotGraphView::DotGraphView(KActionCollection* actions, QWidget* parent) : 
+    QGraphicsView(parent), d_ptr(new DotGraphViewPrivate(actions, this))
+{
+  kDebug() << "New node pic=" << KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-newnode.png");
+  Q_D(DotGraphView);
+  d->m_canvas = 0;
+  d->m_xMargin = d->m_yMargin = 0;
+  d->m_birdEyeView = new PannerView(this);
+  d->m_cvZoom = 1;
+
+  // if there are ever graphic glitches to be found, remove this again
+  setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter |
+                        QGraphicsView::DontSavePainterState);
+
+  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+  
+  d->m_birdEyeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+  d->m_birdEyeView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+  d->m_birdEyeView->raise();
+  d->m_birdEyeView->hide();
+
+  setFocusPolicy(Qt::StrongFocus);
+  setBackgroundRole(QPalette::Window);
+//   viewport()->setMouseTracking(true);
+  
+  connect(d->m_birdEyeView, SIGNAL(zoomRectMovedTo(QPointF)),
+          this, SLOT(zoomRectMovedTo(QPointF)));
+  connect(d->m_birdEyeView, SIGNAL(zoomRectMoveFinished()),
+          this, SLOT(zoomRectMoveFinished()));
+
+  setWhatsThis( i18n( 
+    "<h1>GraphViz dot format graph visualization</h1>"
+    "<p>If the graph is larger than the widget area, an overview "
+        "panner is shown in one edge. Choose through the context menu "
+        "if the optimal position of this overview should be automatically "
+        "computed or put it where you want.</p>"
+    "<h2>How to work with it?</h2>"
+    "<ul>"
+        "<li>To move the graph, you can:"
+            "  <ul>"
+                "    <li>click & drag it</li>"
+                "    <li>use the elevators</li>"
+                "    <li>press the arrows keys</li>"
+                "    <li>click somewhere in the panner view</li>" 
+                "    <li>use the mouse wheel (up and down with no modifier, left and right with the <Alt> key pressed)</li>"
+                    "    <li>or click & drag the panner view</li>"
+                    "  </ul>"
+                "</li>"
+            "<li>To zoom, you can either use the zoom in and zoom out toolbar buttons, or click on the <Shift> key while rolling your mouse wheel.</li>"
+                "<li>Try the contextual menu (usually by right-clicking) to discover other "
+                    "possibilities.</li>"
+                "<li>Try the <tt>Print preview</tt> or the <tt>Page setup</tt> buttons to explore the printing options.</li>"
+                "</ul>"
+            ) );
+
+  readViewConfig();
+  
+  QMatrix m;
+  m.scale(d->m_zoom,d->m_zoom);
+  setMatrix(m);
+  d->setupPopup();
+  setInteractive(true);
+  setDragMode(NoDrag);
+  setRenderHint(QPainter::Antialiasing);
+
+  connect(&d->m_loadThread, SIGNAL(finished()), this, SLOT(slotAGraphReadFinished()));
+  connect(&d->m_layoutThread, SIGNAL(finished()), this, SLOT(slotAGraphLayoutFinished()));
+}
+
+DotGraphView::~DotGraphView()
+{
+  saveViewConfig();
+  Q_D(DotGraphView);
+  delete d;
+}
+
+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;}
+
+DotGraph* DotGraphView::graph() {Q_D(DotGraphView); return d->m_graph;}
+const 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;}
+
+void DotGraphView::setDefaultNewElement(GraphElement* elem) {Q_D(DotGraphView); d->m_defaultNewElement = elem;}
+void DotGraphView::setDefaultNewElementPixmap(const QPixmap& pm) {Q_D(DotGraphView); d->m_defaultNewElementPixmap = pm;}
+
+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;}
+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;}
+
+void DotGraphView::setBackgroundColor(const QColor& color)
+{
+  Q_D(DotGraphView);
+  d->m_backgroundColor = color;
+  d->m_canvas->setBackgroundBrush(QBrush(d->m_backgroundColor));
+}
+
+bool DotGraphView::initEmpty()
+{
+  kDebug();
+  Q_D(DotGraphView);
+  d->m_birdEyeView->hide();
+  d->m_birdEyeView->setScene(0);
+  
+  if (d->m_canvas) 
+  {
+    delete d->m_canvas;
+    d->m_canvas = 0;
+  }
+
+  if (d->m_graph != 0)
+    delete d->m_graph;
+  d->m_graph = new DotGraph();
+  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
+
+  if (d->m_readWrite)
+  {
+    d->m_graph->setReadWrite();
+  }
+  
+//   kDebug() << "Parsing " << m_graph->dotFileName() << " with " << m_graph->layoutCommand();
+  d->m_xMargin = 50;
+  d->m_yMargin = 50;
+
+  QGraphicsScene* newCanvas = new QGraphicsScene();
+  QGraphicsSimpleTextItem* item = newCanvas->addSimpleText(i18n("no graph loaded"));
+//   kDebug() << "Created canvas " << newCanvas;
+  
+  d->m_birdEyeView->setScene(newCanvas);
+//   std::cerr << "After m_birdEyeView set canvas" << std::endl;
+  
+  setScene(newCanvas);
+  d->m_canvas = newCanvas;
+  centerOn(item);
+
+  d->m_cvZoom = 0;
+
+  return true;
+}
+
+bool DotGraphView::slotLoadLibrary(graph_t* graph)
+{
+  kDebug() << "graph_t";
+  Q_D(DotGraphView);
+  d->m_birdEyeView->setScene(0);
+
+  if (d->m_canvas)
+  {
+    d->m_canvas->deleteLater();
+    d->m_canvas = 0;
+  }
+
+  QString layoutCommand = (d->m_graph!=0?d->m_graph->layoutCommand():"");
+  if (d->m_graph != 0)
+    delete d->m_graph;
+
+  if (layoutCommand.isEmpty())
+  layoutCommand = "dot";
+
+  kDebug() << "layoutCommand:" << layoutCommand;
+  d->m_graph = new DotGraph(layoutCommand,"");
+  d->m_graph->setUseLibrary(true);
+
+  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
+  connect(this, SIGNAL(removeEdge(const QString&)), d->m_graph, SLOT(removeEdge(const QString&)));
+  connect(this, SIGNAL(removeNodeNamed(const QString&)), d->m_graph, SLOT(removeNodeNamed(const QString&)));
+  connect(this, SIGNAL(removeElement(const QString&)), d->m_graph, SLOT(removeElement(const QString&)));
+
+  if (d->m_readWrite)
+  {
+    d->m_graph->setReadWrite();
+  }
+
+  if (layoutCommand.isEmpty())
+  {
+    layoutCommand = d->m_graph->chooseLayoutProgramForFile(d->m_graph->dotFileName());
+  }
+  d->m_graph->layoutCommand(layoutCommand);
+
+  GVC_t* gvc = gvContext();
+  gvLayout(gvc, graph, layoutCommand.toUtf8().data());
+  gvRender (gvc, graph, "xdot", NULL);
+
+  d->m_xMargin = 50;
+  d->m_yMargin = 50;
+
+  QGraphicsScene* newCanvas = new QGraphicsScene();
+  kDebug() << "Created canvas " << newCanvas;
+
+  d->m_birdEyeView->setScene(newCanvas);
+  // std::cerr << "After m_birdEyeView set canvas" << std::endl;
+
+  setScene(newCanvas);
+  connect(newCanvas,SIGNAL(selectionChanged ()),this,SLOT(slotSelectionChanged()));
+  d->m_canvas = newCanvas;
+
+  d->m_cvZoom = 0;
+
+  d->m_graph->updateWithGraph(graph);
+
+  gvFreeLayout(gvc, graph);
+  gvFreeContext(gvc);
+  return true;
+}
+
+bool DotGraphView::loadDot(const QString& dotFileName)
+{
+  kDebug() << "'" << dotFileName << "'";
+  Q_D(DotGraphView);
+  d->m_birdEyeView->setScene(0);
+
+  if (d->m_canvas)
+  {
+    d->m_canvas->deleteLater();
+    d->m_canvas = 0;
+  }
+
+  QString layoutCommand = (d->m_graph!=0?d->m_graph->layoutCommand():"");
+  if (d->m_graph != 0)
+    delete d->m_graph;
+  d->m_graph = new DotGraph(layoutCommand,dotFileName);
+  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
+
+  if (d->m_readWrite)
+  {
+    d->m_graph->setReadWrite();
+  }
+  if (layoutCommand.isEmpty())
+  {
+    layoutCommand = d->m_graph->chooseLayoutProgramForFile(d->m_graph->dotFileName());
+  }
+  d->m_graph->layoutCommand(layoutCommand);
+
+//   kDebug() << "Parsing " << m_graph->dotFileName() << " with " << m_graph->layoutCommand();
+  d->m_xMargin = 50;
+  d->m_yMargin = 50;
+
+  QGraphicsScene* newCanvas = new QGraphicsScene();
+  kDebug() << "Created canvas " << newCanvas;
+
+  d->m_birdEyeView->setScene(newCanvas);
+//   std::cerr << "After m_birdEyeView set canvas" << std::endl;
+
+  setScene(newCanvas);
+  connect(newCanvas,SIGNAL(selectionChanged ()),this,SLOT(slotSelectionChanged()));
+  d->m_canvas = newCanvas;
+
+  QGraphicsSimpleTextItem* loadingLabel = newCanvas->addSimpleText(i18n("graph %1 is getting loaded...", dotFileName));
+  loadingLabel->setZValue(100);
+  centerOn(loadingLabel);
+
+  d->m_cvZoom = 0;
+
+  if (!d->m_graph->parseDot(d->m_graph->dotFileName()))
+  {
+    kError() << "NOT successfully parsed!" << endl;
+    loadingLabel->setText(i18n("error parsing file %1", dotFileName));
+    return false;
+  }
+  return true;
+}
+
+bool DotGraphView::loadLibrary(const QString& dotFileName)
+{
+  kDebug() << "'" << dotFileName << "'";
+  Q_D(DotGraphView);
+  if (d->m_canvas)
+    d->m_canvas->clear();
+  QGraphicsSimpleTextItem* loadingLabel = d->m_canvas->addSimpleText(i18n("graph %1 is getting loaded...", dotFileName));
+  loadingLabel->setZValue(100);
+  centerOn(loadingLabel);
+
+  d->m_loadThread.loadFile(dotFileName);
+  
+  return true;
+}
+
+bool DotGraphView::loadLibrary(graph_t* graph, const QString& layoutCommand)
+{
+  kDebug() << "graph_t";
+  Q_D(DotGraphView);
+  d->m_birdEyeView->setScene(0);
+  
+  if (d->m_canvas)
+  {
+    d->m_canvas->deleteLater();
+    d->m_canvas = 0;
+  }
+  
+  if (d->m_graph != 0)
+    delete d->m_graph;
+
+  kDebug() << "layoutCommand:" << layoutCommand;
+  d->m_graph = new DotGraph(layoutCommand,"");
+  d->m_graph->setUseLibrary(true);
+  
+  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
+  
+  if (d->m_readWrite)
+  {
+    d->m_graph->setReadWrite();
+  }
+  
+  d->m_xMargin = 50;
+  d->m_yMargin = 50;
+  
+  QGraphicsScene* newCanvas = new QGraphicsScene();
+  kDebug() << "Created canvas " << newCanvas;
+  
+  d->m_birdEyeView->setScene(newCanvas);
+  setScene(newCanvas);
+  connect(newCanvas,SIGNAL(selectionChanged ()),this,SLOT(slotSelectionChanged()));
+  d->m_canvas = newCanvas;
+  
+  d->m_cvZoom = 0;
+                                 
+  d->m_graph->updateWithGraph(graph);
+
+  return true;
+}
+
+void DotGraphView::slotSelectionChanged()
+{
+  kDebug() << scene()->selectedItems().size();
+}
+
+bool DotGraphView::displayGraph()
+{
+  Q_D(DotGraphView);
+  kDebug() << d->m_graph->backColor();
+//   hide();
+  viewport()->setUpdatesEnabled(false);
+
+  if (d->m_graph->backColor().size() != 0)
+  {
+    setBackgroundColor(QColor(d->m_graph->backColor()));
+  }
+  d->m_canvas->clear();
+
+  if (d->m_graph->nodes().size() > KGV_MAX_PANNER_NODES)
+  {
+    d->m_birdEyeView->setDrawingEnabled(false);
+  }
+  //  QCanvasEllipse* eItem;
+  double scaleX = 1.0, scaleY = 1.0;
+
+  if (d->m_detailLevel == 0)      { scaleX = d->m_graph->scale() * 0.7; scaleY = d->m_graph->scale() * 0.7; }
+  else if (d->m_detailLevel == 1) { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
+  else if (d->m_detailLevel == 2) { scaleX = d->m_graph->scale() * 1.3; scaleY = d->m_graph->scale() * 1.3; }
+  else                        { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
+
+  qreal gh = d->m_graph->height();
+
+  d->m_xMargin = 50;
+  d->m_yMargin = 50;
+
+
+//   m_canvas->setSceneRect(0,0,w+2*m_xMargin, h+2*m_yMargin);
+//   m_canvas->setBackgroundBrush(QBrush(QColor(m_graph->backColor())));
+  d->m_canvas->setBackgroundBrush(QBrush(d->m_backgroundColor));
+  
+//   kDebug() << "sceneRect is now " << m_canvas->sceneRect();
+  
+  kDebug() << "Creating" << d->m_graph->subgraphs().size() << "CanvasSubgraphs from" << d->m_graph;
+  int zvalue = -1;
+  foreach (GraphSubgraph* gsubgraph, d->m_graph->subgraphs())
+  {
+    int newZvalue = d->displaySubgraph(gsubgraph, zvalue);
+    if (newZvalue > zvalue)
+      zvalue = newZvalue;
+  }
+
+  kDebug() << "Creating" << d->m_graph->nodes().size() << "nodes from" << d->m_graph;
+  GraphNodeMap::const_iterator it = d->m_graph->nodes().constBegin();
+  for (; it != d->m_graph->nodes().constEnd();it++)
+  {
+    const QString& id = it.key();
+    GraphNode* gnode = it.value();
+    kDebug() << "Handling" << id << (void*)gnode;
+    kDebug() << "  gnode id=" << gnode->id();
+    kDebug()<<  "  canvasNode=" << (void*)gnode->canvasNode();
+    if (gnode->canvasNode()==0)
+    {
+      kDebug() << "Creating canvas node for" << gnode->id();
+      CanvasNode *cnode = new CanvasNode(this, gnode, d->m_canvas);
+      if (cnode == 0) continue;
+      cnode->initialize(
+        scaleX, scaleY, d->m_xMargin, d->m_yMargin, gh,
+        d->m_graph->wdhcf(), d->m_graph->hdvcf());
+      gnode->setCanvasNode(cnode);
+      d->m_canvas->addItem(cnode);
+//       cnode->setZValue(gnode->z());
+      cnode->setZValue(zvalue+1);
+      cnode->show();
+    }
+    gnode->canvasNode()->computeBoundingRect();
+  }
+
+  kDebug() << "Creating" << d->m_graph->edges().size() << "edges from" << d->m_graph;
+  foreach (GraphEdge* gedge, d->m_graph->edges())
+  {
+    kDebug() << "One GraphEdge:" << gedge->id();
+    if (gedge->canvasEdge() == 0
+      && gedge->fromNode() != 0
+      && gedge->toNode() != 0)
+    {
+      kDebug() << "New CanvasEdge for" << gedge->id();
+      kDebug() << "edge fromNode=" << (void*)gedge->fromNode();
+      kDebug() << "              "<< gedge->fromNode()->id();
+      kDebug() << "edge toNode=" << (void*)gedge->toNode();
+      kDebug() << "              "<< gedge->toNode()->id();
+      CanvasEdge* cedge = new CanvasEdge(this, gedge, scaleX, scaleY, d->m_xMargin,
+          d->m_yMargin, gh, d->m_graph->wdhcf(), d->m_graph->hdvcf());
+
+      gedge->setCanvasEdge(cedge);
+  //     std::cerr << "setting z = " << gedge->z() << std::endl;
+  //    cedge->setZValue(gedge->z());
+      cedge->setZValue(zvalue+2);
+      cedge->show();
+      d->m_canvas->addItem(cedge);
+    }
+    if (gedge->canvasEdge() != 0)
+      gedge->canvasEdge()->computeBoundingRect();
+  }
+  kDebug() << "Adding graph render operations: " << d->m_graph->renderOperations().size();
+  foreach (const DotRenderOp& dro, d->m_graph->renderOperations())
+  {
+    if ( dro.renderop == "T" )
+    {
+//       std::cerr << "Adding graph label '"<<dro.str<<"'" << std::endl;
+      const QString& str = dro.str;
+      int stringWidthGoal = int(dro.integers[3] * scaleX);
+      int fontSize = d->m_graph->fontSize();
+      QFont* font = FontsCache::changeable().fromName(d->m_graph->fontName());
+      font->setPointSize(fontSize);
+      QFontMetrics fm(*font);
+      while (fm.width(str) > stringWidthGoal && fontSize > 1)
+      {
+        fontSize--;
+        font->setPointSize(fontSize);
+        fm = QFontMetrics(*font);
+      }
+      QGraphicsSimpleTextItem* labelView = new QGraphicsSimpleTextItem(str, 0, d->m_canvas);
+      labelView->setFont(*font);
+      labelView->setPos(
+                  (scaleX *
+                       (
+                         (dro.integers[0])
+                         + (((dro.integers[2])*(dro.integers[3]))/2)
+                         - ( (dro.integers[3])/2 )
+                       )
+                      + d->m_xMargin ),
+                      ((gh - (dro.integers[1]))*scaleY)+ d->m_yMargin);
+      /// @todo port that ; how to set text color ?
+      labelView->setPen(QPen(Dot2QtConsts::componentData().qtColor(d->m_graph->fontColor())));
+      labelView->setFont(*font);
+      d->m_labelViews.insert(labelView);
+    }
+  }
+
+  kDebug() << "Finalizing";
+  d->m_cvZoom = 0;
+  d->updateSizes();
+
+  centerOn(d->m_canvas->sceneRect().center());
+
+  viewport()->setUpdatesEnabled(true);
+  QSet<QGraphicsSimpleTextItem*>::iterator labelViewsIt, labelViewsIt_end;
+  labelViewsIt = d->m_labelViews.begin(); labelViewsIt_end = d->m_labelViews.end();
+  for (; labelViewsIt != labelViewsIt_end; labelViewsIt++)
+  {
+    (*labelViewsIt)->show();
+  }
+  d->m_canvas->update();
+  
+  emit graphLoaded();
+
+  return true;
+}
+
+void DotGraphView::focusInEvent(QFocusEvent*)
+{
+  Q_D(DotGraphView);
+  if (!d->m_canvas) return;
+
+//   m_canvas->update();
+}
+
+void DotGraphView::focusOutEvent(QFocusEvent* e)
+{
+  // trigger updates as in focusInEvent
+  focusInEvent(e);
+}
+
+void DotGraphView::keyPressEvent(QKeyEvent* e)
+{
+  Q_D(DotGraphView);
+  if (!d->m_canvas) 
+  {
+    e->ignore();
+    return;
+  }
+
+  // move canvas...
+  if (e->key() == Qt::Key_Home)
+    scrollContentsBy(int(-d->m_canvas->width()),0);
+  else if (e->key() == Qt::Key_End)
+    scrollContentsBy(int(d->m_canvas->width()),0);
+  else if (e->key() == Qt::Key_Prior)
+    scrollContentsBy(0,-viewport()->height()/2);
+  else if (e->key() == Qt::Key_Next)
+    scrollContentsBy(0,viewport()->height()/2);
+  else if (e->key() == Qt::Key_Left)
+    scrollContentsBy(-viewport()->width()/10,0);
+  else if (e->key() == Qt::Key_Right)
+    scrollContentsBy(viewport()->width()/10,0);
+  else if (e->key() == Qt::Key_Down)
+    scrollContentsBy(0,viewport()->height()/10);
+  else if (e->key() == Qt::Key_Up)
+    scrollContentsBy(0,-viewport()->height()/10);
+  else 
+  {
+    e->ignore();
+    return;
+  }
+}
+
+void DotGraphView::wheelEvent(QWheelEvent* e)
+{
+  Q_D(DotGraphView);
+  if (!d->m_canvas) 
+  {
+    e->ignore();
+    return;
+  }
+  e->accept();
+  if (e->state() == Qt::ShiftModifier)
+  {
+    kDebug() << " + Shift: zooming";
+    // move canvas...
+    if (e->delta() < 0)
+    {
+      zoomOut();
+    }
+    else 
+    {
+      zoomIn();
+    }
+  }
+  else
+  {
+    kDebug() << " : scrolling ";
+    if (e->orientation() == Qt::Horizontal)
+    {
+      if (e->delta() < 0)
+      {
+        kDebug() << "scroll by " <<  -viewport()->width()/10 << 0;
+        horizontalScrollBar()->setValue(horizontalScrollBar()->value()+viewport()->width()/10);
+      }
+      else
+      {
+        kDebug() << "scroll by " <<  viewport()->width()/10 << 0;
+        horizontalScrollBar()->setValue(horizontalScrollBar()->value()-viewport()->width()/10);
+      }
+    }
+    else
+    {
+      if (e->delta() < 0)
+      {
+        kDebug() << "scroll by " << 0 << viewport()->width()/10;
+        verticalScrollBar()->setValue(verticalScrollBar()->value()+viewport()->height()/10);
+      }
+      else
+      {
+        kDebug() << "scroll by " << 0 << -viewport()->width()/10;
+        verticalScrollBar()->setValue(verticalScrollBar()->value()-viewport()->height()/10);
+      }
+    }
+  }
+}
+
+void DotGraphView::zoomIn()
+{
+  applyZoom(1.10);
+}
+
+
+void DotGraphView::zoomOut()
+{
+  applyZoom(.90);
+}
+
+void DotGraphView::setZoomFactor(double newZoom)
+{
+  Q_D(DotGraphView);
+  if (newZoom < 0.1 || newZoom > 10)
+    return;
+  d->m_zoom = newZoom;
+  if (d->m_zoom > 1.0 && d->m_zoom < 1.1)
+  {
+    d->m_zoom = 1;
+  }
+
+  const double factor = newZoom / d->m_zoom;
+  qreal centerX = (sceneRect().x() + (viewport()->width() / 2))*factor;
+  qreal centerY = (sceneRect().y() + (viewport()->height() / 2))*factor;
+  
+  setUpdatesEnabled(false);
+  QMatrix m;
+  m.scale(d->m_zoom,d->m_zoom);
+  setMatrix(m);
+  centerOn(centerX, centerY);
+  emit zoomed(d->m_zoom);
+  setUpdatesEnabled(true);
+  d->updateSizes();
+}
+
+void DotGraphView::applyZoom(double factor)
+{
+  Q_D(DotGraphView);
+  setZoomFactor(d->m_zoom * factor);
+}
+
+void DotGraphView::scrollContentsBy(int dx, int dy)
+{
+  Q_D(DotGraphView);
+  QGraphicsView::scrollContentsBy(dx, dy);
+  if (d->m_birdEyeView && scene()) { // we might be shutting down
+    d->m_birdEyeView->moveZoomRectTo(mapToScene(viewport()->rect()).boundingRect().center(), false);
+  }
+}
+
+void DotGraphView::resizeEvent(QResizeEvent* e)
+{
+  Q_D(DotGraphView);
+  kDebug() << "resizeEvent";
+  QGraphicsView::resizeEvent(e);
+  if (d->m_canvas) d->updateSizes(e->size());
+//   std::cerr << "resizeEvent end" << std::endl;
+}
+
+void DotGraphView::zoomRectMovedTo(QPointF newZoomPos)
+{
+//   kDebug() << "DotGraphView::zoomRectMovedTo " << newZoomPos;
+  centerOn(newZoomPos);
+}
+                    
+void DotGraphView::zoomRectMoveFinished()
+{
+  Q_D(DotGraphView);
+//    kDebug() << "zoomRectMoveFinished";
+  d->updateBirdEyeView();
+//   std::cerr << "zoomRectMoveFinished end" << std::endl;
+}
+
+void DotGraphView::mousePressEvent(QMouseEvent* e)
+{
+  Q_D(DotGraphView);
+  if (e->button() != Qt::LeftButton) {
+    return;
+  }
+  kDebug() << e << d->m_editingMode;
+  QGraphicsView::mousePressEvent(e);
+
+  if (d->m_editingMode == AddNewElement)
+  {
+    double scaleX = 1.0, scaleY = 1.0;
+
+    if (d->m_detailLevel == 0)      { scaleX = d->m_graph->scale() * 0.7; scaleY = d->m_graph->scale() * 0.7; }
+    else if (d->m_detailLevel == 1) { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
+    else if (d->m_detailLevel == 2) { scaleX = d->m_graph->scale() * 1.3; scaleY = d->m_graph->scale() * 1.3; }
+    else                        { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
+
+    qreal gh = d->m_graph->height();
+
+
+    QPointF pos = mapToScene(
+        e->pos().x()-d->m_defaultNewElementPixmap.width()/2,
+        e->pos().y()-d->m_defaultNewElementPixmap.height()/2);
+    GraphNode* newNode = new GraphNode();
+    newNode->attributes() = d->m_newElementAttributes;
+    if (newNode->attributes().find("id") == newNode->attributes().end())
+    {
+      newNode->setId(QString("NewNode%1").arg(d->m_graph->nodes().size()));
+    }
+    if (newNode->attributes().find("label") == newNode->attributes().end())
+    {
+      newNode->setLabel(newNode->id());
+    }
+    d->m_graph->nodes().insert(newNode->id(), newNode);
+    CanvasNode* newCNode = new CanvasNode(this, newNode, d->m_canvas);
+    newCNode->initialize(
+      scaleX, scaleY, d->m_xMargin, d->m_yMargin, gh,
+      d->m_graph->wdhcf(), d->m_graph->hdvcf());
+    newNode->setCanvasNode(newCNode);
+    scene()->addItem(newCNode);
+    kDebug() << "setting pos to " << pos;
+    newCNode->setPos(pos);
+    newCNode->setZValue(100);
+    newCNode->show();
+
+
+    d->m_editingMode = None;
+    unsetCursor();
+    emit newNodeAdded(newNode->id());
+  }
+  else if (d->m_editingMode == SelectingElements)
+  {
+  }
+  else
+  {
+    if (d->m_editingMode != None && itemAt(e->pos()) == 0) // click outside any item: unselect all
+    {
+      if (d->m_editingMode == DrawNewEdge) // was drawing an edge; cancel it
+      {
+        if (d->m_newEdgeDraft!=0)
+        {
+          d->m_newEdgeDraft->hide();
+          scene()->removeItem(d->m_newEdgeDraft);
+          delete d->m_newEdgeDraft;
+          d->m_newEdgeDraft = 0;
+        }
+        d->m_newEdgeSource = 0;
+        d->m_editingMode = None;
+      }
+      else if (d->m_editingMode == AddNewEdge)
+      {
+        d->m_editingMode = None;
+      }
+      foreach(GraphEdge* e, d->m_graph->edges())
+      {
+        if (e->isSelected()) {
+          e->setSelected(false);
+          e->canvasEdge()->update();
+        }
+      }
+      foreach(GraphNode* n, d->m_graph->nodes())
+      {
+        if (n->isSelected()) {
+          n->setSelected(false);
+          n->canvasElement()->update();
+        }
+      }
+      foreach(GraphSubgraph* s, d->m_graph->subgraphs())
+      {
+        if (s->isSelected()) {
+          s->setSelected(false);
+          s->canvasElement()->update();
+        }
+      }
+      emit selectionIs(QList<QString>(),QPoint());
+    }
+    d->m_pressPos = e->globalPos();
+    d->m_pressScrollBarsPos = QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value());
+  }
+  d->m_isMoving = true;
+}
+
+void DotGraphView::mouseMoveEvent(QMouseEvent* e)
+{
+  Q_D(DotGraphView);
+  QGraphicsView::mouseMoveEvent(e);
+//   kDebug() << scene()->selectedItems().size();
+
+  if (d->m_editingMode == DrawNewEdge)
+  {
+    if (d->m_newEdgeDraft != 0)
+    {
+      QPointF src = d->m_newEdgeDraft->line().p1();
+      QPointF tgt = mapToScene(e->pos());
+
+//     kDebug() << "Setting new edge draft line to" << QLineF(src,tgt);
+      d->m_newEdgeDraft->setLine(QLineF(src,tgt));
+    }
+  }
+  else if (d->m_editingMode == SelectingElements)
+  {
+//     kDebug() << "selecting";
+  }
+  else if (e->buttons().testFlag(Qt::LeftButton))
+  {
+//     kDebug() << (e->globalPos() - d->m_pressPos);
+    QPoint diff = e->globalPos() - d->m_pressPos;
+    horizontalScrollBar()->setValue(d->m_pressScrollBarsPos.x()-diff.x());
+    verticalScrollBar()->setValue(d->m_pressScrollBarsPos.y()-diff.y());
+  }
+}
+
+void DotGraphView::mouseReleaseEvent(QMouseEvent* e)
+{
+  Q_D(DotGraphView);
+  kDebug() << e << d->m_editingMode;
+//   kDebug() << "setDragMode(NoDrag)";
+//   setDragMode(NoDrag);
+  if (d->m_editingMode == AddNewElement)
+  {
+    d->m_editingMode = None;
+    unsetCursor();
+  }
+  else if (d->m_editingMode == SelectingElements)
+  {
+    QGraphicsView::mouseReleaseEvent(e);
+    kDebug() << "Stopping selection" << scene() << d->m_canvas;
+    QList<QGraphicsItem *> items = scene()->selectedItems();
+    QList<QString> selection;
+    foreach (QGraphicsItem * item, items)
+    {
+      CanvasElement* element = dynamic_cast<CanvasElement*>(item);
+      element->element()->setSelected(true);
+      if (element != 0)
+      {
+        selection.push_back(element->element()->id());
+      }
+    }
+    d->m_editingMode = None;
+    unsetCursor();
+    setDragMode(NoDrag);
+    if (!selection.isEmpty())
+    {
+      update();
+      emit selectionIs(selection, mapToGlobal( e->pos() ));
+    }
+  }
+  else
+  {
+    QGraphicsView::mouseReleaseEvent(e);
+  }
+  d->m_isMoving = false;
+}
+
+void DotGraphView::mouseDoubleClickEvent(QMouseEvent* e)
+{
+  QGraphicsView::mouseDoubleClickEvent(e);
+}
+
+void DotGraphView::contextMenuEvent(QContextMenuEvent* e)
+{
+  Q_D(DotGraphView);
+  kDebug();
+//   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
+
+  d->m_popup->exec(e->globalPos());
+}
+
+void DotGraphView::slotContextMenuEvent(const QString& id, const QPoint& p)
+{
+  kDebug();
+//   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
+
+  emit (contextMenuEvent(id, p));
+}
+
+void DotGraphView::slotElementHoverEnter(CanvasElement* element)
+{
+  kDebug() << element->element()->id();
+  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
+  
+  emit (hoverEnter(element->element()->id()));
+}
+
+void DotGraphView::slotElementHoverLeave(CanvasElement* element)
+{
+  kDebug() << element->element()->id();
+  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
+  
+  emit (hoverLeave(element->element()->id()));
+}
+
+void DotGraphView::slotElementHoverEnter(CanvasEdge* element)
+{
+  kDebug() << element->edge()->id();
+  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
+  
+  emit (hoverEnter(element->edge()->id()));
+}
+
+void DotGraphView::slotElementHoverLeave(CanvasEdge* element)
+{
+  kDebug() << element->edge()->id();
+  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
+  
+  emit (hoverLeave(element->edge()->id()));
+}
+
+void DotGraphView::setLayoutCommand(const QString& command)
+{
+  Q_D(DotGraphView);
+  d->m_graph->layoutCommand(command);
+  reload();
+}
+
+KGraphViewerInterface::PannerPosition DotGraphView::zoomPos(const QString& s)
+{
+  KGraphViewerInterface::PannerPosition  res = DEFAULT_ZOOMPOS;
+  if (s == QString("KGraphViewerInterface::TopLeft")) res = KGraphViewerInterface::TopLeft;
+  if (s == QString("KGraphViewerInterface::TopRight")) res = KGraphViewerInterface::TopRight;
+  if (s == QString("KGraphViewerInterface::BottomLeft")) res = KGraphViewerInterface::BottomLeft;
+  if (s == QString("KGraphViewerInterface::BottomRight")) res = KGraphViewerInterface::BottomRight;
+  if (s == QString("Automatic")) res = KGraphViewerInterface::Auto;
+
+  return res;
+}
+
+void DotGraphView::setPannerEnabled(bool enabled)
+{
+  Q_D(DotGraphView);
+  d->m_bevPopup->setEnabled(d->m_bevEnabledAction->isChecked());
+
+  // TODO: Re-enable
+//   KGraphViewerPartSettings::setBirdsEyeViewEnabled(d->m_bevEnabledAction->isChecked());
+//   KGraphViewerPartSettings::self()->writeConfig();
+
+  d->updateSizes();
+}
+
+void DotGraphView::viewBevActivated(int newZoomPos)
+{
+  Q_D(DotGraphView);
+  d->m_zoomPosition = (KGraphViewerInterface::PannerPosition)newZoomPos;
+  d->updateSizes();
+  emit(sigViewBevActivated(newZoomPos));
+}
+
+QString DotGraphView::zoomPosString(KGraphViewerInterface::PannerPosition p)
+{
+    if (p == KGraphViewerInterface::TopRight) return QString("KGraphViewerInterface::TopRight");
+    if (p == KGraphViewerInterface::BottomLeft) return QString("KGraphViewerInterface::BottomLeft");
+    if (p == KGraphViewerInterface::BottomRight) return QString("KGraphViewerInterface::BottomRight");
+    if (p == KGraphViewerInterface::Auto) return QString("Automatic");
+
+    return QString("KGraphViewerInterface::TopLeft");
+}
+
+void DotGraphView::readViewConfig()
+{
+  Q_D(DotGraphView);
+  KConfigGroup g(KGlobal::config(),"GraphViewLayout");
+  
+  QVariant dl = DEFAULT_DETAILLEVEL;
+  d->m_detailLevel     = g.readEntry("DetailLevel", dl).toInt();
+  d->m_zoomPosition  = zoomPos(g.readEntry("KGraphViewerInterface::PannerPosition",
+            zoomPosString(DEFAULT_ZOOMPOS)));
+  emit(sigViewBevActivated(d->m_zoomPosition));
+}
+
+void DotGraphView::saveViewConfig()
+{
+  Q_D(DotGraphView);
+//   kDebug() << "Saving view config";  
+  KConfigGroup g(KGlobal::config(), "GraphViewLayout");
+
+    writeConfigEntry(&g, "DetailLevel", d->m_detailLevel, DEFAULT_DETAILLEVEL);
+    writeConfigEntry(&g, "KGraphViewerInterface::PannerPosition",
+         zoomPosString(d->m_zoomPosition),
+         zoomPosString(DEFAULT_ZOOMPOS).utf8().data());
+  g.sync();
+}
+
+void DotGraphView::pageSetup()
+{
+  /*
+  Q_D(DotGraphView);
+  if (d->m_printCommand == 0)
+  {
+    d->m_printCommand = new KGVSimplePrintingCommand(this, 0);
+  }
+  d->m_printCommand->showPageSetup(d->m_graph->dotFileName());
+  */
+}
+
+void DotGraphView::print()
+{
+  /*
+  Q_D(DotGraphView);
+  if (d->m_printCommand == 0)
+  {
+    d->m_printCommand = new KGVSimplePrintingCommand(this, 0);
+  }
+  d->m_printCommand->print(d->m_graph->dotFileName());
+  */
+}
+
+void DotGraphView::printPreview()
+{
+  /*
+  Q_D(DotGraphView);
+  if (d->m_printCommand == 0)
+  {
+    d->m_printCommand = new KGVSimplePrintingCommand(this, 0);
+  }
+  d->m_printCommand->showPrintPreview(d->m_graph->dotFileName(), false);
+  */
+}
+
+bool DotGraphView::reload()
+{
+  Q_D(DotGraphView);
+  QString fileName = d->m_graph->dotFileName();
+  if (d->m_graph->useLibrary())
+    return loadLibrary(fileName);
+  else
+    return loadDot(fileName);
+}
+
+void DotGraphView::dirty(const QString& dotFileName)
+{
+  Q_D(DotGraphView);
+//   std::cerr << "SLOT dirty for " << dotFileName << std::endl;
+  if (dotFileName == d->m_graph->dotFileName())
+  {
+    if (KMessageBox::questionYesNo(this, 
+                                i18n("The file %1 has been modified on disk.\nDo you want to reload it?",dotFileName),
+                                i18n("Reload Confirmation"),
+                                KStandardGuiItem::yes(),
+                                KStandardGuiItem::no(),
+                                "reloadOnChangeMode"   ) == KMessageBox::Yes)
+    {
+      if (d->m_graph->useLibrary())
+        loadLibrary(dotFileName);
+      else
+        loadDot(dotFileName);
+    }
+  }
+}
+
+KConfigGroup* DotGraphView::configGroup(KConfig* c,
+                                         const QString& group, const QString& post)
+{
+  QStringList gList = c->groupList();
+  QString res = group;
+  if (gList.contains((group+post).ascii()) ) res += post;
+  return new KConfigGroup(c, res);
+}
+
+void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
+                                     const QString& value, const char* def)
+{
+  if (!c) return;
+  if ((value.isEmpty() && ((def == 0) || (*def == 0))) ||
+      (value == QString(def)))
+    c->deleteEntry(pKey);
+  else
+    c->writeEntry(pKey, value);
+}
+
+void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
+                                     int value, int def)
+{
+  if (!c) return;
+  if (value == def)
+    c->deleteEntry(pKey);
+  else
+    c->writeEntry(pKey, value);
+}
+
+void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
+                                     double value, double def)
+{
+  if (!c) return;
+  if (value == def)
+    c->deleteEntry(pKey);
+  else
+    c->writeEntry(pKey, value);
+}
+
+void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
+                                     bool value, bool def)
+{
+  if (!c) return;
+  if (value == def)
+    c->deleteEntry(pKey);
+  else
+    c->writeEntry(pKey, value);
+}
+
+const QString& DotGraphView::dotFileName() 
+{
+  Q_D(DotGraphView);
+  return d->m_graph->dotFileName();
+}
+
+void DotGraphView::hideToolsWindows()
+{
+  /*
+  Q_D(DotGraphView);
+  if (d->m_printCommand != 0)
+  {
+    d->m_printCommand->hidePageSetup();
+    d->m_printCommand->hidePrintPreview();
+  }
+  */
+}
+
+void DotGraphView::slotExportImage()
+{
+  Q_D(DotGraphView);
+  d->exportToImage();
+}
+
+void DotGraphView::slotLayoutSpecify()
+{
+  {
+  Q_D(DotGraphView);
+    bool ok = false;
+    QString currentLayoutCommand = d->m_graph->layoutCommand();
+    QString layoutCommand = 
+    KInputDialog::getText(
+      i18n("Layout Command"), 
+      i18n("Type in a layout command for the current graph:"), 
+      currentLayoutCommand, 
+      &ok, 
+      this, 
+      0, 
+      QString(), 
+      i18n("Specify here the command that will be used to layout the graph.\n"
+      "The command MUST write its results on stdout in xdot format."));
+    //       std::cerr << "Got layout command: " << layoutCommand << std::endl;
+    if (ok && layoutCommand != currentLayoutCommand)
+    {
+      //         std::cerr << "Setting new layout command: " << layoutCommand << std::endl;
+      setLayoutCommand(layoutCommand);
+    }
+  }
+}
+
+void DotGraphView::slotLayoutReset()
+{
+  setLayoutCommand("");
+}
+
+void DotGraphView::slotSelectLayoutAlgo(const QString& ttext)
+{
+  QString text = ttext;//.mid(1);
+  kDebug() << "DotGraphView::slotSelectLayoutAlgo '" << text << "'";
+  if (text == "Dot")
+  {
+    setLayoutCommand("dot");
+  }
+  else if (text == "Neato")
+  {
+    setLayoutCommand("neato");
+  }
+  else if (text == "Twopi")
+  {
+    setLayoutCommand("twopi");
+  }
+  else if (text == "Fdp")
+  {
+    setLayoutCommand("fdp");
+  }
+  else if (text == "Circo")
+  {
+    setLayoutCommand("circo");
+  }
+  else 
+  {
+    setLayoutCommand(text);
+  }
+}
+
+void DotGraphView::slotSelectLayoutDot()
+{
+  kDebug() << "DotGraphView::slotSelectLayoutDot";
+  setLayoutCommand("dot -Txdot");
+}
+
+void DotGraphView::slotSelectLayoutNeato()
+{
+  kDebug() << "DotGraphView::slotSelectLayoutNeato";
+  setLayoutCommand("neato -Txdot");
+}
+
+void DotGraphView::slotSelectLayoutTwopi()
+{
+  kDebug() << "DotGraphView::slotSelectLayoutTwopi";
+  setLayoutCommand("twopi -Txdot");
+}
+
+void DotGraphView::slotSelectLayoutFdp()
+{
+  kDebug() << "DotGraphView::slotSelectLayoutFdp";
+  setLayoutCommand("fdp -Txdot");
+}
+
+void DotGraphView::slotSelectLayoutCirco()
+{
+  kDebug() << "DotGraphView::slotSelectLayoutCirco";
+  setLayoutCommand("circo -Txdot");
+}
+
+void DotGraphView::slotBevToggled()
+{
+  Q_D(DotGraphView);
+  kDebug() << "DotGraphView::slotBevToggled";
+  kDebug() << "    d->m_bevEnabledAction is checked ? " << d->m_bevEnabledAction->isChecked();
+  setPannerEnabled(d->m_bevEnabledAction->isChecked());
+}
+
+void DotGraphView::slotBevTopLeft()
+{
+  viewBevActivated(KGraphViewerInterface::TopLeft);
+}
+
+void DotGraphView::slotBevTopRight()
+{
+  viewBevActivated(KGraphViewerInterface::TopRight);
+}
+
+void DotGraphView::slotBevBottomLeft()
+{
+  viewBevActivated(KGraphViewerInterface::BottomLeft);
+}
+
+void DotGraphView::slotBevBottomRight()
+{
+  viewBevActivated(KGraphViewerInterface::BottomRight); 
+}
+
+void DotGraphView::slotBevAutomatic()
+{
+  viewBevActivated(KGraphViewerInterface::Auto);
+}
+
+void DotGraphView::slotUpdate()
+{
+  Q_D(DotGraphView);
+  kDebug();
+  d->m_graph->update();
+}
+
+void DotGraphView::prepareAddNewElement(QMap<QString,QString> attribs)
+{
+  Q_D(DotGraphView);
+  kDebug() ;
+  d->m_editingMode = AddNewElement;
+  d->m_newElementAttributes = attribs;
+  unsetCursor();
+  setCursor(QCursor(d->m_defaultNewElementPixmap));
+}
+
+void DotGraphView::prepareAddNewEdge(QMap<QString,QString> attribs)
+{
+  Q_D(DotGraphView);
+  kDebug() << attribs;
+  bool anySelected = false;
+  foreach (GraphEdge* edge, d->m_graph->edges())
+  {
+    if (edge->isSelected())
+    {
+      anySelected = true;
+      QMap<QString,QString>::const_iterator it = attribs.constBegin();
+      for(; it != attribs.constEnd(); it++)
+      {
+        edge->attributes()[it.key()] = it.value();
+      }
+    }
+  }
+  if (anySelected)
+  {
+    return;
+  }
+  d->m_editingMode = AddNewEdge;
+  d->m_newElementAttributes = attribs;
+  unsetCursor();
+  QBitmap bm(KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-newedge.png"));
+  setCursor(QCursor(bm,bm,32,16));
+}
+
+void DotGraphView::prepareSelectElements()
+{
+  Q_D(DotGraphView);
+  kDebug();
+  d->m_editingMode = SelectingElements;
+  setCursor(Qt::CrossCursor);
+  setDragMode ( RubberBandDrag );
+}
+
+void DotGraphView::createNewEdgeDraftFrom(CanvasElement* node)
+{
+  Q_D(DotGraphView);
+  kDebug() << node->element()->id();
+  d->m_editingMode = DrawNewEdge;
+  unsetCursor();
+  d->m_newEdgeSource = node;
+
+  if (d->m_newEdgeDraft != 0)
+  {
+    kDebug() << "removing new edge draft";
+    d->m_newEdgeDraft->hide();
+    scene()->removeItem(d->m_newEdgeDraft);
+    delete d->m_newEdgeDraft;
+    d->m_newEdgeDraft = 0;
+  }
+  d->m_newEdgeDraft = new QGraphicsLineItem(QLineF(node->boundingRect().center()+node->pos(),node->boundingRect().center()+node->pos()+QPointF(10,10)));
+  scene()->addItem(d->m_newEdgeDraft);
+  d->m_newEdgeDraft->setZValue(1000);
+  d->m_newEdgeDraft->show();
+  kDebug() << d->m_newEdgeDraft->line();
+}
+
+void DotGraphView::finishNewEdgeTo(CanvasElement* node)
+{
+  Q_D(DotGraphView);
+  kDebug() << node->element()->id();
+  d->m_editingMode = None;
+  unsetCursor();
+
+  if (d->m_newEdgeDraft != 0)
+  {
+    kDebug() << "removing new edge draft";
+    d->m_newEdgeDraft->hide();
+    scene()->removeItem(d->m_newEdgeDraft);
+    delete d->m_newEdgeDraft;
+    d->m_newEdgeDraft = 0;
+  }
+
+  emit newEdgeFinished(d->m_newEdgeSource->element()->id(),node->element()->id(),d->m_newElementAttributes);
+
+  d->m_newEdgeSource = 0;
+}
+
+// void DotGraphView::slotFinishNewEdge(
+//       const QString& srcId,
+//       const QString& tgtId,
+//       const QMap<QString, QString> newElementAttributes)
+// {
+//   kDebug() ;
+// 
+//   GraphEdge* gedge  = new GraphEdge();
+//   gedge->setFromNode(d->m_graph->nodes()[srcId]);
+//   gedge->setToNode(d->m_graph->nodes()[tgtId]);
+//   gedge->attributes() = newElementAttributes;
+//   foreach (const QString &attrib, newElementAttributes.keys())
+//   {
+//     if (attrib == "z")
+//     {
+//       bool ok;
+//       gedge->setZ(newElementAttributes[attrib].toDouble(&ok));
+//     }
+//   }
+//   gedge->setId(srcId+tgtId+QString::number(d->m_graph->edges().size()));
+//   d->m_graph->edges().insert(gedge->id(), gedge);
+// 
+//   double scaleX = 1.0, scaleY = 1.0;
+// 
+//   if (d->m_detailLevel == 0)      { scaleX = d->m_graph->scale() * 0.7; scaleY = d->m_graph->scale() * 0.7; }
+//   else if (d->m_detailLevel == 1) { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
+//   else if (d->m_detailLevel == 2) { scaleX = d->m_graph->scale() * 1.3; scaleY = d->m_graph->scale() * 1.3; }
+//   else                        { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
+// 
+//   qreal gh = d->m_graph->height();
+//   CanvasEdge* cedge = new CanvasEdge(this, gedge, scaleX, scaleY, d->m_xMargin,
+//         d->m_yMargin, gh, d->m_graph->wdhcf(), d->m_graph->hdvcf());
+// 
+//   gedge->setCanvasEdge(cedge);
+// //     std::cerr << "setting z = " << gedge->z() << std::endl;
+//   cedge->setZValue(gedge->z());
+//   cedge->show();
+//   scene()->addItem(cedge);
+// 
+//   emit newEdgeAdded(gedge->fromNode()->id(),gedge->toNode()->id());
+// }
+
+void DotGraphView::setReadOnly()
+{
+  Q_D(DotGraphView);
+  kDebug() ;
+ d-> m_readWrite = false;
+  if (d->m_graph != 0)
+  {
+    d->m_graph->setReadOnly();
+  }
+}
+
+void DotGraphView::setReadWrite()
+{
+  Q_D(DotGraphView);
+  kDebug() ;
+  d->m_readWrite = true;
+  if (d->m_graph != 0)
+  {
+    d->m_graph->setReadWrite();
+  }
+}
+
+void DotGraphView::slotEdgeSelected(CanvasEdge* edge, Qt::KeyboardModifiers modifiers)
+{
+  Q_D(DotGraphView);
+  kDebug() << edge->edge()->id();
+  QList<QString> selection;
+  selection.push_back(edge->edge()->id());
+  if (!modifiers.testFlag(Qt::ControlModifier))
+  {
+    foreach(GraphEdge* e, d->m_graph->edges())
+    {
+      if (e->canvasEdge() != edge)
+      {
+        e->setSelected(false);
+        e->canvasEdge()->update();
+      }
+    }
+    foreach(GraphNode* n, d->m_graph->nodes())
+    {
+      n->setSelected(false);
+      n->canvasNode()->update();
+    }
+    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
+    {
+      s->setElementSelected(0, false, true);
+    }
+  }
+  else
+  {
+    foreach(GraphEdge* e, d->m_graph->edges())
+    {
+      if (e->canvasEdge() != edge)
+      {
+        if (e->isSelected())
+        {
+          selection.push_back(e->id());
+        }
+      }
+    }
+    foreach(GraphNode* n, d->m_graph->nodes())
+    {
+      if (n->isSelected())
+      {
+        selection.push_back(n->id());
+      }
+    }
+    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
+    {
+      if (s->isSelected())
+      {
+        selection.push_back(s->id());
+      }
+    }
+  }
+  emit selectionIs(selection, QPoint());
+}
+
+void DotGraphView::slotElementSelected(CanvasElement* element, Qt::KeyboardModifiers modifiers)
+{
+  Q_D(DotGraphView);
+  kDebug();
+  QList<QString> selection;
+  selection.push_back(element->element()->id());
+  if (!modifiers.testFlag(Qt::ControlModifier))
+  {
+    foreach(GraphEdge* e, d->m_graph->edges())
+    {
+      if (e->isSelected()) {
+        e->setSelected(false);
+        e->canvasEdge()->update();
+      }
+    }
+    foreach(GraphNode* e, d->m_graph->nodes())
+    {
+      if (e->canvasElement() != element)
+      {
+        if (e->isSelected()) {
+          e->setSelected(false);
+          e->canvasElement()->update();
+        }
+      }
+    }
+    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
+    {
+      s->setElementSelected(element->element(), true, true);
+    }
+  }
+  else
+  {
+    foreach(GraphEdge* e, d->m_graph->edges())
+    {
+      if (e->isSelected())
+      {
+        selection.push_back(e->id());
+      }
+    }
+    foreach(GraphNode* n, d->m_graph->nodes())
+    {
+      if (n->isSelected())
+      {
+        selection.push_back(n->id());
+      }
+    }
+    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
+    {
+      s->retrieveSelectedElementsIds(selection);
+    }
+  }
+  emit selectionIs(selection, QPoint());
+}
+
+void DotGraphView::removeSelectedEdges()
+{
+  Q_D(DotGraphView);
+  kDebug();
+  foreach(GraphEdge* e, d->m_graph->edges())
+  {
+    if (e->isSelected())
+    {
+      kDebug() << "emiting removeEdge " << e->id();
+      d->m_graph->removeEdge(e->id());
+      emit removeEdge(e->id());
+    }
+  }
+}
+
+void DotGraphView::removeSelectedNodes()
+{
+  Q_D(DotGraphView);
+  kDebug();
+  foreach(GraphNode* e, d->m_graph->nodes())
+  {
+    if (e->isSelected())
+    {
+      kDebug() << "emiting removeElement " << e->id();
+      d->m_graph->removeElement(e->id());
+      emit removeElement(e->id());
+    }
+  }
+}
+
+void DotGraphView::removeSelectedSubgraphs()
+{
+  Q_D(DotGraphView);
+  kDebug();
+  foreach(GraphSubgraph* e, d->m_graph->subgraphs())
+  {
+    if (e->isSelected())
+    {
+      kDebug() << "emiting removeElement " << e->id();
+      d->m_graph->removeElement(e->id());
+      emit removeElement(e->id());
+    }
+  }
+}
+
+void DotGraphView::removeSelectedElements()
+{
+  kDebug();
+  removeSelectedNodes();
+  removeSelectedEdges();
+  removeSelectedSubgraphs();
+}
+
+void DotGraphView::timerEvent ( QTimerEvent * event )
+{
+  Q_D(DotGraphView);
+  kDebug() << event->timerId();
+  qreal vpercent = verticalScrollBar()->value()*1.0/100;
+  qreal hpercent = horizontalScrollBar()->value()*1.0/100;
+  if (d->m_scrollDirection == Left)
+  {
+    horizontalScrollBar()->setValue(horizontalScrollBar()->value()-(5*hpercent));
+  }
+  else if (d->m_scrollDirection == Right)
+  {
+    horizontalScrollBar()->setValue(horizontalScrollBar()->value()+(5*hpercent));
+  }
+  else if (d->m_scrollDirection == Top)
+  {
+    verticalScrollBar()->setValue(verticalScrollBar()->value()-(5*vpercent));
+  }
+  else if (d->m_scrollDirection == Bottom)
+  {
+    verticalScrollBar()->setValue(verticalScrollBar()->value()+(5*vpercent));
+  }
+}
+
+void DotGraphView::leaveEvent ( QEvent * /*event*/ )
+{
+  Q_D(DotGraphView);
+  kDebug() << mapFromGlobal(QCursor::pos());
+  if (d->m_editingMode == DrawNewEdge)
+  {
+    d->m_leavedTimer = startTimer(10);
+    if (mapFromGlobal(QCursor::pos()).x() <= 0)
+    {
+      d->m_scrollDirection = Left;
+    }
+    else if (mapFromGlobal(QCursor::pos()).y() <= 0)
+    {
+      d->m_scrollDirection = Top;
+    }
+    else if (mapFromGlobal(QCursor::pos()).x() >= width())
+    {
+      d->m_scrollDirection = Right;
+    }
+    else if (mapFromGlobal(QCursor::pos()).y() >= height())
+    {
+      d->m_scrollDirection = Bottom;
+    }
+  }
+}
+
+void DotGraphView::enterEvent ( QEvent * /*event*/ )
+{
+  Q_D(DotGraphView);
+  kDebug();
+  if (d->m_leavedTimer != std::numeric_limits<int>::max())
+  {
+    killTimer(d->m_leavedTimer);
+    d->m_leavedTimer = std::numeric_limits<int>::max();
+  }
+}
+
+void DotGraphView::slotAGraphReadFinished()
+{
+  Q_D(DotGraphView);
+  QString layoutCommand = (d->m_graph!=0?d->m_graph->layoutCommand():"");
+  if (layoutCommand.isEmpty())
+  {
+    if (!d->m_loadThread.dotFileName().isEmpty())
+      layoutCommand = d->m_graph->chooseLayoutProgramForFile(d->m_loadThread.dotFileName());
+    else
+      layoutCommand = "dot";
+  }
+  d->m_layoutThread.layoutGraph(d->m_loadThread.g(), layoutCommand);
+}
+
+void DotGraphView::slotAGraphLayoutFinished()
+{
+  Q_D(DotGraphView);
+  bool result = loadLibrary(d->m_layoutThread.g(), d->m_layoutThread.layoutCommand());
+  if (result)
+    d->m_graph->dotFileName(d->m_loadThread.dotFileName());
+
+  gvFreeLayout(d->m_layoutThread.gvc(), d->m_layoutThread.g());
+  agclose(d->m_layoutThread.g());
+}
+
+void DotGraphView::slotSelectNode(const QString& nodeName)
+{
+  kDebug() << nodeName;
+  GraphNode* node = dynamic_cast<GraphNode*>(graph()->elementNamed(nodeName));
+  if (node == 0) return;
+  node->setSelected(true);
+  if (node->canvasNode()!=0)
+  {
+    node->canvasNode()->modelChanged();
+    slotElementSelected(node->canvasNode(),Qt::NoModifier);
+  }
+}
+
+void DotGraphView::centerOnNode(const QString& nodeId)
+{
+  GraphNode* node = dynamic_cast<GraphNode*>(graph()->elementNamed(nodeId));
+  if (node == 0) return;
+  if (node->canvasNode()!=0)
+  {
+    centerOn(node->canvasNode());
+  }
+}
+
+
+}
+
+#include "dotgraphview.moc"
+
diff --git a/src/kgraphviz/dotgraphview.h b/src/kgraphviz/dotgraphview.h
new file mode 100644
index 0000000..c405a5a
--- /dev/null
+++ b/src/kgraphviz/dotgraphview.h
@@ -0,0 +1,258 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+/*
+ * Callgraph View
+ */
+
+#ifndef DOTGRAPHVIEW_H
+#define DOTGRAPHVIEW_H
+
+#include "shared/kgraphviewer_interface.h"
+#include "shared/kgraphviewer_export.h"
+
+#include <kconfig.h>
+#include <kactioncollection.h>
+#include <kconfiggroup.h>
+
+#include <QGraphicsView>
+#include <QSet>
+
+class Agraph_t;
+
+class KSelectAction;
+class KToggleAction;
+
+class QMenu;
+class QKeyEvent;
+class QMouseEvent;
+class QFocusEvent;
+class QResizeEvent;
+class QWheelEvent;
+class QContextMenuEvent;
+class QWidget;
+
+namespace KGraphViewer
+{
+
+class GraphElement;
+class GraphSubgraph;
+class CanvasElement;
+class CanvasEdge;
+class PannerView;
+class DotGraph;
+class KGVSimplePrintingCommand;
+
+#define DEFAULT_DETAILLEVEL 1
+
+class DotGraphViewPrivate;
+/**
+ * A CanvasView showing a part of the call graph
+ * and another zoomed out CanvasView in a border acting as
+ * a panner to select to visible part (only if needed)
+ */
+class KGRAPHVIEWER_EXPORT DotGraphView: public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+  enum EditingMode { None, AddNewElement, AddNewEdge, DrawNewEdge, SelectingElements };
+  enum ScrollDirection { Here, Left, Right, Top, Bottom };
+  
+  explicit KGRAPHVIEWER_EXPORT DotGraphView(KActionCollection* actions, QWidget* parent=0);
+  virtual ~DotGraphView();
+
+  bool KGRAPHVIEWER_EXPORT loadDot(const QString& dotFileName);
+  bool KGRAPHVIEWER_EXPORT loadLibrary(const QString& dotFileName);
+  bool loadLibrary(Agraph_t* graph, const QString& layoutCommand = "dot");
+
+  void readViewConfig();
+  void saveViewConfig();
+
+  QWidget* widget() { return this; }
+
+  //TODO: rename zoomPos -> bev / panner, but _please_ make it consistent...
+  KGraphViewerInterface::PannerPosition zoomPos() const;
+  static KGraphViewerInterface::PannerPosition zoomPos(const QString&);
+  static QString zoomPosString(KGraphViewerInterface::PannerPosition);
+  void setPannerEnabled(bool enabled);
+  
+  static KConfigGroup* configGroup(KConfig*, const QString& prefix, const QString& postfix);
+  static void writeConfigEntry(KConfigGroup*, const char* pKey, const QString& value,
+                               const char* def);
+  static void writeConfigEntry(KConfigGroup*, const char* pKey,
+                               int value, int def);
+  static void writeConfigEntry(KConfigGroup*, const char* pKey,
+                               bool value, bool def);
+  static void writeConfigEntry(KConfigGroup*, const char* pKey,
+                               double value, double def);
+
+  virtual void wheelEvent(QWheelEvent* e);
+
+  /// multiplies current zoom factor with @p factor
+  void applyZoom(double factor);
+  /// sets zoom factor to @p factor
+  void setZoomFactor(double factor);
+  
+  void setLayoutCommand(const QString& command);
+    
+  const QString& dotFileName();
+
+  void hideToolsWindows();
+  double zoom() const;
+  KSelectAction* bevPopup();
+
+  DotGraph* graph();
+  const DotGraph* graph() const;
+
+  const GraphElement* defaultNewElement() const;
+  QPixmap defaultNewElementPixmap() const;
+
+  void setDefaultNewElement(GraphElement* elem);
+  void setDefaultNewElementPixmap(const QPixmap& pm);
+
+  void prepareAddNewElement(QMap<QString,QString> attribs);
+  void prepareAddNewEdge(QMap<QString,QString> attribs);
+  void prepareSelectElements();
+  
+  void createNewEdgeDraftFrom(CanvasElement* node);
+  void finishNewEdgeTo(CanvasElement* node);
+
+  EditingMode editingMode() const;
+
+  void KGRAPHVIEWER_EXPORT setReadOnly();
+  void KGRAPHVIEWER_EXPORT setReadWrite();
+  bool isReadWrite() const;
+  bool isReadOnly() const;
+  
+  void removeSelectedNodes();
+  void removeSelectedEdges();
+  void removeSelectedSubgraphs();
+  void removeSelectedElements();
+  
+  bool highlighting();
+  void setHighlighting(bool highlightingValue);
+
+  // public so that the panner view can bubble through
+  void contextMenuEvent(QContextMenuEvent*);
+
+  void setBackgroundColor(const QColor& color);
+  
+Q_SIGNALS:
+  void zoomed(double factor);
+  void sigViewBevEnabledToggled(bool value);
+  void sigViewBevActivated(int newPos);
+  void graphLoaded();
+  void newNodeAdded(const QString&);
+  void newEdgeAdded(const QString&, const QString&);
+  /** signals that the user has activated a remove edge command */
+  void removeEdge(const QString&);
+  /** signals that the user has activated a remove edge command */
+  void removeNodeNamed(const QString&);
+  /** signals that the user has activated a remove element command */
+  void removeElement(const QString&);
+  /** signals the content of the new selection */
+  void selectionIs(const QList<QString>, const QPoint&);
+  /** let the application tweak the created edge if necessary */
+  void newEdgeFinished(
+      const QString&, const QString&,
+      const QMap<QString, QString>&);
+  void contextMenuEvent(const QString&, const QPoint&);
+  void hoverEnter(const QString&);
+  void hoverLeave(const QString&);
+  
+public Q_SLOTS:
+  void zoomIn();
+  void zoomOut();  
+  void zoomRectMovedTo(QPointF newZoomPos);
+  void zoomRectMoveFinished();
+  bool initEmpty();
+  bool slotLoadLibrary(Agraph_t* graph);
+  bool reload();
+  void dirty(const QString& dotFileName);
+  void pageSetup();
+  void print();
+  void printPreview();
+  void viewBevActivated(int newPos);
+  void slotExportImage();
+  void slotSelectLayoutAlgo(const QString& text);
+  void slotLayoutSpecify();
+  void slotLayoutReset();
+  void slotSelectLayoutDot();
+  void slotSelectLayoutNeato();
+  void slotSelectLayoutTwopi();
+  void slotSelectLayoutFdp();
+  void slotSelectLayoutCirco();
+  void slotBevToggled();
+  void slotBevTopLeft();
+  void slotBevTopRight();
+  void slotBevBottomLeft();
+  void slotBevBottomRight();
+  void slotBevAutomatic();
+  void slotUpdate();
+  bool displayGraph();
+  void slotEdgeSelected(CanvasEdge*, Qt::KeyboardModifiers);
+  void slotElementSelected(CanvasElement*, Qt::KeyboardModifiers);
+  void slotSelectionChanged();
+  void slotContextMenuEvent(const QString&, const QPoint&);
+  void slotElementHoverEnter(CanvasElement*);
+  void slotElementHoverLeave(CanvasElement*);
+  void slotElementHoverEnter(CanvasEdge*);
+  void slotElementHoverLeave(CanvasEdge*);
+  void slotSelectNode(const QString& nodeName);
+  void centerOnNode(const QString& nodeId);
+
+protected:
+  void scrollContentsBy(int dx, int dy);
+  void resizeEvent(QResizeEvent*);
+  void mousePressEvent(QMouseEvent*);
+  void mouseMoveEvent(QMouseEvent*);
+  void mouseReleaseEvent(QMouseEvent*);
+  void mouseDoubleClickEvent(QMouseEvent*);
+  void keyPressEvent(QKeyEvent*);
+  void focusInEvent(QFocusEvent*);
+  void focusOutEvent(QFocusEvent*);
+  
+  void timerEvent ( QTimerEvent * event );
+  void leaveEvent ( QEvent * event );
+  void enterEvent ( QEvent * event );
+  
+private Q_SLOTS:
+  void slotAGraphReadFinished();
+  void slotAGraphLayoutFinished();
+  
+protected:
+  DotGraphViewPrivate * const d_ptr;
+
+private:
+  Q_DECLARE_PRIVATE(DotGraphView);
+  
+};
+
+}
+
+#endif // DOTGRAPHVIEW_H
diff --git a/src/kgraphviz/graphedge.cpp b/src/kgraphviz/graphedge.cpp
new file mode 100644
index 0000000..de12caa
--- /dev/null
+++ b/src/kgraphviz/graphedge.cpp
@@ -0,0 +1,175 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.cpp, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+#include "graphedge.h"
+#include "graphnode.h"
+#include "graphsubgraph.h"
+#include "canvasedge.h"
+#include "support/dotdefaults.h"
+#include "support/dotgrammar.h"
+
+#include <graphviz/gvc.h>
+
+#include <KDebug>
+
+namespace KGraphViewer
+{
+  
+/*
+ * Graph Edge
+ */
+
+GraphEdge::GraphEdge() : 
+    GraphElement(),
+    m_fromNode(0),m_toNode(0),
+    m_visible(true),
+    m_colors(),
+    m_dir(DOT_DEFAULT_EDGE_DIR),
+    m_arrowheads()
+{
+//   kDebug() ;
+}
+
+GraphEdge::~GraphEdge()
+{
+//   kDebug() ;
+}
+
+GraphEdge::GraphEdge(const GraphEdge& edge) :
+  GraphElement(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;
+}
+
+void GraphEdge::colors(const QString& cs)
+{
+  m_colors = QStringList::split(":", cs);
+//   kDebug() << fromNode()->id() << " -> " << toNode()->id() << ": nb colors: " << m_colors.size();
+}
+
+const QString GraphEdge::color(uint i) 
+{
+  if (i >= (uint)m_colors.count() && m_attributes.find("color") != m_attributes.end())
+  {
+    colors(m_attributes["color"]);
+  }
+  if (i < (uint)m_colors.count())
+  {
+//     std::cerr << "edge color " << i << " is " << m_colors[i] << std::endl;
+//     kDebug() << fromNode()->id() << " -> " << toNode()->id() << "color" << i << "is" << m_colors[i];
+    return m_colors[i];
+  }
+  else
+  {
+//     kDebug() << fromNode()->id() << " -> " << toNode()->id() << "no edge color " << i << ". returning " << DOT_DEFAULT_EDGE_COLOR;
+    return DOT_DEFAULT_EDGE_COLOR;
+  }
+}
+
+void GraphEdge::updateWithEdge(const GraphEdge& edge)
+{
+  kDebug() << id() << edge.id();
+  m_arrowheads = edge.arrowheads();
+  m_colors = edge.colors();
+  m_dir = edge.dir();
+  GraphElement::updateWithElement(edge);
+  if (canvasEdge())
+  {
+    canvasEdge()->computeBoundingRect();
+    canvasEdge()->modelChanged();
+  }
+}
+
+void GraphEdge::updateWithEdge(edge_t* edge)
+{
+  kDebug();
+  renderOperations().clear();
+  if (agget(edge, (char*)"_draw_") != NULL)
+  {
+    parse_renderop(agget(edge, (char*)"_draw_"), renderOperations());
+    kDebug() << "element renderOperations size is now " << renderOperations().size();
+  }
+  if (agget(edge, (char*)"_ldraw_") != NULL)
+  {
+    parse_renderop(agget(edge, (char*)"_ldraw_"), renderOperations());
+    kDebug() << "element renderOperations size is now " << renderOperations().size();
+  }
+  if (agget(edge, (char*)"_hdraw_") != NULL)
+  {
+    parse_renderop(agget(edge, (char*)"_hdraw_"), renderOperations());
+    kDebug() << "element renderOperations size is now " << renderOperations().size();
+  }
+  if (agget(edge, (char*)"_tdraw_") != NULL)
+  {
+    parse_renderop(agget(edge, (char*)"_tdraw_"), renderOperations());
+    kDebug() << "element renderOperations size is now " << renderOperations().size();
+  }
+  if (agget(edge, (char*)"_hldraw_") != NULL)
+  {
+    parse_renderop(agget(edge, (char*)"_hldraw_"), renderOperations());
+    kDebug() << "element renderOperations size is now " << renderOperations().size();
+  }
+  if (agget(edge, (char*)"_tldraw_") != NULL)
+  {
+    parse_renderop(agget(edge, (char*)"_tldraw_"), renderOperations());
+    kDebug() << "element renderOperations size is now " << renderOperations().size();
+  }
+  Agsym_t *attr = agfstattr(edge);
+  while(attr)
+  {
+    kDebug() /*<< edge->name*/ << ":" << attr->name << agxget(edge,attr->index);
+    m_attributes[attr->name] = agxget(edge,attr->index);
+    attr = agnxtattr(edge,attr);
+  }
+  
+}
+
+QTextStream& operator<<(QTextStream& s, const GraphEdge& e)
+{
+  QString srcLabel = e.fromNode()->id();
+  if (dynamic_cast<const GraphSubgraph*>(e.fromNode()))
+  {
+    srcLabel = QString("subgraph ") + srcLabel;
+  }
+  QString tgtLabel = e.toNode()->id();
+  if (dynamic_cast<const GraphSubgraph*>(e.toNode()))
+  {
+    tgtLabel = QString("subgraph ") + tgtLabel;
+  }
+  s << srcLabel << " -> " << tgtLabel << "  ["
+    << dynamic_cast<const GraphElement&>(e) << "];" << endl;
+
+  return s;
+}
+
+}
+
+#include "graphedge.moc"
diff --git a/src/kgraphviz/graphedge.h b/src/kgraphviz/graphedge.h
new file mode 100644
index 0000000..48331f1
--- /dev/null
+++ b/src/kgraphviz/graphedge.h
@@ -0,0 +1,123 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+/*
+ * Graph Edge
+ */
+
+#ifndef GRAPH_EDGE_H
+#define GRAPH_EDGE_H
+
+#include "graphelement.h"
+#include "support/dotrenderop.h"
+
+#include <QStringList>
+#include <QMap>
+#include <QTextStream>
+
+class Agedge_t;
+
+namespace KGraphViewer
+{
+  
+class CanvasEdge;
+class CanvasNode;
+class GraphNode;
+
+class GraphEdge : public GraphElement
+{
+  Q_OBJECT
+
+public:
+  GraphEdge();
+  virtual ~GraphEdge();
+
+  GraphEdge(const GraphEdge& edge);
+  GraphEdge(Agedge_t* edge);
+  
+  CanvasEdge* canvasEdge() { return (CanvasEdge*)canvasElement(); }
+  const CanvasEdge* canvasEdge() const { return (CanvasEdge*)canvasElement(); }
+  void setCanvasEdge(CanvasEdge* ce) { setCanvasElement((CanvasElement*)ce); }
+
+  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; }
+
+  void setFromNode(GraphElement* n) { m_fromNode = n; }
+  void setToNode(GraphElement* n) { m_toNode = n; }
+
+//   inline const QVector< QPair< float, float > >& edgePoints() const {return m_edgePoints;}
+//   inline QVector< QPair< float, float > >& edgePoints() {return m_edgePoints;}
+//   inline void edgePoints(const QVector< QPair< float, float > >& ep) {m_edgePoints = ep;}
+  
+  inline const QStringList& colors() const {return m_colors;}
+  const QString color(uint i);
+  void colors(const QString& cs); 
+  
+/*  inline void labelX(float x) {m_labelX = x;}
+  inline void labelY(float y) {m_labelY = y;}
+  inline float labelX() const {return m_labelX;}
+  inline float labelY() const {return m_labelY;}*/
+  
+  inline const QString& dir() const {return m_dir;}
+  inline void dir(const QString& dir) {m_dir = dir;}
+
+  inline QList< DotRenderOp >&  arrowheads() {return m_arrowheads;}
+  inline const QList< DotRenderOp >&  arrowheads() const {return m_arrowheads;}
+
+  virtual void updateWithEdge(const GraphEdge& edge);
+  virtual void updateWithEdge(Agedge_t* edge);
+
+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;
+//   float m_labelX, m_labelY;
+  
+  QList< DotRenderOp > m_arrowheads;
+};
+
+
+/** A map associating the bounds nodes of a graph's edges to these edges */
+typedef QMap<QString, GraphEdge*> GraphEdgeMap;
+
+QTextStream& operator<<(QTextStream& s, const GraphEdge& e);
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/graphelement.cpp b/src/kgraphviz/graphelement.cpp
new file mode 100644
index 0000000..d3899d8
--- /dev/null
+++ b/src/kgraphviz/graphelement.cpp
@@ -0,0 +1,203 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#include "graphelement.h"
+#include "canvaselement.h"
+#include "support/dotdefaults.h"
+
+#include <math.h>
+
+#include <kdebug.h>
+
+#include <QRegExp>
+#include <graphviz/gvc.h>
+
+namespace KGraphViewer
+{
+  
+GraphElement::GraphElement() :
+    QObject(),
+    m_attributes(),
+    m_originalAttributes(),
+    m_ce(0),
+    m_z(1.0),
+    m_renderOperations(),
+    m_selected(false)
+{
+/*  label("");
+  id("");
+  style(DOT_DEFAULT_STYLE);
+  shape(DOT_DEFAULT_SHAPE);
+  lineColor(DOT_DEFAULT_LINECOLOR);
+  backColor(DOT_DEFAULT_BACKCOLOR);
+  fontName(DOT_DEFAULT_FONTNAME);
+  fontColor(DOT_DEFAULT_FONTCOLOR);
+  url("");
+  shapeFile("");*/
+  setFontSize(DOT_DEFAULT_FONTSIZE);
+}
+
+GraphElement::GraphElement(const GraphElement& element) : QObject(),
+  m_attributes(),
+  m_originalAttributes(),
+  m_ce(element.m_ce),
+  m_z(element.m_z),
+  m_renderOperations(),
+  m_selected(element.m_selected)
+{
+  kDebug() ;
+  updateWithElement(element);
+}
+
+void GraphElement::updateWithElement(const GraphElement& element)
+{
+  kDebug() << element.id();
+  bool modified = false;
+  if (element.z() != m_z)
+  {
+    m_z = element.z();
+    modified = true;
+  }
+  QMap <QString, QString >::const_iterator it = element.attributes().constBegin();
+  for (;it != element.attributes().constEnd(); it++)
+  {
+    const QString &attrib = it.key();
+    if ( (!m_attributes.contains(attrib)) || (m_attributes[attrib] != it.value()) )
+    {
+      m_attributes[attrib] = it.value();
+      if (attrib == "z")
+      {
+        bool ok;
+        setZ(m_attributes[attrib].toDouble(&ok));
+      }
+      modified = true;
+    }
+  }
+  if (modified)
+  {
+    kDebug() << "modified: update render operations";
+    m_renderOperations = element.m_renderOperations;
+/*    foreach (DotRenderOp op, m_renderOperations)
+    {
+      QString msg;
+      QTextStream dd(&msg);
+      dd << "an op: " << op.renderop << " ";
+      foreach (int i, op.integers)
+      {
+        dd << i << " ";
+      }
+      dd << op.str;
+      kDebug() << msg;
+    }
+    kDebug() << "modified: emiting changed";*/
+    emit changed();
+  }
+  kDebug() << "done" << m_renderOperations.size();
+}
+
+
+QString GraphElement::backColor() const
+{
+  if (m_attributes.find("fillcolor") != m_attributes.end())
+  {
+    return m_attributes["fillcolor"];
+  }
+  else if ( (m_attributes.find("color") != m_attributes.end())
+    && (m_attributes["style"] == "filled") )
+  {
+    return m_attributes["color"];
+  }
+  else
+  {
+    return DOT_DEFAULT_NODE_BACKCOLOR;
+  }
+}
+
+void GraphElement::removeAttribute(const QString& attribName)
+{
+  kDebug() << attribName;
+  m_attributes.remove(attribName);
+  emit changed();
+}
+
+void GraphElement::exportToGraphviz(void* element) const
+{
+  QMap<QString,QString>::const_iterator it, it_end;
+  it = attributes().begin(); it_end = attributes().end();
+  for (;it != it_end; it++)
+  {
+    if (!it.value().isEmpty())
+    {
+      if (it.key() == "label")
+      {
+        QString label = it.value();
+        if (label != "label")
+        {
+          label.replace(QRegExp("\n"),"\\n");
+          //           kDebug() << it.key() << "=\"" << label << "\",";
+          agsafeset(element, it.key().toUtf8().data(), label.toUtf8().data(), QString().toUtf8().data());
+        }
+      }
+      else if (it.key() == "_draw_" || it.key() == "_ldraw_")
+      {
+      }
+      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());
+      }
+    }
+  }
+}
+
+QTextStream& operator<<(QTextStream& s, const GraphElement& n)
+{
+  QMap<QString,QString>::const_iterator it, it_end;
+  it = n.attributes().begin(); it_end = n.attributes().end();
+  for (;it != it_end; it++)
+  {
+    if (!it.value().isEmpty())
+    {
+      if (it.key() == "label")
+      {
+        QString label = it.value();
+        if (label != "label")
+        {
+          label.replace(QRegExp("\n"),"\\n");
+//           kDebug() << it.key() << "=\"" << label << "\",";
+          s << it.key() << "=\"" << label << "\",";
+        }
+      }
+      else if (it.key() == "_draw_" || it.key() == "_ldraw_")
+      {
+      }
+      else if (n.originalAttributes().isEmpty() || n.originalAttributes().contains(it.key()))
+      {
+//         kDebug() << it.key() << it.value();
+        
+          s << it.key() << "=\"" << it.value() << "\",";
+      }
+    }
+  }
+  return s;
+}
+
+}
+
+#include "graphelement.moc"
diff --git a/src/kgraphviz/graphelement.h b/src/kgraphviz/graphelement.h
new file mode 100644
index 0000000..13bdd22
--- /dev/null
+++ b/src/kgraphviz/graphelement.h
@@ -0,0 +1,133 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#ifndef GRAPH_ELEMENT_H
+#define GRAPH_ELEMENT_H
+
+#include "support/dotrenderop.h"
+
+#include <QVector>
+#include <QList>
+#include <QMap>
+#include <QtCore/QTextStream>
+
+namespace KGraphViewer
+{
+  
+class CanvasElement;
+
+/**
+ * The base of all GraphViz dot graph elements (nodes, edges, subgraphs,
+ * graphs). It is used to store the element attributes
+ */
+class GraphElement: public QObject
+{
+  Q_OBJECT
+public:
+  GraphElement();
+  GraphElement(const GraphElement& element);
+  
+  virtual ~GraphElement() {}
+  
+  inline void setId(const QString& id) {m_attributes["id"]=id;}
+  inline void setStyle(const QString& ls) {m_attributes["style"]=ls;}
+  inline void setShape(const QString& lc) {m_attributes["shape"]=lc;}
+  inline void setColor(const QString& nt) {m_attributes["color"]=nt;}
+  inline void setLineColor(const QString& nt) {m_attributes["color"]=nt;}
+  inline void setBackColor(const QString& nc) {m_attributes["bgcolor"]=nc;}
+  
+  inline QString id() const {return m_attributes["id"];}
+  inline QString style() const {return m_attributes["style"];}
+  inline QString shape() const {return m_attributes["shape"];}
+  inline QString color() const {return m_attributes["color"];}
+  inline QString lineColor() const {return m_attributes["color"];}
+  virtual QString backColor() const;
+  
+  inline void setLabel(const QString& label) {m_attributes["label"]=label;}
+  inline const QString label() const {return m_attributes["label"];}
+
+  inline unsigned int fontSize() const {return m_attributes["fontsize"].toUInt();}
+  inline void setFontSize(unsigned int fs) {m_attributes["fontsize"]=QString::number(fs);}
+  inline QString fontName() const {return m_attributes["fontname"];}
+  inline void setFontName(const QString& fn) {m_attributes["fontname"]=fn;}
+  inline QString fontColor() const {return m_attributes["fontcolor"];}
+  inline void setFontColor(const QString& fc) {m_attributes["fontcolor"] = fc;}
+
+  inline DotRenderOpVec& renderOperations() {return m_renderOperations;};
+  inline const DotRenderOpVec& renderOperations() const {return m_renderOperations;};
+  inline void setRenderOperations(DotRenderOpVec& drov) {m_renderOperations = drov;};
+  
+  inline double z() const {return m_z;}
+  inline void setZ(double thez) {m_z = thez;}
+  
+  inline QString shapeFile() const {return m_attributes["shapefile"];}
+  inline void setShapeFile(const QString& sf) {m_attributes["shapefile"] = sf;}
+  
+  inline QString url() const {return m_attributes["URL"];}
+  inline void setUrl(const QString& theUrl) {m_attributes["URL"] = theUrl;}
+
+  virtual void updateWithElement(const GraphElement& element);
+
+  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;}
+
+  virtual inline void storeOriginalAttributes() {m_originalAttributes = m_attributes.keys();}
+
+  virtual void removeAttribute(const QString& attribName);
+
+  inline CanvasElement* canvasElement() {return m_ce;}
+  inline const CanvasElement* canvasElement() const {return m_ce;}
+  inline void setCanvasElement(CanvasElement* ce) {m_ce = ce;}
+
+  inline void setSelected(bool s) {m_selected=s;}
+  inline bool isSelected() {return m_selected;}
+
+  bool isVisible() const { return m_visible; }
+  void setVisible(bool v) { m_visible = v; }
+
+  void exportToGraphviz(void* element)  const;
+
+Q_SIGNALS:
+  void changed();
+
+protected:
+  QMap<QString,QString> m_attributes;
+  QList<QString> m_originalAttributes;
+  
+  CanvasElement* m_ce;
+private:
+  double m_z;
+  bool m_visible;
+
+  DotRenderOpVec m_renderOperations;
+
+  bool m_selected;
+};
+
+
+QTextStream& operator<<(QTextStream& s, const GraphElement& n);
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/graphexporter.cpp b/src/kgraphviz/graphexporter.cpp
new file mode 100644
index 0000000..4192bf1
--- /dev/null
+++ b/src/kgraphviz/graphexporter.cpp
@@ -0,0 +1,164 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.cpp, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+#include "graphexporter.h"
+#include "dotgraph.h"
+
+#include <graphviz/gvc.h>
+
+#include <QFile>
+#include <QTextStream>
+
+#include <kdebug.h>
+#include <ktemporaryfile.h>
+
+namespace KGraphViewer
+{
+  
+GraphExporter::GraphExporter()
+{
+}
+
+GraphExporter::~GraphExporter()
+{
+}
+
+QString GraphExporter::writeDot(const DotGraph* graph, const QString& fileName)
+{
+  kDebug() << fileName;
+
+  QString actualFileName = fileName;
+
+  if (fileName.isEmpty())
+  {
+    KTemporaryFile tempFile;
+    tempFile.setSuffix(".dot");
+    if (!tempFile.open()) 
+    {
+      kError() << "Unable to open for temp file for writing " << tempFile.name() << endl;
+      exit(2);
+    }
+    actualFileName = tempFile.name();
+    kDebug() << "using " << actualFileName;
+  }
+  
+  QFile f(actualFileName);
+  if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
+  {
+    kError() << "Unable to open file for writing " << fileName << endl;
+    exit(2);
+  }
+  
+  QTextStream stream(&f);
+
+  stream << "digraph \"";
+  if (graph->id()!="\"\"")
+  {
+    stream <<graph->id();
+  }
+  stream <<"\" {\n";
+
+  stream << "graph [" << *graph <<"]" << endl;
+
+  /// @TODO Subgraph are not represented as needed in DotGraph, so it is not
+  /// possible to save them back : to be changed !
+//   kDebug() << "writing subgraphs";
+  GraphSubgraphMap::const_iterator sit;
+  for ( sit = graph->subgraphs().begin();
+  sit != graph->subgraphs().end(); ++sit )
+  {
+    const GraphSubgraph& s = **sit;
+    (stream) << s;
+  }
+
+//   kDebug() << "writing nodes";
+  GraphNodeMap::const_iterator nit;
+  for ( nit = graph->nodes().begin();
+        nit != graph->nodes().end(); ++nit )
+  {
+    (stream) << **nit;
+  }
+
+  kDebug() << "writing edges";
+  GraphEdgeMap::const_iterator eit;
+  for ( eit = graph->edges().begin();
+        eit != graph->edges().end(); ++eit )
+  {
+    kDebug() << "writing edge" << (*eit)->id();
+    stream << **eit;
+  }
+
+  stream << "}\n";
+
+  f.close();
+  return actualFileName;
+}
+
+graph_t* GraphExporter::exportToGraphviz(const DotGraph* graph)
+{
+  int type = graph->directed()
+      ?(graph->strict()?AGDIGRAPHSTRICT:AGDIGRAPH)
+      :(graph->strict()?AGRAPHSTRICT:AGRAPH);
+  
+  graph_t* agraph = agopen((graph->id()!="\"\"")?graph->id().toUtf8().data():QString("unnamed").toUtf8().data(), type);
+
+  QTextStream stream;
+  graph->exportToGraphviz(agraph);
+  /// @TODO Subgraph are not represented as needed in DotGraph, so it is not
+  /// possible to save them back : to be changed !
+  //   kDebug() << "writing subgraphs";
+  GraphSubgraphMap::const_iterator sit;
+  for ( sit = graph->subgraphs().begin();
+  sit != graph->subgraphs().end(); ++sit )
+  {
+    const GraphSubgraph& s = **sit;
+    graph_t* subgraph = agsubg(agraph, s.id().toUtf8().data());
+    s.exportToGraphviz(subgraph);
+  }
+  
+  //   kDebug() << "writing nodes";
+  GraphNodeMap::const_iterator nit;
+  foreach (GraphNode* n, graph->nodes())
+  {
+    node_t* node = agnode(agraph, n->id().toUtf8().data());
+    n->exportToGraphviz(node);
+  }
+  
+  kDebug() << "writing edges";
+  GraphEdgeMap::const_iterator eit;
+  foreach (GraphEdge* e, graph->edges())
+  {
+    kDebug() << "writing edge" << e->id();
+    edge_t* edge = agedge(agraph, agnode(agraph, e->fromNode()->id().toUtf8().data()),
+                          agnode(agraph, e->toNode()->id().toUtf8().data()));
+    e->exportToGraphviz(edge);
+  }
+  
+  return agraph;
+}
+
+}
diff --git a/src/kgraphviz/graphexporter.h b/src/kgraphviz/graphexporter.h
new file mode 100644
index 0000000..f6b223e
--- /dev/null
+++ b/src/kgraphviz/graphexporter.h
@@ -0,0 +1,64 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+/*
+ * Graph Exporter
+ */
+
+#ifndef GRAPH_EXPORTER_H
+#define GRAPH_EXPORTER_H
+
+#include <QString>
+
+class Agraph_t;
+
+class KTemporaryFile;
+
+namespace KGraphViewer
+{
+class DotGraph;
+  
+/**
+ * GraphExporter
+ *
+ * Generates a graph file for "dot"
+ */
+class GraphExporter
+{
+public:
+  GraphExporter();
+  virtual ~GraphExporter();
+
+  QString writeDot(const DotGraph* graph, const QString& fileName = QString());
+  Agraph_t* exportToGraphviz(const DotGraph* graph);
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/graphnode.cpp b/src/kgraphviz/graphnode.cpp
new file mode 100644
index 0000000..3bc844a
--- /dev/null
+++ b/src/kgraphviz/graphnode.cpp
@@ -0,0 +1,129 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   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"
+#include "support/dotgrammar.h"
+
+#include <math.h>
+
+#include <graphviz/gvc.h>
+
+#include <kdebug.h>
+
+namespace KGraphViewer
+{
+  
+//
+// GraphNode
+//
+
+GraphNode::GraphNode() :
+    GraphElement()
+{
+//   kDebug() ;
+}
+
+GraphNode::GraphNode(const GraphNode& gn) :
+GraphElement(gn)
+{
+  //   kDebug() ;
+}
+
+GraphNode::GraphNode(node_t* gn) : GraphElement()
+{
+  kDebug();
+  updateWithNode(gn);
+}
+
+void GraphNode::updateWithNode(const GraphNode& node)
+{
+  kDebug() << id() << node.id();
+  GraphElement::updateWithElement(node);
+  if (canvasNode())
+  {
+    canvasNode()->computeBoundingRect();
+    canvasNode()->modelChanged();
+  }
+//   kDebug() << "done";
+}
+
+void GraphNode::updateWithNode(node_t* node)
+{
+  kDebug() << node->name;
+  m_attributes["id"] = node->name;
+  m_attributes["label"] = ND_label(node)->text;
+
+
+  renderOperations().clear();
+  if (agget(node, (char*)"_draw_") != NULL)
+  {
+    parse_renderop(agget(node, (char*)"_draw_"), renderOperations());
+    kDebug() << "_draw_: element renderOperations size is now " << renderOperations().size();
+  }
+  if (agget(node, (char*)"_ldraw_") != NULL)
+  {
+    parse_renderop(agget(node, (char*)"_ldraw_"), renderOperations());
+    kDebug() << "_ldraw_: element renderOperations size is now " << renderOperations().size();
+  }
+
+  Agsym_t *attr = agfstattr(node);
+  while(attr)
+  {
+    kDebug() << node->name << ":" << attr->name << agxget(node,attr->index);
+    m_attributes[attr->name] = agxget(node,attr->index);
+    attr = agnxtattr(node,attr);
+  }
+}
+
+CanvasNode* GraphNode::canvasNode()
+{
+    return dynamic_cast<CanvasNode*>(canvasElement());
+}
+
+const KGraphViewer::CanvasNode* GraphNode::canvasNode() const
+{
+    return dynamic_cast<const CanvasNode*>(canvasElement());
+}
+
+QTextStream& operator<<(QTextStream& s, const GraphNode& n)
+{
+  s << n.id() << "  ["
+    << dynamic_cast<const GraphElement&>(n)
+    <<"];"<<endl;
+  return s;
+}
+
+}
+
+#include "graphnode.moc"
diff --git a/src/kgraphviz/graphnode.h b/src/kgraphviz/graphnode.h
new file mode 100644
index 0000000..ce6c2e9
--- /dev/null
+++ b/src/kgraphviz/graphnode.h
@@ -0,0 +1,86 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+/*
+ * Graph Node model
+ */
+
+#ifndef GRAPH_NODE_H
+#define GRAPH_NODE_H
+
+#include <QVector>
+#include <QList>
+#include <QMap>
+#include <QtCore/QTextStream>
+
+#include "support/dotrenderop.h"
+#include "graphelement.h"
+
+class Agnode_t;
+
+namespace KGraphViewer
+{
+
+class CanvasElement;
+class CanvasNode;
+
+/**
+ * Colors and styles are dot names
+ */
+class GraphNode : public GraphElement
+{
+  Q_OBJECT
+
+public:
+  GraphNode();
+  GraphNode(const GraphNode& gn);
+  GraphNode(Agnode_t* gn);
+  
+  virtual ~GraphNode() {}  
+  
+  CanvasNode* canvasNode();
+  const CanvasNode* canvasNode() const;
+  inline void setCanvasNode(CanvasNode* cn) { setCanvasElement((CanvasElement*)cn); }
+
+  virtual void updateWithNode(const GraphNode& node);
+  virtual void updateWithNode(Agnode_t* node);
+
+  
+private:
+};
+
+/** A map associating the ids of a graph's nodes to these nodes */
+typedef QMap<QString, GraphNode*> GraphNodeMap;
+
+QTextStream& operator<<(QTextStream& s, const GraphNode& n);
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/graphsubgraph.cpp b/src/kgraphviz/graphsubgraph.cpp
new file mode 100644
index 0000000..44b115f
--- /dev/null
+++ b/src/kgraphviz/graphsubgraph.cpp
@@ -0,0 +1,297 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005 Gaël de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/*
+ * Graph Subgraph
+ */
+
+#include "canvassubgraph.h"
+#include "graphsubgraph.h"
+#include "graphnode.h"
+#include "support/dotdefaults.h"
+#include "support/dotgrammar.h"
+
+#include "graphviz/gvc.h"
+
+#include <kdebug.h>
+
+namespace KGraphViewer
+{
+  
+//
+// GraphSubgraph
+//
+
+GraphSubgraph::GraphSubgraph() :
+  GraphElement(), m_content()
+{
+}
+
+GraphSubgraph::GraphSubgraph(graph_t* sg) :
+  GraphElement(), m_content()
+{
+  updateWithSubgraph(sg);
+}
+
+void GraphSubgraph::updateWithSubgraph(const GraphSubgraph& subgraph)
+{
+  kDebug() << id() << subgraph.id();
+  GraphElement::updateWithElement(subgraph);
+
+  bool found = false;
+  foreach (GraphElement* updatingge, subgraph.content())
+  {
+    foreach (GraphElement* ge, content())
+    {
+      if (ge->id() == updatingge->id())
+      {
+        found = true;
+        if (dynamic_cast<GraphNode*>(ge) != 0)
+        {
+          dynamic_cast<GraphNode*>(ge)->updateWithNode(*dynamic_cast<GraphNode*>(updatingge));
+        //     kDebug() << "node " << ngn->id();
+        }
+        else if (dynamic_cast<GraphSubgraph*>(ge) != 0)
+        {
+          dynamic_cast<GraphSubgraph*>(ge)->updateWithSubgraph(*dynamic_cast<GraphSubgraph*>(updatingge));
+        }
+        else
+        {
+          kError() << "Updated element is neither a node nor a subgraph";
+        }
+        break;
+      }
+    }
+    if (!found)
+    {
+  //       kDebug() << "new";
+      if (dynamic_cast<GraphNode*>(updatingge) != 0)
+      {
+        GraphNode* newgn = new GraphNode(*dynamic_cast<GraphNode*>(updatingge));
+  //       kDebug() << "new created";
+        content().push_back(newgn);
+  //       kDebug() << "new inserted";
+      }
+      else if (dynamic_cast<GraphSubgraph*>(updatingge) != 0)
+      {
+        GraphSubgraph* newsg = new GraphSubgraph(*dynamic_cast<GraphSubgraph*>(updatingge));
+        content().push_back(newsg);
+      }
+    }
+  }
+
+  if (canvasSubgraph())
+  {
+    canvasSubgraph()->modelChanged();
+    canvasSubgraph()->computeBoundingRect();
+  }
+//   kDebug() << "done";
+}
+
+void GraphSubgraph::updateWithSubgraph(graph_t* subgraph)
+{
+  kDebug() << subgraph->name;
+  m_attributes["id"] = subgraph->name;
+  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);
+  }
+
+
+  for (edge_t* e = agfstout(subgraph->meta_node->graph, subgraph->meta_node); e;
+      e = agnxtout(subgraph->meta_node->graph, e))
+  {
+    graph_t* sg = agusergraph(e->head);
+    kDebug() << "subsubgraph:" << sg->name;
+    if ( subgraphs().contains(sg->name))
+    {
+      kDebug() << "known subsubgraph";
+      // ???
+      //       nodes()[ngn->name]->setZ(ngn->z());
+      subgraphs()[sg->name]->updateWithSubgraph(sg);
+      if (subgraphs()[sg->name]->canvasElement()!=0)
+      {
+        //         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
+      }
+    }
+    else
+    {
+      kDebug() << "new subsubgraph";
+      GraphSubgraph* newsg = new GraphSubgraph(sg);
+      //       kDebug() << "new created";
+      subgraphs().insert(sg->name, newsg);
+      //       kDebug() << "new inserted";
+    }
+    
+  }
+}
+
+
+QString GraphSubgraph::backColor() const
+{
+  if (m_attributes.find("bgcolor") != m_attributes.end())
+  {
+    return m_attributes["bgcolor"];
+  }
+  else if ( (m_attributes.find("style") != m_attributes.end())
+    && (m_attributes["style"] == "filled")
+    && (m_attributes.find("color") != m_attributes.end()) )
+  {
+    return m_attributes["color"];
+  }
+  else if ((m_attributes.find("style") != m_attributes.end())
+    && (m_attributes["style"] == "filled")
+    && (m_attributes.find("fillcolor") != m_attributes.end()))
+  {
+    return m_attributes["fillcolor"];
+  }
+  else
+  {
+    return DOT_DEFAULT_BACKCOLOR;
+  }
+}
+
+void GraphSubgraph::removeElement(GraphElement* element)
+{
+  m_content.removeAll(element);
+}
+
+GraphElement* GraphSubgraph::elementNamed(const QString& id)
+{
+  if (this->id() == id) return this;
+  foreach (GraphElement* element, content())
+  {
+    if (element->id() == id)
+    {
+      return element;
+    }
+    else if (dynamic_cast<GraphSubgraph*>(element))
+    {
+      GraphElement* subgraphElement = dynamic_cast<GraphSubgraph*>(element)->elementNamed(id);
+      if (subgraphElement != 0)
+      {
+        return subgraphElement;
+      }
+    }
+  }
+  return 0;
+}
+
+bool GraphSubgraph::setElementSelected(
+    GraphElement* element,
+    bool selectValue,
+    bool unselectOthers)
+{
+  if (element)
+    kDebug() << element->id() << selectValue << unselectOthers;
+  bool res = false;
+  if (element == this)
+  {
+    if (isSelected() != selectValue)
+    {
+      setSelected(selectValue);
+      canvasElement()->update();
+    }
+    res = true;
+  }
+  else if (isSelected() && unselectOthers)
+  {
+    setSelected(false);
+    canvasElement()->update();
+  }
+  foreach (GraphElement* el, content())
+  {
+    if (dynamic_cast<GraphSubgraph*>(el) != 0)
+    {
+      bool subres = dynamic_cast<GraphSubgraph*>(el)->setElementSelected(element, selectValue, unselectOthers);
+      if (!res) res = subres;
+    }
+    else if (element == el)
+    {
+      res = true;
+      if (el->isSelected() != selectValue)
+      {
+        el->setSelected(selectValue);
+        el->canvasElement()->update();
+      }
+    }
+    else 
+    {
+      if (unselectOthers && el->isSelected())
+      {
+        el->setSelected(false);
+        el->canvasElement()->update();
+      }
+    }
+  }
+  return res;
+}
+
+void GraphSubgraph::retrieveSelectedElementsIds(QList<QString> selection)
+{
+  if (isSelected())
+  {
+    selection.push_back(id());
+  }
+  foreach (GraphElement* el, content())
+  {
+    if (dynamic_cast<GraphSubgraph*>(el) != 0)
+    {
+      dynamic_cast<GraphSubgraph*>(el)->retrieveSelectedElementsIds(selection);
+    }
+    else  if (el->isSelected())
+    {
+      selection.push_back(el->id());
+    }
+  }
+}
+
+QTextStream& operator<<(QTextStream& s, const GraphSubgraph& sg)
+{
+  s << "subgraph " << sg.id() << "  {"
+    << dynamic_cast<const GraphElement&>(sg);
+  foreach (const GraphElement* el, sg.content())
+  {
+    s << *(dynamic_cast<const GraphNode*>(el));
+  }
+  s <<"}"<<endl;
+  return s;
+}
+
+}
+
+#include "graphsubgraph.moc"
diff --git a/src/kgraphviz/graphsubgraph.h b/src/kgraphviz/graphsubgraph.h
new file mode 100644
index 0000000..4b3477d
--- /dev/null
+++ b/src/kgraphviz/graphsubgraph.h
@@ -0,0 +1,100 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/*
+ * Subgraph model
+ */
+
+#ifndef GRAPH_SUBGRAPH_H
+#define GRAPH_SUBGRAPH_H
+
+#include <QMap>
+#include <QTextStream>
+
+#include "graphelement.h"
+
+class Agraph_t;
+
+namespace KGraphViewer
+{
+
+class CanvasSubgraph;
+class GraphSubgraph;
+
+typedef QMap<QString, GraphSubgraph*> GraphSubgraphMap;
+
+
+/**
+ * Colors and styles are dot names
+ */
+class GraphSubgraph : public GraphElement
+{
+  Q_OBJECT
+
+public:
+  GraphSubgraph();
+  explicit GraphSubgraph(Agraph_t* sg);
+  
+  virtual ~GraphSubgraph() {}  
+
+  inline const GraphSubgraphMap& subgraphs() const {return m_subgraphsMap;}
+  inline GraphSubgraphMap& subgraphs() {return m_subgraphsMap;}
+  
+  void updateWithSubgraph(const GraphSubgraph& subgraph);
+  void updateWithSubgraph(Agraph_t* subgraph);
+  
+  CanvasSubgraph* canvasSubgraph() { return (CanvasSubgraph*)canvasElement();  }
+  void setCanvasSubgraph(CanvasSubgraph* cs) { setCanvasElement((CanvasElement*)cs); }
+
+  virtual QString backColor() const;
+
+  inline const QList<GraphElement*>& content() const {return m_content;}
+  inline QList<GraphElement*>& content() {return m_content;}
+  inline void setContent(QList<GraphElement*>& c) {m_content=c;}
+
+  void removeElement(GraphElement* element);
+
+  /// Recursively walk through this subgraph and its subsubgraphs to find an element named id
+  /// @return the node found or 0 if there is no such node
+  GraphElement* elementNamed(const QString& id);
+
+
+  /// Recursively walk through this subgraph and its subsubgraphs to make
+  /// the given element selected or not depending on the selectValue parameter
+  /// and unselect other elements depending on the  unselect others parameter
+  /// @return true if the given node was found
+  virtual bool setElementSelected(
+      GraphElement* element,
+      bool selectValue,
+      bool unselectOthers);
+
+  void retrieveSelectedElementsIds(QList<QString> selection);
+  
+ private:
+  QList<GraphElement*> m_content;
+  GraphSubgraphMap m_subgraphsMap;
+};
+
+QTextStream& operator<<(QTextStream& stream, const GraphSubgraph& s);
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/pannerview.cpp b/src/kgraphviz/pannerview.cpp
new file mode 100644
index 0000000..de7b1a2
--- /dev/null
+++ b/src/kgraphviz/pannerview.cpp
@@ -0,0 +1,194 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.cpp, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+/*
+ * Callgraph View
+ */
+
+#include "pannerview.h"
+
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+
+#include <QGraphicsScene>
+#include <QPainter>
+#include <QMouseEvent>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "dotgraphview.h"
+
+namespace KGraphViewer
+{
+//
+// PannerView
+//
+PannerView::PannerView(DotGraphView * parent, const char * name)
+  : QGraphicsView(parent), m_drawContents(true), m_parent(parent)
+{
+  m_movingZoomRect = false;
+
+  // why doesn't this avoid flicker ?
+  // viewport()->setBackgroundMode(Qt::NoBackground);
+  setBackgroundMode(Qt::NoBackground);
+
+  // if there are ever graphic glitches to be found, remove this again
+  setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter |
+                        QGraphicsView::DontSavePainterState);
+
+  setToolTip(i18n("View of the complete graph. Click and drag to move the visible part."));
+  setWhatsThis(i18n("<h1>View of the Complete Graph</h1>"
+    "<p>Single clicking somewhere without the red square will move the center of the "
+    "view to where the mouse was clicked.</p><p>Clicking and dragging within the red square "
+    "will cause the view to follow the movement.</p>"));
+}
+
+void PannerView::setZoomRect(QRectF r)
+{
+//   kDebug() << "PannerView::setZoomRect " << r;
+  if (r == m_zoomRect) {
+    return;
+  }
+  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
+  // get new zoom rect
+  m_zoomRect = r;
+  qreal q = mapToScene(15,0).x();
+  qreal d = mapToScene(10,0).x();
+  if (!m_zoomRect.isValid() || m_zoomRect.width() < q || m_zoomRect.height() < q) 
+  {
+    double factor = ((double)m_zoomRect.width())/m_zoomRect.height();
+    qreal newWidth, newHeight;
+    if (factor > 1.0)
+    {
+      newWidth = q;
+      newHeight = newWidth/factor;
+      if (newHeight < d) newHeight = d;
+    }
+    else
+    {
+      newHeight = q;
+      newWidth = newHeight*factor;
+      if (newWidth < d) newWidth = d;
+    }
+    QRectF newRect = m_zoomRect;
+    qreal newXPos = newRect.x() + (newRect.width()/2) - newWidth/2;
+    newXPos = (newXPos<0)?0:newXPos;
+    newRect.setX(newXPos);
+    qreal newYPos = newRect.y() + (newRect.height()/2) -newHeight/2;
+    newYPos = (newYPos<0)?0:newYPos;
+    newRect.setY(newYPos);
+    newRect.setWidth(newWidth);
+    newRect.setHeight(newHeight);
+    m_zoomRect = newRect;
+  }
+  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
+}
+
+void PannerView::moveZoomRectTo(const QPointF& newPos, bool notify)
+{
+  if (!m_zoomRect.isValid()) {
+    return;
+  }
+
+  if (m_zoomRect.center() == newPos) {
+    kDebug() << "same pos, don't do anything";
+    return;
+  }
+
+  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
+  m_zoomRect.moveCenter(newPos);
+  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
+
+  if (m_zoomRect.isValid() && notify) {
+    emit zoomRectMovedTo(newPos);
+    m_lastPos = newPos;
+  }
+}
+
+void PannerView::drawForeground(QPainter * p, const QRectF & rect )
+{
+  if (m_zoomRect.isValid() && rect.intersects(m_zoomRect))
+  {
+    p->save();
+    if (m_zoomRect.width() > 10 && m_zoomRect.height() > 10)
+    {
+      p->setPen(Qt::red);
+      // substract pen width, i.e. draw inside
+      qreal penWidth = p->pen().widthF();
+      p->drawRect(m_zoomRect.adjusted(-penWidth, -penWidth, -penWidth, -penWidth));
+    }
+    else
+    {
+      QBrush brush(Qt::red);
+      p->fillRect(m_zoomRect, brush);
+    }
+    p->restore();
+  }
+}
+
+void PannerView::mousePressEvent(QMouseEvent* e)
+{
+  if (e->button() != Qt::LeftButton) {
+    return;
+  }
+/*  kDebug() << "PannerView::mousePressEvent " 
+              << mapToScene(e->pos()) << " / " << m_zoomRect << " / " << m_zoomRect.center() <<endl;*/
+  moveZoomRectTo(mapToScene(e->pos()));
+  m_movingZoomRect = true;
+}
+
+void PannerView::mouseMoveEvent(QMouseEvent* e)
+{
+  if (!m_movingZoomRect) {
+    return;
+  }
+
+//   kDebug() << "PannerView::mouseMoveEvent " << pos;
+  moveZoomRectTo(mapToScene(e->pos()));
+}
+
+void PannerView::mouseReleaseEvent(QMouseEvent* e)
+{
+  if (e->button() != Qt::LeftButton) {
+    return;
+  }
+  moveZoomRectTo(mapToScene(e->pos()));
+//   kDebug() << "PannerView::mouseReleaseEvent " << pos;
+  m_movingZoomRect = false;
+  emit zoomRectMoveFinished();
+}
+
+void PannerView::contextMenuEvent(QContextMenuEvent* event)
+{
+  m_parent->contextMenuEvent(event);
+}
+
+}
+
+#include "pannerview.moc"
diff --git a/src/kgraphviz/pannerview.h b/src/kgraphviz/pannerview.h
new file mode 100644
index 0000000..c55a703
--- /dev/null
+++ b/src/kgraphviz/pannerview.h
@@ -0,0 +1,84 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/* This file was callgraphview.h, part of KCachegrind.
+   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
+
+   KCachegrind is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+*/
+
+
+/*
+ * Callgraph View
+ */
+
+#ifndef PANNER_VIEW_H
+#define PANNER_VIEW_H
+
+#include <QGraphicsView>
+#include <QWidget>
+//Added by qt3to4:
+#include <QMouseEvent>
+
+namespace KGraphViewer
+{
+
+class DotGraphView;
+
+/**
+ * A panner layed over a QCanvas
+ */
+class PannerView: public QGraphicsView
+{
+  Q_OBJECT
+
+public:
+  explicit PannerView(DotGraphView * parent, const char * name = 0);
+
+  inline void setDrawingEnabled(bool val) {m_drawContents = val;}
+
+public slots:
+  void setZoomRect(QRectF r);
+  void moveZoomRectTo(const QPointF& newPos, const bool notify = true);
+
+signals:
+  void zoomRectMovedTo(QPointF newPos);
+  void zoomRectMoveFinished();
+
+protected:
+  virtual void mousePressEvent(QMouseEvent*);
+  virtual void mouseMoveEvent(QMouseEvent*);
+  virtual void mouseReleaseEvent(QMouseEvent*);
+  virtual void drawForeground(QPainter * p, const QRectF & rect );
+  virtual void contextMenuEvent(QContextMenuEvent* event);
+
+  QRectF m_zoomRect;
+  bool m_movingZoomRect;
+  QPointF m_lastPos;
+  bool m_drawContents;
+  DotGraphView* m_parent;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/support/DotGraphParsingHelper.cpp b/src/kgraphviz/support/DotGraphParsingHelper.cpp
new file mode 100644
index 0000000..0be9e81
--- /dev/null
+++ b/src/kgraphviz/support/DotGraphParsingHelper.cpp
@@ -0,0 +1,344 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+
+#include "DotGraphParsingHelper.h"
+#include "dotgraph.h"
+#include "dotgrammar.h"
+#include "dotdefaults.h"
+//#include "graphsubgraph.h"
+#include "graphnode.h"
+#include "graphedge.h"
+
+#include <boost/throw_exception.hpp>
+#include <boost/spirit/core.hpp>
+#include <boost/spirit/utility/distinct.hpp>
+#include <boost/spirit/utility/loops.hpp>
+#include <boost/spirit/utility/confix.hpp>
+
+
+#include <iostream>
+
+#include <kdebug.h>
+    
+#include <QFile>
+#include<QUuid>
+
+using namespace std;
+
+extern KGraphViewer::DotGraphParsingHelper* phelper;
+
+namespace KGraphViewer
+{
+#define KGV_MAX_ITEMS_TO_LOAD std::numeric_limits<int>::max()
+
+DotGraphParsingHelper::DotGraphParsingHelper():
+  attrid(),
+  valid(),
+  attributed(),
+  subgraphid(),
+  uniq(0),
+  attributes(),
+  graphAttributes(),
+  nodesAttributes(),
+  edgesAttributes(),
+  graphAttributesStack(),
+  nodesAttributesStack(),
+  edgesAttributesStack(),
+  edgebounds(),
+  z(0),
+  maxZ(0),
+  graph(0),
+  gs(0),
+  gn(0),
+  ge(0)
+{
+}
+
+void DotGraphParsingHelper::setgraphelementattributes(GraphElement* ge, const AttributesMap& attributes)
+{
+  AttributesMap::const_iterator it, it_end;
+  it = attributes.begin(); it_end = attributes.end();
+  for (; it != it_end; it++)
+  {
+//     kDebug() << "    " << QString::fromStdString((*it).first) << "\t=\t'" << QString::fromStdString((*it).second) <<"'";
+    if ((*it).first=="label")
+    {
+      QString label = QString::fromUtf8((*it).second.c_str());
+      label.replace("\\n","\n");
+      (*ge).attributes()["label"] = label;
+    }
+    else
+    {
+      (*ge).attributes()[QString::fromStdString((*it).first)] =
+      QString::fromStdString((*it).second);
+    }
+  }
+  
+  if (attributes.find("_draw_") != attributes.end())
+  {
+    parse_renderop((attributes.find("_draw_"))->second, ge->renderOperations());
+//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
+  }
+  if (attributes.find("_ldraw_") != attributes.end())
+  {
+    parse_renderop(attributes.find("_ldraw_")->second, ge->renderOperations());
+//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
+  }
+  if (attributes.find("_hldraw_") != attributes.end())
+  {
+    parse_renderop(attributes.find("_hldraw_")->second, ge->renderOperations());
+//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
+  }
+  if (attributes.find("_tldraw_") != attributes.end())
+  {
+    parse_renderop(attributes.find("_tldraw_")->second, ge->renderOperations());
+//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
+  }
+}
+
+void DotGraphParsingHelper::setgraphattributes()
+{
+//   kDebug() << "Attributes for graph are : ";
+  setgraphelementattributes(graph, graphAttributes);
+}
+
+void DotGraphParsingHelper::setsubgraphattributes()
+{
+//   kDebug() << "Attributes for subgraph are : ";
+  gs->setZ(z);
+//   kDebug() << "z="<<gs->z();
+  setgraphelementattributes(gs, graphAttributes);
+}
+
+void DotGraphParsingHelper::setnodeattributes()
+{
+//   kDebug() << "setnodeattributes with z = " << z;
+  
+  if (gn == 0)
+  {
+//     kDebug() << "gn is null";
+    return;
+  }
+//   kDebug() << "Attributes for node " << gn->id() << " are : ";
+  gn->setZ(z+1);
+//   kDebug() << "z="<<gn->z();
+  setgraphelementattributes(gn, nodesAttributes);
+}
+
+void DotGraphParsingHelper::setedgeattributes()
+{
+//   kDebug() << "setedgeattributeswith z = " << z;
+  
+//   kDebug() << "Attributes for edge " << ge->fromNode()->id() << "->" << ge->toNode()->id() << " are : ";
+  ge->setZ(z+1);
+//   kDebug() << "z="<<ge->z();
+  setgraphelementattributes(ge, edgesAttributes);
+  
+  if (edgesAttributes.find("_tdraw_") != edgesAttributes.end())
+  {
+    parse_renderop(edgesAttributes["_tdraw_"], ge->renderOperations());
+//     kDebug() << "edge renderOperations size is now " << ge->renderOperations().size();
+    DotRenderOpVec::const_iterator it, it_end;
+    it = ge->renderOperations().constBegin(); it_end = ge->renderOperations().constEnd();
+    for (; it != it_end; it++)
+      ge->arrowheads().push_back(*it);
+  }
+  if (edgesAttributes.find("_hdraw_") != edgesAttributes.end())
+  {
+    parse_renderop(edgesAttributes["_hdraw_"], ge->renderOperations());
+//     kDebug() << "edge renderOperations size is now " << ge->renderOperations().size();
+    DotRenderOpVec::const_iterator it, it_end;
+    it = ge->renderOperations().constBegin(); it_end = ge->renderOperations().constEnd();
+    for (; it != it_end; it++)
+      ge->arrowheads().push_back(*it);
+  }
+}
+
+void DotGraphParsingHelper::setattributedlist()
+{
+// //   kDebug() << "Setting attributes list for " << QString::fromStdString(attributed);
+  if (attributed == "graph")
+  {
+    if (attributes.find("bb") != attributes.end())
+    {
+      std::vector< int > v;
+      parse_integers(attributes["bb"].c_str(), v);
+      if (v.size()>=4)
+      {
+//         kDebug() << "setting width and height to " << v[2] << v[3];
+        graph->width(v[2]);
+        graph->height(v[3]);
+      }
+    }
+    AttributesMap::const_iterator it, it_end;
+    it = attributes.begin(); it_end = attributes.end();
+    for (; it != it_end; it++)
+    {
+//       kDebug() << "    " << QString::fromStdString((*it).first) << " = " <<  QString::fromStdString((*it).second);
+      graphAttributes[(*it).first] = (*it).second;
+    }
+  }
+  else if (attributed == "node")
+  {
+    AttributesMap::const_iterator it, it_end;
+    it = attributes.begin(); it_end = attributes.end();
+    for (; it != it_end; it++)
+    {
+//       kDebug() << "    " << QString::fromStdString((*it).first) << " = " <<  QString::fromStdString((*it).second);
+      nodesAttributes[(*it).first] = (*it).second;
+    }
+  }
+  else if (attributed == "edge")
+  {
+    AttributesMap::const_iterator it, it_end;
+    it = attributes.begin(); it_end = attributes.end();
+    for (; it != it_end; it++)
+    {
+//       kDebug() << "    " << QString::fromStdString((*it).first) << " = " <<  QString::fromStdString((*it).second);
+      edgesAttributes[(*it).first] = (*it).second;
+    }
+  }
+  attributes.clear();
+}
+
+void DotGraphParsingHelper::createnode(const std::string& nodeid)
+{
+  QString id = QString::fromStdString(nodeid); 
+//   kDebug() << id;
+  gn = dynamic_cast<GraphNode*>(graph->elementNamed(id));
+  if (gn==0 && graph->nodes().size() < KGV_MAX_ITEMS_TO_LOAD)
+  {
+//     kDebug() << "Creating a new node" << z << (void*)gs;
+    gn = new GraphNode();
+    gn->setId(id);
+//     gn->label(QString::fromStdString(nodeid));
+    if (z>0 && gs != 0)
+    {
+//       kDebug() << "Adding node" << id << "in subgraph" << gs->id();
+      gs->content().push_back(gn);
+    }
+    else
+    {
+//       kDebug() << "Adding node" << id;
+      graph->nodes()[id] = gn;
+    }
+  }
+  edgebounds.clear();
+}
+
+void DotGraphParsingHelper::createsubgraph()
+{
+//   kDebug() ;
+  if (phelper)
+  {
+    std::string str = phelper->subgraphid;
+    if (str.empty())
+    {
+      std::ostringstream oss;
+      oss << "kgv_id_" << phelper->uniq++;
+      str = oss.str();
+    }
+//     kDebug() << QString::fromStdString(str);
+    if (graph->subgraphs().find(QString::fromStdString(str)) == graph->subgraphs().end())
+    {
+//       kDebug() << "Creating a new subgraph";
+      gs = new GraphSubgraph();
+      gs->setId(QString::fromStdString(str));
+//       gs->label(QString::fromStdString(str)); 
+      graph->subgraphs().insert(QString::fromStdString(str), gs);
+//       kDebug() << "there is now"<<graph->subgraphs().size()<<"subgraphs in" << graph;
+    }
+    else
+    {
+//       kDebug() << "Found existing subgraph";
+      gs = *(graph->subgraphs().find(QString::fromStdString(str)));
+    }
+    phelper->subgraphid = "";
+  }
+}
+
+void DotGraphParsingHelper::createedges()
+{
+//   kDebug();
+  std::string node1Name, node2Name;
+  node1Name = edgebounds.front();
+  edgebounds.pop_front();
+  while (!edgebounds.empty())
+  {
+    node2Name = edgebounds.front();
+    edgebounds.pop_front();
+
+    if (graph->nodes().size() >= KGV_MAX_ITEMS_TO_LOAD || graph->edges().size() >= KGV_MAX_ITEMS_TO_LOAD)
+    {
+      return;
+    }
+//     kDebug() << QString::fromStdString(node1Name) << ", " << QString::fromStdString(node2Name);
+    ge = new GraphEdge();
+    GraphElement* gn1 = graph->elementNamed(QString::fromStdString(node1Name));
+    if (gn1 == 0)
+    {
+//       kDebug() << "new node 1";
+      gn1 = new GraphNode();
+      gn1->setId(QString::fromStdString(node1Name));
+      graph->nodes()[QString::fromStdString(node1Name)] = dynamic_cast<GraphNode*>(gn1);
+    }
+    GraphElement* gn2 = graph->elementNamed(QString::fromStdString(node2Name));
+    if (gn2 == 0)
+    {
+//       kDebug() << "new node 2";
+      gn2 = new GraphNode();
+      gn2->setId(QString::fromStdString(node2Name));
+      graph->nodes()[QString::fromStdString(node2Name)] = dynamic_cast<GraphNode*>(gn2);
+    }
+//     kDebug() << "Found gn1="<<gn1<<" and gn2=" << gn2;
+    if (gn1 == 0 || gn2 == 0)
+    {
+      kError() << "Unable to find or create edge bound(s) gn1=" << gn1 << "; gn2=" << gn2;
+    }
+    ge->setFromNode(gn1);
+    ge->setToNode(gn2);
+//     kDebug() << ge->fromNode()->id() << " -> " << ge->toNode()->id();
+    setedgeattributes();
+//     kDebug() << ge->id();
+    if (ge->id().isEmpty())
+    {
+      ge->setId(QString::fromStdString(node1Name)+QString::fromStdString(node2Name)+QUuid::createUuid().toString().remove('{').remove('}').remove('-'));
+    }
+//     kDebug() << ge->id();
+//     kDebug() << "num before=" << graph->edges().size();
+    graph->edges().insert(ge->id(), ge);
+//     kDebug() << "num after=" << graph->edges().size();
+
+
+    node1Name = node2Name;
+  }
+  edgebounds.clear();
+}
+
+void DotGraphParsingHelper::finalactions()
+{
+  GraphEdgeMap::iterator it, it_end;
+  it = graph->edges().begin(); it_end = graph->edges().end();
+  for (; it != it_end; it++)
+  {
+    (*it)->setZ(maxZ+1);
+  }
+}
+
+}
diff --git a/src/kgraphviz/support/DotGraphParsingHelper.h b/src/kgraphviz/support/DotGraphParsingHelper.h
new file mode 100644
index 0000000..465bcf1
--- /dev/null
+++ b/src/kgraphviz/support/DotGraphParsingHelper.h
@@ -0,0 +1,84 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#ifndef DOT_GRAPHPARSINGHELPER_H
+#define DOT_GRAPHPARSINGHELPER_H
+
+#include <map>
+#include <list>
+#include <string>
+
+namespace KGraphViewer
+{
+class DotGraph;
+class GraphSubgraph;
+class GraphNode;
+class GraphEdge;
+class GraphElement;
+
+struct DotGraphParsingHelper
+{
+  typedef std::map< std::string, std::string > AttributesMap;
+
+  DotGraphParsingHelper();
+
+  void createnode(const std::string& nodeid);
+  void createsubgraph();
+  void setgraphattributes();
+  void setsubgraphattributes();
+      void setnodeattributes();
+  void setedgeattributes();
+  void setattributedlist();
+  void createedges();
+  void edgebound(const std::string& bound) {edgebounds.push_back(bound);}
+  void finalactions();
+  void setgraphelementattributes(GraphElement* ge, const AttributesMap& attributes);
+
+  std::string attrid;
+  std::string valid;
+  std::string attributed;
+  std::string subgraphid;
+  
+  unsigned int uniq;
+  
+  AttributesMap attributes;
+  AttributesMap graphAttributes;
+  AttributesMap nodesAttributes;
+  AttributesMap edgesAttributes;
+  std::list< AttributesMap > graphAttributesStack;
+  std::list< AttributesMap > nodesAttributesStack;
+  std::list< AttributesMap > edgesAttributesStack;
+  
+  std::list< std::string > edgebounds;
+  
+  unsigned int z;
+  unsigned int maxZ;
+  
+  DotGraph* graph;
+  
+  GraphSubgraph* gs;
+  GraphNode* gn;
+  GraphEdge* ge;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/kgraphviz/support/FontsCache.cpp b/src/kgraphviz/support/FontsCache.cpp
new file mode 100644
index 0000000..d60078d
--- /dev/null
+++ b/src/kgraphviz/support/FontsCache.cpp
@@ -0,0 +1,51 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+
+#include "FontsCache.h"
+
+#include "dot2qtconsts.h"
+
+FontsCache::~FontsCache()
+{
+  FontsCache::iterator it, it_end;
+  it = begin(); it_end = end();
+  for (; it != it_end; it++)
+  {
+    delete (*it);
+  }
+}
+
+QFont* FontsCache::cachedFont(const QFont& font)
+{
+  if (find(font.key()) == end())
+  {
+    (*this)[font.key()] = new QFont(font);
+  }
+  return (*this)[font.key()];
+}
+
+QFont* FontsCache::fromName(const QString& fontName)
+{
+  if (m_namesToFonts.find(fontName) == m_namesToFonts.end())
+  {
+    QFont font(Dot2QtConsts::componentData().qtFont(fontName));
+    m_namesToFonts[fontName] = cachedFont(font);
+  }
+  return m_namesToFonts[fontName];
+}
diff --git a/src/kgraphviz/support/FontsCache.h b/src/kgraphviz/support/FontsCache.h
new file mode 100644
index 0000000..41af3b9
--- /dev/null
+++ b/src/kgraphviz/support/FontsCache.h
@@ -0,0 +1,53 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+
+#ifndef KGRAPHVIEWER_FONTSCACHE_H
+#define KGRAPHVIEWER_FONTSCACHE_H
+
+#include "Singleton.h"
+
+#include <qfont.h>
+#include <qmap.h>
+#include <qstring.h>
+
+/**
+ * This is a map of fonts used in KgraphViewer
+ *
+ * @short A fonts map
+ * @author Gaël de Chalendar <kleag at free.fr>
+ */
+class FontsCache : 
+  public Singleton<FontsCache>,
+  public QMap<QString, QFont*>
+{
+friend class Singleton<FontsCache>;
+
+public:
+  virtual ~FontsCache();
+
+  QFont* cachedFont(const QFont& font);
+  QFont* fromName(const QString& font);
+
+private:
+  FontsCache() {}
+
+  QMap<QString, QFont*> m_namesToFonts;
+};
+
+#endif
diff --git a/src/kgraphviz/support/dot2qtconsts.cpp b/src/kgraphviz/support/dot2qtconsts.cpp
new file mode 100644
index 0000000..d1fba1f
--- /dev/null
+++ b/src/kgraphviz/support/dot2qtconsts.cpp
@@ -0,0 +1,939 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2007 by Gael de Chalendar (aka Kleag)  *
+ *   kleag at free.fr   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+ ***************************************************************************/
+#include "dot2qtconsts.h"
+#include "dotgrammar.h"
+#include "canvasnode.h"
+
+#include <kdebug.h> 
+#include <QColor>
+
+Dot2QtConsts* Dot2QtConsts::m_componentData = new Dot2QtConsts();
+
+static const struct {
+    const char * input;
+    const char * roman;
+    const char * italic;
+    const char * bold;
+    const char * boldItalic;
+    const char * light;
+    const char * lightItalic;
+} postscriptFontNames[] = {
+    { "arial", "Arial", 0, 0, 0, 0, 0 },
+    { "avantgarde", "AvantGarde-Book", 0, 0, 0, 0, 0 },
+    { "charter", "CharterBT-Roman", 0, 0, 0, 0, 0 },
+    { "garamond", "Garamond-Regular", 0, 0, 0, 0, 0 },
+    { "gillsans", "GillSans", 0, 0, 0, 0, 0 },
+    { "helvetica",
+      "Helvetica", "Helvetica-Oblique",
+      "Helvetica-Bold", "Helvetica-BoldOblique",
+      "Helvetica-Outline", "Helvetica-OutlineOblique" },
+    { "palatino",
+      "Palatino", "Palatino-Italic",
+      "Palatino-Bold", "Palatino-BoldItalic",
+      "Palatino", "Palatino-Italic" },
+    { "times",
+      "Times-Roman", "Times-Italic",
+      "Times-Bold", "Times-BoldItalic",
+      "Times-Outline", "Times-Italic" },
+    { "new century schoolbook", "NewCenturySchlbk-Roman", 0, 0, 0, 0, 0 },
+    { "symbol", "Symbol", "Symbol", "Symbol", "Symbol", "Symbol", "Symbol" },
+    { "terminal", "Courier", 0, 0, 0, 0, 0 },
+    { "times new roman", "TimesNewRoman", 0, 0, 0, 0, 0 },
+    { "utopia", "Utopia-Regular", 0, 0, 0, 0, 0 },
+    { 0, 0, 0, 0, 0, 0, 0 }
+};
+    
+static const struct {
+    const char * name;
+    unsigned int r;
+    unsigned int g;
+    unsigned int b;
+} color_lib[] = {
+    { "snow", 255, 250, 250 },
+    { "ghost white", 248, 248, 255 },
+    { "ghostwhite", 248, 248, 255 },
+    { "white smoke", 245, 245, 245 },
+    { "whitesmoke", 245, 245, 245 },
+    { "gainsboro", 220, 220, 220 },
+    { "floral white", 255, 250, 240 },
+    { "floralwhite", 255, 250, 240 },
+    { "old lace", 253, 245, 230 },
+    { "oldlace", 253, 245, 230 },
+    { "linen", 250, 240, 230 },
+    { "antique white", 250, 235, 215 },
+    { "antiquewhite", 250, 235, 215 },
+    { "papaya whip", 255, 239, 213 },
+    { "papayawhip", 255, 239, 213 },
+    { "blanched almond", 255, 235, 205 },
+    { "blanchedalmond", 255, 235, 205 },
+    { "bisque", 255, 228, 196 },
+    { "peach puff", 255, 218, 185 },
+    { "peachpuff", 255, 218, 185 },
+    { "navajo white", 255, 222, 173 },
+    { "navajowhite", 255, 222, 173 },
+    { "moccasin", 255, 228, 181 },
+    { "cornsilk", 255, 248, 220 },
+    { "ivory", 255, 255, 240 },
+    { "lemon chiffon", 255, 250, 205 },
+    { "lemonchiffon", 255, 250, 205 },
+    { "seashell", 255, 245, 238 },
+    { "honeydew", 240, 255, 240 },
+    { "mint cream", 245, 255, 250 },
+    { "mintcream", 245, 255, 250 },
+    { "azure", 240, 255, 255 },
+    { "alice blue", 240, 248, 255 },
+    { "aliceblue", 240, 248, 255 },
+    { "lavender", 230, 230, 250 },
+    { "lavender blush", 255, 240, 245 },
+    { "lavenderblush", 255, 240, 245 },
+    { "misty rose", 255, 228, 225 },
+    { "mistyrose", 255, 228, 225 },
+    { "white", 255, 255, 255 },
+    { "black", 0, 0, 0 },
+    { "dark slate gray", 47, 79, 79 },
+    { "darkslategray", 47, 79, 79 },
+    { "dark slate grey", 47, 79, 79 },
+    { "darkslategrey", 47, 79, 79 },
+    { "dim gray", 105, 105, 105 },
+    { "dimgray", 105, 105, 105 },
+    { "dim grey", 105, 105, 105 },
+    { "dimgrey", 105, 105, 105 },
+    { "slate gray", 112, 128, 144 },
+    { "slategray", 112, 128, 144 },
+    { "slate grey", 112, 128, 144 },
+    { "slategrey", 112, 128, 144 },
+    { "light slate gray", 119, 136, 153 },
+    { "lightslategray", 119, 136, 153 },
+    { "light slate grey", 119, 136, 153 },
+    { "lightslategrey", 119, 136, 153 },
+    { "gray", 190, 190, 190 },
+    { "grey", 190, 190, 190 },
+    { "light grey", 211, 211, 211 },
+    { "lightgrey", 211, 211, 211 },
+    { "light gray", 211, 211, 211 },
+    { "lightgray", 211, 211, 211 },
+    { "midnight blue", 25, 25, 112 },
+    { "midnightblue", 25, 25, 112 },
+    { "navy", 0, 0, 128 },
+    { "navy blue", 0, 0, 128 },
+    { "navyblue", 0, 0, 128 },
+    { "cornflower blue", 100, 149, 237 },
+    { "cornflowerblue", 100, 149, 237 },
+    { "dark slate blue", 72, 61, 139 },
+    { "darkslateblue", 72, 61, 139 },
+    { "slate blue", 106, 90, 205 },
+    { "slateblue", 106, 90, 205 },
+    { "medium slate blue", 123, 104, 238 },
+    { "mediumslateblue", 123, 104, 238 },
+    { "light slate blue", 132, 112, 255 },
+    { "lightslateblue", 132, 112, 255 },
+    { "medium blue", 0, 0, 205 },
+    { "mediumblue", 0, 0, 205 },
+    { "royal blue", 65, 105, 225 },
+    { "royalblue", 65, 105, 225 },
+    { "blue", 0, 0, 255 },
+    { "dodger blue", 30, 144, 255 },
+    { "dodgerblue", 30, 144, 255 },
+    { "deep sky blue", 0, 191, 255 },
+    { "deepskyblue", 0, 191, 255 },
+    { "sky blue", 135, 206, 235 },
+    { "skyblue", 135, 206, 235 },
+    { "light sky blue", 135, 206, 250 },
+    { "lightskyblue", 135, 206, 250 },
+    { "steel blue", 70, 130, 180 },
+    { "steelblue", 70, 130, 180 },
+    { "light steel blue", 176, 196, 222 },
+    { "lightsteelblue", 176, 196, 222 },
+    { "light blue", 173, 216, 230 },
+    { "lightblue", 173, 216, 230 },
+    { "powder blue", 176, 224, 230 },
+    { "powderblue", 176, 224, 230 },
+    { "pale turquoise", 175, 238, 238 },
+    { "paleturquoise", 175, 238, 238 },
+    { "dark turquoise", 0, 206, 209 },
+    { "darkturquoise", 0, 206, 209 },
+    { "medium turquoise", 72, 209, 204 },
+    { "mediumturquoise", 72, 209, 204 },
+    { "turquoise", 64, 224, 208 },
+    { "cyan", 0, 255, 255 },
+    { "light cyan", 224, 255, 255 },
+    { "lightcyan", 224, 255, 255 },
+    { "cadet blue", 95, 158, 160 },
+    { "cadetblue", 95, 158, 160 },
+    { "medium aquamarine", 102, 205, 170 },
+    { "mediumaquamarine", 102, 205, 170 },
+    { "aquamarine", 127, 255, 212 },
+    { "dark green", 0, 100, 0 },
+    { "darkgreen", 0, 100, 0 },
+    { "dark olive green", 85, 107, 47 },
+    { "darkolivegreen", 85, 107, 47 },
+    { "dark sea green", 143, 188, 143 },
+    { "darkseagreen", 143, 188, 143 },
+    { "sea green", 46, 139, 87 },
+    { "seagreen", 46, 139, 87 },
+    { "medium sea green", 60, 179, 113 },
+    { "mediumseagreen", 60, 179, 113 },
+    { "light sea green", 32, 178, 170 },
+    { "lightseagreen", 32, 178, 170 },
+    { "pale green", 152, 251, 152 },
+    { "palegreen", 152, 251, 152 },
+    { "spring green", 0, 255, 127 },
+    { "springgreen", 0, 255, 127 },
+    { "lawn green", 124, 252, 0 },
+    { "lawngreen", 124, 252, 0 },
+    { "green", 0, 255, 0 },
+    { "chartreuse", 127, 255, 0 },
+    { "medium spring green", 0, 250, 154 },
+    { "mediumspringgreen", 0, 250, 154 },
+    { "green yellow", 173, 255, 47 },
+    { "greenyellow", 173, 255, 47 },
+    { "lime green", 50, 205, 50 },
+    { "limegreen", 50, 205, 50 },
+    { "yellow green", 154, 205, 50 },
+    { "yellowgreen", 154, 205, 50 },
+    { "forest green", 34, 139, 34 },
+    { "forestgreen", 34, 139, 34 },
+    { "olive drab", 107, 142, 35 },
+    { "olivedrab", 107, 142, 35 },
+    { "dark khaki", 189, 183, 107 },
+    { "darkkhaki", 189, 183, 107 },
+    { "khaki", 240, 230, 140 },
+    { "pale goldenrod", 238, 232, 170 },
+    { "palegoldenrod", 238, 232, 170 },
+    { "light goldenrod yellow", 250, 250, 210 },
+    { "lightgoldenrodyellow", 250, 250, 210 },
+    { "light yellow", 255, 255, 224 },
+    { "lightyellow", 255, 255, 224 },
+    { "yellow", 255, 255, 0 },
+    { "gold", 255, 215, 0 },
+    { "light goldenrod", 238, 221, 130 },
+    { "lightgoldenrod", 238, 221, 130 },
+    { "goldenrod", 218, 165, 32 },
+    { "dark goldenrod", 184, 134, 11 },
+    { "darkgoldenrod", 184, 134, 11 },
+    { "rosy brown", 188, 143, 143 },
+    { "rosybrown", 188, 143, 143 },
+    { "indian red", 205, 92, 92 },
+    { "indianred", 205, 92, 92 },
+    { "saddle brown", 139, 69, 19 },
+    { "saddlebrown", 139, 69, 19 },
+    { "sienna", 160, 82, 45 },
+    { "peru", 205, 133, 63 },
+    { "burlywood", 222, 184, 135 },
+    { "beige", 245, 245, 220 },
+    { "wheat", 245, 222, 179 },
+    { "sandy brown", 244, 164, 96 },
+    { "sandybrown", 244, 164, 96 },
+    { "tan", 210, 180, 140 },
+    { "chocolate", 210, 105, 30 },
+    { "firebrick", 178, 34, 34 },
+    { "brown", 165, 42, 42 },
+    { "dark salmon", 233, 150, 122 },
+    { "darksalmon", 233, 150, 122 },
+    { "salmon", 250, 128, 114 },
+    { "light salmon", 255, 160, 122 },
+    { "lightsalmon", 255, 160, 122 },
+    { "orange", 255, 165, 0 },
+    { "dark orange", 255, 140, 0 },
+    { "darkorange", 255, 140, 0 },
+    { "coral", 255, 127, 80 },
+    { "light coral", 240, 128, 128 },
+    { "lightcoral", 240, 128, 128 },
+    { "tomato", 255, 99, 71 },
+    { "orange red", 255, 69, 0 },
+    { "orangered", 255, 69, 0 },
+    { "red", 255, 0, 0 },
+    { "hot pink", 255, 105, 180 },
+    { "hotpink", 255, 105, 180 },
+    { "deep pink", 255, 20, 147 },
+    { "deeppink", 255, 20, 147 },
+    { "pink", 255, 192, 203 },
+    { "light pink", 255, 182, 193 },
+    { "lightpink", 255, 182, 193 },
+    { "pale violet red", 219, 112, 147 },
+    { "palevioletred", 219, 112, 147 },
+    { "maroon", 176, 48, 96 },
+    { "medium violet red", 199, 21, 133 },
+    { "mediumvioletred", 199, 21, 133 },
+    { "violet red", 208, 32, 144 },
+    { "violetred", 208, 32, 144 },
+    { "magenta", 255, 0, 255 },
+    { "violet", 238, 130, 238 },
+    { "plum", 221, 160, 221 },
+    { "orchid", 218, 112, 214 },
+    { "medium orchid", 186, 85, 211 },
+    { "mediumorchid", 186, 85, 211 },
+    { "dark orchid", 153, 50, 204 },
+    { "darkorchid", 153, 50, 204 },
+    { "dark violet", 148, 0, 211 },
+    { "darkviolet", 148, 0, 211 },
+    { "blue violet", 138, 43, 226 },
+    { "blueviolet", 138, 43, 226 },
+    { "purple", 160, 32, 240 },
+    { "medium purple", 147, 112, 219 },
+    { "mediumpurple", 147, 112, 219 },
+    { "thistle", 216, 191, 216 },
+    { "snow1", 255, 250, 250 },
+    { "snow2", 238, 233, 233 },
+    { "snow3", 205, 201, 201 },
+    { "snow4", 139, 137, 137 },
+    { "seashell1", 255, 245, 238 },
+    { "seashell2", 238, 229, 222 },
+    { "seashell3", 205, 197, 191 },
+    { "seashell4", 139, 134, 130 },
+    { "antiquewhite1", 255, 239, 219 },
+    { "antiquewhite2", 238, 223, 204 },
+    { "antiquewhite3", 205, 192, 176 },
+    { "antiquewhite4", 139, 131, 120 },
+    { "bisque1", 255, 228, 196 },
+    { "bisque2", 238, 213, 183 },
+    { "bisque3", 205, 183, 158 },
+    { "bisque4", 139, 125, 107 },
+    { "peachpuff1", 255, 218, 185 },
+    { "peachpuff2", 238, 203, 173 },
+    { "peachpuff3", 205, 175, 149 },
+    { "peachpuff4", 139, 119, 101 },
+    { "navajowhite1", 255, 222, 173 },
+    { "navajowhite2", 238, 207, 161 },
+    { "navajowhite3", 205, 179, 139 },
+    { "navajowhite4", 139, 121, 94 },
+    { "lemonchiffon1", 255, 250, 205 },
+    { "lemonchiffon2", 238, 233, 191 },
+    { "lemonchiffon3", 205, 201, 165 },
+    { "lemonchiffon4", 139, 137, 112 },
+    { "cornsilk1", 255, 248, 220 },
+    { "cornsilk2", 238, 232, 205 },
+    { "cornsilk3", 205, 200, 177 },
+    { "cornsilk4", 139, 136, 120 },
+    { "ivory1", 255, 255, 240 },
+    { "ivory2", 238, 238, 224 },
+    { "ivory3", 205, 205, 193 },
+    { "ivory4", 139, 139, 131 },
+    { "honeydew1", 240, 255, 240 },
+    { "honeydew2", 224, 238, 224 },
+    { "honeydew3", 193, 205, 193 },
+    { "honeydew4", 131, 139, 131 },
+    { "lavenderblush1", 255, 240, 245 },
+    { "lavenderblush2", 238, 224, 229 },
+    { "lavenderblush3", 205, 193, 197 },
+    { "lavenderblush4", 139, 131, 134 },
+    { "mistyrose1", 255, 228, 225 },
+    { "mistyrose2", 238, 213, 210 },
+    { "mistyrose3", 205, 183, 181 },
+    { "mistyrose4", 139, 125, 123 },
+    { "azure1", 240, 255, 255 },
+    { "azure2", 224, 238, 238 },
+    { "azure3", 193, 205, 205 },
+    { "azure4", 131, 139, 139 },
+    { "slateblue1", 131, 111, 255 },
+    { "slateblue2", 122, 103, 238 },
+    { "slateblue3", 105, 89, 205 },
+    { "slateblue4", 71, 60, 139 },
+    { "royalblue1", 72, 118, 255 },
+    { "royalblue2", 67, 110, 238 },
+    { "royalblue3", 58, 95, 205 },
+    { "royalblue4", 39, 64, 139 },
+    { "blue1", 0, 0, 255 },
+    { "blue2", 0, 0, 238 },
+    { "blue3", 0, 0, 205 },
+    { "blue4", 0, 0, 139 },
+    { "dodgerblue1", 30, 144, 255 },
+    { "dodgerblue2", 28, 134, 238 },
+    { "dodgerblue3", 24, 116, 205 },
+    { "dodgerblue4", 16, 78, 139 },
+    { "steelblue1", 99, 184, 255 },
+    { "steelblue2", 92, 172, 238 },
+    { "steelblue3", 79, 148, 205 },
+    { "steelblue4", 54, 100, 139 },
+    { "deepskyblue1", 0, 191, 255 },
+    { "deepskyblue2", 0, 178, 238 },
+    { "deepskyblue3", 0, 154, 205 },
+    { "deepskyblue4", 0, 104, 139 },
+    { "skyblue1", 135, 206, 255 },
+    { "skyblue2", 126, 192, 238 },
+    { "skyblue3", 108, 166, 205 },
+    { "skyblue4", 74, 112, 139 },
+    { "lightskyblue1", 176, 226, 255 },
+    { "lightskyblue2", 164, 211, 238 },
+    { "lightskyblue3", 141, 182, 205 },
+    { "lightskyblue4", 96, 123, 139 },
+    { "slategray1", 198, 226, 255 },
+    { "slategray2", 185, 211, 238 },
+    { "slategray3", 159, 182, 205 },
+    { "slategray4", 108, 123, 139 },
+    { "lightsteelblue1", 202, 225, 255 },
+    { "lightsteelblue2", 188, 210, 238 },
+    { "lightsteelblue3", 162, 181, 205 },
+    { "lightsteelblue4", 110, 123, 139 },
+    { "lightblue1", 191, 239, 255 },
+    { "lightblue2", 178, 223, 238 },
+    { "lightblue3", 154, 192, 205 },
+    { "lightblue4", 104, 131, 139 },
+    { "lightcyan1", 224, 255, 255 },
+    { "lightcyan2", 209, 238, 238 },
+    { "lightcyan3", 180, 205, 205 },
+    { "lightcyan4", 122, 139, 139 },
+    { "paleturquoise1", 187, 255, 255 },
+    { "paleturquoise2", 174, 238, 238 },
+    { "paleturquoise3", 150, 205, 205 },
+    { "paleturquoise4", 102, 139, 139 },
+    { "cadetblue1", 152, 245, 255 },
+    { "cadetblue2", 142, 229, 238 },
+    { "cadetblue3", 122, 197, 205 },
+    { "cadetblue4", 83, 134, 139 },
+    { "turquoise1", 0, 245, 255 },
+    { "turquoise2", 0, 229, 238 },
+    { "turquoise3", 0, 197, 205 },
+    { "turquoise4", 0, 134, 139 },
+    { "cyan1", 0, 255, 255 },
+    { "cyan2", 0, 238, 238 },
+    { "cyan3", 0, 205, 205 },
+    { "cyan4", 0, 139, 139 },
+    { "darkslategray1", 151, 255, 255 },
+    { "darkslategray2", 141, 238, 238 },
+    { "darkslategray3", 121, 205, 205 },
+    { "darkslategray4", 82, 139, 139 },
+    { "aquamarine1", 127, 255, 212 },
+    { "aquamarine2", 118, 238, 198 },
+    { "aquamarine3", 102, 205, 170 },
+    { "aquamarine4", 69, 139, 116 },
+    { "darkseagreen1", 193, 255, 193 },
+    { "darkseagreen2", 180, 238, 180 },
+    { "darkseagreen3", 155, 205, 155 },
+    { "darkseagreen4", 105, 139, 105 },
+    { "seagreen1", 84, 255, 159 },
+    { "seagreen2", 78, 238, 148 },
+    { "seagreen3", 67, 205, 128 },
+    { "seagreen4", 46, 139, 87 },
+    { "palegreen1", 154, 255, 154 },
+    { "palegreen2", 144, 238, 144 },
+    { "palegreen3", 124, 205, 124 },
+    { "palegreen4", 84, 139, 84 },
+    { "springgreen1", 0, 255, 127 },
+    { "springgreen2", 0, 238, 118 },
+    { "springgreen3", 0, 205, 102 },
+    { "springgreen4", 0, 139, 69 },
+    { "green1", 0, 255, 0 },
+    { "green2", 0, 238, 0 },
+    { "green3", 0, 205, 0 },
+    { "green4", 0, 139, 0 },
+    { "chartreuse1", 127, 255, 0 },
+    { "chartreuse2", 118, 238, 0 },
+    { "chartreuse3", 102, 205, 0 },
+    { "chartreuse4", 69, 139, 0 },
+    { "olivedrab1", 192, 255, 62 },
+    { "olivedrab2", 179, 238, 58 },
+    { "olivedrab3", 154, 205, 50 },
+    { "olivedrab4", 105, 139, 34 },
+    { "darkolivegreen1", 202, 255, 112 },
+    { "darkolivegreen2", 188, 238, 104 },
+    { "darkolivegreen3", 162, 205, 90 },
+    { "darkolivegreen4", 110, 139, 61 },
+    { "khaki1", 255, 246, 143 },
+    { "khaki2", 238, 230, 133 },
+    { "khaki3", 205, 198, 115 },
+    { "khaki4", 139, 134, 78 },
+    { "lightgoldenrod1", 255, 236, 139 },
+    { "lightgoldenrod2", 238, 220, 130 },
+    { "lightgoldenrod3", 205, 190, 112 },
+    { "lightgoldenrod4", 139, 129, 76 },
+    { "lightyellow1", 255, 255, 224 },
+    { "lightyellow2", 238, 238, 209 },
+    { "lightyellow3", 205, 205, 180 },
+    { "lightyellow4", 139, 139, 122 },
+    { "yellow1", 255, 255, 0 },
+    { "yellow2", 238, 238, 0 },
+    { "yellow3", 205, 205, 0 },
+    { "yellow4", 139, 139, 0 },
+    { "gold1", 255, 215, 0 },
+    { "gold2", 238, 201, 0 },
+    { "gold3", 205, 173, 0 },
+    { "gold4", 139, 117, 0 },
+    { "goldenrod1", 255, 193, 37 },
+    { "goldenrod2", 238, 180, 34 },
+    { "goldenrod3", 205, 155, 29 },
+    { "goldenrod4", 139, 105, 20 },
+    { "darkgoldenrod1", 255, 185, 15 },
+    { "darkgoldenrod2", 238, 173, 14 },
+    { "darkgoldenrod3", 205, 149, 12 },
+    { "darkgoldenrod4", 139, 101, 8 },
+    { "rosybrown1", 255, 193, 193 },
+    { "rosybrown2", 238, 180, 180 },
+    { "rosybrown3", 205, 155, 155 },
+    { "rosybrown4", 139, 105, 105 },
+    { "indianred1", 255, 106, 106 },
+    { "indianred2", 238, 99, 99 },
+    { "indianred3", 205, 85, 85 },
+    { "indianred4", 139, 58, 58 },
+    { "sienna1", 255, 130, 71 },
+    { "sienna2", 238, 121, 66 },
+    { "sienna3", 205, 104, 57 },
+    { "sienna4", 139, 71, 38 },
+    { "burlywood1", 255, 211, 155 },
+    { "burlywood2", 238, 197, 145 },
+    { "burlywood3", 205, 170, 125 },
+    { "burlywood4", 139, 115, 85 },
+    { "wheat1", 255, 231, 186 },
+    { "wheat2", 238, 216, 174 },
+    { "wheat3", 205, 186, 150 },
+    { "wheat4", 139, 126, 102 },
+    { "tan1", 255, 165, 79 },
+    { "tan2", 238, 154, 73 },
+    { "tan3", 205, 133, 63 },
+    { "tan4", 139, 90, 43 },
+    { "chocolate1", 255, 127, 36 },
+    { "chocolate2", 238, 118, 33 },
+    { "chocolate3", 205, 102, 29 },
+    { "chocolate4", 139, 69, 19 },
+    { "firebrick1", 255, 48, 48 },
+    { "firebrick2", 238, 44, 44 },
+    { "firebrick3", 205, 38, 38 },
+    { "firebrick4", 139, 26, 26 },
+    { "brown1", 255, 64, 64 },
+    { "brown2", 238, 59, 59 },
+    { "brown3", 205, 51, 51 },
+    { "brown4", 139, 35, 35 },
+    { "salmon1", 255, 140, 105 },
+    { "salmon2", 238, 130, 98 },
+    { "salmon3", 205, 112, 84 },
+    { "salmon4", 139, 76, 57 },
+    { "lightsalmon1", 255, 160, 122 },
+    { "lightsalmon2", 238, 149, 114 },
+    { "lightsalmon3", 205, 129, 98 },
+    { "lightsalmon4", 139, 87, 66 },
+    { "orange1", 255, 165, 0 },
+    { "orange2", 238, 154, 0 },
+    { "orange3", 205, 133, 0 },
+    { "orange4", 139, 90, 0 },
+    { "darkorange1", 255, 127, 0 },
+    { "darkorange2", 238, 118, 0 },
+    { "darkorange3", 205, 102, 0 },
+    { "darkorange4", 139, 69, 0 },
+    { "coral1", 255, 114, 86 },
+    { "coral2", 238, 106, 80 },
+    { "coral3", 205, 91, 69 },
+    { "coral4", 139, 62, 47 },
+    { "tomato1", 255, 99, 71 },
+    { "tomato2", 238, 92, 66 },
+    { "tomato3", 205, 79, 57 },
+    { "tomato4", 139, 54, 38 },
+    { "orangered1", 255, 69, 0 },
+    { "orangered2", 238, 64, 0 },
+    { "orangered3", 205, 55, 0 },
+    { "orangered4", 139, 37, 0 },
+    { "red1", 255, 0, 0 },
+    { "red2", 238, 0, 0 },
+    { "red3", 205, 0, 0 },
+    { "red4", 139, 0, 0 },
+    { "deeppink1", 255, 20, 147 },
+    { "deeppink2", 238, 18, 137 },
+    { "deeppink3", 205, 16, 118 },
+    { "deeppink4", 139, 10, 80 },
+    { "hotpink1", 255, 110, 180 },
+    { "hotpink2", 238, 106, 167 },
+    { "hotpink3", 205, 96, 144 },
+    { "hotpink4", 139, 58, 98 },
+    { "pink1", 255, 181, 197 },
+    { "pink2", 238, 169, 184 },
+    { "pink3", 205, 145, 158 },
+    { "pink4", 139, 99, 108 },
+    { "lightpink1", 255, 174, 185 },
+    { "lightpink2", 238, 162, 173 },
+    { "lightpink3", 205, 140, 149 },
+    { "lightpink4", 139, 95, 101 },
+    { "palevioletred1", 255, 130, 171 },
+    { "palevioletred2", 238, 121, 159 },
+    { "palevioletred3", 205, 104, 137 },
+    { "palevioletred4", 139, 71, 93 },
+    { "maroon1", 255, 52, 179 },
+    { "maroon2", 238, 48, 167 },
+    { "maroon3", 205, 41, 144 },
+    { "maroon4", 139, 28, 98 },
+    { "violetred1", 255, 62, 150 },
+    { "violetred2", 238, 58, 140 },
+    { "violetred3", 205, 50, 120 },
+    { "violetred4", 139, 34, 82 },
+    { "magenta1", 255, 0, 255 },
+    { "magenta2", 238, 0, 238 },
+    { "magenta3", 205, 0, 205 },
+    { "magenta4", 139, 0, 139 },
+    { "orchid1", 255, 131, 250 },
+    { "orchid2", 238, 122, 233 },
+    { "orchid3", 205, 105, 201 },
+    { "orchid4", 139, 71, 137 },
+    { "plum1", 255, 187, 255 },
+    { "plum2", 238, 174, 238 },
+    { "plum3", 205, 150, 205 },
+    { "plum4", 139, 102, 139 },
+    { "mediumorchid1", 224, 102, 255 },
+    { "mediumorchid2", 209, 95, 238 },
+    { "mediumorchid3", 180, 82, 205 },
+    { "mediumorchid4", 122, 55, 139 },
+    { "darkorchid1", 191, 62, 255 },
+    { "darkorchid2", 178, 58, 238 },
+    { "darkorchid3", 154, 50, 205 },
+    { "darkorchid4", 104, 34, 139 },
+    { "purple1", 155, 48, 255 },
+    { "purple2", 145, 44, 238 },
+    { "purple3", 125, 38, 205 },
+    { "purple4", 85, 26, 139 },
+    { "mediumpurple1", 171, 130, 255 },
+    { "mediumpurple2", 159, 121, 238 },
+    { "mediumpurple3", 137, 104, 205 },
+    { "mediumpurple4", 93, 71, 139 },
+    { "thistle1", 255, 225, 255 },
+    { "thistle2", 238, 210, 238 },
+    { "thistle3", 205, 181, 205 },
+    { "thistle4", 139, 123, 139 },
+    { "gray0", 0, 0, 0 },
+    { "grey0", 0, 0, 0 },
+    { "gray1", 3, 3, 3 },
+    { "grey1", 3, 3, 3 },
+    { "gray2", 5, 5, 5 },
+    { "grey2", 5, 5, 5 },
+    { "gray3", 8, 8, 8 },
+    { "grey3", 8, 8, 8 },
+    { "gray4", 10, 10, 10 },
+    { "grey4", 10, 10, 10 },
+    { "gray5", 13, 13, 13 },
+    { "grey5", 13, 13, 13 },
+    { "gray6", 15, 15, 15 },
+    { "grey6", 15, 15, 15 },
+    { "gray7", 18, 18, 18 },
+    { "grey7", 18, 18, 18 },
+    { "gray8", 20, 20, 20 },
+    { "grey8", 20, 20, 20 },
+    { "gray9", 23, 23, 23 },
+    { "grey9", 23, 23, 23 },
+    { "gray10", 26, 26, 26 },
+    { "grey10", 26, 26, 26 },
+    { "gray11", 28, 28, 28 },
+    { "grey11", 28, 28, 28 },
+    { "gray12", 31, 31, 31 },
+    { "grey12", 31, 31, 31 },
+    { "gray13", 33, 33, 33 },
+    { "grey13", 33, 33, 33 },
+    { "gray14", 36, 36, 36 },
+    { "grey14", 36, 36, 36 },
+    { "gray15", 38, 38, 38 },
+    { "grey15", 38, 38, 38 },
+    { "gray16", 41, 41, 41 },
+    { "grey16", 41, 41, 41 },
+    { "gray17", 43, 43, 43 },
+    { "grey17", 43, 43, 43 },
+    { "gray18", 46, 46, 46 },
+    { "grey18", 46, 46, 46 },
+    { "gray19", 48, 48, 48 },
+    { "grey19", 48, 48, 48 },
+    { "gray20", 51, 51, 51 },
+    { "grey20", 51, 51, 51 },
+    { "gray21", 54, 54, 54 },
+    { "grey21", 54, 54, 54 },
+    { "gray22", 56, 56, 56 },
+    { "grey22", 56, 56, 56 },
+    { "gray23", 59, 59, 59 },
+    { "grey23", 59, 59, 59 },
+    { "gray24", 61, 61, 61 },
+    { "grey24", 61, 61, 61 },
+    { "gray25", 64, 64, 64 },
+    { "grey25", 64, 64, 64 },
+    { "gray26", 66, 66, 66 },
+    { "grey26", 66, 66, 66 },
+    { "gray27", 69, 69, 69 },
+    { "grey27", 69, 69, 69 },
+    { "gray28", 71, 71, 71 },
+    { "grey28", 71, 71, 71 },
+    { "gray29", 74, 74, 74 },
+    { "grey29", 74, 74, 74 },
+    { "gray30", 77, 77, 77 },
+    { "grey30", 77, 77, 77 },
+    { "gray31", 79, 79, 79 },
+    { "grey31", 79, 79, 79 },
+    { "gray32", 82, 82, 82 },
+    { "grey32", 82, 82, 82 },
+    { "gray33", 84, 84, 84 },
+    { "grey33", 84, 84, 84 },
+    { "gray34", 87, 87, 87 },
+    { "grey34", 87, 87, 87 },
+    { "gray35", 89, 89, 89 },
+    { "grey35", 89, 89, 89 },
+    { "gray36", 92, 92, 92 },
+    { "grey36", 92, 92, 92 },
+    { "gray37", 94, 94, 94 },
+    { "grey37", 94, 94, 94 },
+    { "gray38", 97, 97, 97 },
+    { "grey38", 97, 97, 97 },
+    { "gray39", 99, 99, 99 },
+    { "grey39", 99, 99, 99 },
+    { "gray40", 102, 102, 102 },
+    { "grey40", 102, 102, 102 },
+    { "gray41", 105, 105, 105 },
+    { "grey41", 105, 105, 105 },
+    { "gray42", 107, 107, 107 },
+    { "grey42", 107, 107, 107 },
+    { "gray43", 110, 110, 110 },
+    { "grey43", 110, 110, 110 },
+    { "gray44", 112, 112, 112 },
+    { "grey44", 112, 112, 112 },
+    { "gray45", 115, 115, 115 },
+    { "grey45", 115, 115, 115 },
+    { "gray46", 117, 117, 117 },
+    { "grey46", 117, 117, 117 },
+    { "gray47", 120, 120, 120 },
+    { "grey47", 120, 120, 120 },
+    { "gray48", 122, 122, 122 },
+    { "grey48", 122, 122, 122 },
+    { "gray49", 125, 125, 125 },
+    { "grey49", 125, 125, 125 },
+    { "gray50", 127, 127, 127 },
+    { "grey50", 127, 127, 127 },
+    { "gray51", 130, 130, 130 },
+    { "grey51", 130, 130, 130 },
+    { "gray52", 133, 133, 133 },
+    { "grey52", 133, 133, 133 },
+    { "gray53", 135, 135, 135 },
+    { "grey53", 135, 135, 135 },
+    { "gray54", 138, 138, 138 },
+    { "grey54", 138, 138, 138 },
+    { "gray55", 140, 140, 140 },
+    { "grey55", 140, 140, 140 },
+    { "gray56", 143, 143, 143 },
+    { "grey56", 143, 143, 143 },
+    { "gray57", 145, 145, 145 },
+    { "grey57", 145, 145, 145 },
+    { "gray58", 148, 148, 148 },
+    { "grey58", 148, 148, 148 },
+    { "gray59", 150, 150, 150 },
+    { "grey59", 150, 150, 150 },
+    { "gray60", 153, 153, 153 },
+    { "grey60", 153, 153, 153 },
+    { "gray61", 156, 156, 156 },
+    { "grey61", 156, 156, 156 },
+    { "gray62", 158, 158, 158 },
+    { "grey62", 158, 158, 158 },
+    { "gray63", 161, 161, 161 },
+    { "grey63", 161, 161, 161 },
+    { "gray64", 163, 163, 163 },
+    { "grey64", 163, 163, 163 },
+    { "gray65", 166, 166, 166 },
+    { "grey65", 166, 166, 166 },
+    { "gray66", 168, 168, 168 },
+    { "grey66", 168, 168, 168 },
+    { "gray67", 171, 171, 171 },
+    { "grey67", 171, 171, 171 },
+    { "gray68", 173, 173, 173 },
+    { "grey68", 173, 173, 173 },
+    { "gray69", 176, 176, 176 },
+    { "grey69", 176, 176, 176 },
+    { "gray70", 179, 179, 179 },
+    { "grey70", 179, 179, 179 },
+    { "gray71", 181, 181, 181 },
+    { "grey71", 181, 181, 181 },
+    { "gray72", 184, 184, 184 },
+    { "grey72", 184, 184, 184 },
+    { "gray73", 186, 186, 186 },
+    { "grey73", 186, 186, 186 },
+    { "gray74", 189, 189, 189 },
+    { "grey74", 189, 189, 189 },
+    { "gray75", 191, 191, 191 },
+    { "grey75", 191, 191, 191 },
+    { "gray76", 194, 194, 194 },
+    { "grey76", 194, 194, 194 },
+    { "gray77", 196, 196, 196 },
+    { "grey77", 196, 196, 196 },
+    { "gray78", 199, 199, 199 },
+    { "grey78", 199, 199, 199 },
+    { "gray79", 201, 201, 201 },
+    { "grey79", 201, 201, 201 },
+    { "gray80", 204, 204, 204 },
+    { "grey80", 204, 204, 204 },
+    { "gray81", 207, 207, 207 },
+    { "grey81", 207, 207, 207 },
+    { "gray82", 209, 209, 209 },
+    { "grey82", 209, 209, 209 },
+    { "gray83", 212, 212, 212 },
+    { "grey83", 212, 212, 212 },
+    { "gray84", 214, 214, 214 },
+    { "grey84", 214, 214, 214 },
+    { "gray85", 217, 217, 217 },
+    { "grey85", 217, 217, 217 },
+    { "gray86", 219, 219, 219 },
+    { "grey86", 219, 219, 219 },
+    { "gray87", 222, 222, 222 },
+    { "grey87", 222, 222, 222 },
+    { "gray88", 224, 224, 224 },
+    { "grey88", 224, 224, 224 },
+    { "gray89", 227, 227, 227 },
+    { "grey89", 227, 227, 227 },
+    { "gray90", 229, 229, 229 },
+    { "grey90", 229, 229, 229 },
+    { "gray91", 232, 232, 232 },
+    { "grey91", 232, 232, 232 },
+    { "gray92", 235, 235, 235 },
+    { "grey92", 235, 235, 235 },
+    { "gray93", 237, 237, 237 },
+    { "grey93", 237, 237, 237 },
+    { "gray94", 240, 240, 240 },
+    { "grey94", 240, 240, 240 },
+    { "gray95", 242, 242, 242 },
+    { "grey95", 242, 242, 242 },
+    { "gray96", 245, 245, 245 },
+    { "grey96", 245, 245, 245 },
+    { "gray97", 247, 247, 247 },
+    { "grey97", 247, 247, 247 },
+    { "gray98", 250, 250, 250 },
+    { "grey98", 250, 250, 250 },
+    { "gray99", 252, 252, 252 },
+    { "grey99", 252, 252, 252 },
+    { "gray100", 255, 255, 255 },
+    { "grey100", 255, 255, 255 },
+    { 0, 0, 0, 0 }
+};
+
+Dot2QtConsts::Dot2QtConsts()
+{
+  m_penStyles["solid"] = Qt::SolidLine;
+  m_penStyles["dashed"] = Qt::DashLine;
+  m_penStyles["dotted"] = Qt::DotLine;
+  m_penStyles["invis"] = Qt::NoPen;
+
+  m_colors["crimson"] = "#DC143C";
+  m_colors["hot_pink"] = "#FF69B4";
+  m_colors["light_yellow"] = "#FFFFE0";
+  m_colors["slate_blue"] = "#6A5ACD";
+
+  uint i = 0;
+  while (postscriptFontNames[i].input != 0)
+  {
+    QFont font(postscriptFontNames[i].input);
+    m_psFonts[postscriptFontNames[i].roman] = font;
+    if (postscriptFontNames[i].italic != 0)
+    {
+      QFont italic = font; italic.setItalic(true);
+      m_psFonts[postscriptFontNames[i].italic] = italic;
+    }
+    if (postscriptFontNames[i].bold != 0)
+    {
+      QFont bold = font; bold.setBold(true);
+      m_psFonts[postscriptFontNames[i].bold] = bold;
+    }
+    if (postscriptFontNames[i].boldItalic != 0)
+    {
+      QFont boldItalic = font; 
+      boldItalic.setItalic(true);
+      boldItalic.setBold(true);
+      m_psFonts[postscriptFontNames[i].boldItalic] = boldItalic;
+    }
+    if (postscriptFontNames[i].light != 0)
+    {
+      QFont light = font; light.setWeight(QFont::Light);
+      m_psFonts[postscriptFontNames[i].light] = light;
+    }
+    if (postscriptFontNames[i].lightItalic != 0)
+    {
+      QFont lightItalic = font; 
+      lightItalic.setWeight(QFont::Light);
+      lightItalic.setItalic(true);
+      m_psFonts[postscriptFontNames[i].lightItalic] = lightItalic;
+    }
+    i++;
+  }
+
+  uint j = 0;
+  while (color_lib[j].name != 0)
+  {
+//     kDebug() << "Adding color " << color_lib[j].name;
+    m_qcolors[color_lib[j].name] = QColor(color_lib[j].r,color_lib[j].g,color_lib[j].b);
+    j++;
+  }
+}
+
+
+Dot2QtConsts::~Dot2QtConsts()
+{}
+
+
+QColor Dot2QtConsts::qtColor(const QString& dotColor) const
+{
+//   kDebug() << "Dot2QtConsts::qtColor";
+  QColor color;
+  if (parse_numeric_color(dotColor.ascii(), color))
+  {
+    return color;
+  }
+  else
+  {
+    if (m_qcolors.find(dotColor) != m_qcolors.end())
+    {
+      return (*m_qcolors.find(dotColor));
+    }
+    QColor res(dotColor);
+    if (res.isValid())
+    {
+      return res;
+    }
+    else
+    {
+        if (m_colors.find(dotColor) != m_colors.end())
+        {
+            res = QColor((*m_colors.find(dotColor)));
+            if (res.isValid())
+            {
+                return res;
+            }
+            else
+            {
+                kWarning() << "Unknown stored dot color '" << dotColor << "'. returning Qt black";
+                return Qt::black;
+            }
+        }
+        else
+        {
+//           kWarning() << "Unknown dot color '" << dotColor << "'. returning Qt black";
+          return Qt::black;
+        }
+    }
+  }
+}
+
+Qt::PenStyle Dot2QtConsts::qtPenStyle(const QString& dotLineStyle) const
+{
+  if (m_penStyles.find(dotLineStyle) != m_penStyles.end())
+    return (*(m_penStyles.find(dotLineStyle)));
+  else 
+  {
+    if (!dotLineStyle.left(12).isEmpty()
+	&& dotLineStyle.left(12) != "setlinewidth")
+      kWarning() << "Unknown dot line style '" << dotLineStyle << "'. returning Qt solid line";
+    return Qt::SolidLine;
+  }
+}
+
+QFont Dot2QtConsts::qtFont(const QString& dotFont) const
+{
+  if (m_psFonts.find(dotFont) != m_psFonts.end())
+    return (*(m_psFonts.find(dotFont)));
+  else
+  {
+    qWarning() << "Unknown dot font '" << dotFont << "'. returning Qt default.";
+    return QFont(QFont::substitute(dotFont));
+  }
+}
+
diff --git a/src/kgraphviz/support/dot2qtconsts.h b/src/kgraphviz/support/dot2qtconsts.h
new file mode 100644
index 0000000..c2ec8a9
--- /dev/null
+++ b/src/kgraphviz/support/dot2qtconsts.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2007 by Gael de Chalendar   *
+ *   kleag at free.fr   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+ ***************************************************************************/
+#ifndef DOT2QTCONSTS_H
+#define DOT2QTCONSTS_H
+
+#include <QMap>
+#include <QString>
+#include <QFont>
+
+/**
+ at author Gael de Chalendar
+*/
+class Dot2QtConsts
+{
+public:
+  static Dot2QtConsts& changeable() {return *m_componentData;}
+  static const Dot2QtConsts& componentData() {return *m_componentData;}
+  
+  QColor qtColor(const QString& dotColor) const;
+  Qt::PenStyle qtPenStyle(const QString& dotLineStyle) const;
+  QFont qtFont(const QString& dotFont) const;
+
+private:
+    Dot2QtConsts();
+
+    ~Dot2QtConsts();
+
+  static Dot2QtConsts* m_componentData;
+  
+  QMap< QString, Qt::PenStyle > m_penStyles;
+  QMap< QString, QString > m_colors;
+  QMap< QString, QColor > m_qcolors;
+  QMap< QString, QFont > m_psFonts;
+  
+};
+
+#endif
diff --git a/src/kgraphviz/support/dotdefaults.h b/src/kgraphviz/support/dotdefaults.h
new file mode 100644
index 0000000..ec655f6
--- /dev/null
+++ b/src/kgraphviz/support/dotdefaults.h
@@ -0,0 +1,35 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#ifndef DOT_DEFAULTS_H
+#define DOT_DEFAULTS_H
+
+#define DOT_DEFAULT_DPI 72
+#define DOT_DEFAULT_FONTSIZE 11
+#define DOT_DEFAULT_FONTNAME "Sans"
+#define DOT_DEFAULT_FONTCOLOR "black"
+#define DOT_DEFAULT_EDGE_STYLE "solid"
+#define DOT_DEFAULT_EDGE_DIR "forward"
+#define DOT_DEFAULT_EDGE_COLOR "black"
+#define DOT_DEFAULT_STYLE "solid"
+#define DOT_DEFAULT_SHAPE "ellipse"
+#define DOT_DEFAULT_LINECOLOR "black"
+#define DOT_DEFAULT_NODE_BACKCOLOR "lightgrey"
+#define DOT_DEFAULT_BACKCOLOR "white"
+#endif
+
diff --git a/src/kgraphviz/support/dotgrammar.cpp b/src/kgraphviz/support/dotgrammar.cpp
new file mode 100644
index 0000000..9225238
--- /dev/null
+++ b/src/kgraphviz/support/dotgrammar.cpp
@@ -0,0 +1,540 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#include "dotgrammar.h"
+#include "dotgraph.h"
+#include "dotdefaults.h"
+#include "graphnode.h"
+#include "graphedge.h"
+#include "DotGraphParsingHelper.h"
+
+#include <iostream>
+
+#include <kdebug.h>
+
+#include <QFile>
+
+#include <boost/spirit/include/classic_core.hpp>
+#include <boost/spirit/include/classic_distinct.hpp>
+#include <boost/spirit/include/classic_loops.hpp>
+#include <boost/spirit/include/classic_confix.hpp>
+#include <boost/throw_exception.hpp>
+
+namespace boost
+{
+  void throw_exception(std::exception const &) {}
+}
+
+
+using namespace std;
+using namespace boost;
+using namespace boost::spirit::classic;
+
+using namespace KGraphViewer;
+
+#define KGV_MAX_ITEMS_TO_LOAD std::numeric_limits<size_t>::max()
+#define BOOST_SPIRIT_DEBUG 1
+
+DotGraphParsingHelper* phelper = 0;
+
+std::string therenderop;
+std::string thestr;
+
+void anychar(char const c);
+
+// keyword_p for C++
+// (for basic usage instead of std_p)
+const boost::spirit::classic::distinct_parser<> keyword_p("0-9a-zA-Z_");
+
+template <typename ScannerT>
+DotGrammar::definition<ScannerT>::definition(DotGrammar const& /*self*/)
+{
+  graph  = (!(keyword_p("strict")[&strict]) >> (keyword_p("graph")[&undigraph] | keyword_p("digraph")[&digraph])
+  >> !ID[&graphid] >> ch_p('{') >> !stmt_list >> ch_p('}'))[&finalactions];
+  ID = (
+  ( ( (anychar_p - punct_p) | '_' ) >> *( (anychar_p - punct_p) | '_' ) )
+  | real_p
+  | ( '"' >>  *( (ch_p('\\') >> '"') | (anychar_p - '"') ) >>  '"' )
+  | ( ch_p('<') >>  *( anychar_p  - '<' - '>' | tag ) >>  '>' )
+  );
+  tag = ('<' >> *( anychar_p  - '>') >> '>');
+  stmt_list  =  stmt >> !(ch_p(';')) >> !( stmt_list ) ;
+  stmt  =  (
+  attr_stmt
+  |  subgraph
+  |  edge_stmt
+  |  node_stmt
+  |  ( ID >> '=' >> ID )
+  );
+
+  attr_stmt  = (
+  (keyword_p("graph")[assign_a(phelper->attributed)] >> attr_list[&setattributedlist])[&setgraphattributes]
+  | (keyword_p("node")[assign_a(phelper->attributed)] >> attr_list[&setattributedlist])
+  | (keyword_p("edge")[assign_a(phelper->attributed)] >> attr_list[&setattributedlist])
+  ) ;
+
+  attr_list  = ch_p('[') >> !( a_list ) >> ch_p(']');
+  a_list  =  ((ID[&attrid] >> !( '=' >> ID[&valid] ))[&addattr] >> !(',' >> a_list ));
+  edge_stmt  =  ( (node_id[&edgebound] | subgraph) >>  edgeRHS >> !( attr_list[assign_a(phelper->attributed,"edge")] ) )[&pushAttrList][&setattributedlist][&createedges][&popAttrList];
+  edgeRHS  =  edgeop[&checkedgeop] >> (node_id[&edgebound] | subgraph) >> !( edgeRHS );
+  edgeop = str_p("->") | str_p("--");
+  node_stmt  = ( node_id[&createnode] >> !( attr_list ) )[assign_a(phelper->attributed,"node")][&pushAttrList][&setattributedlist][&setnodeattributes][&popAttrList];
+  node_id  =  (ID >> !( port ));
+  port  =  ( ch_p(':') >> ID >> !( ':' >> compass_pt ) )
+  |  ( ':' >> compass_pt );
+  subgraph  =  ( !( keyword_p("subgraph") >> !( ID[&subgraphid] ) ) >> ch_p('{')[&createsubgraph][&incrz][&pushAttrListC] >> stmt_list >> ch_p('}') [&decrz][&popAttrListC])
+  |  ( keyword_p("subgraph") >> ID[&subgraphid]);
+  compass_pt  =  (keyword_p("n") | keyword_p("ne") | keyword_p("e")
+  | keyword_p("se") | keyword_p("s") | keyword_p("sw")
+  | keyword_p("w") | keyword_p("nw") );
+}
+
+
+
+
+void incrz(char const /*first*/)
+{
+  if (phelper)
+  {
+    phelper->z++;
+    if (phelper->z > phelper->maxZ)
+    {
+      phelper->maxZ = phelper->z;
+    }
+  }
+}
+
+void anychar(char const c)
+{
+//   kDebug() << c;
+}
+
+void decrz(char const /*first*/)
+{
+  if (phelper)
+  {
+    phelper->z--;
+    phelper->gs = 0;
+  }
+}
+
+void dump(char const* first, char const* last)
+{
+  std::string str(first, last);
+  kError() << ">>>> " << QString::fromStdString(str) << " <<<<" << endl;
+}
+
+void strict(char const* /*first*/, char const* /*last*/)
+{
+  if (phelper) phelper->graph->strict(true);
+}
+
+void gotid(char const* first, char const* last)
+{
+  std::string id(first,last);
+//   kDebug() << "Got ID  = '"<<QString::fromStdString(phelper->attrid)<<"'";
+}
+
+void undigraph(char const* /*first*/, char const* /*last*/)
+{
+//   kDebug() << "Setting graph as undirected";
+  if (phelper) phelper->graph->directed(false);
+}
+
+void digraph(char const* /*first*/, char const* /*last*/)
+{
+//   kDebug() << "Setting graph as directed";
+  if (phelper) phelper->graph->directed(true);
+}
+
+void graphid(char const* first, char const* last)
+{
+//   kDebug() << QString::fromStdString(std::string(first,last));
+  if (phelper) phelper->graph->setId(QString::fromStdString(std::string(first,last)));
+}
+
+void attrid(char const* first, char const* last)
+{
+  if (phelper) 
+  {
+    std::string id(first,last);
+    if (id.size()>0 && id[0] == '"') id = id.substr(1);
+    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
+    phelper->attrid = id;
+    phelper->valid = "";
+//     kDebug() << "Got attr ID  = '"<<QString::fromStdString(phelper->attrid)<<"'";
+  }
+}
+
+void subgraphid(char const* first, char const* last)
+{
+  std::string id(first,last);
+//   kDebug() << QString::fromStdString(id);
+  if (phelper) 
+  {
+    if (id.size()>0 && id[0] == '"') id = id.substr(1);
+    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
+    phelper->subgraphid = id;
+//     kDebug() << "Got subgraph id = '"<<QString::fromStdString(phelper->subgraphid)<<"'";
+  }
+}
+
+void valid(char const* first, char const* last)
+{
+  std::string id(first,last);
+  if (phelper)
+  {
+    if (id.size()>0 && id[0] == '"') id = id.substr(1);
+    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
+    phelper->valid = id;
+//     kDebug() << "Got attr val = '"<<QString::fromStdString(id)<<"'";
+  }
+}
+
+void addattr(char const* /*first*/, char const* /*last*/)
+{
+  if (phelper) 
+  {
+    phelper->attributes.insert(std::make_pair(phelper->attrid,phelper->valid));
+  }
+}
+
+void pushAttrListC(char const /*c*/)
+{
+  pushAttrList(0,0);
+}
+
+void pushAttrList(char const* /*first*/, char const* /*last*/)
+{
+//   kDebug() << "Pushing attributes";
+  if (phelper)
+  {
+    phelper->graphAttributesStack.push_back(phelper->graphAttributes);
+    phelper->nodesAttributesStack.push_back(phelper->nodesAttributes);
+    phelper->edgesAttributesStack.push_back(phelper->edgesAttributes);
+  }
+}
+
+void popAttrListC(char const /*c*/)
+{
+  popAttrList(0,0);
+}
+
+void popAttrList(char const* /*first*/, char const* /*last*/)
+{
+//   kDebug() << "Poping attributes";
+  if (phelper) 
+  {
+    phelper->graphAttributes = phelper->graphAttributesStack.back();
+    phelper->graphAttributesStack.pop_back();
+    phelper->nodesAttributes = phelper->nodesAttributesStack.back();
+    phelper->nodesAttributesStack.pop_back();
+    phelper->edgesAttributes = phelper->edgesAttributesStack.back();
+    phelper->edgesAttributesStack.pop_back();
+  }
+//   kDebug() << "Poped";
+}
+
+void createnode(char const* first, char const* last)
+{
+//   kDebug() << (void*)first << (void*)last << QString::fromStdString(std::string(first,last));
+  if (phelper!=0 && first!=0 && last != 0) 
+  {
+    std::string id(first,last);
+    if (id.size()>0 && id[0] == '"') id = id.substr(1);
+    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
+    phelper->createnode(id);
+  }
+}
+
+void createsubgraph(char const /*c*/)
+{
+  if (phelper) 
+  {
+    phelper->createsubgraph();
+  }
+}
+
+void setgraphattributes(char const* /*first*/, char const* /*last*/)
+{
+//   kDebug() << "setgraphattributes with z = " << phelper->z;
+  if (phelper) 
+  {
+    if (phelper->z == 1) // main graph
+    {
+      phelper->setgraphattributes();
+    }
+    else
+    {
+      phelper->setsubgraphattributes();
+    }
+  }
+}
+
+void setnodeattributes(char const* /*first*/, char const* /*last*/)
+{
+//   kDebug() << "setnodeattributes with z = " << phelper->z;
+  if (phelper) 
+  {
+    phelper->setnodeattributes();
+  }
+}
+
+void setattributedlist(char const* /*first*/, char const* /*last*/)
+{
+  if (phelper) 
+  {
+    phelper->setattributedlist();
+  }
+}
+
+void checkedgeop(char const* first, char const* last)
+{
+  std::string str(first,last);
+  if (phelper) 
+  {
+    if ( ( (phelper->graph->directed()) && (str == "->") ) || 
+      ( (!phelper->graph->directed()) && (str == "--") ) )
+      return;
+    
+    kError() << "Error !! uncoherent relation : directed = '" << phelper->graph->directed() << "' and op = '" << QString::fromStdString(str) << "'" << endl;
+  }
+}
+
+void edgebound(char const* first, char const* last)
+{
+//   kDebug() << "edgebound: " << QString::fromStdString(std::string(first,last));
+  if (phelper) 
+  {
+    std::string id(first,last);
+    if (id.size()>0 && id[0] == '"') id = id.substr(1);
+    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
+    phelper->edgebound(id);
+  }
+}
+
+void createedges(char const* /*first*/, char const* /*last*/)
+{
+  if (phelper) 
+  {
+    phelper->createedges();
+  }
+}
+
+void finalactions(char const* /*first*/, char const* /*last*/)
+{
+  if (phelper) 
+  {
+    phelper->finalactions();
+  }
+}
+
+bool parse_point(char const* str, QPoint& p)
+{
+  int x,y;
+  bool res;
+  res = parse(str,
+              (
+                int_p[assign_a(x)] >> ',' >> int_p[assign_a(y)]
+              )
+              ,
+              +space_p).full;
+  if (!res) return false;
+  p = QPoint(x,y);
+  return true;
+}
+
+bool parse_numeric_color(char const* str, QColor& c)
+{
+  if (str==0) return false;
+  int r,g,b,a;
+  bool res;
+  uint_parser<unsigned, 16, 2, 2> hex2digits_p;
+  res = parse(str,
+              (
+                ch_p('#') >> 
+                hex2digits_p[assign_a(r)] >>  
+                hex2digits_p[assign_a(g)] >> 
+                hex2digits_p[assign_a(b)] >> 
+                !hex2digits_p[assign_a(a)]
+              )
+              ,
+              +space_p).full;
+  if (res)
+  {
+    c.setRgb(r,g,b);
+    return true;
+  }
+  
+  double h,s,v;
+  res = parse(str,
+              (
+                real_p[assign_a(h)] >> !ch_p(',') >> real_p[assign_a(s)] >> !ch_p(',') >> real_p[assign_a(v)]
+              )
+              ,
+              +space_p).full;
+  if (res)
+  {
+    c.setHsv(int(255*h),int(255*s),int(255*v));
+    return true;
+  }
+  return false;
+}
+
+bool parse_real(char const* str, double& d)
+{
+  return parse(str,
+               (
+                 real_p[assign_a(d)]
+               )
+               ,
+               +space_p).full;
+}
+
+bool parse_integers(char const* str, std::vector<int>& v)
+{
+  return parse(str,
+               (
+                 int_p[push_back_a(v)] >> *(',' >> int_p[push_back_a(v)])
+               )
+               ,
+               +space_p).full;
+}
+
+bool parse_spline(char const* str, QVector< QPair< float, float > >& points)
+{
+//   kDebug() << "Parsing spline..." << QString::fromStdString(str);
+  char e = 'n', s = 'n';
+  int sx,sy,ex,ey;
+  QPair< float, float > p;
+  bool res;
+  res = parse(str,
+              (
+                !(ch_p('e')[assign_a(e)] >> ',' >> int_p[assign_a(ex)] >> ',' >> int_p[assign_a(ey)]) 
+                >> !(ch_p('s')[assign_a(s)] >> ',' >> int_p[assign_a(sx)] >> ',' >> int_p[assign_a(sy)])
+                >> ((int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)]))[push_back_a(points,p)] 
+                >> +(
+                      (int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)])[push_back_a(points,p)] >> 
+                      (int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)])[push_back_a(points,p)] >> 
+                      (int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)])[push_back_a(points,p)]
+                    )
+              )
+              ,
+              +space_p).full;
+  if (!res) return false;
+  if (s == 's')
+  {
+//     kDebug() << "inserting the s point";
+    points.insert(points.begin(), qMakePair(float(sx),float(sy)));
+  }
+  if (e == 'e')
+  {
+//     points.insert(points.begin(), qMakePair(float(ex),float(ey)));
+  }
+  return true;
+}
+
+DotRenderOp renderop ;
+
+DotRenderOpVec* renderopvec = 0;
+
+void init_op()
+{
+  renderop = DotRenderOp();
+}
+
+void valid_op(char const* first, char const* last)
+{
+  std::string s(first, last);
+  renderop.renderop = QString::fromUtf8(therenderop.c_str());
+  renderop.str = QString::fromUtf8(thestr.c_str());
+
+//   kDebug() << "Validating render operation '"<<QString::fromStdString(s)<<"': '"<<renderop.renderop<<"/"<<renderop.str<<"'";
+  renderopvec->push_back(renderop);
+  renderop.renderop = "";
+  renderop.integers = QList<int>();
+  renderop.str = "";
+}
+
+bool parse_renderop(const std::string& str, DotRenderOpVec& arenderopvec)
+{
+//   kDebug() << QString::fromUtf8(str.c_str()) << str.size();
+  if (str.empty())
+  {
+    return false;
+  }
+  init_op();
+  renderopvec = &arenderopvec;
+  bool res;
+  int c;
+  res = parse(str.c_str(),
+              (
+                +(
+                   (
+                     (ch_p('E')|ch_p('e'))[assign_a(therenderop)] >> +space_p >>
+                     repeat_p(4)[int_p[push_back_a(renderop.integers)] >> +space_p]
+                   )[&valid_op] 
+                   | (
+                       (ch_p('P')|ch_p('p')|ch_p('L')|ch_p('B')|ch_p('b'))[assign_a(therenderop)] >> +space_p >>
+                       int_p[assign_a(c)][push_back_a(renderop.integers)] >> +space_p >> 
+                       repeat_p(boost::ref(c))[
+                                                int_p[push_back_a(renderop.integers)] >> +space_p >> 
+                                                int_p[push_back_a(renderop.integers)] >> +space_p
+                                              ] 
+                     )[&valid_op]
+  // "T 1537 228 0 40 9 -#1 (== 0) T 1537 217 0 90 19 -MAIN:./main/main.pl "
+                   | (
+                       ch_p('T')[assign_a(therenderop)] >> +space_p >>
+                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
+                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
+                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
+                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
+                       int_p[assign_a(c)] >> +space_p >> '-' >> 
+                       (repeat_p(boost::ref(c))[anychar_p])[assign_a(thestr)] >> +space_p
+                     )[&valid_op]
+  // c 9 -#000000ff 
+                     | (
+                       (ch_p('C')|ch_p('c')|ch_p('S'))[assign_a(therenderop)] >> +space_p >>
+                       int_p[assign_a(c)] >> +space_p >> '-' >> 
+                       (repeat_p(boost::ref(c))[anychar_p])[assign_a(thestr)] >> +space_p
+                     )[&valid_op] 
+  // F 14,000000 11 -Times-Roman 
+                    | (
+                       ch_p('F')[assign_a(therenderop)] >> +space_p >>
+                       int_p[push_back_a(renderop.integers)] >> (ch_p(',')|ch_p('.')) >> int_p >> +space_p >>
+                       int_p[assign_a(c)] >> +space_p >> '-' >> 
+                       (repeat_p(boost::ref(c))[anychar_p])[assign_a(thestr)] >> +space_p
+                     )[&valid_op]
+                 )
+                 ) >> !end_p
+             ).full;
+  if (res ==false)
+  {
+    kError() << "ERROR: parse_renderop failed on "<< QString::fromStdString(str);
+    kError() << "       Last renderop string is "<<QString::fromStdString(str.c_str());
+  }
+//   delete renderop; renderop = 0;
+  return res;
+}
+
+bool parse(const std::string& str)
+{
+  DotGrammar g;
+  return boost::spirit::classic::parse(str.c_str(), g >> end_p, (+boost::spirit::classic::space_p|boost::spirit::classic::comment_p("/*", "*/"))).full;
+}
+
diff --git a/src/kgraphviz/support/dotgrammar.h b/src/kgraphviz/support/dotgrammar.h
new file mode 100644
index 0000000..37661d4
--- /dev/null
+++ b/src/kgraphviz/support/dotgrammar.h
@@ -0,0 +1,108 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+/*
+ * GraphViz dot Graph parsing grammar implemented with boost Spirit
+ */
+
+#ifndef DOT_GRAMMAR_H
+#define DOT_GRAMMAR_H
+
+#include "dotrenderop.h"
+
+#include <boost/spirit/include/classic_actions.hpp>
+#include <boost/spirit/include/classic_grammar.hpp>
+#include <boost/spirit/include/classic_rule.hpp>
+
+#include <QPoint>
+#include <QColor>
+#include <QPair>
+#include <QVector>
+
+#include <map>
+#include <list>
+#include <string>
+#include <sstream>
+
+bool parse(const std::string& str);
+
+void gotid(char const* first, char const* last);
+void dump(char const* first, char const* last);
+void strict(char const* first, char const* last);
+void undigraph(char const* first, char const* last);
+void digraph(char const* first, char const* last);
+void graphid(char const* first, char const* last);
+void attrid(char const* first, char const* last);
+void subgraphid(char const* first, char const* last);
+void valid(char const* first, char const* last);
+void addattr(char const* first, char const* last);
+void pushAttrListC(char const c);
+void popAttrListC(char const c);
+void pushAttrList(char const* first, char const* last);
+void popAttrList(char const* first, char const* last);
+void createsubgraph(char const);
+void createnode(char const* first, char const* last);
+void setgraphattributes(char const* first, char const* last);
+void setsubgraphattributes(char const* first, char const* last);
+void setnodeattributes(char const* first, char const* last);
+void setattributedlist(char const* first, char const* last);
+void checkedgeop(char const* first, char const* last);
+void edgebound(char const* first, char const* last);
+void createedges(char const* first, char const* last);
+void incrz(char const);
+void decrz(char const);
+void finalactions(char const* first, char const* last);
+
+bool parse_point(char const* str, QPoint& p);
+bool parse_real(char const* str, double& d);
+bool parse_integers(char const* str, std::vector<int>& v);
+bool parse_spline(char const* str, QVector< QPair< float, float > >& points);
+void init_op();
+void valid_op(char const* first, char const* last);
+bool parse_renderop(const std::string& str, DotRenderOpVec& arenderopvec);
+bool parse_numeric_color(char const* str, QColor& c);
+
+struct DotGrammar : public boost::spirit::classic::grammar<DotGrammar>
+{
+  template <typename ScannerT>
+  struct definition
+  {
+    definition(DotGrammar const& self);
+    
+    boost::spirit::classic::rule<ScannerT> graph, ID, tag, stmt_list, stmt, attr_stmt,
+    attr_list, a_list, edge_stmt, edgeop,
+    edgeRHS, node_stmt, node_id,
+    port, subgraph, compass_pt;
+    
+    boost::spirit::classic::rule<ScannerT> const& start() const
+    {
+      return graph;
+    }
+  };
+  
+};
+
+
+
+
+
+
+#endif
+
+
+
diff --git a/src/kgraphviz/support/dotrenderop.h b/src/kgraphviz/support/dotrenderop.h
new file mode 100644
index 0000000..0ef0113
--- /dev/null
+++ b/src/kgraphviz/support/dotrenderop.h
@@ -0,0 +1,39 @@
+/* This file is part of KGraphViewer.
+   Copyright (C) 2007 Gael de Chalendar <kleag at free.fr>
+
+   KGraphViewer is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA
+*/
+
+#ifndef DOT_RENDEROP_H
+#define DOT_RENDEROP_H
+
+#include <QString>
+#include <QList>
+#include <QTextStream>
+
+/**
+ * members are interpreted in function of render operations definitions given at:
+ * @URL http://www.graphviz.org/cvs/doc/info/output.html#d:dot
+ */
+struct DotRenderOp
+{
+  QString renderop;
+  QList< int > integers;
+  QString str;
+};
+
+typedef QList< DotRenderOp > DotRenderOpVec;
+
+#endif
diff --git a/src/kgraphviz/support/layoutagraphthread.cpp b/src/kgraphviz/support/layoutagraphthread.cpp
new file mode 100644
index 0000000..a222800
--- /dev/null
+++ b/src/kgraphviz/support/layoutagraphthread.cpp
@@ -0,0 +1,41 @@
+/*
+    This file is part of KGraphViewer.
+    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of
+    the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "layoutagraphthread.h"
+
+#include <kdebug.h>
+
+void LayoutAGraphThread::run()
+{
+  kDebug();
+  m_gvc = gvContext();
+  gvLayout(m_gvc, m_g, m_layoutCommand.toUtf8().data());
+  gvRender (m_gvc, m_g, "xdot", NULL);
+}
+
+void LayoutAGraphThread::layoutGraph(graph_t* graph, const QString& layoutCommand)
+{
+  kDebug();
+  if (isRunning())
+    return;
+  m_g = graph;
+  m_layoutCommand = layoutCommand;
+  start();
+}
+
diff --git a/src/kgraphviz/support/layoutagraphthread.h b/src/kgraphviz/support/layoutagraphthread.h
new file mode 100644
index 0000000..1c3955d
--- /dev/null
+++ b/src/kgraphviz/support/layoutagraphthread.h
@@ -0,0 +1,44 @@
+/*
+    This file is part of KGraphViewer.
+    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of
+    the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef LAYOUTAGRAPHTHREAD_H
+#define LAYOUTAGRAPHTHREAD_H
+
+#include <QThread>
+
+#include <graphviz/gvc.h>
+
+class LayoutAGraphThread : public QThread
+{
+public:
+  void layoutGraph(graph_t* graph, const QString& layoutCommand);
+  inline graph_t* g() {return m_g;}
+  inline GVC_t* gvc() {return m_gvc;}
+  inline const QString& layoutCommand() const {return m_layoutCommand;}
+  
+protected:
+virtual void run();
+
+private:
+  QString m_layoutCommand;
+  graph_t* m_g;
+  GVC_t *m_gvc;
+};
+
+#endif // LAYOUTAGRAPHTHREAD_H
diff --git a/src/kgraphviz/support/loadagraphthread.cpp b/src/kgraphviz/support/loadagraphthread.cpp
new file mode 100644
index 0000000..1d56bdc
--- /dev/null
+++ b/src/kgraphviz/support/loadagraphthread.cpp
@@ -0,0 +1,41 @@
+/*
+    This file is part of KGraphViewer.
+    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of
+    the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "loadagraphthread.h"
+
+#include <kdebug.h>
+
+void LoadAGraphThread::run()
+{
+  kDebug() << m_dotFileName;
+  GVC_t *gvc;
+  FILE* fp;
+  gvc = gvContext();
+  fp = fopen(m_dotFileName.toUtf8().data(), "r");
+  m_g = agread(fp);
+}
+
+void LoadAGraphThread::loadFile(const QString& dotFileName)
+{
+  kDebug();
+  if (isRunning())
+    return;
+  m_dotFileName = dotFileName;
+  start();
+}
diff --git a/src/kgraphviz/support/loadagraphthread.h b/src/kgraphviz/support/loadagraphthread.h
new file mode 100644
index 0000000..08eb78a
--- /dev/null
+++ b/src/kgraphviz/support/loadagraphthread.h
@@ -0,0 +1,44 @@
+/*
+    This file is part of KGraphViewer.
+    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
+
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of
+    the License, or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef LOADAGRAPHTHREAD_H
+#define LOADAGRAPHTHREAD_H
+
+#include <QThread>
+
+#include <graphviz/gvc.h>
+
+class LoadAGraphThread : public QThread
+{
+public:
+  void loadFile(const QString& dotFileName);
+  inline graph_t* g() {return m_g;}
+  inline const QString& dotFileName() {return m_dotFileName;}
+  inline GVC_t* gvc() {return m_gvc;}
+  
+protected:
+  virtual void run();
+
+private:
+  QString m_dotFileName;
+  graph_t *m_g;
+  GVC_t *m_gvc;
+};
+
+#endif // LOADAGRAPHTHREAD_H
diff --git a/src/part/CMakeLists.txt b/src/part/CMakeLists.txt
index 3375063..63477e1 100644
--- a/src/part/CMakeLists.txt
+++ b/src/part/CMakeLists.txt
@@ -7,7 +7,7 @@ link_directories(
 
 ########### next target ###############
 
-set( kgraphviewerlib_LIB_SRCS loadagraphthread.cpp layoutagraphthread.cpp graphelement.cpp graphsubgraph.cpp graphnode.cpp graphedge.cpp graphexporter.cpp pannerview.cpp canvassubgraph.cpp canvasnode.cpp canvasedge.cpp canvaselement.cpp dotgraph.cpp dotgraphview.cpp dot2qtconsts.cpp dotgrammar.cpp DotGraphParsingHelper.cpp FontsCache.cpp simpleprintingsettings.cpp simpleprintingengine.cpp simpleprintingcommand.cpp simpleprintingpagesetup.cpp simpleprintpreviewwindow_p.cpp simpleprintpreviewwindow.cpp KgvGlobal.cpp KgvUnit.cpp KgvUnitWidgets.cpp KgvPageLayoutColumns.cpp KgvPageLayoutDia.cpp KgvPageLayout.cpp KgvPageLayoutHeader.cpp KgvPageLayoutSize.cpp)
+set( kgraphviewerlib_LIB_SRCS simpleprintingsettings.cpp simpleprintingengine.cpp simpleprintingcommand.cpp simpleprintingpagesetup.cpp simpleprintpreviewwindow_p.cpp simpleprintpreviewwindow.cpp KgvGlobal.cpp KgvUnit.cpp KgvUnitWidgets.cpp KgvPageLayoutColumns.cpp KgvPageLayoutDia.cpp KgvPageLayout.cpp KgvPageLayoutHeader.cpp KgvPageLayoutSize.cpp)
 
 kde4_add_kcfg_files( kgraphviewerlib_LIB_SRCS kgraphviewer_partsettings.kcfgc )
 
@@ -15,11 +15,12 @@ set( kgraphviewerprinting_UI simpleprintingpagesetupbase.ui KgvPageLayoutColumns
 
 kde4_add_ui_files(kgraphviewerlib_LIB_SRCS ${kgraphviewerprinting_UI} )
 
-
 kde4_add_library(kgraphviewerlib SHARED ${kgraphviewerlib_LIB_SRCS})
 
+set(kgraphviewerlib_DEPENDS "kgraphviz")
+
 add_definitions(-DQT_STL)
-target_link_libraries(kgraphviewerlib  ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} ${KDE4_KDE3SUPPORT_LIBS} ${KDE4_KHTML_LIBS} ${KDE4_KWALLETCLIENT_LIBS} ${KDE4_KDESU_LIBS} ${graphviz_LIBRARIES})
+target_link_libraries(kgraphviewerlib ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} ${KDE4_KDE3SUPPORT_LIBS} ${KDE4_KHTML_LIBS} ${KDE4_KWALLETCLIENT_LIBS} ${KDE4_KDESU_LIBS} ${graphviz_LIBRARIES} kgraphviz)
 
 set_target_properties(kgraphviewerlib PROPERTIES VERSION 2.1 SOVERSION 3 OUTPUT_NAME kgraphviewer )
 
@@ -33,7 +34,7 @@ set( kgraphviewerpart_PART_SRCS kgraphviewer_part.cpp  )
 kde4_add_plugin(kgraphviewerpart ${kgraphviewerpart_PART_SRCS})
 
 add_definitions(-DQT_STL)
-target_link_libraries(kgraphviewerpart ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} ${KDE4_KDE3SUPPORT_LIBS} ${KDE4_KHTML_LIBS} ${KDE4_KWALLETCLIENT_LIBS} ${KDE4_KDESU_LIBS} gvc graph pathplan cdt kgraphviewerlib)
+target_link_libraries(kgraphviewerpart ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} ${KDE4_KDE3SUPPORT_LIBS} ${KDE4_KHTML_LIBS} ${KDE4_KWALLETCLIENT_LIBS} ${KDE4_KDESU_LIBS} gvc graph pathplan cdt kgraphviewerlib kgraphviz)
 
 install( TARGETS kgraphviewerpart DESTINATION ${PLUGIN_INSTALL_DIR})
 
@@ -47,7 +48,3 @@ install( FILES kgraphviewer_part.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
 install( FILES kgraphviewer-bev.png DESTINATION ${DATA_INSTALL_DIR}/kgraphviewerpart/pics )
 install( FILES kgraphviewer-newnode.png DESTINATION ${DATA_INSTALL_DIR}/kgraphviewerpart/pics )
 install( FILES kgraphviewer-newedge.png DESTINATION ${DATA_INSTALL_DIR}/kgraphviewerpart/pics )
-
-install(FILES kgraphviewer_interface.h DESTINATION ${INCLUDE_INSTALL_DIR}/kgraphviewer/ COMPONENT Devel)
-install(FILES dotgraphview.h DESTINATION ${INCLUDE_INSTALL_DIR}/kgraphviewer/ COMPONENT Devel)
-install(FILES kgraphviewer_export.h DESTINATION ${INCLUDE_INSTALL_DIR}/kgraphviewer/ COMPONENT Devel)
diff --git a/src/part/DotGraphParsingHelper.cpp b/src/part/DotGraphParsingHelper.cpp
deleted file mode 100644
index 0be9e81..0000000
--- a/src/part/DotGraphParsingHelper.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-
-#include "DotGraphParsingHelper.h"
-#include "dotgraph.h"
-#include "dotgrammar.h"
-#include "dotdefaults.h"
-//#include "graphsubgraph.h"
-#include "graphnode.h"
-#include "graphedge.h"
-
-#include <boost/throw_exception.hpp>
-#include <boost/spirit/core.hpp>
-#include <boost/spirit/utility/distinct.hpp>
-#include <boost/spirit/utility/loops.hpp>
-#include <boost/spirit/utility/confix.hpp>
-
-
-#include <iostream>
-
-#include <kdebug.h>
-    
-#include <QFile>
-#include<QUuid>
-
-using namespace std;
-
-extern KGraphViewer::DotGraphParsingHelper* phelper;
-
-namespace KGraphViewer
-{
-#define KGV_MAX_ITEMS_TO_LOAD std::numeric_limits<int>::max()
-
-DotGraphParsingHelper::DotGraphParsingHelper():
-  attrid(),
-  valid(),
-  attributed(),
-  subgraphid(),
-  uniq(0),
-  attributes(),
-  graphAttributes(),
-  nodesAttributes(),
-  edgesAttributes(),
-  graphAttributesStack(),
-  nodesAttributesStack(),
-  edgesAttributesStack(),
-  edgebounds(),
-  z(0),
-  maxZ(0),
-  graph(0),
-  gs(0),
-  gn(0),
-  ge(0)
-{
-}
-
-void DotGraphParsingHelper::setgraphelementattributes(GraphElement* ge, const AttributesMap& attributes)
-{
-  AttributesMap::const_iterator it, it_end;
-  it = attributes.begin(); it_end = attributes.end();
-  for (; it != it_end; it++)
-  {
-//     kDebug() << "    " << QString::fromStdString((*it).first) << "\t=\t'" << QString::fromStdString((*it).second) <<"'";
-    if ((*it).first=="label")
-    {
-      QString label = QString::fromUtf8((*it).second.c_str());
-      label.replace("\\n","\n");
-      (*ge).attributes()["label"] = label;
-    }
-    else
-    {
-      (*ge).attributes()[QString::fromStdString((*it).first)] =
-      QString::fromStdString((*it).second);
-    }
-  }
-  
-  if (attributes.find("_draw_") != attributes.end())
-  {
-    parse_renderop((attributes.find("_draw_"))->second, ge->renderOperations());
-//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
-  }
-  if (attributes.find("_ldraw_") != attributes.end())
-  {
-    parse_renderop(attributes.find("_ldraw_")->second, ge->renderOperations());
-//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
-  }
-  if (attributes.find("_hldraw_") != attributes.end())
-  {
-    parse_renderop(attributes.find("_hldraw_")->second, ge->renderOperations());
-//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
-  }
-  if (attributes.find("_tldraw_") != attributes.end())
-  {
-    parse_renderop(attributes.find("_tldraw_")->second, ge->renderOperations());
-//     kDebug() << "element renderOperations size is now " << ge->renderOperations().size();
-  }
-}
-
-void DotGraphParsingHelper::setgraphattributes()
-{
-//   kDebug() << "Attributes for graph are : ";
-  setgraphelementattributes(graph, graphAttributes);
-}
-
-void DotGraphParsingHelper::setsubgraphattributes()
-{
-//   kDebug() << "Attributes for subgraph are : ";
-  gs->setZ(z);
-//   kDebug() << "z="<<gs->z();
-  setgraphelementattributes(gs, graphAttributes);
-}
-
-void DotGraphParsingHelper::setnodeattributes()
-{
-//   kDebug() << "setnodeattributes with z = " << z;
-  
-  if (gn == 0)
-  {
-//     kDebug() << "gn is null";
-    return;
-  }
-//   kDebug() << "Attributes for node " << gn->id() << " are : ";
-  gn->setZ(z+1);
-//   kDebug() << "z="<<gn->z();
-  setgraphelementattributes(gn, nodesAttributes);
-}
-
-void DotGraphParsingHelper::setedgeattributes()
-{
-//   kDebug() << "setedgeattributeswith z = " << z;
-  
-//   kDebug() << "Attributes for edge " << ge->fromNode()->id() << "->" << ge->toNode()->id() << " are : ";
-  ge->setZ(z+1);
-//   kDebug() << "z="<<ge->z();
-  setgraphelementattributes(ge, edgesAttributes);
-  
-  if (edgesAttributes.find("_tdraw_") != edgesAttributes.end())
-  {
-    parse_renderop(edgesAttributes["_tdraw_"], ge->renderOperations());
-//     kDebug() << "edge renderOperations size is now " << ge->renderOperations().size();
-    DotRenderOpVec::const_iterator it, it_end;
-    it = ge->renderOperations().constBegin(); it_end = ge->renderOperations().constEnd();
-    for (; it != it_end; it++)
-      ge->arrowheads().push_back(*it);
-  }
-  if (edgesAttributes.find("_hdraw_") != edgesAttributes.end())
-  {
-    parse_renderop(edgesAttributes["_hdraw_"], ge->renderOperations());
-//     kDebug() << "edge renderOperations size is now " << ge->renderOperations().size();
-    DotRenderOpVec::const_iterator it, it_end;
-    it = ge->renderOperations().constBegin(); it_end = ge->renderOperations().constEnd();
-    for (; it != it_end; it++)
-      ge->arrowheads().push_back(*it);
-  }
-}
-
-void DotGraphParsingHelper::setattributedlist()
-{
-// //   kDebug() << "Setting attributes list for " << QString::fromStdString(attributed);
-  if (attributed == "graph")
-  {
-    if (attributes.find("bb") != attributes.end())
-    {
-      std::vector< int > v;
-      parse_integers(attributes["bb"].c_str(), v);
-      if (v.size()>=4)
-      {
-//         kDebug() << "setting width and height to " << v[2] << v[3];
-        graph->width(v[2]);
-        graph->height(v[3]);
-      }
-    }
-    AttributesMap::const_iterator it, it_end;
-    it = attributes.begin(); it_end = attributes.end();
-    for (; it != it_end; it++)
-    {
-//       kDebug() << "    " << QString::fromStdString((*it).first) << " = " <<  QString::fromStdString((*it).second);
-      graphAttributes[(*it).first] = (*it).second;
-    }
-  }
-  else if (attributed == "node")
-  {
-    AttributesMap::const_iterator it, it_end;
-    it = attributes.begin(); it_end = attributes.end();
-    for (; it != it_end; it++)
-    {
-//       kDebug() << "    " << QString::fromStdString((*it).first) << " = " <<  QString::fromStdString((*it).second);
-      nodesAttributes[(*it).first] = (*it).second;
-    }
-  }
-  else if (attributed == "edge")
-  {
-    AttributesMap::const_iterator it, it_end;
-    it = attributes.begin(); it_end = attributes.end();
-    for (; it != it_end; it++)
-    {
-//       kDebug() << "    " << QString::fromStdString((*it).first) << " = " <<  QString::fromStdString((*it).second);
-      edgesAttributes[(*it).first] = (*it).second;
-    }
-  }
-  attributes.clear();
-}
-
-void DotGraphParsingHelper::createnode(const std::string& nodeid)
-{
-  QString id = QString::fromStdString(nodeid); 
-//   kDebug() << id;
-  gn = dynamic_cast<GraphNode*>(graph->elementNamed(id));
-  if (gn==0 && graph->nodes().size() < KGV_MAX_ITEMS_TO_LOAD)
-  {
-//     kDebug() << "Creating a new node" << z << (void*)gs;
-    gn = new GraphNode();
-    gn->setId(id);
-//     gn->label(QString::fromStdString(nodeid));
-    if (z>0 && gs != 0)
-    {
-//       kDebug() << "Adding node" << id << "in subgraph" << gs->id();
-      gs->content().push_back(gn);
-    }
-    else
-    {
-//       kDebug() << "Adding node" << id;
-      graph->nodes()[id] = gn;
-    }
-  }
-  edgebounds.clear();
-}
-
-void DotGraphParsingHelper::createsubgraph()
-{
-//   kDebug() ;
-  if (phelper)
-  {
-    std::string str = phelper->subgraphid;
-    if (str.empty())
-    {
-      std::ostringstream oss;
-      oss << "kgv_id_" << phelper->uniq++;
-      str = oss.str();
-    }
-//     kDebug() << QString::fromStdString(str);
-    if (graph->subgraphs().find(QString::fromStdString(str)) == graph->subgraphs().end())
-    {
-//       kDebug() << "Creating a new subgraph";
-      gs = new GraphSubgraph();
-      gs->setId(QString::fromStdString(str));
-//       gs->label(QString::fromStdString(str)); 
-      graph->subgraphs().insert(QString::fromStdString(str), gs);
-//       kDebug() << "there is now"<<graph->subgraphs().size()<<"subgraphs in" << graph;
-    }
-    else
-    {
-//       kDebug() << "Found existing subgraph";
-      gs = *(graph->subgraphs().find(QString::fromStdString(str)));
-    }
-    phelper->subgraphid = "";
-  }
-}
-
-void DotGraphParsingHelper::createedges()
-{
-//   kDebug();
-  std::string node1Name, node2Name;
-  node1Name = edgebounds.front();
-  edgebounds.pop_front();
-  while (!edgebounds.empty())
-  {
-    node2Name = edgebounds.front();
-    edgebounds.pop_front();
-
-    if (graph->nodes().size() >= KGV_MAX_ITEMS_TO_LOAD || graph->edges().size() >= KGV_MAX_ITEMS_TO_LOAD)
-    {
-      return;
-    }
-//     kDebug() << QString::fromStdString(node1Name) << ", " << QString::fromStdString(node2Name);
-    ge = new GraphEdge();
-    GraphElement* gn1 = graph->elementNamed(QString::fromStdString(node1Name));
-    if (gn1 == 0)
-    {
-//       kDebug() << "new node 1";
-      gn1 = new GraphNode();
-      gn1->setId(QString::fromStdString(node1Name));
-      graph->nodes()[QString::fromStdString(node1Name)] = dynamic_cast<GraphNode*>(gn1);
-    }
-    GraphElement* gn2 = graph->elementNamed(QString::fromStdString(node2Name));
-    if (gn2 == 0)
-    {
-//       kDebug() << "new node 2";
-      gn2 = new GraphNode();
-      gn2->setId(QString::fromStdString(node2Name));
-      graph->nodes()[QString::fromStdString(node2Name)] = dynamic_cast<GraphNode*>(gn2);
-    }
-//     kDebug() << "Found gn1="<<gn1<<" and gn2=" << gn2;
-    if (gn1 == 0 || gn2 == 0)
-    {
-      kError() << "Unable to find or create edge bound(s) gn1=" << gn1 << "; gn2=" << gn2;
-    }
-    ge->setFromNode(gn1);
-    ge->setToNode(gn2);
-//     kDebug() << ge->fromNode()->id() << " -> " << ge->toNode()->id();
-    setedgeattributes();
-//     kDebug() << ge->id();
-    if (ge->id().isEmpty())
-    {
-      ge->setId(QString::fromStdString(node1Name)+QString::fromStdString(node2Name)+QUuid::createUuid().toString().remove('{').remove('}').remove('-'));
-    }
-//     kDebug() << ge->id();
-//     kDebug() << "num before=" << graph->edges().size();
-    graph->edges().insert(ge->id(), ge);
-//     kDebug() << "num after=" << graph->edges().size();
-
-
-    node1Name = node2Name;
-  }
-  edgebounds.clear();
-}
-
-void DotGraphParsingHelper::finalactions()
-{
-  GraphEdgeMap::iterator it, it_end;
-  it = graph->edges().begin(); it_end = graph->edges().end();
-  for (; it != it_end; it++)
-  {
-    (*it)->setZ(maxZ+1);
-  }
-}
-
-}
diff --git a/src/part/DotGraphParsingHelper.h b/src/part/DotGraphParsingHelper.h
deleted file mode 100644
index 465bcf1..0000000
--- a/src/part/DotGraphParsingHelper.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-#ifndef DOT_GRAPHPARSINGHELPER_H
-#define DOT_GRAPHPARSINGHELPER_H
-
-#include <map>
-#include <list>
-#include <string>
-
-namespace KGraphViewer
-{
-class DotGraph;
-class GraphSubgraph;
-class GraphNode;
-class GraphEdge;
-class GraphElement;
-
-struct DotGraphParsingHelper
-{
-  typedef std::map< std::string, std::string > AttributesMap;
-
-  DotGraphParsingHelper();
-
-  void createnode(const std::string& nodeid);
-  void createsubgraph();
-  void setgraphattributes();
-  void setsubgraphattributes();
-      void setnodeattributes();
-  void setedgeattributes();
-  void setattributedlist();
-  void createedges();
-  void edgebound(const std::string& bound) {edgebounds.push_back(bound);}
-  void finalactions();
-  void setgraphelementattributes(GraphElement* ge, const AttributesMap& attributes);
-
-  std::string attrid;
-  std::string valid;
-  std::string attributed;
-  std::string subgraphid;
-  
-  unsigned int uniq;
-  
-  AttributesMap attributes;
-  AttributesMap graphAttributes;
-  AttributesMap nodesAttributes;
-  AttributesMap edgesAttributes;
-  std::list< AttributesMap > graphAttributesStack;
-  std::list< AttributesMap > nodesAttributesStack;
-  std::list< AttributesMap > edgesAttributesStack;
-  
-  std::list< std::string > edgebounds;
-  
-  unsigned int z;
-  unsigned int maxZ;
-  
-  DotGraph* graph;
-  
-  GraphSubgraph* gs;
-  GraphNode* gn;
-  GraphEdge* ge;
-};
-
-}
-
-#endif
-
-
-
diff --git a/src/part/FontsCache.cpp b/src/part/FontsCache.cpp
deleted file mode 100644
index d60078d..0000000
--- a/src/part/FontsCache.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-
-#include "FontsCache.h"
-
-#include "dot2qtconsts.h"
-
-FontsCache::~FontsCache()
-{
-  FontsCache::iterator it, it_end;
-  it = begin(); it_end = end();
-  for (; it != it_end; it++)
-  {
-    delete (*it);
-  }
-}
-
-QFont* FontsCache::cachedFont(const QFont& font)
-{
-  if (find(font.key()) == end())
-  {
-    (*this)[font.key()] = new QFont(font);
-  }
-  return (*this)[font.key()];
-}
-
-QFont* FontsCache::fromName(const QString& fontName)
-{
-  if (m_namesToFonts.find(fontName) == m_namesToFonts.end())
-  {
-    QFont font(Dot2QtConsts::componentData().qtFont(fontName));
-    m_namesToFonts[fontName] = cachedFont(font);
-  }
-  return m_namesToFonts[fontName];
-}
diff --git a/src/part/FontsCache.h b/src/part/FontsCache.h
deleted file mode 100644
index 41af3b9..0000000
--- a/src/part/FontsCache.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-
-#ifndef KGRAPHVIEWER_FONTSCACHE_H
-#define KGRAPHVIEWER_FONTSCACHE_H
-
-#include "Singleton.h"
-
-#include <qfont.h>
-#include <qmap.h>
-#include <qstring.h>
-
-/**
- * This is a map of fonts used in KgraphViewer
- *
- * @short A fonts map
- * @author Gaël de Chalendar <kleag at free.fr>
- */
-class FontsCache : 
-  public Singleton<FontsCache>,
-  public QMap<QString, QFont*>
-{
-friend class Singleton<FontsCache>;
-
-public:
-  virtual ~FontsCache();
-
-  QFont* cachedFont(const QFont& font);
-  QFont* fromName(const QString& font);
-
-private:
-  FontsCache() {}
-
-  QMap<QString, QFont*> m_namesToFonts;
-};
-
-#endif
diff --git a/src/part/canvasedge.cpp b/src/part/canvasedge.cpp
deleted file mode 100644
index 1d062fa..0000000
--- a/src/part/canvasedge.cpp
+++ /dev/null
@@ -1,591 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.cpp, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-#include "canvasedge.h"
-#include "canvaselement.h"
-#include "graphedge.h"
-#include "graphnode.h"
-#include "dotdefaults.h"
-#include "dot2qtconsts.h"
-#include "dotgraphview.h"
-#include "FontsCache.h"
-
-#include <KAction>
-#include <KDebug>
-#include <KLocale>
-
-#include <QPainter>
-#include <QGraphicsSceneMouseEvent>
-#include <QMenu>
-
-#include <math.h>
-#include <iostream>
-
-//
-// CanvasEdge
-//
-
-namespace KGraphViewer
-{
-
-CanvasEdge::CanvasEdge(DotGraphView* view, GraphEdge* e,
-                       qreal scaleX, qreal scaleY,
-                       qreal xMargin, qreal yMargin, qreal gh,
-                       qreal wdhcf, qreal hdvcf,
-                       QGraphicsItem* parent)
-                       : QAbstractGraphicsShapeItem(parent),
-    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())
-{
-  kDebug() << "edge "  << edge()->fromNode()->id() << "->"  << edge()->toNode()->id() << m_gh;
-  setBoundingRegionGranularity(0.9);
-  m_font = FontsCache::changeable().fromName(e->fontName());
-
-  computeBoundingRect();
-//   kDebug() << "boundingRect computed: " << m_boundingRect;
-  
-  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()));
-  
-  
-  connect(e,SIGNAL(changed()),this,SLOT(modelChanged()));
-  connect(this, SIGNAL(selected(CanvasEdge*, Qt::KeyboardModifiers)), view, SLOT(slotEdgeSelected(CanvasEdge*, Qt::KeyboardModifiers)));
-  
-  connect(this, SIGNAL(edgeContextMenuEvent(const QString&, const QPoint&)), view, SLOT(slotContextMenuEvent(const QString&, const QPoint&)));
-
-  setAcceptHoverEvents ( true );
-
-  kDebug() << "connect slotElementHoverEnter";
-  connect(this, SIGNAL(hoverEnter(CanvasEdge*)), view, SLOT(slotElementHoverEnter(CanvasEdge*)));
-  connect(this, SIGNAL(hoverLeave(CanvasEdge*)), view, SLOT(slotElementHoverLeave(CanvasEdge*)));
-  
-} 
-
-CanvasEdge::~CanvasEdge()
-{
-  delete m_popup;
-}
-
-
-QRectF CanvasEdge::boundingRect() const
-{
-  return m_boundingRect;
-}
-
-QPainterPath CanvasEdge::shape () const
-{
-//   kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id();
-  if (m_boundingRegion.isEmpty()) {
-    m_boundingRegion.addRegion(boundingRegion(QTransform()));
-  }
-  return m_boundingRegion;
-  /*
-  foreach (const DotRenderOp& dro, edge()->renderOperations())
-  {
-    if ( dro.renderop == "B" )
-    {
-      for (int splineNum = 0; splineNum < edge()->colors().count() || (splineNum==0 && edge()->colors().count()==0); splineNum++)
-      {
-        QPolygonF points(dro.integers[0]);
-        for (int i = 0; i < dro.integers[0]; i++)
-        {
-          qreal nom = (dro.integers[2*dro.integers[0]]-dro.integers[2]);
-          qreal denom = (dro.integers[2*dro.integers[0]-1]-dro.integers[1]);
-          qreal diffX, diffY;
-          if (nom == 0)
-          {
-            diffX = 0;
-            diffY = 2*(edge()->colors().count()/2 - splineNum);
-          }
-          else if (denom ==0)
-          {
-            diffX = 2*(edge()->colors().count()/2 - splineNum);
-            diffY = 0;
-          }
-          else
-          {
-            double pente = nom/denom;
-            if (pente < 0)
-            {
-              diffX = 2*(edge()->colors().count()/2 - splineNum);
-              diffY = edge()->colors().count()/2 + splineNum;
-            }
-            else
-            {
-              diffX = 2*(edge()->colors().count()/2 - splineNum);
-              diffY = 2*(edge()->colors().count()/2 - splineNum);
-            }
-          }
-          QPointF p(
-              //NOTE: when uncommenting, fix nested comments in here:
-              (dro.integers[2*i+1]/ *%m_wdhcf* /*m_scaleX) +m_xMargin + diffX,
-              (m_gh-dro.integers[2*i+2]/ *%m_hdvcf* /)*m_scaleY + m_yMargin + diffY
-                  );
-          points[i] = p;
-        }
-        path.moveTo(points[0]);
-        for (int j = 0; j < (points.size()-1)/3; j++)
-        {
-          path.cubicTo(points[3*j + 1],points[3*j+1 + 1], points[3*j+2 + 1]);
-        }
-        for (int j = (points.size()-1)/3-3; j >= 0 ; j--)
-        {
-          path.cubicTo(points[3*j + 1],points[3*j+1 + 1], points[3*j+2 + 1]);
-        }
-      }
-    }
-  }
-  return path;
-  */
-}
-
-
-
-void CanvasEdge::paint(QPainter* p, const QStyleOptionGraphicsItem* option,
-                   QWidget* widget)
-{
-//   kDebug();
-Q_UNUSED(option)
-Q_UNUSED(widget)
-  if (m_boundingRect == QRectF())
-  {
-    return;
-  }
-  /// computes the scaling of line width
-  qreal widthScaleFactor = (m_scaleX+m_scaleY)/2;
-  if (widthScaleFactor < 1)
-  {
-    widthScaleFactor = 1;
-  }
-
-  if (edge()->style()=="invis")
-  {
-    return;
-  }
-  if (edge()->renderOperations().isEmpty())
-  {
-    if ((edge()->fromNode()->canvasElement()!=0)
-      && (edge()->toNode()->canvasElement()!=0))
-    {
-      p->drawLine(
-        edge()->fromNode()->canvasElement()->boundingRect().center()+edge()->fromNode()->canvasElement()->pos(),
-        edge()->toNode()->canvasElement()->boundingRect().center()+edge()->toNode()->canvasElement()->pos());
-    }
-    return;
-  }
-
-  QColor lineColor = Dot2QtConsts::componentData().qtColor(edge()->color(0));
-  QColor backColor;
-  
-  QList<QPointF> allPoints;
-  foreach (const DotRenderOp& dro, edge()->renderOperations())
-  {
-    //     kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "renderop" << dro.renderop << "; selected:" << edge()->isSelected();
-    if (dro.renderop == "c")
-    {
-      QColor c(dro.str.mid(0,7));
-      bool ok;
-      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
-      lineColor = c;
-//       kDebug() << "c" << dro.str.mid(0,7) << lineColor;
-    }
-    else if (dro.renderop == "C")
-    {
-      QColor c(dro.str.mid(0,7));
-      bool ok;
-      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
-/*      if (m_hovered && m_view->highlighting())
-      {
-        c = c.lighter();
-      }*/
-      backColor = c;
-//       kDebug() << "C" << dro.str.mid(0,7) << backColor;
-    }
-    else if ( dro.renderop == "T" )
-    {
-      const QString& str = dro.str;
-    
-      qreal stringWidthGoal = dro.integers[3] * m_scaleX;
-      int fontSize = edge()->fontSize();
-      m_font->setPointSize(fontSize);
-      QFontMetrics fm(*m_font);
-      while (fm.width(str) > stringWidthGoal && fontSize > 1)
-      {
-        fontSize--;
-        m_font->setPointSize(fontSize);
-        fm = QFontMetrics(*m_font);
-      }
-      p->save();
-      p->setFont(*m_font);
-      
-      p->setPen(Dot2QtConsts::componentData().qtColor(edge()->fontColor()));
-
-      qreal x = (m_scaleX *
-                       (
-                         (dro.integers[0])
-                         + (((-dro.integers[2])*(fm.width(dro.str)))/2)
-                         - ( (fm.width(dro.str))/2 )
-                       )
-                      )
-                      + m_xMargin;
-      qreal y = ((m_gh - (dro.integers[1]))*m_scaleY)+ m_yMargin;
-      QPointF point(x,y);
-//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawText" << edge()->fontColor() << point;
-
-      p->drawText(point,str);
-      p->restore();
-    }      
-    else if (( dro.renderop == "p" ) || (dro.renderop == "P" ))
-    {
-      QPolygonF polygon(dro.integers[0]);
-      for (int i = 0; i < dro.integers[0]; i++)
-      {
-        QPointF point(
-            (int(dro.integers[2*i+1])/*%m_wdhcf*/)*m_scaleX +m_xMargin,
-            (int(m_gh-dro.integers[2*i+2])/*%m_hdvcf*/)*m_scaleY + m_yMargin
-                );
-        polygon[i] = point;
-//         kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id()  << point;
-        allPoints.append(point);
-      }
-      if (dro.renderop == "P" )
-      {
-        p->save();
-        p->setBrush(lineColor);
-        p->drawPolygon(polygon);
-//         kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawPolygon" << edge()->color(0) << polygon;
-        p->restore();
-      }
-      else
-      {
-        p->setBrush(Dot2QtConsts::componentData().qtColor("white"));
-      }
-      QPen pen(lineColor);
-      if (edge()->style() == "bold")
-      {
-        pen.setStyle(Qt::SolidLine);
-        pen.setWidth((int)(2 * widthScaleFactor));
-      }
-      else
-      {
-        pen.setWidth((int)(1 * widthScaleFactor));
-        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(edge()->style()));
-      }
-      p->save();
-      p->setPen(pen);
-//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawPolyline" << edge()->color(0) << polygon;
-      p->drawPolyline(polygon);
-      p->restore();
-    }
-    else if (( dro.renderop == "e" ) || (dro.renderop == "E" ))
-    {
-      qreal w = m_scaleX * dro.integers[2] * 2;
-      qreal h = m_scaleY *  dro.integers[3] * 2;
-      qreal x = (m_xMargin + (dro.integers[0]/*%m_wdhcf*/)*m_scaleX) - w/2;
-      qreal y = ((m_gh -  dro.integers[1]/*%m_hdvcf*/)*m_scaleY + m_yMargin) - h/2;
-      p->save();
-      if (dro.renderop == "E" )
-      {
-        p->setBrush(lineColor);
-      }
-      else
-      {
-        p->setBrush(Dot2QtConsts::componentData().qtColor("white"));
-      }
-      QPen pen(lineColor);
-      if (edge()->style() == "bold")
-      {
-        pen.setStyle(Qt::SolidLine);
-        pen.setWidth(int(2 * widthScaleFactor));
-      }
-      else
-      {
-        pen.setWidth(int(1 * widthScaleFactor));
-        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(edge()->style()));
-      }
-      p->setPen(pen);
-      QRectF rect(x,y,w,h);
-//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawEllipse" << edge()->color(0) << rect;
-      p->drawEllipse(rect);
-      p->restore();
-    }
-    else if ( dro.renderop == "B" )
-    {
-      uint lineWidth = 1;
-      QPen pen;
-      if (edge()->style() == "bold")
-      {
-        pen.setStyle(Qt::SolidLine);
-        pen.setWidth(int(2 * widthScaleFactor));
-      }
-      else if (edge()->style() != "filled")
-      {
-        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(edge()->style()));
-      }
-      if (edge()->style().left(12) == "setlinewidth")
-      {
-        bool ok;
-        lineWidth = edge()->style().mid(12, edge()->style().length()-1-12).toInt(&ok);
-        pen.setWidth(int(lineWidth * widthScaleFactor));
-      }
-      if (edge()->attributes().contains("penwidth"))
-      {
-        bool ok;
-        lineWidth = edge()->attributes()["penwidth"].toInt(&ok);
-        pen.setWidth(int(lineWidth * widthScaleFactor));
-      }
-      if (edge()->attributes().contains("color"))
-      {
-        kDebug() << "set edge color to " << QColor(edge()->attributes()["color"]).name();
-        lineColor = QColor(edge()->attributes()["color"]);
-      }
-      for (int splineNum = 0; splineNum < edge()->colors().count() || (splineNum==0 && edge()->colors().count()==0); splineNum++)
-      {
-        QPolygonF points(dro.integers[0]);
-        for (int i = 0; i < dro.integers[0]; i++)
-        {
-          // computing of diffX and diffY to draw parallel edges
-          // when asked through the corresponding GraphViz feature
-          qreal nom = (dro.integers[2*dro.integers[0]]-dro.integers[2]);
-          qreal denom = (dro.integers[2*dro.integers[0]-1]-dro.integers[1]);
-          qreal diffX, diffY;
-          if (nom == 0)
-          {
-            diffX = 0;
-            diffY = 2*(edge()->colors().count()/2 - splineNum);
-          }
-          else if (denom ==0)
-          {
-            diffX = 2*(edge()->colors().count()/2 - splineNum);
-            diffY = 0;
-          }
-          else
-          {
-            double pente = nom/denom;
-            if (pente < 0)
-            {
-              diffX = 2*(edge()->colors().count()/2 - splineNum);
-              diffY = edge()->colors().count()/2 + splineNum;
-            }
-            else
-            {
-              diffX = 2*(edge()->colors().count()/2 - splineNum);
-              diffY = 2*(edge()->colors().count()/2 - splineNum);
-            }
-          }
-          QPointF p(
-              (dro.integers[2*i+1]/*%m_wdhcf*/*m_scaleX) +m_xMargin + diffX,
-              (m_gh-dro.integers[2*i+2]/*%m_hdvcf*/)*m_scaleY + m_yMargin + diffY
-                  );
-          points[i] = p;
-//           kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id()  << p;
-          allPoints.append(p);
-        }
-        kDebug() << "Setting pen color to " << edge()->color(splineNum);
-        if (splineNum != 0)
-          lineColor = Dot2QtConsts::componentData().qtColor(edge()->color(splineNum));
-        pen.setColor(lineColor);
-        p->save();
-//         p->setBrush(Dot2QtConsts::componentData().qtColor(edge()->color(0)));
-        p->setBrush(Qt::NoBrush);
-        p->setPen(pen);
-        QPainterPath path;
-        path.moveTo(points[0]);
-        for (int j = 0; j < (points.size()-1)/3; j++)
-        {
-          path.cubicTo(points[3*j + 1],points[3*j+1 + 1], points[3*j+2 + 1]);
-        }
-//         kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "drawPath" << edge()->color(splineNum) << points.first() << points.last();
-        p->drawPath(path);
-        p->restore();
-      }
-    }
-  }
-  if (edge()->isSelected())
-  {
-//     kDebug() << "draw square";
-//     p->drawRect(m_boundingRect);
-    qreal maxDist = 0;
-    QPair<QPointF,QPointF> pointsPair;
-    foreach(const QPointF& point1, allPoints)
-    {
-      foreach(const QPointF& point2, allPoints)
-      {
-        if (distance(point1, point2) > maxDist)
-        {
-          maxDist = distance(point1, point2);
-          pointsPair = qMakePair(point1, point2);
-        }
-      }
-    }
-    if (maxDist>0)
-    {
-      p->save();
-      //         p->setBrush(Dot2QtConsts::componentData().qtColor(edge()->color(0)));
-      p->setBrush(Qt::black);
-      p->setPen(Qt::black);
-      p->drawRect(QRectF(pointsPair.first-QPointF(3,3),QSizeF(6,6)));
-      p->drawRect(QRectF(pointsPair.second-QPointF(3,3),QSizeF(6,6)));
-      p->restore();
-    }
-  }
-}
-
-void CanvasEdge::modelChanged()
-{
-//   kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id();
-  prepareGeometryChange();
-  computeBoundingRect();
-}
-
-void CanvasEdge::computeBoundingRect()
-{
-//   kDebug();
-  //invalidate bounding region cache
-  m_boundingRegion = QPainterPath();
-  if (edge()->renderOperations().isEmpty())
-  {
-    if ((edge()->fromNode()->canvasElement()==0)
-      || (edge()->toNode()->canvasElement()==0)
-      || edge()->style()=="invis")
-    {
-      m_boundingRect = QRectF();
-    }
-    else
-    {
-      QRectF br(
-      edge()->fromNode()->canvasElement()->boundingRect().center()+edge()->fromNode()->canvasElement()->pos(),
-                edge()->toNode()->canvasElement()->boundingRect().center()+edge()->toNode()->canvasElement()->pos());
-//       kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() <<br;
-      m_boundingRect = br;
-    }
-  }
-  else
-  {
-    QPolygonF points;
-    foreach (const DotRenderOp& dro, edge()->renderOperations())
-    {
-//       kDebug() << dro.renderop  << ", ";
-      if ( (dro.renderop != "B") && (dro.renderop != "p") &&  (dro.renderop != "P") ) continue;
-      uint previousSize = points.size();
-      points.resize(previousSize+dro.integers[0]);
-      for (int i = 0; i < dro.integers[0]; i++)
-      {
-        QPointF p(
-            ((dro.integers[2*i+1]/*%m_wdhcf*/)*m_scaleX) +m_xMargin,
-            ((m_gh-dro.integers[2*i+2]/*%m_hdvcf*/)*m_scaleY) + m_yMargin
-                );
-        points[previousSize+i] = p;
-      }
-    }
-//     kDebug() << points.size() << "points";
-    if (points.size() == 0) return;
-
-    int len = points.count();
-    QPolygonF a = points,  b = points;
-    a.translate(-1, -1);
-    b.translate(1, 1);
-    a.resize(2*len);
-    for (int i=0;i<len;i++)
-    {
-      a[len+i] = b[i];
-    }
-//     kDebug() << a.size() << "points";
-
-    m_boundingRect = a.boundingRect();
-  }
-  kDebug() << edge()->fromNode()->id() << "->" << edge()->toNode()->id() << "New bounding rect is:" << m_boundingRect;
-}
-
-void CanvasEdge::mousePressEvent(QGraphicsSceneMouseEvent * event)
-{
-  kDebug() << event;
-  if (m_view->isReadOnly())
-  {
-    return;
-  }
-  if (event->button() == Qt::LeftButton)
-  {
-    edge()->setSelected(!edge()->isSelected());
-    if (edge()->isSelected())
-    {
-      emit(selected(this,event->modifiers()));
-    }
-    update();
-  }
-  else if (event->button() == Qt::RightButton)
-  {
-    if (!edge()->isSelected())
-    {
-      edge()->setSelected(true);
-      emit(selected(this,event->modifiers()));
-      update();
-    }
-    kDebug() << "emiting edgeContextMenuEvent("<<m_edge->id()<<","<<event->screenPos()<<")";
-    emit(edgeContextMenuEvent(m_edge->id(), event->screenPos() ));
-// opens the selected edge contextual menu and if necessary select the edge
-/*    kDebug() << "opens the contextual menu";
-    m_popup->exec(event->screenPos());*/
-  }
-}
-
-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();
-}
-
-void CanvasEdge::hoverEnterEvent( QGraphicsSceneHoverEvent * event )
-{
-  Q_UNUSED(event)
-  kDebug() << edge()->id();
-  emit hoverEnter(this);
-}
-
-void CanvasEdge::hoverLeaveEvent( QGraphicsSceneHoverEvent * event )
-{
-  Q_UNUSED(event)
-  kDebug() << edge()->id();
-  emit hoverLeave(this);
-}
-
-}
-
-#include "canvasedge.moc"
diff --git a/src/part/canvasedge.h b/src/part/canvasedge.h
deleted file mode 100644
index 4efe8e3..0000000
--- a/src/part/canvasedge.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-#ifndef CANVAS_EDGE_H
-#define CANVAS_EDGE_H
-
-#include <QGraphicsScene>
-#include <QGraphicsPathItem>
-#include <QAbstractGraphicsShapeItem>
-#include <QWidget>
-#include <QMap>
-#include <QFont>
-
-#include "graphexporter.h"
-
-
-class QMenu;
-
-/*
- * Canvas Items:
- * - CanvasNode       (Rectangular Area)
- * - CanvasEdge       (Spline curve)
- * - CanvasEdgeLabel  (Label for edges)
- * - CanvasEdgeArrow  (Arrows at the end of the edge spline)
- */
-namespace KGraphViewer
-{
-
-class CanvasNode;
-class CanvasEdge;
-class GraphEdge;
-class DotGraphView;
-
-
-class CanvasEdge : public QObject, public QAbstractGraphicsShapeItem
-{
-Q_OBJECT
-public:
-  explicit CanvasEdge(DotGraphView* v, GraphEdge*,
-             qreal scaleX, qreal scaleY,
-             qreal xMargin, qreal yMargin, qreal gh,
-             qreal wdhcf, qreal hdvcf, QGraphicsItem* parent = 0);
-
-  virtual ~CanvasEdge();
-  
-  QRectF boundingRect() const;
-
-  QPainterPath shape () const;
-
-  void paint(QPainter* p, const QStyleOptionGraphicsItem *option,
-        QWidget *widget);
-
-  inline GraphEdge* edge() { return m_edge; }
-  inline const GraphEdge* edge() const { return m_edge; }
-
-  inline void setGh(qreal gh) {m_gh = gh;}
-  
-  void computeBoundingRect();
-
-Q_SIGNALS:
-  void selected(CanvasEdge*, Qt::KeyboardModifiers);
-  void edgeContextMenuEvent(const QString&, const QPoint&);
-  void hoverEnter(CanvasEdge*);
-  void hoverLeave(CanvasEdge*);
-  
-public Q_SLOTS:
-  void modelChanged();
-  void slotRemoveEdge();
-
-protected:
-  virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
-  virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
-  virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
-  
-private:
-  qreal distance(const QPointF& point1, const QPointF& point2);
-  
-  qreal m_scaleX, m_scaleY;
-  qreal m_xMargin, m_yMargin, m_gh, m_wdhcf, m_hdvcf;
-  GraphEdge* m_edge;
-  QRectF m_boundingRect;
-  QFont* m_font;
-  DotGraphView* m_view;
-  QMenu* m_popup;
-  mutable QPainterPath m_boundingRegion;
-};
-
-}
-
-#endif
-
-
-
diff --git a/src/part/canvaselement.cpp b/src/part/canvaselement.cpp
deleted file mode 100644
index e3d6284..0000000
--- a/src/part/canvaselement.cpp
+++ /dev/null
@@ -1,575 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-
-#include "canvaselement.h"
-#include "dotgraphview.h"
-#include "graphelement.h"
-#include "dotdefaults.h"
-#include "dot2qtconsts.h"
-#include "FontsCache.h"
-
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-
-#include <QPainter>
-#include <QGraphicsScene>
-#include <QGraphicsSceneMouseEvent>
-#include <QMenu>
-
-#include <kdebug.h>
-#include <klocale.h>
-#include <KAction>
-
-namespace KGraphViewer
-{
-  
-  
-CanvasElement::CanvasElement(
-                              DotGraphView* v,
-                              GraphElement* gelement,
-                              QGraphicsScene* c,
-                              QGraphicsItem* parent
-                            )
-  : QObject(), QAbstractGraphicsShapeItem(parent),
-    m_scaleX(0), m_scaleY(0),
-    m_xMargin(0), m_yMargin(0), m_gh(0), m_wdhcf(0), m_hdvcf(0),
-    m_element(gelement), m_view(v),
-    m_font(0),
-    m_pen(Dot2QtConsts::componentData().qtColor(gelement->fontColor())),
-    m_popup(new QMenu()),
-    m_hovered(false)
-{
-//   kDebug();
-  m_font = FontsCache::changeable().fromName(gelement->fontName());
-/*  kDebug() << "Creating CanvasElement for "<<gelement->id();
-  kDebug() << "    data: " << wdhcf << "," << hdvcf << "," << gh << "," 
-    << scaleX << "," << scaleY << "," << xMargin << "," << yMargin << endl;*/
-  
-  if (element()->style() == "bold")
-  {
-    m_pen.setStyle(Qt::SolidLine);
-    m_pen.setWidth(int(2*((m_scaleX+m_scaleY)/2)));
-  }
-  else if (element()->style() != "filled")
-  {
-    m_pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(m_element->style()));
-    m_pen.setWidth(int((m_scaleX+m_scaleY)/2));
-    if (element()->style().left(12) == "setlinewidth")
-    {
-      bool ok;
-      uint lineWidth = element()->style().mid(13, m_element->style().length()-1-13).toInt(&ok);
-      m_pen.setWidth(lineWidth * int((m_scaleX+m_scaleY)/2));
-    }
-  }
-  if (m_element->style() == "filled")
-  {
-    m_brush = Dot2QtConsts::componentData().qtColor(element()->backColor());
-//     QCanvasPolygon::drawShape(p);
-  }
-  else
-  {
-    m_brush = c->backgroundBrush();
-  }
-  
-  // the message should be given (or possible to be given) by the part user
-  KAction* removeElementAction = new KAction(i18n("Remove selected element(s)"), this);
-  m_popup->addAction(removeElementAction);
-  connect(removeElementAction,SIGNAL(triggered(bool)),this,SLOT(slotRemoveElement()));
-
-  connect(this, SIGNAL(selected(CanvasElement*, Qt::KeyboardModifiers)), v, SLOT(slotElementSelected(CanvasElement*, Qt::KeyboardModifiers)));
-
-  connect(this, SIGNAL(elementContextMenuEvent(const QString&, const QPoint&)), v, SLOT(slotContextMenuEvent(const QString&, const QPoint&)));
-
-  setAcceptHoverEvents ( true );
-
-  connect(this, SIGNAL(hoverEnter(CanvasElement*)), v, SLOT(slotElementHoverEnter(CanvasElement*)));
-  connect(this, SIGNAL(hoverLeave(CanvasElement*)), v, SLOT(slotElementHoverLeave(CanvasElement*)));
-  
-}
-
-CanvasElement::~CanvasElement()
-{
-  delete m_popup;
-}
-
-void CanvasElement::modelChanged()
-{
-  kDebug() ;//<< id();
-  m_pen = QPen(Dot2QtConsts::componentData().qtColor(m_element->fontColor()));
-  m_font = FontsCache::changeable().fromName(m_element->fontName());
-  prepareGeometryChange();
-  computeBoundingRect();
-}
-
-void CanvasElement::initialize(qreal scaleX, qreal scaleY,
-                            qreal xMargin, qreal yMargin, qreal gh,
-                            qreal wdhcf, qreal hdvcf)
-{
-//   kDebug();
-  setFlag(QGraphicsItem::ItemIsMovable, true);
-  setFlag(QGraphicsItem::ItemIsSelectable, true);
-
-  m_scaleX = scaleX; m_scaleY = scaleY;
-  m_xMargin = xMargin; m_yMargin = yMargin;
-//   m_gh = gh;
-  m_wdhcf = wdhcf; m_hdvcf = hdvcf;
-
-  setZValue(m_element->z());
-
-  computeBoundingRect();
-}
-
-QRectF CanvasElement::boundingRect () const
-{
-  return m_boundingRect;
-}
-
-void CanvasElement::computeBoundingRect()
-{
-//   kDebug() << element();
-  kDebug() << element()->id() << zValue();
-  
-  qreal adjust = 0.5;
-  QRectF rect;
-  if (element()->renderOperations().isEmpty())
-  {
-    kDebug() << "no render operation";
-    rect = QRectF(0,0,(m_view->defaultNewElementPixmap().size().width())*m_scaleX,(m_view->defaultNewElementPixmap().size().height())*m_scaleY);
-    m_boundingRect = rect;
-  }
-  else
-  {
-    DotRenderOpVec::const_iterator it, it_end;
-    it = element()->renderOperations().constBegin(); it_end = element()->renderOperations().constEnd();
-    for (; it != it_end; it++)
-    {
-//       QString msg;
-//       QTextStream dd(&msg);
-//       dd << element()->id() << " an op: " << (*it).renderop << " ";
-//       foreach (int i, (*it).integers)
-//       {
-//         dd << i << " ";
-//       }
-//       dd << (*it).str;
-//       kDebug() << msg;
-
-      if ((*it).renderop == "e" || (*it).renderop == "E")
-      {
-//         kDebug() << "integers[0]=" << (*it).integers[0] << "; m_wdhcf=" << m_wdhcf
-//             << "(*it).integers[0]/*%m_wdhcf*/=" << (*it).integers[0]/*%m_wdhcf*/;
-        qreal w = m_scaleX * (*it).integers[2] * 2;
-        qreal h = m_scaleY * (*it).integers[3] * 2;
-        qreal x = m_xMargin + (((*it).integers[0]/*%m_wdhcf*/)*m_scaleX) - w/2;
-        qreal y = ((m_gh - (*it).integers[1]/*%m_hdvcf*/)*m_scaleY) + m_yMargin - h/2;
-        m_boundingRect = QRectF(x - adjust,y - adjust, w + adjust, h + adjust);
-//         kDebug() << "'" << element()->id() << "' set rect for ellipse to " << rect;
-      }
-      else if  ((*it).renderop == "p" || (*it).renderop == "P")
-      {
-        QPolygonF polygon((*it).integers[0]);
-        for (int i = 0; i < (*it).integers[0]; i++)
-        {
-          qreal x,y;
-          x = ((*it).integers[2*i+1] == m_wdhcf)?(*it).integers[2*i+1]:(*it).integers[2*i+1]/*%m_wdhcf*/;
-          y = ((*it).integers[2*i+2] == m_hdvcf)?(*it).integers[2*i+2]:(*it).integers[2*i+2]/*%m_hdvcf*/;
-          {
-
-          }
-          QPointF p(
-                    x*m_scaleX +m_xMargin,
-                    (m_gh-y)*m_scaleY + m_yMargin
-                  );
-          polygon[i] = p;
-        }
-        m_boundingRect = polygon.boundingRect();
-//         kDebug() << "'" << element()->id() << "' set rect for polygon to " << rect;
-      }
-    }
-  }
-  setPos(0,0);
-}
-
-void CanvasElement::paint(QPainter* p, const QStyleOptionGraphicsItem *option,
-QWidget *widget)
-{
-  Q_UNUSED(option)
-  Q_UNUSED(widget)
-  /// computes the scaling of line width
-  qreal widthScaleFactor = (m_scaleX+m_scaleY)/2;
-  if (widthScaleFactor < 1)
-  {
-    widthScaleFactor = 1;
-  }
-  
-  QString msg;
-  QTextStream dd(&msg);
-  foreach (const DotRenderOp &op, element()->renderOperations())
-  {
-    dd << element()->id() << " an op: " << op.renderop << " ";
-    foreach (int i, op.integers)
-    {
-      dd << i << " ";
-    }
-    dd << op.str << endl;
-  }
-//   kDebug() << msg;
-
-  if (element()->renderOperations().isEmpty() && m_view->isReadWrite())
-  {
-    kError() << element()->id() << ": no render operation. This should not happen.";
-    return;
-  }
-
-  QListIterator<DotRenderOp> it(element()->renderOperations());
-//   it.toBack();
-
-  QColor lineColor = Dot2QtConsts::componentData().qtColor(element()->lineColor());
-  QColor backColor = Dot2QtConsts::componentData().qtColor(element()->backColor());
-  if (m_hovered && m_view->highlighting())
-  {
-    backColor = backColor.lighter();
-  }
-  
-  while (it.hasNext())
-  {
-    const DotRenderOp& dro = it.next();
-    if (dro.renderop == "c")
-    {
-      QColor c(dro.str.mid(0,7));
-      bool ok;
-      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
-      lineColor = c;
-//       kDebug() << "c" << dro.str.mid(0,7) << lineColor;
-    }
-    else if (dro.renderop == "C")
-    {
-      QColor c(dro.str.mid(0,7));
-      bool ok;
-      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
-      if (m_hovered && m_view->highlighting())
-      {
-        c = c.lighter();
-      }
-      backColor = c;
-//       kDebug() << "C" << dro.str.mid(0,7) << backColor;
-    }
-    else if (dro.renderop == "e" || dro.renderop == "E")
-    {
-      QPen pen = p->pen();
-      qreal w = m_scaleX * dro.integers[2] * 2;
-      qreal h = m_scaleY * dro.integers[3] * 2;
-      qreal x = m_xMargin + ((dro.integers[0]/*%m_wdhcf*/)*m_scaleX) - w/2;
-      qreal y = ((m_gh - dro.integers[1]/*%m_hdvcf*/)*m_scaleY) + m_yMargin - h/2;
-      QRectF rect(x,y,w,h);
-      p->save();
-      p->setBrush(backColor);
-      pen.setColor(lineColor);
-      if (element()->attributes().contains("penwidth"))
-      {
-        bool ok;
-        int lineWidth = element()->attributes()["penwidth"].toInt(&ok);
-        pen.setWidth(int(lineWidth * widthScaleFactor));
-      }
-      p->setPen(pen);
-      
-//       kDebug() << element()->id() << "drawEllipse" << lineColor << backColor << rect;
-//       rect = QRectF(0,0,100,100);
-      p->drawEllipse(rect);
-      p->restore();
-    }
-    else if(dro.renderop == "p" || dro.renderop == "P")
-    {
-//       std::cerr << "Drawing polygon for node '"<<element()->id()<<"': ";
-      QPolygonF points(dro.integers[0]);
-      for (int i = 0; i < dro.integers[0]; i++)
-      {
-        qreal x,y;
-        x = (dro.integers[2*i+1] == m_wdhcf)?dro.integers[2*i+1]:dro.integers[2*i+1]/*%m_wdhcf*/;
-        y = (dro.integers[2*i+2] == m_hdvcf)?dro.integers[2*i+2]:dro.integers[2*i+2]/*%m_hdvcf*/;
-        QPointF p(
-                  (x*m_scaleX) + m_xMargin,
-                  ((m_gh-y)*m_scaleY) + m_yMargin
-                );
-/*        kDebug() << "    point: (" << dro.integers[2*i+1] << ","
-                  << dro.integers[2*i+2] << ") " << m_wdhcf << "/" << m_hdvcf;*/
-        points[i] = p;
-      }
-      p->save();
-
-      QPen pen = p->pen();
-      pen.setColor(lineColor);
-      if (element()->style() == "bold")
-      {
-        pen.setStyle(Qt::SolidLine);
-        pen.setWidth(2);
-      }
-      if (element()->attributes().contains("penwidth"))
-      {
-        bool ok;
-        int lineWidth = element()->attributes()["penwidth"].toInt(&ok);
-        pen.setWidth(int(lineWidth * widthScaleFactor));
-      }
-      else if (element()->style() != "filled")
-      {
-        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(element()->style()));
-      }
-      if (element()->style().left(12) == "setlinewidth")
-      {
-        bool ok;
-        uint lineWidth = element()->style().mid(12, element()->style().length()-1-12).toInt(&ok);
-        pen.setWidth(lineWidth);
-      }
-      p->setPen(pen);
-      p->setBrush(backColor);
-/*      if (element()->style() == "filled")
-      {
-        p->setBrush(Dot2QtConsts::componentData().qtColor(element()->backColor()));
-    //     QCanvasPolygon::paint(p);
-      }
-      else
-      {
-        p->setBrush(canvas()->backgroundColor());
-      }*/
-//       kDebug() << element()->id() << "drawPolygon" << points;
-      p->drawPolygon(points);
-      p->restore();
-      if (!element()->shapeFile().isEmpty())
-      {
-        QPixmap pix(element()->shapeFile());
-        if (!pix.isNull())
-        {
-          p->drawPixmap(int(points.boundingRect().left()), int(points.boundingRect().top()), pix);
-        }
-      }
-    }
-
-  }
-
-  it.toFront();
-  while (it.hasNext())
-  {
-    const DotRenderOp& dro = it.next();
-    if (dro.renderop == "c")
-    {
-      QColor c(dro.str.mid(0,7));
-      bool ok;
-      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
-      lineColor = c;
-//       kDebug() << "c" << dro.str.mid(0,7) << lineColor;
-    }
-    else if (dro.renderop == "C")
-    {
-      QColor c(dro.str.mid(0,7));
-      bool ok;
-      c.setAlpha(255-dro.str.mid(8).toInt(&ok,16));
-      if (m_hovered && m_view->highlighting())
-      {
-        c = c.lighter();
-      }
-      backColor = c;
-//       kDebug() << "C" << dro.str.mid(0,7) << backColor;
-    }
-    else if ( dro.renderop == "L" )
-    {
-//       kDebug() << "Label";
-      QPolygonF points(dro.integers[0]);
-      for (int i = 0; i < dro.integers[0]; i++)
-      {
-        qreal x,y;
-        x = (dro.integers[2*i+1] == m_wdhcf)?dro.integers[2*i+1]:dro.integers[2*i+1]/*%m_wdhcf*/;
-        y = (dro.integers[2*i+2] == m_hdvcf)?dro.integers[2*i+2]:dro.integers[2*i+2]/*%m_hdvcf*/;
-        QPointF p(
-                  (x*m_scaleX) +m_xMargin,
-                  ((m_gh-y)*m_scaleY) + m_yMargin
-                );
-        points[i] = p;
-      }
-      p->save();
-      QPen pen(lineColor);
-      if (element()->style() == "bold")
-      {
-        pen.setStyle(Qt::SolidLine);
-        pen.setWidth(2);
-      }
-      else if (element()->style() != "filled")
-      {
-        pen.setStyle(Dot2QtConsts::componentData().qtPenStyle(element()->style()));
-      }
-      p->setPen(pen);
-//       kDebug() << element()->id() << "drawPolyline" << points;
-      p->drawPolyline(points);
-      p->restore();
-    }
-  }
-
-//   kDebug() << "Drawing" << element()->id() << "labels";
-  QString color = lineColor.name();
-  it.toFront();
-  while (it.hasNext())
-  {
-    const DotRenderOp& dro = it.next();
-    if (dro.renderop == "c" || dro.renderop == "C")
-    {
-      color = dro.str.mid(0,7);
-//       kDebug() << dro.renderop << color;
-    }
-    else if (dro.renderop == "F")
-    {
-      element()->setFontName(dro.str);
-      element()->setFontSize(dro.integers[0]);
-//       kDebug() << "F" << element()->fontName() << element()->fontColor() << element()->fontSize();
-    }
-    else if ( dro.renderop == "T" )
-    {
-      // we suppose here that the color has been set just before
-      element()->setFontColor(color);
-      // draw a label
-//       kDebug() << "Drawing a label " << dro.integers[0]
-//       << " " << dro.integers[1] << " " << dro.integers[2]
-//       << " " << dro.integers[3] << " " << dro.str
-//         << " (" << element()->fontName() << ", " << element()->fontSize()
-//         << ", " << element()->fontColor() << ")";
-
-      int stringWidthGoal = int(dro.integers[3] * m_scaleX);
-      int fontSize = element()->fontSize();
-//       kDebug() << element()->id() << " initial fontSize " << fontSize;
-      m_font->setPointSize(fontSize);
-      QFontMetrics fm(*m_font);
-      while (fm.width(dro.str) > stringWidthGoal && fontSize > 1)
-      {
-        fontSize--;
-        m_font->setPointSize(fontSize);
-        fm = QFontMetrics(*m_font);
-      }
-      p->save();
-      p->setFont(*m_font);
-      QPen pen(m_pen);
-      pen.setColor(element()->fontColor());
-      p->setPen(pen);
-      qreal x = (m_scaleX *
-                       (
-                         (dro.integers[0])
-                         + (((-dro.integers[2])*(fm.width(dro.str)))/2)
-                         - ( (fm.width(dro.str))/2 )
-                       )
-                      )
-                      + m_xMargin;
-      qreal y = ((m_gh - (dro.integers[1]))*m_scaleY)+ m_yMargin;
-      QPointF point(x,y);
-//       kDebug() << element()->id() << "drawText" << point << " " << fontSize;
-      p->drawText(point, dro.str);
-      p->restore();
-    }
-  }
-  if (element()->isSelected())
-  {
-//     kDebug() << "element is selected: draw selection marks";
-    p->save();
-    p->setBrush(Qt::black);
-    p->setPen(Qt::black);
-    p->drawRect(QRectF(m_boundingRect.topLeft(),QSizeF(6,6)));
-    p->drawRect(QRectF(m_boundingRect.topRight()-QPointF(6,0),QSizeF(6,6)));
-    p->drawRect(QRectF(m_boundingRect.bottomLeft()-QPointF(0,6),QSizeF(6,6)));
-    p->drawRect(QRectF(m_boundingRect.bottomRight()-QPointF(6,6),QSizeF(6,6)));
-    p->restore();
-  }
-}
-
-void CanvasElement::mousePressEvent(QGraphicsSceneMouseEvent* event)
-{
-  kDebug() << m_element->id() << boundingRect();
-  if (m_view->isReadOnly())
-  {
-    return;
-  }
-  if (m_view->editingMode() == DotGraphView::AddNewEdge)
-  {
-    m_view->createNewEdgeDraftFrom(this);
-    return;
-  }
-  else if (m_view->editingMode() == DotGraphView::DrawNewEdge)
-  {
-    m_view->finishNewEdgeTo(this);
-    return;
-  }
-  if (event->button() == Qt::LeftButton)
-  {
-    m_element->setSelected(!m_element->isSelected());
-    if (m_element->isSelected())
-    {
-      emit(selected(this,event->modifiers()));
-    }
-    update();
-  }
-  else if (event->button() == Qt::RightButton)
-  {
-    // opens the selected edge contextual menu and if necessary select the edge
-    if (!m_element->isSelected())
-    {
-      m_element->setSelected(true);
-      emit(selected(this,event->modifiers()));
-      update();
-    }
-    
-//     kDebug() << "opens the contextual menu";
-//     m_popup->exec(event->screenPos());
-    emit(elementContextMenuEvent(m_element->id(), event->screenPos() ));
-  }
-}
-
-void CanvasElement::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
-{
-  Q_UNUSED(event)
-//   kDebug() ;
-}
-
-void CanvasElement::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
-{
-  Q_UNUSED(event)
-//   kDebug() ;
-}
-
-void CanvasElement::slotRemoveElement()
-{
-  kDebug();
-  m_view->removeSelectedElements();
-}
-
-void CanvasElement::hoverEnterEvent( QGraphicsSceneHoverEvent * event )
-{
-  Q_UNUSED(event)
-//   kDebug();
-  m_hovered = true;
-  update();
-  emit hoverEnter(this);
-}
-
-void CanvasElement::hoverLeaveEvent( QGraphicsSceneHoverEvent * event )
-{
-  Q_UNUSED(event)
-//   kDebug();
-  m_hovered = false;
-  update();
-  emit hoverLeave(this);
-}
-
-}
-
-#include "canvaselement.moc"
diff --git a/src/part/canvaselement.h b/src/part/canvaselement.h
deleted file mode 100644
index d37a208..0000000
--- a/src/part/canvaselement.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/*
- * Canvas Subgraph (subgraph node view)
- */
-
-#ifndef CANVAS_ELEMENT_H
-#define CANVAS_ELEMENT_H
-
-#include <QAbstractGraphicsShapeItem>
-#include <QPen>
-#include <QBrush>
-
-class QMenu;
-class QGraphicsScene;
-
-
-namespace KGraphViewer
-{
-class GraphElement;
-class DotGraphView;
-
-class CanvasElement: public QObject, public QAbstractGraphicsShapeItem
-{
-Q_OBJECT
-public:
-  CanvasElement(
-      DotGraphView* v, 
-      GraphElement* s,
-      QGraphicsScene* c,
-      QGraphicsItem* parent = 0);
-      
-  virtual ~CanvasElement();
-  
-  GraphElement* element() { return m_element; }
-
-  virtual void paint(QPainter* p, const QStyleOptionGraphicsItem *option,
-        QWidget *widget = 0 );
-
-  virtual QRectF boundingRect () const;
-
-  void computeBoundingRect();
-  
-  void initialize(qreal scaleX, qreal scaleY,
-                  qreal xMargin, qreal yMargin, qreal gh,
-                  qreal wdhcf, qreal hdvcf);
-
-  inline void setGh(qreal gh) {m_gh = gh;}
-  
-  protected:
-  virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
-  virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
-  virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
-  virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
-  virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent * event );
-
-  qreal m_scaleX, m_scaleY;
-  qreal m_xMargin, m_yMargin, m_gh, m_wdhcf, m_hdvcf;
-  GraphElement* m_element;
-  DotGraphView* m_view;
-  QFont* m_font;
-  QPen m_pen;
-  QBrush m_brush;
-  QRectF m_boundingRect;
-  QMenu* m_popup;
-
-  bool m_hovered;
-  
-Q_SIGNALS:
-  void selected(CanvasElement*, Qt::KeyboardModifiers);
-  void elementContextMenuEvent(const QString&, const QPoint&);
-  void hoverEnter(CanvasElement*);
-  void hoverLeave(CanvasElement*);
-  
-public Q_SLOTS:
-  void modelChanged();
-  void slotRemoveElement();
-};
-
-}
-
-#endif // CANVAS_ELEMENT_H
-
-
-
diff --git a/src/part/canvasnode.cpp b/src/part/canvasnode.cpp
deleted file mode 100644
index 5688258..0000000
--- a/src/part/canvasnode.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.cpp, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Callgraph View
- */
-
-#include "canvasnode.h"
-#include "dotgraphview.h"
-#include "graphnode.h"
-#include "dotdefaults.h"
-#include "dot2qtconsts.h"
-#include "FontsCache.h"
-
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-
-#include <QGraphicsScene>
-#include <QMatrix>
-#include <QPainter>
-#include <QStyle>
-#include <QPolygonF>
-#include <QPixmap>
-
-#include <kdebug.h>
-#include <klocale.h>
-
-namespace KGraphViewer
-{
-  
-CanvasNode::CanvasNode(DotGraphView* v,
-                        GraphNode* s,
-                        QGraphicsScene* c,
-                        QGraphicsItem* parent)
-: CanvasElement(v,(GraphElement*)s, c, parent)
-
-{
-  kDebug() << s->id();
-  connect(s,SIGNAL(changed()),this,SLOT(modelChanged()));
-
-  QString tipStr;
-  QString id = s->id();
-  QString label = s->label();
-  tipStr = i18n("id='%1'\nlabel='%2'",id,label);
-//   kDebug() << "CanvasEllipseNode setToolTip " << tipStr;
-  setToolTip(tipStr);
-}
-
-// CanvasHtmlNode::CanvasHtmlNode(
-//                                           DotGraphView* v, 
-//                                           GraphNode* n,
-//                                           const DotRenderOp& dro,
-//                                           const DotRenderOpVec& dros,
-//                                           QGraphicsScene* c,
-//                                           double scaleX, double scaleY, 
-//                                           int xMargin, int yMargin, int gh,
-//                                           int wdhcf, int hdvcf
-//                                         )
-// : KHTMLPart(v->viewport()), CanvasNode(v, n)
-// {
-//   m_renderOperations = dros;
-// //   kDebug() << "Creating "<<node()->id()<<" CanvasHtmlNode for" << n
-// //     << " with label '" << n->label() << "'";
-// 
-//   QString myHTMLCode = n->label();
-//   myHTMLCode = myHTMLCode.mid(1, myHTMLCode.length() - 2);
-// //   kDebug() << "HTML = " << myHTMLCode;
-//   begin(KUrl(QString("file:") + QDir::currentPath() + "/index.html"));
-//   setAutoloadImages(true);
-//   write(myHTMLCode);
-//   kDebug() << "HTML written.";
-//   end();
-//   setStatusMessagesEnabled (false);
-// //   view()->setFrameShape ( QFrame::NoFrame );
-// //   view()->setFrameShadow ( QFrame::Plain );
-// //   view()->setLineWidth ( 0 );
-// //   view()->setMidLineWidth ( 0 );
-// //   view()->setHScrollBarMode ( Q3ScrollView::AlwaysOff );
-// //   view()->setVScrollBarMode ( Q3ScrollView::AlwaysOff );
-//   view()->setMarginWidth(0);
-//   view()->setMarginHeight(0);
-//   m_zoomFactor = m_view->zoom();
-//   view()->part()->setZoomFactor(int(m_zoomFactor*100));
-//   view()->move(int(n->x()*scaleX*m_zoomFactor), int((gh-n->y())*scaleY*m_zoomFactor));
-//   view()->setMinimumSize(int(n->w()*scaleX),int(n->h()*scaleY*m_zoomFactor));
-//   view()->setMaximumSize(int(n->w()*scaleX),int(n->h()*scaleY*m_zoomFactor));
-//   view()->adjustSize();
-//   KHTMLPart::show();
-//   CanvasHtmlNode::connect(v, SIGNAL(contentsMoving ( int, int)), this, SLOT(move(int, int)));
-//   CanvasHtmlNode::connect(v, SIGNAL(zoomed (double)), this, SLOT(zoomed(double)));
-// }
-// 
-// CanvasHtmlNode::~CanvasHtmlNode() 
-// {
-//   KHTMLPart::hide();
-// }
-// 
-// // void CanvasHtmlNode::paint(QPainter& p)
-// // {
-// //   view()->drawContents(&p);
-// // }
-// 
-// void CanvasHtmlNode::move(int x, int y)
-// {
-// //   kDebug() << "CanvasHtmlNode::move("<<x<<", "<<y<<")";
-//   m_xMovedTo = x; m_yMovedTo = y;
-//   view()->move(int((node()->x())*m_scaleX*m_zoomFactor - m_xMovedTo), int((m_gh-node()->y())*m_scaleY*m_zoomFactor) - m_yMovedTo);
-// //   view()->move(int(x*m_scaleX), int((m_gh-y)*m_scaleY));
-// }
-// 
-// void CanvasHtmlNode::zoomed(double factor)
-// {
-//   m_zoomFactor = factor;
-//   view()->part()->setZoomFactor(int(factor*100));
-//   view()->move(int(node()->x()*m_scaleX*m_zoomFactor - m_xMovedTo), int((m_gh-node()->y())*m_scaleY*m_zoomFactor - m_yMovedTo));
-//   view()->setMinimumSize(int(node()->w()*m_scaleX*m_zoomFactor),int(node()->h()*m_scaleY*m_zoomFactor));
-//   view()->setMaximumSize(int(node()->w()*m_scaleX*m_zoomFactor),int(node()->h()*m_scaleY*m_zoomFactor));
-//   view()->adjustSize();
-// }
-
-}
-
-#include "canvasnode.moc"
diff --git a/src/part/canvasnode.h b/src/part/canvasnode.h
deleted file mode 100644
index fdb8436..0000000
--- a/src/part/canvasnode.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-/*
- * Canvas Node (graph node view)
- */
-
-#ifndef CANVAS_NODE_H
-#define CANVAS_NODE_H
-
-#include "canvaselement.h"
-
-namespace KGraphViewer
-{
-  
-class GraphNode;
-
-class CanvasNode : public CanvasElement
-{
-  Q_OBJECT
-public:
-  CanvasNode(DotGraphView* v,
-            GraphNode* s,
-            QGraphicsScene* c,
-            QGraphicsItem* parent = 0);
-  
-  virtual ~CanvasNode() {}
-  
-};
-
-// class CanvasHtmlNode: public KHTMLPart, public CanvasNode
-// {
-//   Q_OBJECT
-// public:
-//   CanvasHtmlNode(
-//                      DotGraphView* v, 
-//                      GraphNode* n,
-//                      const DotRenderOp& dro,
-//                      const DotRenderOpVec& dros,
-//                      QGraphicsScene* c,
-//                      double scaleX, double scaleY, int xMargin, int yMargin, int gh,
-//                      int wdhcf, int hdvcf);
-//   virtual ~CanvasHtmlNode();
-//   
-//   QRect rect() {return view()->contentsRect();}
-//   
-// protected:
-// //   virtual void paint(QPainter&);
-// 
-// public slots:
-//   void move(int x, int y);
-//   void zoomed(double factor);
-// 
-// private:
-//   double m_zoomFactor;
-//   int m_xMovedTo, m_yMovedTo;
-// };
-
-}
-#endif
-
-
-
diff --git a/src/part/canvassubgraph.cpp b/src/part/canvassubgraph.cpp
deleted file mode 100644
index a0ea4b4..0000000
--- a/src/part/canvassubgraph.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-
-#include "canvassubgraph.h"
-
-namespace KGraphViewer
-{
-  
-  
-CanvasSubgraph::CanvasSubgraph(
-                              DotGraphView* v,
-                              GraphSubgraph* gsubgraph,
-                              QGraphicsScene* c,
-                              QGraphicsItem* parent
-                            ) : CanvasElement(v,(GraphElement*)gsubgraph,c,parent)
-{
-}
-
-}
-
-#include "canvassubgraph.moc"
diff --git a/src/part/canvassubgraph.h b/src/part/canvassubgraph.h
deleted file mode 100644
index 868a516..0000000
--- a/src/part/canvassubgraph.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/*
- * Canvas Subgraph (subgraph node view)
- */
-
-#ifndef CANVAS_SUBGRAPH_H
-#define CANVAS_SUBGRAPH_H
-
-#include "canvaselement.h"
-
-class QGraphicsScene;
-
-namespace KGraphViewer
-{
-  
-class GraphSubgraph;
-class DotGraphView;
-
-class CanvasSubgraph: public CanvasElement
-{
-  Q_OBJECT
-
-public:
-  CanvasSubgraph(
-      DotGraphView* v, 
-      GraphSubgraph* s,
-      QGraphicsScene* c,
-      QGraphicsItem* parent = 0);
-  virtual ~CanvasSubgraph() {}
-  
-protected:
-};
-
-}
-
-#endif
-
-
-
diff --git a/src/part/dot2qtconsts.cpp b/src/part/dot2qtconsts.cpp
deleted file mode 100644
index d1fba1f..0000000
--- a/src/part/dot2qtconsts.cpp
+++ /dev/null
@@ -1,939 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-2007 by Gael de Chalendar (aka Kleag)  *
- *   kleag at free.fr   *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
- ***************************************************************************/
-#include "dot2qtconsts.h"
-#include "dotgrammar.h"
-#include "canvasnode.h"
-
-#include <kdebug.h> 
-#include <QColor>
-
-Dot2QtConsts* Dot2QtConsts::m_componentData = new Dot2QtConsts();
-
-static const struct {
-    const char * input;
-    const char * roman;
-    const char * italic;
-    const char * bold;
-    const char * boldItalic;
-    const char * light;
-    const char * lightItalic;
-} postscriptFontNames[] = {
-    { "arial", "Arial", 0, 0, 0, 0, 0 },
-    { "avantgarde", "AvantGarde-Book", 0, 0, 0, 0, 0 },
-    { "charter", "CharterBT-Roman", 0, 0, 0, 0, 0 },
-    { "garamond", "Garamond-Regular", 0, 0, 0, 0, 0 },
-    { "gillsans", "GillSans", 0, 0, 0, 0, 0 },
-    { "helvetica",
-      "Helvetica", "Helvetica-Oblique",
-      "Helvetica-Bold", "Helvetica-BoldOblique",
-      "Helvetica-Outline", "Helvetica-OutlineOblique" },
-    { "palatino",
-      "Palatino", "Palatino-Italic",
-      "Palatino-Bold", "Palatino-BoldItalic",
-      "Palatino", "Palatino-Italic" },
-    { "times",
-      "Times-Roman", "Times-Italic",
-      "Times-Bold", "Times-BoldItalic",
-      "Times-Outline", "Times-Italic" },
-    { "new century schoolbook", "NewCenturySchlbk-Roman", 0, 0, 0, 0, 0 },
-    { "symbol", "Symbol", "Symbol", "Symbol", "Symbol", "Symbol", "Symbol" },
-    { "terminal", "Courier", 0, 0, 0, 0, 0 },
-    { "times new roman", "TimesNewRoman", 0, 0, 0, 0, 0 },
-    { "utopia", "Utopia-Regular", 0, 0, 0, 0, 0 },
-    { 0, 0, 0, 0, 0, 0, 0 }
-};
-    
-static const struct {
-    const char * name;
-    unsigned int r;
-    unsigned int g;
-    unsigned int b;
-} color_lib[] = {
-    { "snow", 255, 250, 250 },
-    { "ghost white", 248, 248, 255 },
-    { "ghostwhite", 248, 248, 255 },
-    { "white smoke", 245, 245, 245 },
-    { "whitesmoke", 245, 245, 245 },
-    { "gainsboro", 220, 220, 220 },
-    { "floral white", 255, 250, 240 },
-    { "floralwhite", 255, 250, 240 },
-    { "old lace", 253, 245, 230 },
-    { "oldlace", 253, 245, 230 },
-    { "linen", 250, 240, 230 },
-    { "antique white", 250, 235, 215 },
-    { "antiquewhite", 250, 235, 215 },
-    { "papaya whip", 255, 239, 213 },
-    { "papayawhip", 255, 239, 213 },
-    { "blanched almond", 255, 235, 205 },
-    { "blanchedalmond", 255, 235, 205 },
-    { "bisque", 255, 228, 196 },
-    { "peach puff", 255, 218, 185 },
-    { "peachpuff", 255, 218, 185 },
-    { "navajo white", 255, 222, 173 },
-    { "navajowhite", 255, 222, 173 },
-    { "moccasin", 255, 228, 181 },
-    { "cornsilk", 255, 248, 220 },
-    { "ivory", 255, 255, 240 },
-    { "lemon chiffon", 255, 250, 205 },
-    { "lemonchiffon", 255, 250, 205 },
-    { "seashell", 255, 245, 238 },
-    { "honeydew", 240, 255, 240 },
-    { "mint cream", 245, 255, 250 },
-    { "mintcream", 245, 255, 250 },
-    { "azure", 240, 255, 255 },
-    { "alice blue", 240, 248, 255 },
-    { "aliceblue", 240, 248, 255 },
-    { "lavender", 230, 230, 250 },
-    { "lavender blush", 255, 240, 245 },
-    { "lavenderblush", 255, 240, 245 },
-    { "misty rose", 255, 228, 225 },
-    { "mistyrose", 255, 228, 225 },
-    { "white", 255, 255, 255 },
-    { "black", 0, 0, 0 },
-    { "dark slate gray", 47, 79, 79 },
-    { "darkslategray", 47, 79, 79 },
-    { "dark slate grey", 47, 79, 79 },
-    { "darkslategrey", 47, 79, 79 },
-    { "dim gray", 105, 105, 105 },
-    { "dimgray", 105, 105, 105 },
-    { "dim grey", 105, 105, 105 },
-    { "dimgrey", 105, 105, 105 },
-    { "slate gray", 112, 128, 144 },
-    { "slategray", 112, 128, 144 },
-    { "slate grey", 112, 128, 144 },
-    { "slategrey", 112, 128, 144 },
-    { "light slate gray", 119, 136, 153 },
-    { "lightslategray", 119, 136, 153 },
-    { "light slate grey", 119, 136, 153 },
-    { "lightslategrey", 119, 136, 153 },
-    { "gray", 190, 190, 190 },
-    { "grey", 190, 190, 190 },
-    { "light grey", 211, 211, 211 },
-    { "lightgrey", 211, 211, 211 },
-    { "light gray", 211, 211, 211 },
-    { "lightgray", 211, 211, 211 },
-    { "midnight blue", 25, 25, 112 },
-    { "midnightblue", 25, 25, 112 },
-    { "navy", 0, 0, 128 },
-    { "navy blue", 0, 0, 128 },
-    { "navyblue", 0, 0, 128 },
-    { "cornflower blue", 100, 149, 237 },
-    { "cornflowerblue", 100, 149, 237 },
-    { "dark slate blue", 72, 61, 139 },
-    { "darkslateblue", 72, 61, 139 },
-    { "slate blue", 106, 90, 205 },
-    { "slateblue", 106, 90, 205 },
-    { "medium slate blue", 123, 104, 238 },
-    { "mediumslateblue", 123, 104, 238 },
-    { "light slate blue", 132, 112, 255 },
-    { "lightslateblue", 132, 112, 255 },
-    { "medium blue", 0, 0, 205 },
-    { "mediumblue", 0, 0, 205 },
-    { "royal blue", 65, 105, 225 },
-    { "royalblue", 65, 105, 225 },
-    { "blue", 0, 0, 255 },
-    { "dodger blue", 30, 144, 255 },
-    { "dodgerblue", 30, 144, 255 },
-    { "deep sky blue", 0, 191, 255 },
-    { "deepskyblue", 0, 191, 255 },
-    { "sky blue", 135, 206, 235 },
-    { "skyblue", 135, 206, 235 },
-    { "light sky blue", 135, 206, 250 },
-    { "lightskyblue", 135, 206, 250 },
-    { "steel blue", 70, 130, 180 },
-    { "steelblue", 70, 130, 180 },
-    { "light steel blue", 176, 196, 222 },
-    { "lightsteelblue", 176, 196, 222 },
-    { "light blue", 173, 216, 230 },
-    { "lightblue", 173, 216, 230 },
-    { "powder blue", 176, 224, 230 },
-    { "powderblue", 176, 224, 230 },
-    { "pale turquoise", 175, 238, 238 },
-    { "paleturquoise", 175, 238, 238 },
-    { "dark turquoise", 0, 206, 209 },
-    { "darkturquoise", 0, 206, 209 },
-    { "medium turquoise", 72, 209, 204 },
-    { "mediumturquoise", 72, 209, 204 },
-    { "turquoise", 64, 224, 208 },
-    { "cyan", 0, 255, 255 },
-    { "light cyan", 224, 255, 255 },
-    { "lightcyan", 224, 255, 255 },
-    { "cadet blue", 95, 158, 160 },
-    { "cadetblue", 95, 158, 160 },
-    { "medium aquamarine", 102, 205, 170 },
-    { "mediumaquamarine", 102, 205, 170 },
-    { "aquamarine", 127, 255, 212 },
-    { "dark green", 0, 100, 0 },
-    { "darkgreen", 0, 100, 0 },
-    { "dark olive green", 85, 107, 47 },
-    { "darkolivegreen", 85, 107, 47 },
-    { "dark sea green", 143, 188, 143 },
-    { "darkseagreen", 143, 188, 143 },
-    { "sea green", 46, 139, 87 },
-    { "seagreen", 46, 139, 87 },
-    { "medium sea green", 60, 179, 113 },
-    { "mediumseagreen", 60, 179, 113 },
-    { "light sea green", 32, 178, 170 },
-    { "lightseagreen", 32, 178, 170 },
-    { "pale green", 152, 251, 152 },
-    { "palegreen", 152, 251, 152 },
-    { "spring green", 0, 255, 127 },
-    { "springgreen", 0, 255, 127 },
-    { "lawn green", 124, 252, 0 },
-    { "lawngreen", 124, 252, 0 },
-    { "green", 0, 255, 0 },
-    { "chartreuse", 127, 255, 0 },
-    { "medium spring green", 0, 250, 154 },
-    { "mediumspringgreen", 0, 250, 154 },
-    { "green yellow", 173, 255, 47 },
-    { "greenyellow", 173, 255, 47 },
-    { "lime green", 50, 205, 50 },
-    { "limegreen", 50, 205, 50 },
-    { "yellow green", 154, 205, 50 },
-    { "yellowgreen", 154, 205, 50 },
-    { "forest green", 34, 139, 34 },
-    { "forestgreen", 34, 139, 34 },
-    { "olive drab", 107, 142, 35 },
-    { "olivedrab", 107, 142, 35 },
-    { "dark khaki", 189, 183, 107 },
-    { "darkkhaki", 189, 183, 107 },
-    { "khaki", 240, 230, 140 },
-    { "pale goldenrod", 238, 232, 170 },
-    { "palegoldenrod", 238, 232, 170 },
-    { "light goldenrod yellow", 250, 250, 210 },
-    { "lightgoldenrodyellow", 250, 250, 210 },
-    { "light yellow", 255, 255, 224 },
-    { "lightyellow", 255, 255, 224 },
-    { "yellow", 255, 255, 0 },
-    { "gold", 255, 215, 0 },
-    { "light goldenrod", 238, 221, 130 },
-    { "lightgoldenrod", 238, 221, 130 },
-    { "goldenrod", 218, 165, 32 },
-    { "dark goldenrod", 184, 134, 11 },
-    { "darkgoldenrod", 184, 134, 11 },
-    { "rosy brown", 188, 143, 143 },
-    { "rosybrown", 188, 143, 143 },
-    { "indian red", 205, 92, 92 },
-    { "indianred", 205, 92, 92 },
-    { "saddle brown", 139, 69, 19 },
-    { "saddlebrown", 139, 69, 19 },
-    { "sienna", 160, 82, 45 },
-    { "peru", 205, 133, 63 },
-    { "burlywood", 222, 184, 135 },
-    { "beige", 245, 245, 220 },
-    { "wheat", 245, 222, 179 },
-    { "sandy brown", 244, 164, 96 },
-    { "sandybrown", 244, 164, 96 },
-    { "tan", 210, 180, 140 },
-    { "chocolate", 210, 105, 30 },
-    { "firebrick", 178, 34, 34 },
-    { "brown", 165, 42, 42 },
-    { "dark salmon", 233, 150, 122 },
-    { "darksalmon", 233, 150, 122 },
-    { "salmon", 250, 128, 114 },
-    { "light salmon", 255, 160, 122 },
-    { "lightsalmon", 255, 160, 122 },
-    { "orange", 255, 165, 0 },
-    { "dark orange", 255, 140, 0 },
-    { "darkorange", 255, 140, 0 },
-    { "coral", 255, 127, 80 },
-    { "light coral", 240, 128, 128 },
-    { "lightcoral", 240, 128, 128 },
-    { "tomato", 255, 99, 71 },
-    { "orange red", 255, 69, 0 },
-    { "orangered", 255, 69, 0 },
-    { "red", 255, 0, 0 },
-    { "hot pink", 255, 105, 180 },
-    { "hotpink", 255, 105, 180 },
-    { "deep pink", 255, 20, 147 },
-    { "deeppink", 255, 20, 147 },
-    { "pink", 255, 192, 203 },
-    { "light pink", 255, 182, 193 },
-    { "lightpink", 255, 182, 193 },
-    { "pale violet red", 219, 112, 147 },
-    { "palevioletred", 219, 112, 147 },
-    { "maroon", 176, 48, 96 },
-    { "medium violet red", 199, 21, 133 },
-    { "mediumvioletred", 199, 21, 133 },
-    { "violet red", 208, 32, 144 },
-    { "violetred", 208, 32, 144 },
-    { "magenta", 255, 0, 255 },
-    { "violet", 238, 130, 238 },
-    { "plum", 221, 160, 221 },
-    { "orchid", 218, 112, 214 },
-    { "medium orchid", 186, 85, 211 },
-    { "mediumorchid", 186, 85, 211 },
-    { "dark orchid", 153, 50, 204 },
-    { "darkorchid", 153, 50, 204 },
-    { "dark violet", 148, 0, 211 },
-    { "darkviolet", 148, 0, 211 },
-    { "blue violet", 138, 43, 226 },
-    { "blueviolet", 138, 43, 226 },
-    { "purple", 160, 32, 240 },
-    { "medium purple", 147, 112, 219 },
-    { "mediumpurple", 147, 112, 219 },
-    { "thistle", 216, 191, 216 },
-    { "snow1", 255, 250, 250 },
-    { "snow2", 238, 233, 233 },
-    { "snow3", 205, 201, 201 },
-    { "snow4", 139, 137, 137 },
-    { "seashell1", 255, 245, 238 },
-    { "seashell2", 238, 229, 222 },
-    { "seashell3", 205, 197, 191 },
-    { "seashell4", 139, 134, 130 },
-    { "antiquewhite1", 255, 239, 219 },
-    { "antiquewhite2", 238, 223, 204 },
-    { "antiquewhite3", 205, 192, 176 },
-    { "antiquewhite4", 139, 131, 120 },
-    { "bisque1", 255, 228, 196 },
-    { "bisque2", 238, 213, 183 },
-    { "bisque3", 205, 183, 158 },
-    { "bisque4", 139, 125, 107 },
-    { "peachpuff1", 255, 218, 185 },
-    { "peachpuff2", 238, 203, 173 },
-    { "peachpuff3", 205, 175, 149 },
-    { "peachpuff4", 139, 119, 101 },
-    { "navajowhite1", 255, 222, 173 },
-    { "navajowhite2", 238, 207, 161 },
-    { "navajowhite3", 205, 179, 139 },
-    { "navajowhite4", 139, 121, 94 },
-    { "lemonchiffon1", 255, 250, 205 },
-    { "lemonchiffon2", 238, 233, 191 },
-    { "lemonchiffon3", 205, 201, 165 },
-    { "lemonchiffon4", 139, 137, 112 },
-    { "cornsilk1", 255, 248, 220 },
-    { "cornsilk2", 238, 232, 205 },
-    { "cornsilk3", 205, 200, 177 },
-    { "cornsilk4", 139, 136, 120 },
-    { "ivory1", 255, 255, 240 },
-    { "ivory2", 238, 238, 224 },
-    { "ivory3", 205, 205, 193 },
-    { "ivory4", 139, 139, 131 },
-    { "honeydew1", 240, 255, 240 },
-    { "honeydew2", 224, 238, 224 },
-    { "honeydew3", 193, 205, 193 },
-    { "honeydew4", 131, 139, 131 },
-    { "lavenderblush1", 255, 240, 245 },
-    { "lavenderblush2", 238, 224, 229 },
-    { "lavenderblush3", 205, 193, 197 },
-    { "lavenderblush4", 139, 131, 134 },
-    { "mistyrose1", 255, 228, 225 },
-    { "mistyrose2", 238, 213, 210 },
-    { "mistyrose3", 205, 183, 181 },
-    { "mistyrose4", 139, 125, 123 },
-    { "azure1", 240, 255, 255 },
-    { "azure2", 224, 238, 238 },
-    { "azure3", 193, 205, 205 },
-    { "azure4", 131, 139, 139 },
-    { "slateblue1", 131, 111, 255 },
-    { "slateblue2", 122, 103, 238 },
-    { "slateblue3", 105, 89, 205 },
-    { "slateblue4", 71, 60, 139 },
-    { "royalblue1", 72, 118, 255 },
-    { "royalblue2", 67, 110, 238 },
-    { "royalblue3", 58, 95, 205 },
-    { "royalblue4", 39, 64, 139 },
-    { "blue1", 0, 0, 255 },
-    { "blue2", 0, 0, 238 },
-    { "blue3", 0, 0, 205 },
-    { "blue4", 0, 0, 139 },
-    { "dodgerblue1", 30, 144, 255 },
-    { "dodgerblue2", 28, 134, 238 },
-    { "dodgerblue3", 24, 116, 205 },
-    { "dodgerblue4", 16, 78, 139 },
-    { "steelblue1", 99, 184, 255 },
-    { "steelblue2", 92, 172, 238 },
-    { "steelblue3", 79, 148, 205 },
-    { "steelblue4", 54, 100, 139 },
-    { "deepskyblue1", 0, 191, 255 },
-    { "deepskyblue2", 0, 178, 238 },
-    { "deepskyblue3", 0, 154, 205 },
-    { "deepskyblue4", 0, 104, 139 },
-    { "skyblue1", 135, 206, 255 },
-    { "skyblue2", 126, 192, 238 },
-    { "skyblue3", 108, 166, 205 },
-    { "skyblue4", 74, 112, 139 },
-    { "lightskyblue1", 176, 226, 255 },
-    { "lightskyblue2", 164, 211, 238 },
-    { "lightskyblue3", 141, 182, 205 },
-    { "lightskyblue4", 96, 123, 139 },
-    { "slategray1", 198, 226, 255 },
-    { "slategray2", 185, 211, 238 },
-    { "slategray3", 159, 182, 205 },
-    { "slategray4", 108, 123, 139 },
-    { "lightsteelblue1", 202, 225, 255 },
-    { "lightsteelblue2", 188, 210, 238 },
-    { "lightsteelblue3", 162, 181, 205 },
-    { "lightsteelblue4", 110, 123, 139 },
-    { "lightblue1", 191, 239, 255 },
-    { "lightblue2", 178, 223, 238 },
-    { "lightblue3", 154, 192, 205 },
-    { "lightblue4", 104, 131, 139 },
-    { "lightcyan1", 224, 255, 255 },
-    { "lightcyan2", 209, 238, 238 },
-    { "lightcyan3", 180, 205, 205 },
-    { "lightcyan4", 122, 139, 139 },
-    { "paleturquoise1", 187, 255, 255 },
-    { "paleturquoise2", 174, 238, 238 },
-    { "paleturquoise3", 150, 205, 205 },
-    { "paleturquoise4", 102, 139, 139 },
-    { "cadetblue1", 152, 245, 255 },
-    { "cadetblue2", 142, 229, 238 },
-    { "cadetblue3", 122, 197, 205 },
-    { "cadetblue4", 83, 134, 139 },
-    { "turquoise1", 0, 245, 255 },
-    { "turquoise2", 0, 229, 238 },
-    { "turquoise3", 0, 197, 205 },
-    { "turquoise4", 0, 134, 139 },
-    { "cyan1", 0, 255, 255 },
-    { "cyan2", 0, 238, 238 },
-    { "cyan3", 0, 205, 205 },
-    { "cyan4", 0, 139, 139 },
-    { "darkslategray1", 151, 255, 255 },
-    { "darkslategray2", 141, 238, 238 },
-    { "darkslategray3", 121, 205, 205 },
-    { "darkslategray4", 82, 139, 139 },
-    { "aquamarine1", 127, 255, 212 },
-    { "aquamarine2", 118, 238, 198 },
-    { "aquamarine3", 102, 205, 170 },
-    { "aquamarine4", 69, 139, 116 },
-    { "darkseagreen1", 193, 255, 193 },
-    { "darkseagreen2", 180, 238, 180 },
-    { "darkseagreen3", 155, 205, 155 },
-    { "darkseagreen4", 105, 139, 105 },
-    { "seagreen1", 84, 255, 159 },
-    { "seagreen2", 78, 238, 148 },
-    { "seagreen3", 67, 205, 128 },
-    { "seagreen4", 46, 139, 87 },
-    { "palegreen1", 154, 255, 154 },
-    { "palegreen2", 144, 238, 144 },
-    { "palegreen3", 124, 205, 124 },
-    { "palegreen4", 84, 139, 84 },
-    { "springgreen1", 0, 255, 127 },
-    { "springgreen2", 0, 238, 118 },
-    { "springgreen3", 0, 205, 102 },
-    { "springgreen4", 0, 139, 69 },
-    { "green1", 0, 255, 0 },
-    { "green2", 0, 238, 0 },
-    { "green3", 0, 205, 0 },
-    { "green4", 0, 139, 0 },
-    { "chartreuse1", 127, 255, 0 },
-    { "chartreuse2", 118, 238, 0 },
-    { "chartreuse3", 102, 205, 0 },
-    { "chartreuse4", 69, 139, 0 },
-    { "olivedrab1", 192, 255, 62 },
-    { "olivedrab2", 179, 238, 58 },
-    { "olivedrab3", 154, 205, 50 },
-    { "olivedrab4", 105, 139, 34 },
-    { "darkolivegreen1", 202, 255, 112 },
-    { "darkolivegreen2", 188, 238, 104 },
-    { "darkolivegreen3", 162, 205, 90 },
-    { "darkolivegreen4", 110, 139, 61 },
-    { "khaki1", 255, 246, 143 },
-    { "khaki2", 238, 230, 133 },
-    { "khaki3", 205, 198, 115 },
-    { "khaki4", 139, 134, 78 },
-    { "lightgoldenrod1", 255, 236, 139 },
-    { "lightgoldenrod2", 238, 220, 130 },
-    { "lightgoldenrod3", 205, 190, 112 },
-    { "lightgoldenrod4", 139, 129, 76 },
-    { "lightyellow1", 255, 255, 224 },
-    { "lightyellow2", 238, 238, 209 },
-    { "lightyellow3", 205, 205, 180 },
-    { "lightyellow4", 139, 139, 122 },
-    { "yellow1", 255, 255, 0 },
-    { "yellow2", 238, 238, 0 },
-    { "yellow3", 205, 205, 0 },
-    { "yellow4", 139, 139, 0 },
-    { "gold1", 255, 215, 0 },
-    { "gold2", 238, 201, 0 },
-    { "gold3", 205, 173, 0 },
-    { "gold4", 139, 117, 0 },
-    { "goldenrod1", 255, 193, 37 },
-    { "goldenrod2", 238, 180, 34 },
-    { "goldenrod3", 205, 155, 29 },
-    { "goldenrod4", 139, 105, 20 },
-    { "darkgoldenrod1", 255, 185, 15 },
-    { "darkgoldenrod2", 238, 173, 14 },
-    { "darkgoldenrod3", 205, 149, 12 },
-    { "darkgoldenrod4", 139, 101, 8 },
-    { "rosybrown1", 255, 193, 193 },
-    { "rosybrown2", 238, 180, 180 },
-    { "rosybrown3", 205, 155, 155 },
-    { "rosybrown4", 139, 105, 105 },
-    { "indianred1", 255, 106, 106 },
-    { "indianred2", 238, 99, 99 },
-    { "indianred3", 205, 85, 85 },
-    { "indianred4", 139, 58, 58 },
-    { "sienna1", 255, 130, 71 },
-    { "sienna2", 238, 121, 66 },
-    { "sienna3", 205, 104, 57 },
-    { "sienna4", 139, 71, 38 },
-    { "burlywood1", 255, 211, 155 },
-    { "burlywood2", 238, 197, 145 },
-    { "burlywood3", 205, 170, 125 },
-    { "burlywood4", 139, 115, 85 },
-    { "wheat1", 255, 231, 186 },
-    { "wheat2", 238, 216, 174 },
-    { "wheat3", 205, 186, 150 },
-    { "wheat4", 139, 126, 102 },
-    { "tan1", 255, 165, 79 },
-    { "tan2", 238, 154, 73 },
-    { "tan3", 205, 133, 63 },
-    { "tan4", 139, 90, 43 },
-    { "chocolate1", 255, 127, 36 },
-    { "chocolate2", 238, 118, 33 },
-    { "chocolate3", 205, 102, 29 },
-    { "chocolate4", 139, 69, 19 },
-    { "firebrick1", 255, 48, 48 },
-    { "firebrick2", 238, 44, 44 },
-    { "firebrick3", 205, 38, 38 },
-    { "firebrick4", 139, 26, 26 },
-    { "brown1", 255, 64, 64 },
-    { "brown2", 238, 59, 59 },
-    { "brown3", 205, 51, 51 },
-    { "brown4", 139, 35, 35 },
-    { "salmon1", 255, 140, 105 },
-    { "salmon2", 238, 130, 98 },
-    { "salmon3", 205, 112, 84 },
-    { "salmon4", 139, 76, 57 },
-    { "lightsalmon1", 255, 160, 122 },
-    { "lightsalmon2", 238, 149, 114 },
-    { "lightsalmon3", 205, 129, 98 },
-    { "lightsalmon4", 139, 87, 66 },
-    { "orange1", 255, 165, 0 },
-    { "orange2", 238, 154, 0 },
-    { "orange3", 205, 133, 0 },
-    { "orange4", 139, 90, 0 },
-    { "darkorange1", 255, 127, 0 },
-    { "darkorange2", 238, 118, 0 },
-    { "darkorange3", 205, 102, 0 },
-    { "darkorange4", 139, 69, 0 },
-    { "coral1", 255, 114, 86 },
-    { "coral2", 238, 106, 80 },
-    { "coral3", 205, 91, 69 },
-    { "coral4", 139, 62, 47 },
-    { "tomato1", 255, 99, 71 },
-    { "tomato2", 238, 92, 66 },
-    { "tomato3", 205, 79, 57 },
-    { "tomato4", 139, 54, 38 },
-    { "orangered1", 255, 69, 0 },
-    { "orangered2", 238, 64, 0 },
-    { "orangered3", 205, 55, 0 },
-    { "orangered4", 139, 37, 0 },
-    { "red1", 255, 0, 0 },
-    { "red2", 238, 0, 0 },
-    { "red3", 205, 0, 0 },
-    { "red4", 139, 0, 0 },
-    { "deeppink1", 255, 20, 147 },
-    { "deeppink2", 238, 18, 137 },
-    { "deeppink3", 205, 16, 118 },
-    { "deeppink4", 139, 10, 80 },
-    { "hotpink1", 255, 110, 180 },
-    { "hotpink2", 238, 106, 167 },
-    { "hotpink3", 205, 96, 144 },
-    { "hotpink4", 139, 58, 98 },
-    { "pink1", 255, 181, 197 },
-    { "pink2", 238, 169, 184 },
-    { "pink3", 205, 145, 158 },
-    { "pink4", 139, 99, 108 },
-    { "lightpink1", 255, 174, 185 },
-    { "lightpink2", 238, 162, 173 },
-    { "lightpink3", 205, 140, 149 },
-    { "lightpink4", 139, 95, 101 },
-    { "palevioletred1", 255, 130, 171 },
-    { "palevioletred2", 238, 121, 159 },
-    { "palevioletred3", 205, 104, 137 },
-    { "palevioletred4", 139, 71, 93 },
-    { "maroon1", 255, 52, 179 },
-    { "maroon2", 238, 48, 167 },
-    { "maroon3", 205, 41, 144 },
-    { "maroon4", 139, 28, 98 },
-    { "violetred1", 255, 62, 150 },
-    { "violetred2", 238, 58, 140 },
-    { "violetred3", 205, 50, 120 },
-    { "violetred4", 139, 34, 82 },
-    { "magenta1", 255, 0, 255 },
-    { "magenta2", 238, 0, 238 },
-    { "magenta3", 205, 0, 205 },
-    { "magenta4", 139, 0, 139 },
-    { "orchid1", 255, 131, 250 },
-    { "orchid2", 238, 122, 233 },
-    { "orchid3", 205, 105, 201 },
-    { "orchid4", 139, 71, 137 },
-    { "plum1", 255, 187, 255 },
-    { "plum2", 238, 174, 238 },
-    { "plum3", 205, 150, 205 },
-    { "plum4", 139, 102, 139 },
-    { "mediumorchid1", 224, 102, 255 },
-    { "mediumorchid2", 209, 95, 238 },
-    { "mediumorchid3", 180, 82, 205 },
-    { "mediumorchid4", 122, 55, 139 },
-    { "darkorchid1", 191, 62, 255 },
-    { "darkorchid2", 178, 58, 238 },
-    { "darkorchid3", 154, 50, 205 },
-    { "darkorchid4", 104, 34, 139 },
-    { "purple1", 155, 48, 255 },
-    { "purple2", 145, 44, 238 },
-    { "purple3", 125, 38, 205 },
-    { "purple4", 85, 26, 139 },
-    { "mediumpurple1", 171, 130, 255 },
-    { "mediumpurple2", 159, 121, 238 },
-    { "mediumpurple3", 137, 104, 205 },
-    { "mediumpurple4", 93, 71, 139 },
-    { "thistle1", 255, 225, 255 },
-    { "thistle2", 238, 210, 238 },
-    { "thistle3", 205, 181, 205 },
-    { "thistle4", 139, 123, 139 },
-    { "gray0", 0, 0, 0 },
-    { "grey0", 0, 0, 0 },
-    { "gray1", 3, 3, 3 },
-    { "grey1", 3, 3, 3 },
-    { "gray2", 5, 5, 5 },
-    { "grey2", 5, 5, 5 },
-    { "gray3", 8, 8, 8 },
-    { "grey3", 8, 8, 8 },
-    { "gray4", 10, 10, 10 },
-    { "grey4", 10, 10, 10 },
-    { "gray5", 13, 13, 13 },
-    { "grey5", 13, 13, 13 },
-    { "gray6", 15, 15, 15 },
-    { "grey6", 15, 15, 15 },
-    { "gray7", 18, 18, 18 },
-    { "grey7", 18, 18, 18 },
-    { "gray8", 20, 20, 20 },
-    { "grey8", 20, 20, 20 },
-    { "gray9", 23, 23, 23 },
-    { "grey9", 23, 23, 23 },
-    { "gray10", 26, 26, 26 },
-    { "grey10", 26, 26, 26 },
-    { "gray11", 28, 28, 28 },
-    { "grey11", 28, 28, 28 },
-    { "gray12", 31, 31, 31 },
-    { "grey12", 31, 31, 31 },
-    { "gray13", 33, 33, 33 },
-    { "grey13", 33, 33, 33 },
-    { "gray14", 36, 36, 36 },
-    { "grey14", 36, 36, 36 },
-    { "gray15", 38, 38, 38 },
-    { "grey15", 38, 38, 38 },
-    { "gray16", 41, 41, 41 },
-    { "grey16", 41, 41, 41 },
-    { "gray17", 43, 43, 43 },
-    { "grey17", 43, 43, 43 },
-    { "gray18", 46, 46, 46 },
-    { "grey18", 46, 46, 46 },
-    { "gray19", 48, 48, 48 },
-    { "grey19", 48, 48, 48 },
-    { "gray20", 51, 51, 51 },
-    { "grey20", 51, 51, 51 },
-    { "gray21", 54, 54, 54 },
-    { "grey21", 54, 54, 54 },
-    { "gray22", 56, 56, 56 },
-    { "grey22", 56, 56, 56 },
-    { "gray23", 59, 59, 59 },
-    { "grey23", 59, 59, 59 },
-    { "gray24", 61, 61, 61 },
-    { "grey24", 61, 61, 61 },
-    { "gray25", 64, 64, 64 },
-    { "grey25", 64, 64, 64 },
-    { "gray26", 66, 66, 66 },
-    { "grey26", 66, 66, 66 },
-    { "gray27", 69, 69, 69 },
-    { "grey27", 69, 69, 69 },
-    { "gray28", 71, 71, 71 },
-    { "grey28", 71, 71, 71 },
-    { "gray29", 74, 74, 74 },
-    { "grey29", 74, 74, 74 },
-    { "gray30", 77, 77, 77 },
-    { "grey30", 77, 77, 77 },
-    { "gray31", 79, 79, 79 },
-    { "grey31", 79, 79, 79 },
-    { "gray32", 82, 82, 82 },
-    { "grey32", 82, 82, 82 },
-    { "gray33", 84, 84, 84 },
-    { "grey33", 84, 84, 84 },
-    { "gray34", 87, 87, 87 },
-    { "grey34", 87, 87, 87 },
-    { "gray35", 89, 89, 89 },
-    { "grey35", 89, 89, 89 },
-    { "gray36", 92, 92, 92 },
-    { "grey36", 92, 92, 92 },
-    { "gray37", 94, 94, 94 },
-    { "grey37", 94, 94, 94 },
-    { "gray38", 97, 97, 97 },
-    { "grey38", 97, 97, 97 },
-    { "gray39", 99, 99, 99 },
-    { "grey39", 99, 99, 99 },
-    { "gray40", 102, 102, 102 },
-    { "grey40", 102, 102, 102 },
-    { "gray41", 105, 105, 105 },
-    { "grey41", 105, 105, 105 },
-    { "gray42", 107, 107, 107 },
-    { "grey42", 107, 107, 107 },
-    { "gray43", 110, 110, 110 },
-    { "grey43", 110, 110, 110 },
-    { "gray44", 112, 112, 112 },
-    { "grey44", 112, 112, 112 },
-    { "gray45", 115, 115, 115 },
-    { "grey45", 115, 115, 115 },
-    { "gray46", 117, 117, 117 },
-    { "grey46", 117, 117, 117 },
-    { "gray47", 120, 120, 120 },
-    { "grey47", 120, 120, 120 },
-    { "gray48", 122, 122, 122 },
-    { "grey48", 122, 122, 122 },
-    { "gray49", 125, 125, 125 },
-    { "grey49", 125, 125, 125 },
-    { "gray50", 127, 127, 127 },
-    { "grey50", 127, 127, 127 },
-    { "gray51", 130, 130, 130 },
-    { "grey51", 130, 130, 130 },
-    { "gray52", 133, 133, 133 },
-    { "grey52", 133, 133, 133 },
-    { "gray53", 135, 135, 135 },
-    { "grey53", 135, 135, 135 },
-    { "gray54", 138, 138, 138 },
-    { "grey54", 138, 138, 138 },
-    { "gray55", 140, 140, 140 },
-    { "grey55", 140, 140, 140 },
-    { "gray56", 143, 143, 143 },
-    { "grey56", 143, 143, 143 },
-    { "gray57", 145, 145, 145 },
-    { "grey57", 145, 145, 145 },
-    { "gray58", 148, 148, 148 },
-    { "grey58", 148, 148, 148 },
-    { "gray59", 150, 150, 150 },
-    { "grey59", 150, 150, 150 },
-    { "gray60", 153, 153, 153 },
-    { "grey60", 153, 153, 153 },
-    { "gray61", 156, 156, 156 },
-    { "grey61", 156, 156, 156 },
-    { "gray62", 158, 158, 158 },
-    { "grey62", 158, 158, 158 },
-    { "gray63", 161, 161, 161 },
-    { "grey63", 161, 161, 161 },
-    { "gray64", 163, 163, 163 },
-    { "grey64", 163, 163, 163 },
-    { "gray65", 166, 166, 166 },
-    { "grey65", 166, 166, 166 },
-    { "gray66", 168, 168, 168 },
-    { "grey66", 168, 168, 168 },
-    { "gray67", 171, 171, 171 },
-    { "grey67", 171, 171, 171 },
-    { "gray68", 173, 173, 173 },
-    { "grey68", 173, 173, 173 },
-    { "gray69", 176, 176, 176 },
-    { "grey69", 176, 176, 176 },
-    { "gray70", 179, 179, 179 },
-    { "grey70", 179, 179, 179 },
-    { "gray71", 181, 181, 181 },
-    { "grey71", 181, 181, 181 },
-    { "gray72", 184, 184, 184 },
-    { "grey72", 184, 184, 184 },
-    { "gray73", 186, 186, 186 },
-    { "grey73", 186, 186, 186 },
-    { "gray74", 189, 189, 189 },
-    { "grey74", 189, 189, 189 },
-    { "gray75", 191, 191, 191 },
-    { "grey75", 191, 191, 191 },
-    { "gray76", 194, 194, 194 },
-    { "grey76", 194, 194, 194 },
-    { "gray77", 196, 196, 196 },
-    { "grey77", 196, 196, 196 },
-    { "gray78", 199, 199, 199 },
-    { "grey78", 199, 199, 199 },
-    { "gray79", 201, 201, 201 },
-    { "grey79", 201, 201, 201 },
-    { "gray80", 204, 204, 204 },
-    { "grey80", 204, 204, 204 },
-    { "gray81", 207, 207, 207 },
-    { "grey81", 207, 207, 207 },
-    { "gray82", 209, 209, 209 },
-    { "grey82", 209, 209, 209 },
-    { "gray83", 212, 212, 212 },
-    { "grey83", 212, 212, 212 },
-    { "gray84", 214, 214, 214 },
-    { "grey84", 214, 214, 214 },
-    { "gray85", 217, 217, 217 },
-    { "grey85", 217, 217, 217 },
-    { "gray86", 219, 219, 219 },
-    { "grey86", 219, 219, 219 },
-    { "gray87", 222, 222, 222 },
-    { "grey87", 222, 222, 222 },
-    { "gray88", 224, 224, 224 },
-    { "grey88", 224, 224, 224 },
-    { "gray89", 227, 227, 227 },
-    { "grey89", 227, 227, 227 },
-    { "gray90", 229, 229, 229 },
-    { "grey90", 229, 229, 229 },
-    { "gray91", 232, 232, 232 },
-    { "grey91", 232, 232, 232 },
-    { "gray92", 235, 235, 235 },
-    { "grey92", 235, 235, 235 },
-    { "gray93", 237, 237, 237 },
-    { "grey93", 237, 237, 237 },
-    { "gray94", 240, 240, 240 },
-    { "grey94", 240, 240, 240 },
-    { "gray95", 242, 242, 242 },
-    { "grey95", 242, 242, 242 },
-    { "gray96", 245, 245, 245 },
-    { "grey96", 245, 245, 245 },
-    { "gray97", 247, 247, 247 },
-    { "grey97", 247, 247, 247 },
-    { "gray98", 250, 250, 250 },
-    { "grey98", 250, 250, 250 },
-    { "gray99", 252, 252, 252 },
-    { "grey99", 252, 252, 252 },
-    { "gray100", 255, 255, 255 },
-    { "grey100", 255, 255, 255 },
-    { 0, 0, 0, 0 }
-};
-
-Dot2QtConsts::Dot2QtConsts()
-{
-  m_penStyles["solid"] = Qt::SolidLine;
-  m_penStyles["dashed"] = Qt::DashLine;
-  m_penStyles["dotted"] = Qt::DotLine;
-  m_penStyles["invis"] = Qt::NoPen;
-
-  m_colors["crimson"] = "#DC143C";
-  m_colors["hot_pink"] = "#FF69B4";
-  m_colors["light_yellow"] = "#FFFFE0";
-  m_colors["slate_blue"] = "#6A5ACD";
-
-  uint i = 0;
-  while (postscriptFontNames[i].input != 0)
-  {
-    QFont font(postscriptFontNames[i].input);
-    m_psFonts[postscriptFontNames[i].roman] = font;
-    if (postscriptFontNames[i].italic != 0)
-    {
-      QFont italic = font; italic.setItalic(true);
-      m_psFonts[postscriptFontNames[i].italic] = italic;
-    }
-    if (postscriptFontNames[i].bold != 0)
-    {
-      QFont bold = font; bold.setBold(true);
-      m_psFonts[postscriptFontNames[i].bold] = bold;
-    }
-    if (postscriptFontNames[i].boldItalic != 0)
-    {
-      QFont boldItalic = font; 
-      boldItalic.setItalic(true);
-      boldItalic.setBold(true);
-      m_psFonts[postscriptFontNames[i].boldItalic] = boldItalic;
-    }
-    if (postscriptFontNames[i].light != 0)
-    {
-      QFont light = font; light.setWeight(QFont::Light);
-      m_psFonts[postscriptFontNames[i].light] = light;
-    }
-    if (postscriptFontNames[i].lightItalic != 0)
-    {
-      QFont lightItalic = font; 
-      lightItalic.setWeight(QFont::Light);
-      lightItalic.setItalic(true);
-      m_psFonts[postscriptFontNames[i].lightItalic] = lightItalic;
-    }
-    i++;
-  }
-
-  uint j = 0;
-  while (color_lib[j].name != 0)
-  {
-//     kDebug() << "Adding color " << color_lib[j].name;
-    m_qcolors[color_lib[j].name] = QColor(color_lib[j].r,color_lib[j].g,color_lib[j].b);
-    j++;
-  }
-}
-
-
-Dot2QtConsts::~Dot2QtConsts()
-{}
-
-
-QColor Dot2QtConsts::qtColor(const QString& dotColor) const
-{
-//   kDebug() << "Dot2QtConsts::qtColor";
-  QColor color;
-  if (parse_numeric_color(dotColor.ascii(), color))
-  {
-    return color;
-  }
-  else
-  {
-    if (m_qcolors.find(dotColor) != m_qcolors.end())
-    {
-      return (*m_qcolors.find(dotColor));
-    }
-    QColor res(dotColor);
-    if (res.isValid())
-    {
-      return res;
-    }
-    else
-    {
-        if (m_colors.find(dotColor) != m_colors.end())
-        {
-            res = QColor((*m_colors.find(dotColor)));
-            if (res.isValid())
-            {
-                return res;
-            }
-            else
-            {
-                kWarning() << "Unknown stored dot color '" << dotColor << "'. returning Qt black";
-                return Qt::black;
-            }
-        }
-        else
-        {
-//           kWarning() << "Unknown dot color '" << dotColor << "'. returning Qt black";
-          return Qt::black;
-        }
-    }
-  }
-}
-
-Qt::PenStyle Dot2QtConsts::qtPenStyle(const QString& dotLineStyle) const
-{
-  if (m_penStyles.find(dotLineStyle) != m_penStyles.end())
-    return (*(m_penStyles.find(dotLineStyle)));
-  else 
-  {
-    if (!dotLineStyle.left(12).isEmpty()
-	&& dotLineStyle.left(12) != "setlinewidth")
-      kWarning() << "Unknown dot line style '" << dotLineStyle << "'. returning Qt solid line";
-    return Qt::SolidLine;
-  }
-}
-
-QFont Dot2QtConsts::qtFont(const QString& dotFont) const
-{
-  if (m_psFonts.find(dotFont) != m_psFonts.end())
-    return (*(m_psFonts.find(dotFont)));
-  else
-  {
-    qWarning() << "Unknown dot font '" << dotFont << "'. returning Qt default.";
-    return QFont(QFont::substitute(dotFont));
-  }
-}
-
diff --git a/src/part/dot2qtconsts.h b/src/part/dot2qtconsts.h
deleted file mode 100644
index c2ec8a9..0000000
--- a/src/part/dot2qtconsts.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-2007 by Gael de Chalendar   *
- *   kleag at free.fr   *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
- ***************************************************************************/
-#ifndef DOT2QTCONSTS_H
-#define DOT2QTCONSTS_H
-
-#include <QMap>
-#include <QString>
-#include <QFont>
-
-/**
- at author Gael de Chalendar
-*/
-class Dot2QtConsts
-{
-public:
-  static Dot2QtConsts& changeable() {return *m_componentData;}
-  static const Dot2QtConsts& componentData() {return *m_componentData;}
-  
-  QColor qtColor(const QString& dotColor) const;
-  Qt::PenStyle qtPenStyle(const QString& dotLineStyle) const;
-  QFont qtFont(const QString& dotFont) const;
-
-private:
-    Dot2QtConsts();
-
-    ~Dot2QtConsts();
-
-  static Dot2QtConsts* m_componentData;
-  
-  QMap< QString, Qt::PenStyle > m_penStyles;
-  QMap< QString, QString > m_colors;
-  QMap< QString, QColor > m_qcolors;
-  QMap< QString, QFont > m_psFonts;
-  
-};
-
-#endif
diff --git a/src/part/dotdefaults.h b/src/part/dotdefaults.h
deleted file mode 100644
index ec655f6..0000000
--- a/src/part/dotdefaults.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-#ifndef DOT_DEFAULTS_H
-#define DOT_DEFAULTS_H
-
-#define DOT_DEFAULT_DPI 72
-#define DOT_DEFAULT_FONTSIZE 11
-#define DOT_DEFAULT_FONTNAME "Sans"
-#define DOT_DEFAULT_FONTCOLOR "black"
-#define DOT_DEFAULT_EDGE_STYLE "solid"
-#define DOT_DEFAULT_EDGE_DIR "forward"
-#define DOT_DEFAULT_EDGE_COLOR "black"
-#define DOT_DEFAULT_STYLE "solid"
-#define DOT_DEFAULT_SHAPE "ellipse"
-#define DOT_DEFAULT_LINECOLOR "black"
-#define DOT_DEFAULT_NODE_BACKCOLOR "lightgrey"
-#define DOT_DEFAULT_BACKCOLOR "white"
-#endif
-
diff --git a/src/part/dotgrammar.cpp b/src/part/dotgrammar.cpp
deleted file mode 100644
index 9225238..0000000
--- a/src/part/dotgrammar.cpp
+++ /dev/null
@@ -1,540 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-#include "dotgrammar.h"
-#include "dotgraph.h"
-#include "dotdefaults.h"
-#include "graphnode.h"
-#include "graphedge.h"
-#include "DotGraphParsingHelper.h"
-
-#include <iostream>
-
-#include <kdebug.h>
-
-#include <QFile>
-
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_distinct.hpp>
-#include <boost/spirit/include/classic_loops.hpp>
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/throw_exception.hpp>
-
-namespace boost
-{
-  void throw_exception(std::exception const &) {}
-}
-
-
-using namespace std;
-using namespace boost;
-using namespace boost::spirit::classic;
-
-using namespace KGraphViewer;
-
-#define KGV_MAX_ITEMS_TO_LOAD std::numeric_limits<size_t>::max()
-#define BOOST_SPIRIT_DEBUG 1
-
-DotGraphParsingHelper* phelper = 0;
-
-std::string therenderop;
-std::string thestr;
-
-void anychar(char const c);
-
-// keyword_p for C++
-// (for basic usage instead of std_p)
-const boost::spirit::classic::distinct_parser<> keyword_p("0-9a-zA-Z_");
-
-template <typename ScannerT>
-DotGrammar::definition<ScannerT>::definition(DotGrammar const& /*self*/)
-{
-  graph  = (!(keyword_p("strict")[&strict]) >> (keyword_p("graph")[&undigraph] | keyword_p("digraph")[&digraph])
-  >> !ID[&graphid] >> ch_p('{') >> !stmt_list >> ch_p('}'))[&finalactions];
-  ID = (
-  ( ( (anychar_p - punct_p) | '_' ) >> *( (anychar_p - punct_p) | '_' ) )
-  | real_p
-  | ( '"' >>  *( (ch_p('\\') >> '"') | (anychar_p - '"') ) >>  '"' )
-  | ( ch_p('<') >>  *( anychar_p  - '<' - '>' | tag ) >>  '>' )
-  );
-  tag = ('<' >> *( anychar_p  - '>') >> '>');
-  stmt_list  =  stmt >> !(ch_p(';')) >> !( stmt_list ) ;
-  stmt  =  (
-  attr_stmt
-  |  subgraph
-  |  edge_stmt
-  |  node_stmt
-  |  ( ID >> '=' >> ID )
-  );
-
-  attr_stmt  = (
-  (keyword_p("graph")[assign_a(phelper->attributed)] >> attr_list[&setattributedlist])[&setgraphattributes]
-  | (keyword_p("node")[assign_a(phelper->attributed)] >> attr_list[&setattributedlist])
-  | (keyword_p("edge")[assign_a(phelper->attributed)] >> attr_list[&setattributedlist])
-  ) ;
-
-  attr_list  = ch_p('[') >> !( a_list ) >> ch_p(']');
-  a_list  =  ((ID[&attrid] >> !( '=' >> ID[&valid] ))[&addattr] >> !(',' >> a_list ));
-  edge_stmt  =  ( (node_id[&edgebound] | subgraph) >>  edgeRHS >> !( attr_list[assign_a(phelper->attributed,"edge")] ) )[&pushAttrList][&setattributedlist][&createedges][&popAttrList];
-  edgeRHS  =  edgeop[&checkedgeop] >> (node_id[&edgebound] | subgraph) >> !( edgeRHS );
-  edgeop = str_p("->") | str_p("--");
-  node_stmt  = ( node_id[&createnode] >> !( attr_list ) )[assign_a(phelper->attributed,"node")][&pushAttrList][&setattributedlist][&setnodeattributes][&popAttrList];
-  node_id  =  (ID >> !( port ));
-  port  =  ( ch_p(':') >> ID >> !( ':' >> compass_pt ) )
-  |  ( ':' >> compass_pt );
-  subgraph  =  ( !( keyword_p("subgraph") >> !( ID[&subgraphid] ) ) >> ch_p('{')[&createsubgraph][&incrz][&pushAttrListC] >> stmt_list >> ch_p('}') [&decrz][&popAttrListC])
-  |  ( keyword_p("subgraph") >> ID[&subgraphid]);
-  compass_pt  =  (keyword_p("n") | keyword_p("ne") | keyword_p("e")
-  | keyword_p("se") | keyword_p("s") | keyword_p("sw")
-  | keyword_p("w") | keyword_p("nw") );
-}
-
-
-
-
-void incrz(char const /*first*/)
-{
-  if (phelper)
-  {
-    phelper->z++;
-    if (phelper->z > phelper->maxZ)
-    {
-      phelper->maxZ = phelper->z;
-    }
-  }
-}
-
-void anychar(char const c)
-{
-//   kDebug() << c;
-}
-
-void decrz(char const /*first*/)
-{
-  if (phelper)
-  {
-    phelper->z--;
-    phelper->gs = 0;
-  }
-}
-
-void dump(char const* first, char const* last)
-{
-  std::string str(first, last);
-  kError() << ">>>> " << QString::fromStdString(str) << " <<<<" << endl;
-}
-
-void strict(char const* /*first*/, char const* /*last*/)
-{
-  if (phelper) phelper->graph->strict(true);
-}
-
-void gotid(char const* first, char const* last)
-{
-  std::string id(first,last);
-//   kDebug() << "Got ID  = '"<<QString::fromStdString(phelper->attrid)<<"'";
-}
-
-void undigraph(char const* /*first*/, char const* /*last*/)
-{
-//   kDebug() << "Setting graph as undirected";
-  if (phelper) phelper->graph->directed(false);
-}
-
-void digraph(char const* /*first*/, char const* /*last*/)
-{
-//   kDebug() << "Setting graph as directed";
-  if (phelper) phelper->graph->directed(true);
-}
-
-void graphid(char const* first, char const* last)
-{
-//   kDebug() << QString::fromStdString(std::string(first,last));
-  if (phelper) phelper->graph->setId(QString::fromStdString(std::string(first,last)));
-}
-
-void attrid(char const* first, char const* last)
-{
-  if (phelper) 
-  {
-    std::string id(first,last);
-    if (id.size()>0 && id[0] == '"') id = id.substr(1);
-    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
-    phelper->attrid = id;
-    phelper->valid = "";
-//     kDebug() << "Got attr ID  = '"<<QString::fromStdString(phelper->attrid)<<"'";
-  }
-}
-
-void subgraphid(char const* first, char const* last)
-{
-  std::string id(first,last);
-//   kDebug() << QString::fromStdString(id);
-  if (phelper) 
-  {
-    if (id.size()>0 && id[0] == '"') id = id.substr(1);
-    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
-    phelper->subgraphid = id;
-//     kDebug() << "Got subgraph id = '"<<QString::fromStdString(phelper->subgraphid)<<"'";
-  }
-}
-
-void valid(char const* first, char const* last)
-{
-  std::string id(first,last);
-  if (phelper)
-  {
-    if (id.size()>0 && id[0] == '"') id = id.substr(1);
-    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
-    phelper->valid = id;
-//     kDebug() << "Got attr val = '"<<QString::fromStdString(id)<<"'";
-  }
-}
-
-void addattr(char const* /*first*/, char const* /*last*/)
-{
-  if (phelper) 
-  {
-    phelper->attributes.insert(std::make_pair(phelper->attrid,phelper->valid));
-  }
-}
-
-void pushAttrListC(char const /*c*/)
-{
-  pushAttrList(0,0);
-}
-
-void pushAttrList(char const* /*first*/, char const* /*last*/)
-{
-//   kDebug() << "Pushing attributes";
-  if (phelper)
-  {
-    phelper->graphAttributesStack.push_back(phelper->graphAttributes);
-    phelper->nodesAttributesStack.push_back(phelper->nodesAttributes);
-    phelper->edgesAttributesStack.push_back(phelper->edgesAttributes);
-  }
-}
-
-void popAttrListC(char const /*c*/)
-{
-  popAttrList(0,0);
-}
-
-void popAttrList(char const* /*first*/, char const* /*last*/)
-{
-//   kDebug() << "Poping attributes";
-  if (phelper) 
-  {
-    phelper->graphAttributes = phelper->graphAttributesStack.back();
-    phelper->graphAttributesStack.pop_back();
-    phelper->nodesAttributes = phelper->nodesAttributesStack.back();
-    phelper->nodesAttributesStack.pop_back();
-    phelper->edgesAttributes = phelper->edgesAttributesStack.back();
-    phelper->edgesAttributesStack.pop_back();
-  }
-//   kDebug() << "Poped";
-}
-
-void createnode(char const* first, char const* last)
-{
-//   kDebug() << (void*)first << (void*)last << QString::fromStdString(std::string(first,last));
-  if (phelper!=0 && first!=0 && last != 0) 
-  {
-    std::string id(first,last);
-    if (id.size()>0 && id[0] == '"') id = id.substr(1);
-    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
-    phelper->createnode(id);
-  }
-}
-
-void createsubgraph(char const /*c*/)
-{
-  if (phelper) 
-  {
-    phelper->createsubgraph();
-  }
-}
-
-void setgraphattributes(char const* /*first*/, char const* /*last*/)
-{
-//   kDebug() << "setgraphattributes with z = " << phelper->z;
-  if (phelper) 
-  {
-    if (phelper->z == 1) // main graph
-    {
-      phelper->setgraphattributes();
-    }
-    else
-    {
-      phelper->setsubgraphattributes();
-    }
-  }
-}
-
-void setnodeattributes(char const* /*first*/, char const* /*last*/)
-{
-//   kDebug() << "setnodeattributes with z = " << phelper->z;
-  if (phelper) 
-  {
-    phelper->setnodeattributes();
-  }
-}
-
-void setattributedlist(char const* /*first*/, char const* /*last*/)
-{
-  if (phelper) 
-  {
-    phelper->setattributedlist();
-  }
-}
-
-void checkedgeop(char const* first, char const* last)
-{
-  std::string str(first,last);
-  if (phelper) 
-  {
-    if ( ( (phelper->graph->directed()) && (str == "->") ) || 
-      ( (!phelper->graph->directed()) && (str == "--") ) )
-      return;
-    
-    kError() << "Error !! uncoherent relation : directed = '" << phelper->graph->directed() << "' and op = '" << QString::fromStdString(str) << "'" << endl;
-  }
-}
-
-void edgebound(char const* first, char const* last)
-{
-//   kDebug() << "edgebound: " << QString::fromStdString(std::string(first,last));
-  if (phelper) 
-  {
-    std::string id(first,last);
-    if (id.size()>0 && id[0] == '"') id = id.substr(1);
-    if (id.size()>0 && id[id.size()-1] == '"') id = id.substr(0,id.size()-1);
-    phelper->edgebound(id);
-  }
-}
-
-void createedges(char const* /*first*/, char const* /*last*/)
-{
-  if (phelper) 
-  {
-    phelper->createedges();
-  }
-}
-
-void finalactions(char const* /*first*/, char const* /*last*/)
-{
-  if (phelper) 
-  {
-    phelper->finalactions();
-  }
-}
-
-bool parse_point(char const* str, QPoint& p)
-{
-  int x,y;
-  bool res;
-  res = parse(str,
-              (
-                int_p[assign_a(x)] >> ',' >> int_p[assign_a(y)]
-              )
-              ,
-              +space_p).full;
-  if (!res) return false;
-  p = QPoint(x,y);
-  return true;
-}
-
-bool parse_numeric_color(char const* str, QColor& c)
-{
-  if (str==0) return false;
-  int r,g,b,a;
-  bool res;
-  uint_parser<unsigned, 16, 2, 2> hex2digits_p;
-  res = parse(str,
-              (
-                ch_p('#') >> 
-                hex2digits_p[assign_a(r)] >>  
-                hex2digits_p[assign_a(g)] >> 
-                hex2digits_p[assign_a(b)] >> 
-                !hex2digits_p[assign_a(a)]
-              )
-              ,
-              +space_p).full;
-  if (res)
-  {
-    c.setRgb(r,g,b);
-    return true;
-  }
-  
-  double h,s,v;
-  res = parse(str,
-              (
-                real_p[assign_a(h)] >> !ch_p(',') >> real_p[assign_a(s)] >> !ch_p(',') >> real_p[assign_a(v)]
-              )
-              ,
-              +space_p).full;
-  if (res)
-  {
-    c.setHsv(int(255*h),int(255*s),int(255*v));
-    return true;
-  }
-  return false;
-}
-
-bool parse_real(char const* str, double& d)
-{
-  return parse(str,
-               (
-                 real_p[assign_a(d)]
-               )
-               ,
-               +space_p).full;
-}
-
-bool parse_integers(char const* str, std::vector<int>& v)
-{
-  return parse(str,
-               (
-                 int_p[push_back_a(v)] >> *(',' >> int_p[push_back_a(v)])
-               )
-               ,
-               +space_p).full;
-}
-
-bool parse_spline(char const* str, QVector< QPair< float, float > >& points)
-{
-//   kDebug() << "Parsing spline..." << QString::fromStdString(str);
-  char e = 'n', s = 'n';
-  int sx,sy,ex,ey;
-  QPair< float, float > p;
-  bool res;
-  res = parse(str,
-              (
-                !(ch_p('e')[assign_a(e)] >> ',' >> int_p[assign_a(ex)] >> ',' >> int_p[assign_a(ey)]) 
-                >> !(ch_p('s')[assign_a(s)] >> ',' >> int_p[assign_a(sx)] >> ',' >> int_p[assign_a(sy)])
-                >> ((int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)]))[push_back_a(points,p)] 
-                >> +(
-                      (int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)])[push_back_a(points,p)] >> 
-                      (int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)])[push_back_a(points,p)] >> 
-                      (int_p[assign_a(p.first)] >> ',' >> int_p[assign_a(p.second)])[push_back_a(points,p)]
-                    )
-              )
-              ,
-              +space_p).full;
-  if (!res) return false;
-  if (s == 's')
-  {
-//     kDebug() << "inserting the s point";
-    points.insert(points.begin(), qMakePair(float(sx),float(sy)));
-  }
-  if (e == 'e')
-  {
-//     points.insert(points.begin(), qMakePair(float(ex),float(ey)));
-  }
-  return true;
-}
-
-DotRenderOp renderop ;
-
-DotRenderOpVec* renderopvec = 0;
-
-void init_op()
-{
-  renderop = DotRenderOp();
-}
-
-void valid_op(char const* first, char const* last)
-{
-  std::string s(first, last);
-  renderop.renderop = QString::fromUtf8(therenderop.c_str());
-  renderop.str = QString::fromUtf8(thestr.c_str());
-
-//   kDebug() << "Validating render operation '"<<QString::fromStdString(s)<<"': '"<<renderop.renderop<<"/"<<renderop.str<<"'";
-  renderopvec->push_back(renderop);
-  renderop.renderop = "";
-  renderop.integers = QList<int>();
-  renderop.str = "";
-}
-
-bool parse_renderop(const std::string& str, DotRenderOpVec& arenderopvec)
-{
-//   kDebug() << QString::fromUtf8(str.c_str()) << str.size();
-  if (str.empty())
-  {
-    return false;
-  }
-  init_op();
-  renderopvec = &arenderopvec;
-  bool res;
-  int c;
-  res = parse(str.c_str(),
-              (
-                +(
-                   (
-                     (ch_p('E')|ch_p('e'))[assign_a(therenderop)] >> +space_p >>
-                     repeat_p(4)[int_p[push_back_a(renderop.integers)] >> +space_p]
-                   )[&valid_op] 
-                   | (
-                       (ch_p('P')|ch_p('p')|ch_p('L')|ch_p('B')|ch_p('b'))[assign_a(therenderop)] >> +space_p >>
-                       int_p[assign_a(c)][push_back_a(renderop.integers)] >> +space_p >> 
-                       repeat_p(boost::ref(c))[
-                                                int_p[push_back_a(renderop.integers)] >> +space_p >> 
-                                                int_p[push_back_a(renderop.integers)] >> +space_p
-                                              ] 
-                     )[&valid_op]
-  // "T 1537 228 0 40 9 -#1 (== 0) T 1537 217 0 90 19 -MAIN:./main/main.pl "
-                   | (
-                       ch_p('T')[assign_a(therenderop)] >> +space_p >>
-                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
-                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
-                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
-                       int_p[push_back_a(renderop.integers)] >> +space_p >> 
-                       int_p[assign_a(c)] >> +space_p >> '-' >> 
-                       (repeat_p(boost::ref(c))[anychar_p])[assign_a(thestr)] >> +space_p
-                     )[&valid_op]
-  // c 9 -#000000ff 
-                     | (
-                       (ch_p('C')|ch_p('c')|ch_p('S'))[assign_a(therenderop)] >> +space_p >>
-                       int_p[assign_a(c)] >> +space_p >> '-' >> 
-                       (repeat_p(boost::ref(c))[anychar_p])[assign_a(thestr)] >> +space_p
-                     )[&valid_op] 
-  // F 14,000000 11 -Times-Roman 
-                    | (
-                       ch_p('F')[assign_a(therenderop)] >> +space_p >>
-                       int_p[push_back_a(renderop.integers)] >> (ch_p(',')|ch_p('.')) >> int_p >> +space_p >>
-                       int_p[assign_a(c)] >> +space_p >> '-' >> 
-                       (repeat_p(boost::ref(c))[anychar_p])[assign_a(thestr)] >> +space_p
-                     )[&valid_op]
-                 )
-                 ) >> !end_p
-             ).full;
-  if (res ==false)
-  {
-    kError() << "ERROR: parse_renderop failed on "<< QString::fromStdString(str);
-    kError() << "       Last renderop string is "<<QString::fromStdString(str.c_str());
-  }
-//   delete renderop; renderop = 0;
-  return res;
-}
-
-bool parse(const std::string& str)
-{
-  DotGrammar g;
-  return boost::spirit::classic::parse(str.c_str(), g >> end_p, (+boost::spirit::classic::space_p|boost::spirit::classic::comment_p("/*", "*/"))).full;
-}
-
diff --git a/src/part/dotgrammar.h b/src/part/dotgrammar.h
deleted file mode 100644
index 37661d4..0000000
--- a/src/part/dotgrammar.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2006-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/*
- * GraphViz dot Graph parsing grammar implemented with boost Spirit
- */
-
-#ifndef DOT_GRAMMAR_H
-#define DOT_GRAMMAR_H
-
-#include "dotrenderop.h"
-
-#include <boost/spirit/include/classic_actions.hpp>
-#include <boost/spirit/include/classic_grammar.hpp>
-#include <boost/spirit/include/classic_rule.hpp>
-
-#include <QPoint>
-#include <QColor>
-#include <QPair>
-#include <QVector>
-
-#include <map>
-#include <list>
-#include <string>
-#include <sstream>
-
-bool parse(const std::string& str);
-
-void gotid(char const* first, char const* last);
-void dump(char const* first, char const* last);
-void strict(char const* first, char const* last);
-void undigraph(char const* first, char const* last);
-void digraph(char const* first, char const* last);
-void graphid(char const* first, char const* last);
-void attrid(char const* first, char const* last);
-void subgraphid(char const* first, char const* last);
-void valid(char const* first, char const* last);
-void addattr(char const* first, char const* last);
-void pushAttrListC(char const c);
-void popAttrListC(char const c);
-void pushAttrList(char const* first, char const* last);
-void popAttrList(char const* first, char const* last);
-void createsubgraph(char const);
-void createnode(char const* first, char const* last);
-void setgraphattributes(char const* first, char const* last);
-void setsubgraphattributes(char const* first, char const* last);
-void setnodeattributes(char const* first, char const* last);
-void setattributedlist(char const* first, char const* last);
-void checkedgeop(char const* first, char const* last);
-void edgebound(char const* first, char const* last);
-void createedges(char const* first, char const* last);
-void incrz(char const);
-void decrz(char const);
-void finalactions(char const* first, char const* last);
-
-bool parse_point(char const* str, QPoint& p);
-bool parse_real(char const* str, double& d);
-bool parse_integers(char const* str, std::vector<int>& v);
-bool parse_spline(char const* str, QVector< QPair< float, float > >& points);
-void init_op();
-void valid_op(char const* first, char const* last);
-bool parse_renderop(const std::string& str, DotRenderOpVec& arenderopvec);
-bool parse_numeric_color(char const* str, QColor& c);
-
-struct DotGrammar : public boost::spirit::classic::grammar<DotGrammar>
-{
-  template <typename ScannerT>
-  struct definition
-  {
-    definition(DotGrammar const& self);
-    
-    boost::spirit::classic::rule<ScannerT> graph, ID, tag, stmt_list, stmt, attr_stmt,
-    attr_list, a_list, edge_stmt, edgeop,
-    edgeRHS, node_stmt, node_id,
-    port, subgraph, compass_pt;
-    
-    boost::spirit::classic::rule<ScannerT> const& start() const
-    {
-      return graph;
-    }
-  };
-  
-};
-
-
-
-
-
-
-#endif
-
-
-
diff --git a/src/part/dotgraph.cpp b/src/part/dotgraph.cpp
deleted file mode 100644
index b80e957..0000000
--- a/src/part/dotgraph.cpp
+++ /dev/null
@@ -1,1019 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-#include "dotgraph.h"
-#include "dotgrammar.h"
-#include "graphexporter.h"
-#include "DotGraphParsingHelper.h"
-#include "canvasedge.h"
-#include "canvasnode.h"
-#include "canvassubgraph.h"
-
-#include <math.h>
-#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "fdstream.hpp"
-#include <boost/spirit/include/classic_assign_actor.hpp>
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/spirit/include/classic_distinct.hpp>
-
-#include <graphviz/gvc.h>
-
-#include <KDebug>
-#include <KLocale>
-#include <KMessageBox>
-
-#include <QFile>
-#include <QPair>
-#include <QByteArray>
-#include <QProcess>
-#include <QMutexLocker>
-#include <QUuid>
-
-using namespace boost;
-using namespace boost::spirit::classic;
-
-extern KGraphViewer::DotGraphParsingHelper* phelper;
-
-
-namespace KGraphViewer
-{
-
-const distinct_parser<> keyword_p("0-9a-zA-Z_");
-
-DotGraph::DotGraph() :
-  GraphElement(),
-  m_dotFileName(""),m_width(0.0), m_height(0.0),m_scale(1.0),
-  m_directed(true),m_strict(false),
-  m_layoutCommand(""),
-  m_horizCellFactor(0), m_vertCellFactor(0),
-  m_wdhcf(0), m_hdvcf(0),
-  m_readWrite(false),
-  m_dot(0),
-  m_phase(Initial),
-  m_useLibrary(false)
-{
-  setId("unnamed");
-}
-
-DotGraph::DotGraph(const QString& command, const QString& fileName) :
-  GraphElement(),
-  m_dotFileName(fileName),m_width(0.0), m_height(0.0),m_scale(1.0),
-  m_directed(true),m_strict(false),
-  m_layoutCommand(command),
-  m_horizCellFactor(0), m_vertCellFactor(0),
-  m_wdhcf(0), m_hdvcf(0),
-  m_readWrite(false),
-  m_dot(0),
-  m_phase(Initial),
-  m_useLibrary(false)
-{
-  setId("unnamed");
-}
-
-DotGraph::~DotGraph()  
-{
-  GraphNodeMap::iterator itn, itn_end;
-  itn = m_nodesMap.begin(); itn_end = m_nodesMap.end();
-  for (; itn != itn_end; itn++)
-  {
-    delete *itn;
-  }
-
-  GraphEdgeMap::iterator ite, ite_end;
-  ite = m_edgesMap.begin(); ite_end = m_edgesMap.end();
-  for (; ite != ite_end; ite++)
-  {
-    delete (*ite);
-  }
-}
-
-QString DotGraph::chooseLayoutProgramForFile(const QString& str)
-{
-  QFile iFILE(str);
-
-  if (!iFILE.open(QIODevice::ReadOnly))
-  {
-    kError() << "Can't test dot file. Will try to use the dot command on the file: '" << str << "'" << endl;
-    return "dot";// -Txdot";
-  }
-
-  QByteArray fileContent = iFILE.readAll();
-  if (fileContent.isEmpty()) return "";
-  std::string s =  fileContent.data();
-  std::string cmd = "dot";
-  parse(s.c_str(),
-        (
-          !(keyword_p("strict")) >> (keyword_p("graph")[assign_a(cmd,"neato")])
-        ), (space_p|comment_p("/*", "*/")) );
-
-  return  QString::fromStdString(cmd);// + " -Txdot" ;
-}
-
-bool DotGraph::parseDot(const QString& str)
-{
-  kDebug() << str;
-  m_useLibrary = false;
-  if (m_layoutCommand.isEmpty())
-  {
-    m_layoutCommand = chooseLayoutProgramForFile(str);
-    if (m_layoutCommand.isEmpty())
-    {
-      m_layoutCommand = chooseLayoutProgramForFile(str);
-      return false;
-    }
-  }
-
-  kDebug() << "Running " << m_layoutCommand  << str;
-  QStringList options;
-  /// @TODO handle the non-dot commands that could don't know the -T option
-//  if (m_readWrite && m_phase == Initial)
-//  {
-//    options << "-Tdot";
-//  }
-//  else
-//  {
-    options << "-Txdot";
-//   }
-  options << str;
-
-  kDebug() << "m_dot is " << m_dot  << ". Acquiring mutex";
-  QMutexLocker locker(&m_dotProcessMutex);
-  kDebug() << "mutex acquired ";
-  if (m_dot != 0)
-  {
-    disconnect(m_dot,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotDotRunningDone(int,QProcess::ExitStatus)));
-    disconnect(m_dot,SIGNAL(error(QProcess::ProcessError)),this,SLOT(slotDotRunningError(QProcess::ProcessError)));
-    m_dot->kill();
-    delete m_dot;
-  }
-  m_dot = new QProcess();
-  connect(m_dot,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotDotRunningDone(int,QProcess::ExitStatus)));
-  connect(m_dot,SIGNAL(error(QProcess::ProcessError)),this,SLOT(slotDotRunningError(QProcess::ProcessError)));
-  m_dot->start(m_layoutCommand, options);
-  kDebug() << "process started";
- return true;
-}
-
-bool DotGraph::update()
-{
-  GraphExporter exporter;
-  if (!m_useLibrary)
-  {
-    kDebug() << "command";
-    QString str = exporter.writeDot(this);
-    return parseDot(str);
-  }
-  else
-  {
-    kDebug() << "library";
-    graph_t* graph = exporter.exportToGraphviz(this);
-
-    GVC_t* gvc = gvContext();
-    gvLayout(gvc, graph, m_layoutCommand.toUtf8().data());
-    gvRender (gvc, graph, "xdot", NULL);
-
-    updateWithGraph(graph);
-    
-    gvFreeLayout(gvc, graph);
-    agclose(graph);
-    bool result = (gvFreeContext(gvc) == 0);
-    return result;
-  }
-}
-
-QByteArray DotGraph::getDotResult(int , QProcess::ExitStatus )
-{
-  kDebug();
-
-  QMutexLocker locker(&m_dotProcessMutex);
-  if (m_dot == 0)
-  {
-    return QByteArray();
-  }
-  QByteArray result = m_dot->readAll();
-  delete m_dot;
-  m_dot = 0;
-  return result;
-}
-
-void DotGraph::slotDotRunningDone(int exitCode, QProcess::ExitStatus exitStatus)
-{
-  kDebug();
-  
-  QByteArray result = getDotResult(exitCode, exitStatus);
-  result.replace("\\\n","");
-
-  kDebug() << "string content is:" << endl << result << endl << "=====================" << result.size();
-  std::string s =  result.data();
-  //   std::cerr << "stdstring content is:" << std::endl << s << std::endl << "===================== " << s.size() << std::endl;
-  if (phelper != 0)
-  {
-    phelper->graph = 0;
-    delete phelper;
-  }
-//   if (parsingResult)
-//   {
-//     if (m_readWrite)
-//     {
-//       storeOriginalAttributes();
-//       update();
-//     }
-//     computeCells();
-//   }
-
-  DotGraph newGraph(m_layoutCommand, m_dotFileName);
-  phelper = new DotGraphParsingHelper;
-  phelper->graph = &newGraph;
-  phelper->z = 1;
-  phelper->maxZ = 1;
-  phelper->uniq = 0;
-
-  kDebug() << "parsing new dot";
-  bool parsingResult = parse(s);
-  delete phelper;
-  phelper = 0;
-  kDebug() << "phelper deleted";
-
-  if (parsingResult)
-  {
-    kDebug() << "calling updateWithGraph";
-    updateWithGraph(newGraph);
-  }
-  else
-  {
-    kDebug() << "parsing failed";
-    kError() << "parsing failed";
-  }
-//   return parsingResult;
-//   if (m_readWrite && m_phase == Initial)
-//   {
-//     m_phase = Final;
-//     update();
-//   }
-//   else
-//   {
-    kDebug() << "emiting readyToDisplay";
-    emit(readyToDisplay());
-//   }
-}
-
-void DotGraph::slotDotRunningError(QProcess::ProcessError error)
-{
-  kError() << "DotGraph::slotDotRunningError" << error;
-  switch (error)
-  {
-    case QProcess::FailedToStart:
-      KMessageBox::error(0, i18n("Unable to start %1.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
-    break;
-    case QProcess::Crashed:
-      KMessageBox::error(0, i18n("%1 crashed.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
-    break;
-    case QProcess::Timedout:
-      KMessageBox::error(0, i18n("%1 timed out.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
-    break;
-    case QProcess::WriteError:
-      KMessageBox::error(0, i18n("Was not able to write data to the %1 process.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
-    break;
-    case QProcess::ReadError:
-      KMessageBox::error(0, i18n("Was not able to read data from the %1 process.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
-    break;
-    default:
-      KMessageBox::error(0, i18n("Unknown error running %1.", m_layoutCommand),i18n("Layout process failed"),KMessageBox::Notify);
-  }
-}
-
-unsigned int DotGraph::cellNumber(int x, int y)
-{
-/*  kDebug() << "x= " << x << ", y= " << y << ", m_width= " << m_width << ", m_height= " << m_height << ", m_horizCellFactor= " << m_horizCellFactor << ", m_vertCellFactor= " << m_vertCellFactor  << ", m_wdhcf= " << m_wdhcf << ", m_hdvcf= " << m_hdvcf;*/
-  
-  unsigned int nx = (unsigned int)(( x - ( x % int(m_wdhcf) ) ) / m_wdhcf);
-  unsigned int ny = (unsigned int)(( y - ( y % int(m_hdvcf) ) ) / m_hdvcf);
-/*  kDebug() << "nx = " << (unsigned int)(( x - ( x % int(m_wdhcf) ) ) / m_wdhcf);
-  kDebug() << "ny = " << (unsigned int)(( y - ( y % int(m_hdvcf) ) ) / m_hdvcf);
-  kDebug() << "res = " << ny * m_horizCellFactor + nx;*/
-  
-  unsigned int res = ny * m_horizCellFactor + nx;
-  return res;
-}
-
-#define MAXCELLWEIGHT 800
-
-void DotGraph::computeCells()
-{
-  return;
-  kDebug() << m_width << m_height << endl;
-  m_horizCellFactor = m_vertCellFactor = 1;
-  m_wdhcf = (int)ceil(((double)m_width) / m_horizCellFactor)+1;
-  m_hdvcf = (int)ceil(((double)m_height) / m_vertCellFactor)+1;
-  bool stop = true;
-  do
-  {
-    stop = true;
-    m_cells.clear();
-//     m_cells.resize(m_horizCellFactor * m_vertCellFactor);
-    
-    GraphNodeMap::iterator it, it_end;
-    it = m_nodesMap.begin(); it_end = m_nodesMap.end();
-    for (; it != it_end; it++)
-    {
-      GraphNode* gn = *it;
-//       int cellNum = cellNumber(int(gn->x()), int(gn->y()));
-      int cellNum = cellNumber(0,0);
-      kDebug() << "Found cell number " << cellNum;
-
-      if (m_cells.size() <= cellNum)
-      {
-        m_cells.resize(cellNum+1);
-      }
-      m_cells[cellNum].insert(gn);
-      
-      kDebug() << "after insert";
-      if ( m_cells[cellNum].size() > MAXCELLWEIGHT )
-      {
-        kDebug() << "cell number " << cellNum  << " contains " << m_cells[cellNum].size() << " nodes";
-        if ((m_width/m_horizCellFactor) > (m_height/m_vertCellFactor))
-        {
-          m_horizCellFactor++;
-          m_wdhcf = m_width / m_horizCellFactor;
-        }
-        else
-        {
-          m_vertCellFactor++;
-          m_hdvcf = m_height / m_vertCellFactor;
-        }
-        kDebug() << "cell factor is now " << m_horizCellFactor << " / " << m_vertCellFactor;
-        stop = false;
-        break;
-      }
-    }
-  } while (!stop);
-  kDebug() << "m_wdhcf=" << m_wdhcf << "; m_hdvcf=" << m_hdvcf << endl;
-  kDebug() << "finished" << endl;
-}
-
-QSet< GraphNode* >& DotGraph::nodesOfCell(unsigned int id)
-{
-  return m_cells[id];
-}
-
-void DotGraph::storeOriginalAttributes()
-{
-  foreach (GraphNode* node, nodes())
-  {
-    node->storeOriginalAttributes();
-  }
-  foreach (GraphEdge* edge, edges())
-  {
-    edge->storeOriginalAttributes();
-  }
-  foreach (GraphSubgraph* subgraph, subgraphs())
-  {
-    subgraph->storeOriginalAttributes();
-  }
-  GraphElement::storeOriginalAttributes();
-}
-
-void DotGraph::saveTo(const QString& fileName)
-{
-  kDebug() << fileName;
-  m_dotFileName = fileName;
-  GraphExporter exporter;
-  exporter.writeDot(this, fileName);
-}
-
-void DotGraph::updateWithGraph(graph_t* newGraph)
-{
-  kDebug();
-
-  // copy global graph render operations and attributes
-  renderOperations().clear();
-  if (agget(newGraph, (char*)"_draw_") != NULL)
-  {
-    parse_renderop(agget(newGraph, (char*)"_draw_"), renderOperations());
-    kDebug() << "_draw_: element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(newGraph, (char*)"_ldraw_") != NULL)
-  {
-    parse_renderop(agget(newGraph, (char*)"_ldraw_"), renderOperations());
-    kDebug() << "_ldraw_: element renderOperations size is now " << renderOperations().size();
-  }
-  
-  Agsym_t *attr = agfstattr(newGraph);
-  while(attr)
-  {
-    kDebug() << newGraph->name << ":" << attr->name << agxget(newGraph,attr->index);
-    m_attributes[attr->name] = agxget(newGraph,attr->index);
-    attr = agnxtattr(newGraph,attr);
-  }
-  
-  // copy subgraphs
-  for (edge_t* e = agfstout(newGraph->meta_node->graph, newGraph->meta_node); e;
-      e = agnxtout(newGraph->meta_node->graph, e))
-  {
-    graph_t* sg = agusergraph(e->head);
-    kDebug() << "subgraph:" << sg->name;
-    if (subgraphs().contains(sg->name))
-    {
-      kDebug() << "known";
-      // ???
-      //       nodes()[ngn->name]->setZ(ngn->z());
-      subgraphs()[sg->name]->updateWithSubgraph(sg);
-      if (subgraphs()[sg->name]->canvasElement()!=0)
-      {
-        //         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
-      }
-    }
-    else
-    {
-      kDebug() << "new";
-      GraphSubgraph* newsg = new GraphSubgraph(sg);
-      //       kDebug() << "new created";
-      subgraphs().insert(sg->name, newsg);
-      //       kDebug() << "new inserted";
-    }
-
-  }
-
-  // copy nodes
-  node_t* ngn = agfstnode(newGraph);
-  kDebug() << "first node:" << (void*)ngn;
-  
-  while (ngn != NULL)
-//   foreach (GraphNode* ngn, newGraph.nodes())
-  {
-    kDebug() << "node " << ngn->name;
-    if (nodes().contains(ngn->name))
-    {
-      kDebug() << "known";
-// ???
-//       nodes()[ngn->name]->setZ(ngn->z());
-      nodes()[ngn->name]->updateWithNode(ngn);
-      if (nodes()[ngn->name]->canvasElement()!=0)
-      {
-        //         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
-      }
-    }
-    else
-    {
-      kDebug() << "new";
-      GraphNode* newgn = new GraphNode(ngn);
-      //       kDebug() << "new created";
-      nodes().insert(ngn->name, newgn);
-      //       kDebug() << "new inserted";
-    }
-
-    // copy node edges
-    edge_t* nge = agfstout(newGraph, ngn);
-    while (nge != NULL)
-    {
-      kDebug() << "edge " << nge->id;
-      QString edgeName = QString(nge->head->name) + nge->tail->name;
-      if (edges().contains(edgeName))
-      {
-        kDebug() << "edge known" << nge->id;
-//         edges()[nge->name]->setZ(nge->z());
-        edges()[edgeName]->updateWithEdge(nge);
-        if (edges()[edgeName]->canvasEdge()!=0)
-        {
-          //         edges()[nge->id()]->canvasEdge()->setGh(m_height);
-        }
-      }
-      else
-      {
-        kDebug() << "new edge" << edgeName;
-        {
-          GraphEdge* newEdge = new GraphEdge();
-          newEdge->setId(edgeName);
-          newEdge->updateWithEdge(nge);
-          if (elementNamed(nge->tail->name) == 0)
-          {
-            GraphNode* newgn = new GraphNode();
-            //       kDebug() << "new created";
-            nodes().insert(nge->tail->name, newgn);
-          }
-          newEdge->setFromNode(elementNamed(nge->tail->name));
-          if (elementNamed(nge->head->name) == 0)
-          {
-            GraphNode* newgn = new GraphNode();
-            //       kDebug() << "new created";
-            nodes().insert(nge->head->name, newgn);
-          }
-          newEdge->setToNode(elementNamed(nge->head->name));
-          edges().insert(edgeName, newEdge);
-        }
-      }
-      nge = agnxtedge(newGraph, nge, ngn);
-    }
-    ngn = agnxtnode(newGraph, ngn);
-  }
-  kDebug() << "Done";
-  emit readyToDisplay();
-  computeCells();
-}
-
-void DotGraph::updateWithGraph(const DotGraph& newGraph)
-{
-  kDebug();
-  GraphElement::updateWithElement(newGraph);
-  m_width=newGraph.width();
-  m_height=newGraph.height();
-  m_scale=newGraph.scale();
-  m_directed=newGraph.directed();
-  m_strict=newGraph.strict();
-  computeCells();
-  foreach (GraphSubgraph* nsg, newGraph.subgraphs())
-  {
-    kDebug() << "subgraph" << nsg->id();
-    if (subgraphs().contains(nsg->id()))
-    {
-      kDebug() << "subgraph known" << nsg->id();
-      subgraphs().value(nsg->id())->updateWithSubgraph(*nsg);
-      if (subgraphs().value(nsg->id())->canvasElement()!=0)
-      {
-//         subgraphs().value(nsg->id())->canvasElement()->setGh(m_height);
-      }
-    }
-    else
-    {
-      kDebug() << "new subgraph" << nsg->id();
-      GraphSubgraph* newSubgraph = new GraphSubgraph();
-      newSubgraph->updateWithSubgraph(*nsg);
-      newSubgraph->setZ(0);
-      subgraphs().insert(nsg->id(), newSubgraph);
-    }
-  }
-  foreach (GraphNode* ngn, newGraph.nodes())
-  {
-    kDebug() << "node " << ngn->id();
-    if (nodes().contains(ngn->id()))
-    {
-      kDebug() << "known";
-      nodes()[ngn->id()]->setZ(ngn->z());
-      nodes()[ngn->id()]->updateWithNode(*ngn);
-      if (nodes()[ngn->id()]->canvasElement()!=0)
-      {
-//         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
-      }
-    }
-    else
-    {
-      kDebug() << "new";
-      GraphNode* newgn = new GraphNode(*ngn);
-//       kDebug() << "new created";
-      nodes().insert(ngn->id(), newgn);
-//       kDebug() << "new inserted";
-    }
-  }
-  foreach (GraphEdge* nge, newGraph.edges())
-  {
-    kDebug() << "edge " << nge->id();
-    if (edges().contains(nge->id()))
-    {
-      kDebug() << "edge known" << nge->id();
-      edges()[nge->id()]->setZ(nge->z());
-      edges()[nge->id()]->updateWithEdge(*nge);
-      if (edges()[nge->id()]->canvasEdge()!=0)
-      {
-//         edges()[nge->id()]->canvasEdge()->setGh(m_height);
-      }
-    }
-    else
-    {
-      kDebug() << "new edge" << nge->id();
-      {
-        GraphEdge* newEdge = new GraphEdge();
-        newEdge->setId(nge->id());
-        newEdge->updateWithEdge(*nge);
-        newEdge->setFromNode(elementNamed(nge->fromNode()->id()));
-        newEdge->setToNode(elementNamed(nge->toNode()->id()));
-        edges().insert(nge->id(), newEdge);
-      }
-    }
-  }
-  kDebug() << "Done";
-  computeCells();
-}
-
-void DotGraph::removeNodeNamed(const QString& nodeName)
-{
-  kDebug() << nodeName;
-  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(nodeName));
-  if (node == 0)
-  {
-    kError() << "No such node " << nodeName;
-    return;
-  }
-  
-  GraphEdgeMap::iterator it, it_end;
-  it = m_edgesMap.begin(); it_end = m_edgesMap.end();
-  while (it != it_end)
-  {
-    if ( it.value()->fromNode() == node
-        || it.value()->toNode() == node )
-    {
-      GraphEdge* edge = it.value();
-      if (edge->canvasEdge() != 0)
-      {
-        edge->canvasEdge()->hide();
-        delete edge->canvasEdge();
-        delete edge;
-      }
-      it = edges().erase(it);
-    }
-    else
-    {
-      ++it;
-    }
-  }
-
-  if (node->canvasNode() != 0)
-  {
-    node->canvasNode()->hide();
-    delete node->canvasNode();
-    node->setCanvasNode(0);
-  }
-  nodes().remove(nodeName);
-  delete node;
-
-}
-
-void DotGraph::removeNodeFromSubgraph(
-    const QString& nodeName,
-    const QString& subgraphName)
-{
-  kDebug() << nodeName << subgraphName;
-  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(nodeName));
-  if (node == 0)
-  {
-    kError() << "No such node " << nodeName;
-    return;
-  }
-
-  GraphSubgraph* subgraph = subgraphs()[subgraphName];
-  if (subgraph == 0)
-  {
-    kError() << "No such subgraph " << subgraphName;
-    return;
-  }
-  
-  subgraph->removeElement(node);
-  if (subgraph->content().isEmpty())
-  {
-    removeSubgraphNamed(subgraphName);
-  }
-}
-
-void DotGraph::removeSubgraphNamed(const QString& subgraphName)
-{
-  kDebug() << subgraphName << " from " << subgraphs().keys();
-  GraphSubgraph* subgraph = subgraphs()[subgraphName];
-
-  if (subgraph == 0)
-  {
-    kError() << "Subgraph" << subgraphName << "not found";
-    return;
-  }
-  GraphEdgeMap::iterator it, it_end;
-  it = m_edgesMap.begin(); it_end = m_edgesMap.end();
-  while (it != it_end)
-  {
-    if ( it.value()->fromNode() == subgraph
-        || it.value()->toNode() == subgraph )
-    {
-      GraphEdge* edge = it.value();
-      if (edge->canvasEdge() != 0)
-      {
-        edge->canvasEdge()->hide();
-        delete edge->canvasEdge();
-        delete edge;
-      }
-      it = edges().erase(it);
-    }
-    else
-    {
-      ++it;
-    }
-  }
-
-  if (subgraph->canvasSubgraph() != 0)
-  {
-    subgraph->canvasSubgraph()->hide();
-    delete subgraph->canvasSubgraph();
-    subgraph->setCanvasSubgraph(0);
-  }
-  foreach(GraphElement* element, subgraph->content())
-  {
-    if (dynamic_cast<GraphNode*>(element) != 0)
-    {
-      kDebug() << "Adding" << element->id() << "to main graph";
-      nodes()[element->id()] = dynamic_cast<GraphNode*>(element);
-    }
-    else if (dynamic_cast<GraphSubgraph*>(element) != 0)
-    {
-      subgraphs()[element->id()] = dynamic_cast<GraphSubgraph*>(element);
-    }
-    else
-    {
-      kError() << "Don't know how to handle" << element->id();
-    }
-  }
-  subgraph->content().clear();
-  subgraphs().remove(subgraphName);
-  delete subgraph;
-}
-
-void DotGraph::removeEdge(const QString& id)
-{
-  kDebug() << id;
-  GraphEdgeMap::iterator it = edges().begin();
-  for (; it != edges().end(); it++)
-  {
-    GraphEdge* edge = it.value();
-    if (edge->id() ==id)
-    {
-      if (edge->canvasEdge() != 0)
-      {
-        edge->canvasEdge()->hide();
-        delete edge->canvasEdge();
-        delete edge;
-      }
-      edges().remove(id);
-      break;
-    }
-  }
-}
-
-void DotGraph::removeElement(const QString& id)
-{
-  kDebug() << id;
-  GraphNodeMap::const_iterator itN = nodes().constBegin();
-  for (; itN != nodes().constEnd(); itN++)
-  {
-    const GraphNode* node = itN.value();
-    if (node->id() == id)
-    {
-      removeNodeNamed(id);
-      return;
-    }
-  }
-  GraphEdgeMap::const_iterator itE = edges().constBegin();
-  for (; itE != edges().constEnd(); itE++)
-  {
-    const GraphEdge* edge = itE.value();
-    if (edge->id() == id)
-    {
-      removeEdge(id);
-      return;
-    }
-  }
-  GraphSubgraphMap::const_iterator itS = subgraphs().constBegin();
-  for (; itS != subgraphs().constEnd(); itS++)
-  {
-    const GraphSubgraph* subgraph = itS.value();
-    if (subgraph->id() == id)
-    {
-      removeSubgraphNamed(id);
-      return;
-    }
-  }
-}
-
-void DotGraph::setAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue)
-{
-  if (nodes().contains(elementId))
-  {
-    nodes()[elementId]->attributes()[attributeName] = attributeValue;
-  }
-  else if (edges().contains(elementId))
-  {
-    edges()[elementId]->attributes()[attributeName] = attributeValue;
-  }
-  else if (subgraphs().contains(elementId))
-  {
-    subgraphs()[elementId]->attributes()[attributeName] = attributeValue;
-  }
-}
-
-GraphElement* DotGraph::elementNamed(const QString& id)
-{
-  GraphElement* ret = 0;
-  if ((ret = m_nodesMap.value(id, 0))) {
-    return ret;
-  }
-  if ((ret = m_edgesMap.value(id, 0))) {
-    return ret;
-  }
-  foreach(GraphSubgraph* subGraph, m_subgraphsMap) {
-    if ((ret = subGraph->elementNamed(id))) {
-      return ret;
-    }
-  }
-  return 0;
-}
-
-void DotGraph::setGraphAttributes(QMap<QString,QString> attribs)
-{
-  kDebug() << attribs;
-  attributes() = attribs;
-}
-
-
-void DotGraph::addNewNode(QMap<QString,QString> attribs)
-{
-  kDebug() << attribs;
-  GraphNode* newNode = new GraphNode();
-  newNode->attributes() = attribs;
-  nodes().insert(newNode->id(), newNode);
-  kDebug() << "node added as" << newNode->id();
-}
-
-void DotGraph::addNewSubgraph(QMap<QString,QString> attribs)
-{
-  kDebug() << attribs;
-  GraphSubgraph* newSG = new GraphSubgraph();
-  newSG->attributes() = attribs;
-  subgraphs()[newSG->id()] = newSG;
-  kDebug() << "subgraph added as" << newSG->id();
-}
-
-void DotGraph::addNewNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph)
-{
-  kDebug() << attribs << "to" << subgraph;
-  GraphNode* newNode = new GraphNode();
-  newNode->attributes() = attribs;
-  subgraphs()[subgraph]->content().push_back(newNode);
-
-  kDebug() << "node added as" << newNode->id() << "in" << subgraph;
-}
-
-void DotGraph::addExistingNodeToSubgraph(QMap<QString,QString> attribs,QString subgraph)
-{
-  kDebug() << attribs << "to" << subgraph;
-  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(attribs["id"]));
-  if (node == 0)
-  {
-    kError() << "No such node" << attribs["id"];
-    return;
-  }
-  if (nodes().contains(attribs["id"]))
-  {
-    nodes().remove(attribs["id"]);
-    node->attributes() = attribs;
-    subgraphs()[subgraph]->content().push_back(node);
-    kDebug() << "node " << node->id() << " added in " << subgraph;
-  }
-  else
-  {
-    foreach(GraphSubgraph* gs, subgraphs())
-    {
-      GraphElement* elt = 0;
-      foreach(GraphElement* element, gs->content())
-      {
-        if (element == node)
-        {
-          elt = element;
-          break;
-        }
-      }
-      if (elt != 0)
-      {
-        kDebug() << "removing node " << elt->id() << " from " << gs->id();
-        gs->removeElement(elt);
-        subgraphs()[subgraph]->content().push_back(elt);
-        kDebug() << "node " << elt->id() << " added in " << subgraph;
-        break;
-      }
-    }
-  }
-}
-
-void DotGraph::moveExistingNodeToMainGraph(QMap<QString,QString> attribs)
-{
-  kDebug() << attribs;
-  GraphNode* node = dynamic_cast<GraphNode*>(elementNamed(attribs["id"]));
-  if (node == 0)
-  {
-    kError() << "No such node" << attribs["id"];
-    return;
-  }
-  else if (nodes().contains(attribs["id"]))
-  {
-    kError() << "Node" << attribs["id"] << "already in main graph";
-    return;
-  }
-  else
-  {
-    foreach(GraphSubgraph* gs, subgraphs())
-    {
-      bool found = false;
-      foreach(GraphElement* element, gs->content())
-      {
-        if (element == node)
-        {
-          found = true;
-          break;
-        }
-      }
-      if (found)
-      {
-        kDebug() << "removing node " << node->id() << " from " << gs->id();
-        gs->removeElement(node);
-        nodes()[node->id()] = node;
-        kDebug() << "node " << node->id() << " moved to main graph";
-        break;
-      }
-    }
-  }
-}
-
-void DotGraph::addNewEdge(QString src, QString tgt, QMap<QString,QString> attribs)
-{
-  kDebug() << src << tgt << attribs;
-  GraphEdge* newEdge = new GraphEdge();
-  newEdge->attributes() = attribs;
-  GraphElement* srcElement = elementNamed(src);
-  if (srcElement == 0)
-  {
-    srcElement = elementNamed(QString("cluster_")+src);
-  }
-  GraphElement* tgtElement = elementNamed(tgt);
-  if (tgtElement == 0)
-  {
-    tgtElement = elementNamed(QString("cluster_")+tgt);
-  }
-  
-  if (srcElement == 0 || tgtElement == 0)
-  {
-    kError() << src << "or" << tgt << "missing";
-    return;
-  }
-  if (attribs.contains("id"))
-  {
-    newEdge->setId(attribs["id"]);
-  }
-  else
-  {
-    newEdge->setId(src+tgt+QUuid::createUuid().toString().remove('{').remove('}').remove('-'));
-  }
-  newEdge->setFromNode(srcElement);
-  newEdge->setToNode(tgtElement);
-  edges().insert(newEdge->id(), newEdge);
-}
-
-void DotGraph::removeAttribute(const QString& nodeName, const QString& attribName)
-{
-  kDebug();
-  GraphElement* element = elementNamed(nodeName);
-  if (element != 0)
-  {
-    element->removeAttribute(attribName);
-  }
-}
-
-void DotGraph::renameNode(const QString& oldNodeName, const QString& newNodeName)
-{
-  if (oldNodeName != newNodeName)
-  {
-    kDebug() << "Renaming " << oldNodeName << " into " << newNodeName;
-    GraphNode* node = nodes()[oldNodeName];
-    nodes().remove(oldNodeName);
-    node->setId(newNodeName);
-    nodes()[newNodeName] = node;
-  }
-}
-
-QString DotGraph::backColor() const
-{
-  kDebug();
-  if (m_attributes.find("bgcolor") != m_attributes.end())
-  {
-    return m_attributes["bgcolor"];
-  }
-  else
-  {
-    return QString();
-  }
-}
-
-
-}
-
-#include "dotgraph.moc"
diff --git a/src/part/dotgraph.h b/src/part/dotgraph.h
deleted file mode 100644
index 9de9855..0000000
--- a/src/part/dotgraph.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/*
- * GraphViz dot Graph model
- */
-
-#ifndef DOT_GRAPH_H
-#define DOT_GRAPH_H
-
-#include <QList>
-#include <QSet>
-#include <QString>
-#include <QProcess>
-#include <QMutex>
-
-#include "kgraphviewer_export.h"
-#include "graphelement.h"
-#include "graphsubgraph.h"
-#include "graphnode.h"
-#include "graphedge.h"
-#include "dotdefaults.h"
-
-class Agraph_t;
-
-namespace KGraphViewer
-{
-  
-/**
-  * A class representing the model of a GraphViz dot graph
-  */
-class DotGraph : public GraphElement
-{
-  Q_OBJECT
-public:
-  enum ParsePhase {Initial, Final};
-  
-  DotGraph();
-  DotGraph(const QString& command, const QString& fileName);
-
-  virtual ~DotGraph();
-  
-  QString chooseLayoutProgramForFile(const QString& str);
-  bool parseDot(const QString& str);
-  
-  /** Constant accessor to the nodes of this graph */
-  inline const GraphNodeMap& nodes() const {return m_nodesMap;}
-  /** Constant accessor to the edges of this graph */
-  inline const GraphEdgeMap& edges() const {return m_edgesMap;}
-  inline const GraphSubgraphMap& subgraphs() const {return m_subgraphsMap;}
-  /** Accessor to the nodes of this graph */
-  inline GraphNodeMap& nodes() {return m_nodesMap;}
-  /** Accessor to the edges of this graph */
-  inline GraphEdgeMap& edges() {return m_edgesMap;}
-  inline GraphSubgraphMap& subgraphs() {return m_subgraphsMap;}
-  double width() const {return m_width;}
-  double height() const {return m_height;}
-  double scale() const {return m_scale;}
-  void width(double w) {m_width = w;}
-  void height(double h) {m_height = h;}
-  void scale(double s) {m_scale = s;}
-  virtual QString backColor() const;
-  
-  inline void strict(bool s) {m_strict = s;}
-  inline void directed(bool d) {m_directed = d;}
-  inline bool strict() const {return m_strict;}
-  inline bool directed() const {return m_directed;}
-
-  QSet< GraphNode* >& nodesOfCell(unsigned int id);
-  
-  inline unsigned int horizCellFactor() const {return m_horizCellFactor;}
-  inline unsigned int vertCellFactor() const {return m_vertCellFactor;}
-  inline double wdhcf() const {return m_wdhcf;}
-  inline double hdvcf() const {return m_hdvcf;}
-  
-  inline void layoutCommand(const QString& command) {m_layoutCommand = command;}
-  inline const QString& layoutCommand() {return m_layoutCommand;}
-  
-  inline void dotFileName(const QString& fileName) {m_dotFileName = fileName;}
-  inline const QString& dotFileName() const {return m_dotFileName;}
-
-  bool update();
-
-  inline void setReadWrite() {m_readWrite = true;}
-  inline void setReadOnly() {m_readWrite = false;}
-
-  virtual void storeOriginalAttributes();
-
-  void KGRAPHVIEWER_EXPORT saveTo(const QString& fileName);
-
-  virtual void updateWithGraph(Agraph_t* newGraph);
-  virtual void updateWithGraph(const DotGraph& graph);
-
-  void KGRAPHVIEWER_EXPORT setAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue);
-
-  GraphElement* elementNamed(const QString& id);
-
-  inline void setUseLibrary(bool value) {m_useLibrary = value;}
-  inline bool useLibrary() {return m_useLibrary;}
-
-  void KGRAPHVIEWER_EXPORT setGraphAttributes(QMap<QString,QString> attribs);
-  void KGRAPHVIEWER_EXPORT addNewNode(QMap<QString,QString> attribs);
-  void KGRAPHVIEWER_EXPORT addNewSubgraph(QMap<QString,QString> attribs);
-  void KGRAPHVIEWER_EXPORT addNewNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph);
-  void KGRAPHVIEWER_EXPORT addExistingNodeToSubgraph(QMap<QString,QString> attribs,QString subgraph);
-  void KGRAPHVIEWER_EXPORT moveExistingNodeToMainGraph(QMap<QString,QString> attribs);
-  void KGRAPHVIEWER_EXPORT addNewEdge(QString src, QString tgt, QMap<QString,QString> attribs);
-  void KGRAPHVIEWER_EXPORT removeAttribute(const QString& nodeName, const QString& attribName);
-  void KGRAPHVIEWER_EXPORT renameNode(const QString& oldNodeName, const QString& newNodeName);
-  void KGRAPHVIEWER_EXPORT removeNodeNamed(const QString& nodeName);
-  void KGRAPHVIEWER_EXPORT removeNodeFromSubgraph(const QString& nodeName, const QString& subgraphName);
-  void KGRAPHVIEWER_EXPORT removeSubgraphNamed(const QString& subgraphName);
-  void KGRAPHVIEWER_EXPORT removeEdge(const QString& id);
-  void KGRAPHVIEWER_EXPORT removeElement(const QString& id);
-
-Q_SIGNALS:
-  void readyToDisplay();
-
-private Q_SLOTS:
-  void slotDotRunningDone(int,QProcess::ExitStatus);
-  void slotDotRunningError(QProcess::ProcessError);
-  
-private:
-  unsigned int cellNumber(int x, int y);
-  void computeCells();
-  QByteArray getDotResult(int exitCode, QProcess::ExitStatus exitStatus);
-    
-  QString m_dotFileName;
-  GraphSubgraphMap m_subgraphsMap;
-  GraphNodeMap m_nodesMap;
-  GraphEdgeMap m_edgesMap;
-  double m_width, m_height;
-  double m_scale;
-  bool m_directed;
-  bool m_strict;
-  QString m_layoutCommand;
-  
-  unsigned int m_horizCellFactor, m_vertCellFactor;
-  QVector< QSet< GraphNode* > > m_cells;
-  
-  double m_wdhcf, m_hdvcf;
-
-  bool m_readWrite;
-  QProcess* m_dot;
-
-  ParsePhase m_phase;
-
-  QMutex m_dotProcessMutex;
-
-  bool m_useLibrary;
-};
-
-}
-
-#endif
-
-
-
diff --git a/src/part/dotgraphview.cpp b/src/part/dotgraphview.cpp
deleted file mode 100644
index 4751462..0000000
--- a/src/part/dotgraphview.cpp
+++ /dev/null
@@ -1,2262 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.cpp, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Callgraph View
- */
-
-#include "dotgraphview.h"
-
-#include "dotgraph.h"
-#include "graphelement.h"
-#include "pannerview.h"
-#include "canvassubgraph.h"
-#include "canvasedge.h"
-#include "dot2qtconsts.h"
-#include "graphnode.h"
-#include "canvasnode.h"
-#include "graphedge.h"
-#include "FontsCache.h"
-#include "kgraphviewer_partsettings.h"
-#include "simpleprintingcommand.h"
-#include "graphexporter.h"
-#include "loadagraphthread.h"
-#include "layoutagraphthread.h"
-
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-#include <limits>
-
-#include <graphviz/types.h>
-
-#include <QMatrix>
-#include <QPainter>
-#include <QStyle>
-#include <QImage>
-#include <QContextMenuEvent>
-#include <QKeyEvent>
-#include <QPixmap>
-#include <QBitmap>
-#include <QResizeEvent>
-#include <QFocusEvent>
-#include <QMouseEvent>
-#include <QWheelEvent>
-#include <QMenu>
-#include <QGraphicsSimpleTextItem>
-#include <QScrollBar>
-#include <QUuid>
-
-#include <kdebug.h>
-#include <klocale.h>
-#include <kfiledialog.h>
-#include <kmessagebox.h>
-#include <kinputdialog.h>
-#include <kselectaction.h>
-#include <ktoggleaction.h>
-#include <kstandarddirs.h>
-#include <kactionmenu.h>
-    
-// DotGraphView defaults
-
-#define DEFAULT_ZOOMPOS      KGraphViewerInterface::Auto
-#define KGV_MAX_PANNER_NODES 100
-
-namespace KGraphViewer
-{
-
-class DotGraphViewPrivate
-{
-
-public:
-  DotGraphViewPrivate(KActionCollection* actions, DotGraphView* parent) : 
-   m_labelViews(),
-    m_popup(0),
-    m_zoom(1),
-    m_isMoving(false),
-    m_exporter(),
-    m_zoomPosition(DEFAULT_ZOOMPOS),
-    m_lastAutoPosition(KGraphViewerInterface::TopLeft),
-    m_graph(0),
-    m_printCommand(0),
-    m_actions(actions),
-    m_detailLevel(DEFAULT_DETAILLEVEL),
-    m_defaultNewElement(0),
-    m_defaultNewElementPixmap(KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-newnode.png")),
-    m_editingMode(DotGraphView::None),
-    m_newEdgeSource(0),
-    m_newEdgeDraft(0),
-    m_readWrite(false),
-    m_leavedTimer(std::numeric_limits<int>::max()),
-    m_highlighting(false),
-    m_loadThread(),
-    m_layoutThread(),
-    m_backgroundColor(QColor("white")),
-    q_ptr( parent )
-  {
-    
-  }
-  virtual ~DotGraphViewPrivate()
-  {
-    delete m_birdEyeView;
-    m_birdEyeView = 0;
-    if (m_popup != 0)
-    {
-      delete m_popup;
-    }
-    if (m_canvas)
-    {
-      Q_Q(DotGraphView);
-      q->setScene(0);
-      delete m_canvas;
-    }
-    if (m_graph != 0)
-    {
-      delete m_graph;
-    }
-  }
-  
-
-  void updateSizes(QSizeF s = QSizeF(0,0));
-  void updateBirdEyeView();
-  void setupPopup();
-  void exportToImage();
-  KActionCollection* actionCollection() {return m_actions;}
-  int displaySubgraph(GraphSubgraph* gsubgraph, int zValue, CanvasElement* parent = 0);
-
-
-  QSet<QGraphicsSimpleTextItem*> m_labelViews;
-  QGraphicsScene* m_canvas;
-  QMenu* m_popup;
-  KSelectAction* m_bevPopup;
-  KSelectAction* m_layoutAlgoSelectAction;
-  int m_xMargin, m_yMargin;
-  PannerView *m_birdEyeView;
-  double m_cvZoom;
-  double m_zoom;
-  bool m_isMoving;
-  QPoint m_lastPos;
-
-  GraphExporter m_exporter;
-
-  // widget options
-  KGraphViewerInterface::PannerPosition m_zoomPosition, m_lastAutoPosition;
-
-  DotGraph* m_graph;
-
-  KGVSimplePrintingCommand* m_printCommand;
-
-  KToggleAction* m_bevEnabledAction;
-  KActionCollection* m_actions;
-
-  int m_detailLevel;
-
-  GraphElement* m_defaultNewElement;
-
-  /** image used for a new node just added in an edited graph because this new node has
-    *  still no attribute and thus no render operation */
-  QPixmap m_defaultNewElementPixmap;
-  DotGraphView::EditingMode m_editingMode;
-
-  CanvasElement* m_newEdgeSource;
-  QGraphicsLineItem* m_newEdgeDraft;
-
-  bool m_readWrite;
-
-  QMap<QString, QString> m_newElementAttributes;
-
-  /// identifier of the timer started when the mouse leaves the view during
-  /// edge drawing
-  int m_leavedTimer;
-
-  DotGraphView::ScrollDirection m_scrollDirection;
-
-  QPoint m_pressPos;
-  QPoint m_pressScrollBarsPos;
-
-  /// true if elements should be highlighted on hover; false otherwise
-  bool m_highlighting;
-
-  /// A thread to load graphviz agraph files
-  LoadAGraphThread m_loadThread;
-
-  /// A thread to layout graphviz agraph files
-  LayoutAGraphThread m_layoutThread;
-
-  /// The graph background color
-  QColor m_backgroundColor;
-
-  DotGraphView * const q_ptr;
-  Q_DECLARE_PUBLIC(DotGraphView);
-};
-  
-void DotGraphViewPrivate::updateSizes(QSizeF s)
-{
-  kDebug() ;
-  Q_Q(DotGraphView);
-  if (m_canvas == 0)
-    return;
-  if (s == QSizeF(0,0)) s = q->size();
-  
-  // the part of the canvas that should be visible
-  qreal cWidth  = m_canvas->width()  - 2*m_xMargin + 100;
-  qreal cHeight = m_canvas->height() - 2*m_yMargin + 100;
-  
-  // hide birds eye view if no overview needed
-  if (//!_data || !_activeItem ||
-      !KGraphViewerPartSettings::birdsEyeViewEnabled() ||
-      (((cWidth * m_zoom) < s.width()) && (cHeight * m_zoom) < s.height()))
-  {
-    m_birdEyeView->hide();
-    return;
-  }
-  m_birdEyeView->hide();
-  
-  // first, assume use of 1/3 of width/height (possible larger)
-  double zoom = .33 * s.width() / cWidth;
-  if (zoom * cHeight < .33 * s.height()) zoom = .33 * s.height() / cHeight;
-  
-  // fit to widget size
-  if (cWidth  * zoom  > s.width())   zoom = s.width() / (double)cWidth;
-  if (cHeight * zoom  > s.height())  zoom = s.height() / (double)cHeight;
-  
-  // scale to never use full height/width
-  zoom = zoom * 3/4;
-  
-  // at most a zoom of 1/3
-  if (zoom > .33) zoom = .33;
-  
-  if (zoom != m_cvZoom)
-  {
-    m_cvZoom = zoom;
-    
-    QMatrix wm;
-    wm.scale( zoom, zoom );
-    m_birdEyeView->setMatrix(wm);
-    
-    // make it a little bigger to compensate for widget frame
-    m_birdEyeView->resize((cWidth * zoom) + 4,
-                          (cHeight * zoom) + 4);
-    
-  }
-  updateBirdEyeView();
-  m_birdEyeView->setZoomRect(q->mapToScene(q->viewport()->rect()).boundingRect());
-  m_birdEyeView->show();
-  QSizeF newCanvasSize = m_canvas->sceneRect().size();
-  if (newCanvasSize.width() < q->viewport()->width())
-  {
-    newCanvasSize.setWidth(q->viewport()->width());
-  }
-  else if (q->viewport()->width() < m_canvas->sceneRect().size().width())
-  {
-    newCanvasSize.setWidth(m_canvas->sceneRect().size().width());
-  }
-  if (newCanvasSize.height() < q->viewport()->height())
-  {
-    newCanvasSize.setHeight(q->viewport()->height());
-  }
-  else if (q->viewport()->height() < m_canvas->sceneRect().size().height())
-  {
-    newCanvasSize.setHeight(m_canvas->sceneRect().size().height());
-  }
-  //   std::cerr << "done." << std::endl;
-}
-
-void DotGraphViewPrivate::updateBirdEyeView()
-{
-  Q_Q(DotGraphView);
-  qreal cvW = m_birdEyeView->width();
-  qreal cvH = m_birdEyeView->height();
-  qreal x = q->width()- cvW - q->verticalScrollBar()->width()    -2;
-  qreal y = q->height()-cvH - q->horizontalScrollBar()->height() -2;
-  QPoint oldZoomPos = m_birdEyeView->pos();
-  QPoint newZoomPos = QPoint(0,0);
-  KGraphViewerInterface::PannerPosition zp = m_zoomPosition;
-  if (zp == KGraphViewerInterface::Auto)
-  {
-    QPointF tl1Pos = q->mapToScene(QPoint(0,0));
-    QPointF tl2Pos = q->mapToScene(QPoint(cvW,cvH));
-    QPointF tr1Pos = q->mapToScene(QPoint(x,0));
-    QPointF tr2Pos = q->mapToScene(QPoint(x+cvW,cvH));
-    QPointF bl1Pos = q->mapToScene(QPoint(0,y));
-    QPointF bl2Pos = q->mapToScene(QPoint(cvW,y+cvH));
-    QPointF br1Pos = q->mapToScene(QPoint(x,y));
-    QPointF br2Pos = q->mapToScene(QPoint(x+cvW,y+cvH));
-    int tlCols = m_canvas->items(QRectF(tl1Pos.x(),tl1Pos.y(),tl2Pos.x(),tl2Pos.y())).count();
-    kDebug() << tr1Pos.x() << tr1Pos.y() << tr2Pos.x() << tr2Pos.y();
-    int trCols = m_canvas->items(QRectF(tr1Pos.x(),tr1Pos.y(),tr2Pos.x(),tr2Pos.y())).count();
-    int blCols = m_canvas->items(QRectF(bl1Pos.x(),bl1Pos.y(),bl2Pos.x(),bl2Pos.y())).count();
-    int brCols = m_canvas->items(QRectF(br1Pos.x(),br1Pos.y(),br2Pos.x(),br2Pos.y())).count();
-    int minCols = tlCols;
-    zp = m_lastAutoPosition;
-    switch(zp)
-    {
-      case KGraphViewerInterface::TopRight:    minCols = trCols; break;
-      case KGraphViewerInterface::BottomLeft:  minCols = blCols; break;
-      case KGraphViewerInterface::BottomRight: minCols = brCols; break;
-      default:
-      case KGraphViewerInterface::TopLeft:     minCols = tlCols; break;
-    }
-    if (minCols > tlCols) { minCols = tlCols; zp = KGraphViewerInterface::TopLeft; }
-    if (minCols > trCols) { minCols = trCols; zp = KGraphViewerInterface::TopRight; }
-    if (minCols > blCols) { minCols = blCols; zp = KGraphViewerInterface::BottomLeft; }
-    if (minCols > brCols) { minCols = brCols; zp = KGraphViewerInterface::BottomRight; }
-    
-    m_lastAutoPosition = zp;
-  }
-  
-  switch(zp)
-  {
-    case KGraphViewerInterface::TopRight:
-      newZoomPos = QPoint(x,0);
-      break;
-    case KGraphViewerInterface::BottomLeft:
-      newZoomPos = QPoint(0,y);
-      break;
-    case KGraphViewerInterface::BottomRight:
-      newZoomPos = QPoint(x,y);
-      break;
-    default:
-      break;
-  }
-  if (newZoomPos != oldZoomPos)
-    m_birdEyeView->move(newZoomPos);
-}
-
-int DotGraphViewPrivate::displaySubgraph(GraphSubgraph* gsubgraph, int zValue, CanvasElement* parent)
-{
-  kDebug();
-  Q_Q(DotGraphView);
-  double scaleX = 1.0, scaleY = 1.0;
-  
-  if (m_detailLevel == 0)      { scaleX = m_graph->scale() * 0.7; scaleY = m_graph->scale() * 0.7; }
-  else if (m_detailLevel == 1) { scaleX = m_graph->scale() * 1.0; scaleY = m_graph->scale() * 1.0; }
-  else if (m_detailLevel == 2) { scaleX = m_graph->scale() * 1.3; scaleY = m_graph->scale() * 1.3; }
-  else                        { scaleX = m_graph->scale() * 1.0; scaleY = m_graph->scale() * 1.0; }
-  
-  qreal gh = m_graph->height();
-  
-  if (gsubgraph->canvasSubgraph() == 0)
-  {
-    kDebug() << "Creating canvas subgraph for" << gsubgraph->id();
-    CanvasSubgraph* csubgraph = new CanvasSubgraph(q, gsubgraph, m_canvas, parent);
-    csubgraph->initialize(
-      scaleX, scaleY, m_xMargin, m_yMargin, gh,
-      m_graph->wdhcf(), m_graph->hdvcf());
-    gsubgraph->setCanvasSubgraph(csubgraph);
-    //       csubgraph->setZValue(gsubgraph->z());
-    csubgraph->setZValue(zValue+=2);
-    csubgraph->show();
-    m_canvas->addItem(csubgraph);
-    kDebug() << " one CanvasSubgraph... Done";
-  }
-  foreach (GraphElement* element, gsubgraph->content())
-  {
-    GraphNode* gnode = dynamic_cast<GraphNode*>(element);
-    if (gnode->canvasNode()==0)
-    {
-      kDebug() << "Creating canvas node for:" << gnode->id();
-      CanvasNode *cnode = new CanvasNode(q, gnode, m_canvas);
-      if (cnode == 0) continue;
-      cnode->initialize(
-        scaleX, scaleY, m_xMargin, m_yMargin, gh,
-        m_graph->wdhcf(), m_graph->hdvcf());
-      gnode->setCanvasNode(cnode);
-      m_canvas->addItem(cnode);
-      //       cnode->setZValue(gnode->z());
-      cnode->setZValue(zValue+1);
-      cnode->show();
-    }
-    gnode->canvasNode()->computeBoundingRect();
-  }
-  gsubgraph->canvasSubgraph()->computeBoundingRect();
-  
-  int newZvalue = zValue;
-  foreach(GraphSubgraph* ssg, gsubgraph->subgraphs())
-  {
-    int hereZvalue = displaySubgraph(ssg, zValue, gsubgraph->canvasSubgraph());
-    if (hereZvalue > newZvalue)
-      newZvalue = hereZvalue;
-  }
-  return newZvalue;
-}
-
-void DotGraphViewPrivate::setupPopup()
-{
-  Q_Q(DotGraphView);
-  if (m_popup != 0)
-  {
-    return;
-  }
-  kDebug() << "DotGraphView::setupPopup";
-  m_popup = new QMenu();
-  
-  m_layoutAlgoSelectAction = new KSelectAction(i18n("Select Layout Algo"),q);
-  actionCollection()->addAction("view_layout_algo",m_layoutAlgoSelectAction);
-  
-  QStringList layoutAlgos;
-  KAction* lea = new KAction(i18n(" "), q);
-  lea->setWhatsThis(i18n("Specify yourself the layout command to use. Given a dot file, it should produce an xdot file on its standard output."));
-  actionCollection()->addAction("layout_specifiy",lea);
-  lea->setCheckable(false);
-  
-  KAction* lda = new KAction(i18n("Dot"), q);
-  lda->setWhatsThis(i18n("Layout the graph using the dot program."));
-  actionCollection()->addAction("layout_dot",lda);
-  lda->setCheckable(false);
-  
-  KAction* lna = new KAction(i18n("Neato"), q);
-  lna->setWhatsThis(i18n("Layout the graph using the neato program."));
-  actionCollection()->addAction("layout_neato",lna);
-  lna->setCheckable(false);
-  
-  KAction* lta = new KAction(i18n("Twopi"), q);
-  lta->setWhatsThis(i18n("Layout the graph using the twopi program."));
-  actionCollection()->addAction("layout_twopi",lta);
-  lta->setCheckable(false);
-  
-  KAction* lfa = new KAction(i18n("Fdp"), q);
-  lfa->setWhatsThis(i18n("Layout the graph using the fdp program."));
-  actionCollection()->addAction("layout_fdp",lfa);
-  lfa->setCheckable(false);
-  
-  KAction* lca = new KAction(i18n("Circo"), q);
-  lca->setWhatsThis(i18n("Layout the graph using the circo program."));
-  actionCollection()->addAction("layout_c",lca);
-  lca->setCheckable(false);
-  
-  m_layoutAlgoSelectAction->addAction(lea);
-  m_layoutAlgoSelectAction->addAction(lda);
-  m_layoutAlgoSelectAction->addAction(lna);
-  m_layoutAlgoSelectAction->addAction(lta);
-  m_layoutAlgoSelectAction->addAction(lfa);
-  m_layoutAlgoSelectAction->addAction(lca);
-  
-  m_layoutAlgoSelectAction->setCurrentItem(1);
-  m_layoutAlgoSelectAction->setEditable(true);
-  m_layoutAlgoSelectAction->setToolTip(i18n("Choose a GraphViz layout algorithm or edit your own one."));
-  m_layoutAlgoSelectAction->setWhatsThis(i18n(
-    "Choose a GraphViz layout algorithm or type in your own command that will "
-    "generate a graph in the xdot format on its standard output. For example, to "
-    "manually specify the <tt>G</tt> option to the dot command, type in: "
-    "<tt>dot -Gname=MyGraphName -Txdot </tt>"));
-  QObject::connect(m_layoutAlgoSelectAction, SIGNAL(triggered (const QString &)),
-          q, SLOT(slotSelectLayoutAlgo(const QString&)));
-  
-  
-  QMenu* layoutPopup = m_popup->addMenu(i18n("Layout"));
-  layoutPopup->addAction(m_layoutAlgoSelectAction);
-  QAction* slc = layoutPopup->addAction(i18n("Specify layout command"), q, SLOT(slotLayoutSpecify()));
-  slc->setWhatsThis(i18n("Specify yourself the layout command to use. Given a dot file, it should produce an xdot file on its standard output."));
-  QAction* rlc = layoutPopup->addAction(i18n("Reset layout command to default"), q, SLOT(slotLayoutReset()));
-  rlc->setWhatsThis(i18n("Resets the layout command to use to the default depending on the graph type (directed or not)."));
-  
-  m_popup->addAction(KIcon("zoom-in"), i18n("Zoom In"), q, SLOT(zoomIn()));
-  m_popup->addAction(KIcon("zoom-out"), i18n("Zoom Out"), q, SLOT(zoomOut()));
-  
-  m_popup->insertSeparator();
-  
-  KActionMenu* file_exportMenu = new KActionMenu(i18n("Export Graph"), q);
-  actionCollection()->addAction("file_export",file_exportMenu);
-  file_exportMenu->setToolTip(i18n("Allows the graph to be exported in another format."));
-  file_exportMenu->setWhatsThis(i18n(
-    "Use the Export Graph menu to export the graph in another format. "
-    "There is currently only one export format supported: as a PNG image."));
-  
-  
-  m_popup->addAction(file_exportMenu);
-  KAction* exportToImageAction = new KAction(i18n("As Image..."),q);
-  exportToImageAction->setWhatsThis(i18n("Export the graph to an image file (currently PNG only.)"));
-  actionCollection()->addAction("export_image", exportToImageAction);
-  QObject::connect(exportToImageAction,SIGNAL(triggered(bool)), q, SLOT(slotExportImage()));
-  
-  file_exportMenu->addAction(exportToImageAction);
-  
-  
-  m_popup->insertSeparator();
-  
-  m_bevEnabledAction = new KToggleAction(
-    KIcon(KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-bev.png")),
-                                        i18n("Enable Bird's-eye View"), q);
-    actionCollection()->addAction("view_bev_enabled",m_bevEnabledAction);
-    m_bevEnabledAction->setShortcut(Qt::CTRL+Qt::Key_B);
-    m_bevEnabledAction->setWhatsThis(i18n("Enables or disables the Bird's-eye View"));
-    QObject::connect(m_bevEnabledAction,
-            SIGNAL(toggled(bool)),
-            q,
-            SLOT(slotBevToggled()));
-    m_bevEnabledAction->setCheckable(true);
-    m_popup->addAction(m_bevEnabledAction);
-    
-    m_bevPopup = new KSelectAction(i18n("Birds-eye View"), q);
-  m_bevPopup->setWhatsThis(i18n("Allows the Bird's-eye View to be setup."));
-  m_popup->addAction(m_bevPopup);
-  actionCollection()->addAction("view_bev",m_bevPopup);
-  
-  KAction* btla = new KAction(i18n("Top Left"), q);
-  btla->setWhatsThis(i18n("Puts the Bird's-eye View in the top-left corner."));
-  btla->setCheckable(true);
-  actionCollection()->addAction("bev_top_left",btla);
-  QObject::connect(btla, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
-          q, SLOT(slotBevTopLeft()));
-  KAction* btra = new KAction(i18n("Top Right"), q);
-  btra->setWhatsThis(i18n("Puts the Bird's-eye View in the top-right corner."));
-  btra->setCheckable(true);
-  actionCollection()->addAction("bev_top_right",btra);
-  QObject::connect(btra, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
-          q, SLOT(slotBevTopRight()));
-  KAction* bbla = new KAction(i18n("Bottom Left"), q);
-  bbla->setWhatsThis(i18n("Puts the Bird's-eye View in the bottom-left corner."));
-  bbla->setCheckable(true);
-  actionCollection()->addAction("bev_bottom_left",bbla);
-  QObject::connect(bbla, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
-          q, SLOT(slotBevBottomLeft()));
-  KAction* bbra = new KAction(i18n("Bottom Right"), q);
-  bbra->setWhatsThis(i18n("Puts the Bird's-eye View in the bottom-right corner."));
-  bbra->setCheckable(true);
-  actionCollection()->addAction("bev_bottom_right",bbra);
-  QObject::connect(bbra, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
-          q, SLOT(slotBevBottomRight()));
-  KAction* bba = new KAction(i18n("Automatic"), q);
-  bba->setWhatsThis(i18n("Let KGraphViewer automatically choose the position of the Bird's-eye View."));
-  bba->setCheckable(true);
-  actionCollection()->addAction("bev_automatic",bba);
-  QObject::connect(bba, SIGNAL(triggered (Qt::MouseButtons, Qt::KeyboardModifiers)),
-          q, SLOT(slotBevAutomatic()));
-  m_bevPopup->addAction(btla);
-  m_bevPopup->addAction(btra);
-  m_bevPopup->addAction(bbla);
-  m_bevPopup->addAction(bbra);
-  m_bevPopup->addAction(bba);
-  switch (m_zoomPosition)
-  {
-    case KGraphViewerInterface::TopLeft:
-      btla->setChecked(true);
-      break;
-    case KGraphViewerInterface::TopRight:
-      btra->setChecked(true);
-      break;
-    case KGraphViewerInterface::BottomLeft:
-      bbla->setChecked(true);
-      break;
-    case KGraphViewerInterface::BottomRight:
-      bbra->setChecked(true);
-      break;
-    case KGraphViewerInterface::Auto:
-      bba->setChecked(true);
-      break;
-  }
-  
-  
-  kDebug() << "    m_bevEnabledAction setting checked to : " << KGraphViewerPartSettings::birdsEyeViewEnabled();
-  m_bevEnabledAction->setChecked(KGraphViewerPartSettings::birdsEyeViewEnabled());
-  m_bevPopup->setEnabled(KGraphViewerPartSettings::birdsEyeViewEnabled());
-}
-
-void DotGraphViewPrivate::exportToImage()
-{
-  // write current content of canvas as image to file
-  if (!m_canvas) return;
-  
-  QString fn = KFileDialog::getSaveFileName(KUrl(":"),QString("*.png"),0,QString(""));
-  
-  if (!fn.isEmpty())
-  {
-    QPixmap pix(m_canvas->sceneRect().size().toSize());
-    QPainter p(&pix);
-    m_canvas->render( &p );
-    pix.save(fn,"PNG");
-  }
-}
-
-
-//
-// DotGraphView
-//
-DotGraphView::DotGraphView(KActionCollection* actions, QWidget* parent) : 
-    QGraphicsView(parent), d_ptr(new DotGraphViewPrivate(actions, this))
-{
-  kDebug() << "New node pic=" << KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-newnode.png");
-  Q_D(DotGraphView);
-  d->m_canvas = 0;
-  d->m_xMargin = d->m_yMargin = 0;
-  d->m_birdEyeView = new PannerView(this);
-  d->m_cvZoom = 1;
-
-  // if there are ever graphic glitches to be found, remove this again
-  setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter |
-                        QGraphicsView::DontSavePainterState);
-
-  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-  
-  d->m_birdEyeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  d->m_birdEyeView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  d->m_birdEyeView->raise();
-  d->m_birdEyeView->hide();
-
-  setFocusPolicy(Qt::StrongFocus);
-  setBackgroundRole(QPalette::Window);
-//   viewport()->setMouseTracking(true);
-  
-  connect(d->m_birdEyeView, SIGNAL(zoomRectMovedTo(QPointF)),
-          this, SLOT(zoomRectMovedTo(QPointF)));
-  connect(d->m_birdEyeView, SIGNAL(zoomRectMoveFinished()),
-          this, SLOT(zoomRectMoveFinished()));
-
-  setWhatsThis( i18n( 
-    "<h1>GraphViz dot format graph visualization</h1>"
-    "<p>If the graph is larger than the widget area, an overview "
-        "panner is shown in one edge. Choose through the context menu "
-        "if the optimal position of this overview should be automatically "
-        "computed or put it where you want.</p>"
-    "<h2>How to work with it?</h2>"
-    "<ul>"
-        "<li>To move the graph, you can:"
-            "  <ul>"
-                "    <li>click & drag it</li>"
-                "    <li>use the elevators</li>"
-                "    <li>press the arrows keys</li>"
-                "    <li>click somewhere in the panner view</li>" 
-                "    <li>use the mouse wheel (up and down with no modifier, left and right with the <Alt> key pressed)</li>"
-                    "    <li>or click & drag the panner view</li>"
-                    "  </ul>"
-                "</li>"
-            "<li>To zoom, you can either use the zoom in and zoom out toolbar buttons, or click on the <Shift> key while rolling your mouse wheel.</li>"
-                "<li>Try the contextual menu (usually by right-clicking) to discover other "
-                    "possibilities.</li>"
-                "<li>Try the <tt>Print preview</tt> or the <tt>Page setup</tt> buttons to explore the printing options.</li>"
-                "</ul>"
-            ) );
-
-  readViewConfig();
-  
-  QMatrix m;
-  m.scale(d->m_zoom,d->m_zoom);
-  setMatrix(m);
-  d->setupPopup();
-  setInteractive(true);
-  setDragMode(NoDrag);
-  setRenderHint(QPainter::Antialiasing);
-
-  connect(&d->m_loadThread, SIGNAL(finished()), this, SLOT(slotAGraphReadFinished()));
-  connect(&d->m_layoutThread, SIGNAL(finished()), this, SLOT(slotAGraphLayoutFinished()));
-}
-
-DotGraphView::~DotGraphView()
-{
-  saveViewConfig();
-  Q_D(DotGraphView);
-  delete d;
-}
-
-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;}
-
-DotGraph* DotGraphView::graph() {Q_D(DotGraphView); return d->m_graph;}
-const 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;}
-
-void DotGraphView::setDefaultNewElement(GraphElement* elem) {Q_D(DotGraphView); d->m_defaultNewElement = elem;}
-void DotGraphView::setDefaultNewElementPixmap(const QPixmap& pm) {Q_D(DotGraphView); d->m_defaultNewElementPixmap = pm;}
-
-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;}
-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;}
-
-void DotGraphView::setBackgroundColor(const QColor& color)
-{
-  Q_D(DotGraphView);
-  d->m_backgroundColor = color;
-  d->m_canvas->setBackgroundBrush(QBrush(d->m_backgroundColor));
-}
-
-bool DotGraphView::initEmpty()
-{
-  kDebug();
-  Q_D(DotGraphView);
-  d->m_birdEyeView->hide();
-  d->m_birdEyeView->setScene(0);
-  
-  if (d->m_canvas) 
-  {
-    delete d->m_canvas;
-    d->m_canvas = 0;
-  }
-
-  if (d->m_graph != 0)
-    delete d->m_graph;
-  d->m_graph = new DotGraph();
-  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
-
-  if (d->m_readWrite)
-  {
-    d->m_graph->setReadWrite();
-  }
-  
-//   kDebug() << "Parsing " << m_graph->dotFileName() << " with " << m_graph->layoutCommand();
-  d->m_xMargin = 50;
-  d->m_yMargin = 50;
-
-  QGraphicsScene* newCanvas = new QGraphicsScene();
-  QGraphicsSimpleTextItem* item = newCanvas->addSimpleText(i18n("no graph loaded"));
-//   kDebug() << "Created canvas " << newCanvas;
-  
-  d->m_birdEyeView->setScene(newCanvas);
-//   std::cerr << "After m_birdEyeView set canvas" << std::endl;
-  
-  setScene(newCanvas);
-  d->m_canvas = newCanvas;
-  centerOn(item);
-
-  d->m_cvZoom = 0;
-
-  return true;
-}
-
-bool DotGraphView::slotLoadLibrary(graph_t* graph)
-{
-  kDebug() << "graph_t";
-  Q_D(DotGraphView);
-  d->m_birdEyeView->setScene(0);
-
-  if (d->m_canvas)
-  {
-    d->m_canvas->deleteLater();
-    d->m_canvas = 0;
-  }
-
-  QString layoutCommand = (d->m_graph!=0?d->m_graph->layoutCommand():"");
-  if (d->m_graph != 0)
-    delete d->m_graph;
-
-  if (layoutCommand.isEmpty())
-  layoutCommand = "dot";
-
-  kDebug() << "layoutCommand:" << layoutCommand;
-  d->m_graph = new DotGraph(layoutCommand,"");
-  d->m_graph->setUseLibrary(true);
-
-  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
-  connect(this, SIGNAL(removeEdge(const QString&)), d->m_graph, SLOT(removeEdge(const QString&)));
-  connect(this, SIGNAL(removeNodeNamed(const QString&)), d->m_graph, SLOT(removeNodeNamed(const QString&)));
-  connect(this, SIGNAL(removeElement(const QString&)), d->m_graph, SLOT(removeElement(const QString&)));
-
-  if (d->m_readWrite)
-  {
-    d->m_graph->setReadWrite();
-  }
-
-  if (layoutCommand.isEmpty())
-  {
-    layoutCommand = d->m_graph->chooseLayoutProgramForFile(d->m_graph->dotFileName());
-  }
-  d->m_graph->layoutCommand(layoutCommand);
-
-  GVC_t* gvc = gvContext();
-  gvLayout(gvc, graph, layoutCommand.toUtf8().data());
-  gvRender (gvc, graph, "xdot", NULL);
-
-  d->m_xMargin = 50;
-  d->m_yMargin = 50;
-
-  QGraphicsScene* newCanvas = new QGraphicsScene();
-  kDebug() << "Created canvas " << newCanvas;
-
-  d->m_birdEyeView->setScene(newCanvas);
-  // std::cerr << "After m_birdEyeView set canvas" << std::endl;
-
-  setScene(newCanvas);
-  connect(newCanvas,SIGNAL(selectionChanged ()),this,SLOT(slotSelectionChanged()));
-  d->m_canvas = newCanvas;
-
-  d->m_cvZoom = 0;
-
-  d->m_graph->updateWithGraph(graph);
-
-  gvFreeLayout(gvc, graph);
-  gvFreeContext(gvc);
-  return true;
-}
-
-bool DotGraphView::loadDot(const QString& dotFileName)
-{
-  kDebug() << "'" << dotFileName << "'";
-  Q_D(DotGraphView);
-  d->m_birdEyeView->setScene(0);
-
-  if (d->m_canvas)
-  {
-    d->m_canvas->deleteLater();
-    d->m_canvas = 0;
-  }
-
-  QString layoutCommand = (d->m_graph!=0?d->m_graph->layoutCommand():"");
-  if (d->m_graph != 0)
-    delete d->m_graph;
-  d->m_graph = new DotGraph(layoutCommand,dotFileName);
-  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
-
-  if (d->m_readWrite)
-  {
-    d->m_graph->setReadWrite();
-  }
-  if (layoutCommand.isEmpty())
-  {
-    layoutCommand = d->m_graph->chooseLayoutProgramForFile(d->m_graph->dotFileName());
-  }
-  d->m_graph->layoutCommand(layoutCommand);
-
-//   kDebug() << "Parsing " << m_graph->dotFileName() << " with " << m_graph->layoutCommand();
-  d->m_xMargin = 50;
-  d->m_yMargin = 50;
-
-  QGraphicsScene* newCanvas = new QGraphicsScene();
-  kDebug() << "Created canvas " << newCanvas;
-
-  d->m_birdEyeView->setScene(newCanvas);
-//   std::cerr << "After m_birdEyeView set canvas" << std::endl;
-
-  setScene(newCanvas);
-  connect(newCanvas,SIGNAL(selectionChanged ()),this,SLOT(slotSelectionChanged()));
-  d->m_canvas = newCanvas;
-
-  QGraphicsSimpleTextItem* loadingLabel = newCanvas->addSimpleText(i18n("graph %1 is getting loaded...", dotFileName));
-  loadingLabel->setZValue(100);
-  centerOn(loadingLabel);
-
-  d->m_cvZoom = 0;
-
-  if (!d->m_graph->parseDot(d->m_graph->dotFileName()))
-  {
-    kError() << "NOT successfully parsed!" << endl;
-    loadingLabel->setText(i18n("error parsing file %1", dotFileName));
-    return false;
-  }
-  return true;
-}
-
-bool DotGraphView::loadLibrary(const QString& dotFileName)
-{
-  kDebug() << "'" << dotFileName << "'";
-  Q_D(DotGraphView);
-  if (d->m_canvas)
-    d->m_canvas->clear();
-  QGraphicsSimpleTextItem* loadingLabel = d->m_canvas->addSimpleText(i18n("graph %1 is getting loaded...", dotFileName));
-  loadingLabel->setZValue(100);
-  centerOn(loadingLabel);
-
-  d->m_loadThread.loadFile(dotFileName);
-  
-  return true;
-}
-
-bool DotGraphView::loadLibrary(graph_t* graph, const QString& layoutCommand)
-{
-  kDebug() << "graph_t";
-  Q_D(DotGraphView);
-  d->m_birdEyeView->setScene(0);
-  
-  if (d->m_canvas)
-  {
-    d->m_canvas->deleteLater();
-    d->m_canvas = 0;
-  }
-  
-  if (d->m_graph != 0)
-    delete d->m_graph;
-
-  kDebug() << "layoutCommand:" << layoutCommand;
-  d->m_graph = new DotGraph(layoutCommand,"");
-  d->m_graph->setUseLibrary(true);
-  
-  connect(d->m_graph,SIGNAL(readyToDisplay()),this,SLOT(displayGraph()));
-  
-  if (d->m_readWrite)
-  {
-    d->m_graph->setReadWrite();
-  }
-  
-  d->m_xMargin = 50;
-  d->m_yMargin = 50;
-  
-  QGraphicsScene* newCanvas = new QGraphicsScene();
-  kDebug() << "Created canvas " << newCanvas;
-  
-  d->m_birdEyeView->setScene(newCanvas);
-  setScene(newCanvas);
-  connect(newCanvas,SIGNAL(selectionChanged ()),this,SLOT(slotSelectionChanged()));
-  d->m_canvas = newCanvas;
-  
-  d->m_cvZoom = 0;
-                                 
-  d->m_graph->updateWithGraph(graph);
-
-  return true;
-}
-
-void DotGraphView::slotSelectionChanged()
-{
-  kDebug() << scene()->selectedItems().size();
-}
-
-bool DotGraphView::displayGraph()
-{
-  Q_D(DotGraphView);
-  kDebug() << d->m_graph->backColor();
-//   hide();
-  viewport()->setUpdatesEnabled(false);
-
-  if (d->m_graph->backColor().size() != 0)
-  {
-    setBackgroundColor(QColor(d->m_graph->backColor()));
-  }
-  d->m_canvas->clear();
-
-  if (d->m_graph->nodes().size() > KGV_MAX_PANNER_NODES)
-  {
-    d->m_birdEyeView->setDrawingEnabled(false);
-  }
-  //  QCanvasEllipse* eItem;
-  double scaleX = 1.0, scaleY = 1.0;
-
-  if (d->m_detailLevel == 0)      { scaleX = d->m_graph->scale() * 0.7; scaleY = d->m_graph->scale() * 0.7; }
-  else if (d->m_detailLevel == 1) { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
-  else if (d->m_detailLevel == 2) { scaleX = d->m_graph->scale() * 1.3; scaleY = d->m_graph->scale() * 1.3; }
-  else                        { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
-
-  qreal gh = d->m_graph->height();
-
-  d->m_xMargin = 50;
-  d->m_yMargin = 50;
-
-
-//   m_canvas->setSceneRect(0,0,w+2*m_xMargin, h+2*m_yMargin);
-//   m_canvas->setBackgroundBrush(QBrush(QColor(m_graph->backColor())));
-  d->m_canvas->setBackgroundBrush(QBrush(d->m_backgroundColor));
-  
-//   kDebug() << "sceneRect is now " << m_canvas->sceneRect();
-  
-  kDebug() << "Creating" << d->m_graph->subgraphs().size() << "CanvasSubgraphs from" << d->m_graph;
-  int zvalue = -1;
-  foreach (GraphSubgraph* gsubgraph, d->m_graph->subgraphs())
-  {
-    int newZvalue = d->displaySubgraph(gsubgraph, zvalue);
-    if (newZvalue > zvalue)
-      zvalue = newZvalue;
-  }
-
-  kDebug() << "Creating" << d->m_graph->nodes().size() << "nodes from" << d->m_graph;
-  GraphNodeMap::const_iterator it = d->m_graph->nodes().constBegin();
-  for (; it != d->m_graph->nodes().constEnd();it++)
-  {
-    const QString& id = it.key();
-    GraphNode* gnode = it.value();
-    kDebug() << "Handling" << id << (void*)gnode;
-    kDebug() << "  gnode id=" << gnode->id();
-    kDebug()<<  "  canvasNode=" << (void*)gnode->canvasNode();
-    if (gnode->canvasNode()==0)
-    {
-      kDebug() << "Creating canvas node for" << gnode->id();
-      CanvasNode *cnode = new CanvasNode(this, gnode, d->m_canvas);
-      if (cnode == 0) continue;
-      cnode->initialize(
-        scaleX, scaleY, d->m_xMargin, d->m_yMargin, gh,
-        d->m_graph->wdhcf(), d->m_graph->hdvcf());
-      gnode->setCanvasNode(cnode);
-      d->m_canvas->addItem(cnode);
-//       cnode->setZValue(gnode->z());
-      cnode->setZValue(zvalue+1);
-      cnode->show();
-    }
-    gnode->canvasNode()->computeBoundingRect();
-  }
-
-  kDebug() << "Creating" << d->m_graph->edges().size() << "edges from" << d->m_graph;
-  foreach (GraphEdge* gedge, d->m_graph->edges())
-  {
-    kDebug() << "One GraphEdge:" << gedge->id();
-    if (gedge->canvasEdge() == 0
-      && gedge->fromNode() != 0
-      && gedge->toNode() != 0)
-    {
-      kDebug() << "New CanvasEdge for" << gedge->id();
-      kDebug() << "edge fromNode=" << (void*)gedge->fromNode();
-      kDebug() << "              "<< gedge->fromNode()->id();
-      kDebug() << "edge toNode=" << (void*)gedge->toNode();
-      kDebug() << "              "<< gedge->toNode()->id();
-      CanvasEdge* cedge = new CanvasEdge(this, gedge, scaleX, scaleY, d->m_xMargin,
-          d->m_yMargin, gh, d->m_graph->wdhcf(), d->m_graph->hdvcf());
-
-      gedge->setCanvasEdge(cedge);
-  //     std::cerr << "setting z = " << gedge->z() << std::endl;
-  //    cedge->setZValue(gedge->z());
-      cedge->setZValue(zvalue+2);
-      cedge->show();
-      d->m_canvas->addItem(cedge);
-    }
-    if (gedge->canvasEdge() != 0)
-      gedge->canvasEdge()->computeBoundingRect();
-  }
-  kDebug() << "Adding graph render operations: " << d->m_graph->renderOperations().size();
-  foreach (const DotRenderOp& dro, d->m_graph->renderOperations())
-  {
-    if ( dro.renderop == "T" )
-    {
-//       std::cerr << "Adding graph label '"<<dro.str<<"'" << std::endl;
-      const QString& str = dro.str;
-      int stringWidthGoal = int(dro.integers[3] * scaleX);
-      int fontSize = d->m_graph->fontSize();
-      QFont* font = FontsCache::changeable().fromName(d->m_graph->fontName());
-      font->setPointSize(fontSize);
-      QFontMetrics fm(*font);
-      while (fm.width(str) > stringWidthGoal && fontSize > 1)
-      {
-        fontSize--;
-        font->setPointSize(fontSize);
-        fm = QFontMetrics(*font);
-      }
-      QGraphicsSimpleTextItem* labelView = new QGraphicsSimpleTextItem(str, 0, d->m_canvas);
-      labelView->setFont(*font);
-      labelView->setPos(
-                  (scaleX *
-                       (
-                         (dro.integers[0])
-                         + (((dro.integers[2])*(dro.integers[3]))/2)
-                         - ( (dro.integers[3])/2 )
-                       )
-                      + d->m_xMargin ),
-                      ((gh - (dro.integers[1]))*scaleY)+ d->m_yMargin);
-      /// @todo port that ; how to set text color ?
-      labelView->setPen(QPen(Dot2QtConsts::componentData().qtColor(d->m_graph->fontColor())));
-      labelView->setFont(*font);
-      d->m_labelViews.insert(labelView);
-    }
-  }
-
-  kDebug() << "Finalizing";
-  d->m_cvZoom = 0;
-  d->updateSizes();
-
-  centerOn(d->m_canvas->sceneRect().center());
-
-  viewport()->setUpdatesEnabled(true);
-  QSet<QGraphicsSimpleTextItem*>::iterator labelViewsIt, labelViewsIt_end;
-  labelViewsIt = d->m_labelViews.begin(); labelViewsIt_end = d->m_labelViews.end();
-  for (; labelViewsIt != labelViewsIt_end; labelViewsIt++)
-  {
-    (*labelViewsIt)->show();
-  }
-  d->m_canvas->update();
-  
-  emit graphLoaded();
-
-  return true;
-}
-
-void DotGraphView::focusInEvent(QFocusEvent*)
-{
-  Q_D(DotGraphView);
-  if (!d->m_canvas) return;
-
-//   m_canvas->update();
-}
-
-void DotGraphView::focusOutEvent(QFocusEvent* e)
-{
-  // trigger updates as in focusInEvent
-  focusInEvent(e);
-}
-
-void DotGraphView::keyPressEvent(QKeyEvent* e)
-{
-  Q_D(DotGraphView);
-  if (!d->m_canvas) 
-  {
-    e->ignore();
-    return;
-  }
-
-  // move canvas...
-  if (e->key() == Qt::Key_Home)
-    scrollContentsBy(int(-d->m_canvas->width()),0);
-  else if (e->key() == Qt::Key_End)
-    scrollContentsBy(int(d->m_canvas->width()),0);
-  else if (e->key() == Qt::Key_Prior)
-    scrollContentsBy(0,-viewport()->height()/2);
-  else if (e->key() == Qt::Key_Next)
-    scrollContentsBy(0,viewport()->height()/2);
-  else if (e->key() == Qt::Key_Left)
-    scrollContentsBy(-viewport()->width()/10,0);
-  else if (e->key() == Qt::Key_Right)
-    scrollContentsBy(viewport()->width()/10,0);
-  else if (e->key() == Qt::Key_Down)
-    scrollContentsBy(0,viewport()->height()/10);
-  else if (e->key() == Qt::Key_Up)
-    scrollContentsBy(0,-viewport()->height()/10);
-  else 
-  {
-    e->ignore();
-    return;
-  }
-}
-
-void DotGraphView::wheelEvent(QWheelEvent* e)
-{
-  Q_D(DotGraphView);
-  if (!d->m_canvas) 
-  {
-    e->ignore();
-    return;
-  }
-  e->accept();
-  if (e->state() == Qt::ShiftModifier)
-  {
-    kDebug() << " + Shift: zooming";
-    // move canvas...
-    if (e->delta() < 0)
-    {
-      zoomOut();
-    }
-    else 
-    {
-      zoomIn();
-    }
-  }
-  else
-  {
-    kDebug() << " : scrolling ";
-    if (e->orientation() == Qt::Horizontal)
-    {
-      if (e->delta() < 0)
-      {
-        kDebug() << "scroll by " <<  -viewport()->width()/10 << 0;
-        horizontalScrollBar()->setValue(horizontalScrollBar()->value()+viewport()->width()/10);
-      }
-      else
-      {
-        kDebug() << "scroll by " <<  viewport()->width()/10 << 0;
-        horizontalScrollBar()->setValue(horizontalScrollBar()->value()-viewport()->width()/10);
-      }
-    }
-    else
-    {
-      if (e->delta() < 0)
-      {
-        kDebug() << "scroll by " << 0 << viewport()->width()/10;
-        verticalScrollBar()->setValue(verticalScrollBar()->value()+viewport()->height()/10);
-      }
-      else
-      {
-        kDebug() << "scroll by " << 0 << -viewport()->width()/10;
-        verticalScrollBar()->setValue(verticalScrollBar()->value()-viewport()->height()/10);
-      }
-    }
-  }
-}
-
-void DotGraphView::zoomIn()
-{
-  applyZoom(1.10);
-}
-
-
-void DotGraphView::zoomOut()
-{
-  applyZoom(.90);
-}
-
-void DotGraphView::setZoomFactor(double newZoom)
-{
-  Q_D(DotGraphView);
-  if (newZoom < 0.1 || newZoom > 10)
-    return;
-  d->m_zoom = newZoom;
-  if (d->m_zoom > 1.0 && d->m_zoom < 1.1)
-  {
-    d->m_zoom = 1;
-  }
-
-  const double factor = newZoom / d->m_zoom;
-  qreal centerX = (sceneRect().x() + (viewport()->width() / 2))*factor;
-  qreal centerY = (sceneRect().y() + (viewport()->height() / 2))*factor;
-  
-  setUpdatesEnabled(false);
-  QMatrix m;
-  m.scale(d->m_zoom,d->m_zoom);
-  setMatrix(m);
-  centerOn(centerX, centerY);
-  emit zoomed(d->m_zoom);
-  setUpdatesEnabled(true);
-  d->updateSizes();
-}
-
-void DotGraphView::applyZoom(double factor)
-{
-  Q_D(DotGraphView);
-  setZoomFactor(d->m_zoom * factor);
-}
-
-void DotGraphView::scrollContentsBy(int dx, int dy)
-{
-  Q_D(DotGraphView);
-  QGraphicsView::scrollContentsBy(dx, dy);
-  if (d->m_birdEyeView && scene()) { // we might be shutting down
-    d->m_birdEyeView->moveZoomRectTo(mapToScene(viewport()->rect()).boundingRect().center(), false);
-  }
-}
-
-void DotGraphView::resizeEvent(QResizeEvent* e)
-{
-  Q_D(DotGraphView);
-  kDebug() << "resizeEvent";
-  QGraphicsView::resizeEvent(e);
-  if (d->m_canvas) d->updateSizes(e->size());
-//   std::cerr << "resizeEvent end" << std::endl;
-}
-
-void DotGraphView::zoomRectMovedTo(QPointF newZoomPos)
-{
-//   kDebug() << "DotGraphView::zoomRectMovedTo " << newZoomPos;
-  centerOn(newZoomPos);
-}
-                    
-void DotGraphView::zoomRectMoveFinished()
-{
-  Q_D(DotGraphView);
-//    kDebug() << "zoomRectMoveFinished";
-  d->updateBirdEyeView();
-//   std::cerr << "zoomRectMoveFinished end" << std::endl;
-}
-
-void DotGraphView::mousePressEvent(QMouseEvent* e)
-{
-  Q_D(DotGraphView);
-  if (e->button() != Qt::LeftButton) {
-    return;
-  }
-  kDebug() << e << d->m_editingMode;
-  QGraphicsView::mousePressEvent(e);
-
-  if (d->m_editingMode == AddNewElement)
-  {
-    double scaleX = 1.0, scaleY = 1.0;
-
-    if (d->m_detailLevel == 0)      { scaleX = d->m_graph->scale() * 0.7; scaleY = d->m_graph->scale() * 0.7; }
-    else if (d->m_detailLevel == 1) { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
-    else if (d->m_detailLevel == 2) { scaleX = d->m_graph->scale() * 1.3; scaleY = d->m_graph->scale() * 1.3; }
-    else                        { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
-
-    qreal gh = d->m_graph->height();
-
-
-    QPointF pos = mapToScene(
-        e->pos().x()-d->m_defaultNewElementPixmap.width()/2,
-        e->pos().y()-d->m_defaultNewElementPixmap.height()/2);
-    GraphNode* newNode = new GraphNode();
-    newNode->attributes() = d->m_newElementAttributes;
-    if (newNode->attributes().find("id") == newNode->attributes().end())
-    {
-      newNode->setId(QString("NewNode%1").arg(d->m_graph->nodes().size()));
-    }
-    if (newNode->attributes().find("label") == newNode->attributes().end())
-    {
-      newNode->setLabel(newNode->id());
-    }
-    d->m_graph->nodes().insert(newNode->id(), newNode);
-    CanvasNode* newCNode = new CanvasNode(this, newNode, d->m_canvas);
-    newCNode->initialize(
-      scaleX, scaleY, d->m_xMargin, d->m_yMargin, gh,
-      d->m_graph->wdhcf(), d->m_graph->hdvcf());
-    newNode->setCanvasNode(newCNode);
-    scene()->addItem(newCNode);
-    kDebug() << "setting pos to " << pos;
-    newCNode->setPos(pos);
-    newCNode->setZValue(100);
-    newCNode->show();
-
-
-    d->m_editingMode = None;
-    unsetCursor();
-    emit newNodeAdded(newNode->id());
-  }
-  else if (d->m_editingMode == SelectingElements)
-  {
-  }
-  else
-  {
-    if (d->m_editingMode != None && itemAt(e->pos()) == 0) // click outside any item: unselect all
-    {
-      if (d->m_editingMode == DrawNewEdge) // was drawing an edge; cancel it
-      {
-        if (d->m_newEdgeDraft!=0)
-        {
-          d->m_newEdgeDraft->hide();
-          scene()->removeItem(d->m_newEdgeDraft);
-          delete d->m_newEdgeDraft;
-          d->m_newEdgeDraft = 0;
-        }
-        d->m_newEdgeSource = 0;
-        d->m_editingMode = None;
-      }
-      else if (d->m_editingMode == AddNewEdge)
-      {
-        d->m_editingMode = None;
-      }
-      foreach(GraphEdge* e, d->m_graph->edges())
-      {
-        if (e->isSelected()) {
-          e->setSelected(false);
-          e->canvasEdge()->update();
-        }
-      }
-      foreach(GraphNode* n, d->m_graph->nodes())
-      {
-        if (n->isSelected()) {
-          n->setSelected(false);
-          n->canvasElement()->update();
-        }
-      }
-      foreach(GraphSubgraph* s, d->m_graph->subgraphs())
-      {
-        if (s->isSelected()) {
-          s->setSelected(false);
-          s->canvasElement()->update();
-        }
-      }
-      emit selectionIs(QList<QString>(),QPoint());
-    }
-    d->m_pressPos = e->globalPos();
-    d->m_pressScrollBarsPos = QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value());
-  }
-  d->m_isMoving = true;
-}
-
-void DotGraphView::mouseMoveEvent(QMouseEvent* e)
-{
-  Q_D(DotGraphView);
-  QGraphicsView::mouseMoveEvent(e);
-//   kDebug() << scene()->selectedItems().size();
-
-  if (d->m_editingMode == DrawNewEdge)
-  {
-    if (d->m_newEdgeDraft != 0)
-    {
-      QPointF src = d->m_newEdgeDraft->line().p1();
-      QPointF tgt = mapToScene(e->pos());
-
-//     kDebug() << "Setting new edge draft line to" << QLineF(src,tgt);
-      d->m_newEdgeDraft->setLine(QLineF(src,tgt));
-    }
-  }
-  else if (d->m_editingMode == SelectingElements)
-  {
-//     kDebug() << "selecting";
-  }
-  else if (e->buttons().testFlag(Qt::LeftButton))
-  {
-//     kDebug() << (e->globalPos() - d->m_pressPos);
-    QPoint diff = e->globalPos() - d->m_pressPos;
-    horizontalScrollBar()->setValue(d->m_pressScrollBarsPos.x()-diff.x());
-    verticalScrollBar()->setValue(d->m_pressScrollBarsPos.y()-diff.y());
-  }
-}
-
-void DotGraphView::mouseReleaseEvent(QMouseEvent* e)
-{
-  Q_D(DotGraphView);
-  kDebug() << e << d->m_editingMode;
-//   kDebug() << "setDragMode(NoDrag)";
-//   setDragMode(NoDrag);
-  if (d->m_editingMode == AddNewElement)
-  {
-    d->m_editingMode = None;
-    unsetCursor();
-  }
-  else if (d->m_editingMode == SelectingElements)
-  {
-    QGraphicsView::mouseReleaseEvent(e);
-    kDebug() << "Stopping selection" << scene() << d->m_canvas;
-    QList<QGraphicsItem *> items = scene()->selectedItems();
-    QList<QString> selection;
-    foreach (QGraphicsItem * item, items)
-    {
-      CanvasElement* element = dynamic_cast<CanvasElement*>(item);
-      element->element()->setSelected(true);
-      if (element != 0)
-      {
-        selection.push_back(element->element()->id());
-      }
-    }
-    d->m_editingMode = None;
-    unsetCursor();
-    setDragMode(NoDrag);
-    if (!selection.isEmpty())
-    {
-      update();
-      emit selectionIs(selection, mapToGlobal( e->pos() ));
-    }
-  }
-  else
-  {
-    QGraphicsView::mouseReleaseEvent(e);
-  }
-  d->m_isMoving = false;
-}
-
-void DotGraphView::mouseDoubleClickEvent(QMouseEvent* e)
-{
-  QGraphicsView::mouseDoubleClickEvent(e);
-}
-
-void DotGraphView::contextMenuEvent(QContextMenuEvent* e)
-{
-  Q_D(DotGraphView);
-  kDebug();
-//   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
-
-  d->m_popup->exec(e->globalPos());
-}
-
-void DotGraphView::slotContextMenuEvent(const QString& id, const QPoint& p)
-{
-  kDebug();
-//   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
-
-  emit (contextMenuEvent(id, p));
-}
-
-void DotGraphView::slotElementHoverEnter(CanvasElement* element)
-{
-  kDebug() << element->element()->id();
-  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
-  
-  emit (hoverEnter(element->element()->id()));
-}
-
-void DotGraphView::slotElementHoverLeave(CanvasElement* element)
-{
-  kDebug() << element->element()->id();
-  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
-  
-  emit (hoverLeave(element->element()->id()));
-}
-
-void DotGraphView::slotElementHoverEnter(CanvasEdge* element)
-{
-  kDebug() << element->edge()->id();
-  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
-  
-  emit (hoverEnter(element->edge()->id()));
-}
-
-void DotGraphView::slotElementHoverLeave(CanvasEdge* element)
-{
-  kDebug() << element->edge()->id();
-  //   QList<QGraphicsItem *> l = scene()->collidingItems(scene()->itemAt(e->pos()));
-  
-  emit (hoverLeave(element->edge()->id()));
-}
-
-void DotGraphView::setLayoutCommand(const QString& command)
-{
-  Q_D(DotGraphView);
-  d->m_graph->layoutCommand(command);
-  reload();
-}
-
-KGraphViewerInterface::PannerPosition DotGraphView::zoomPos(const QString& s)
-{
-  KGraphViewerInterface::PannerPosition  res = DEFAULT_ZOOMPOS;
-  if (s == QString("KGraphViewerInterface::TopLeft")) res = KGraphViewerInterface::TopLeft;
-  if (s == QString("KGraphViewerInterface::TopRight")) res = KGraphViewerInterface::TopRight;
-  if (s == QString("KGraphViewerInterface::BottomLeft")) res = KGraphViewerInterface::BottomLeft;
-  if (s == QString("KGraphViewerInterface::BottomRight")) res = KGraphViewerInterface::BottomRight;
-  if (s == QString("Automatic")) res = KGraphViewerInterface::Auto;
-
-  return res;
-}
-
-void DotGraphView::setPannerEnabled(bool enabled)
-{
-  Q_D(DotGraphView);
-  d->m_bevPopup->setEnabled(d->m_bevEnabledAction->isChecked());
-  KGraphViewerPartSettings::setBirdsEyeViewEnabled(d->m_bevEnabledAction->isChecked());
-  KGraphViewerPartSettings::self()->writeConfig();
-  d->updateSizes();
-}
-
-void DotGraphView::viewBevActivated(int newZoomPos)
-{
-  Q_D(DotGraphView);
-  d->m_zoomPosition = (KGraphViewerInterface::PannerPosition)newZoomPos;
-  d->updateSizes();
-  emit(sigViewBevActivated(newZoomPos));
-}
-
-QString DotGraphView::zoomPosString(KGraphViewerInterface::PannerPosition p)
-{
-    if (p == KGraphViewerInterface::TopRight) return QString("KGraphViewerInterface::TopRight");
-    if (p == KGraphViewerInterface::BottomLeft) return QString("KGraphViewerInterface::BottomLeft");
-    if (p == KGraphViewerInterface::BottomRight) return QString("KGraphViewerInterface::BottomRight");
-    if (p == KGraphViewerInterface::Auto) return QString("Automatic");
-
-    return QString("KGraphViewerInterface::TopLeft");
-}
-
-void DotGraphView::readViewConfig()
-{
-  Q_D(DotGraphView);
-  KConfigGroup g(KGlobal::config(),"GraphViewLayout");
-  
-  QVariant dl = DEFAULT_DETAILLEVEL;
-  d->m_detailLevel     = g.readEntry("DetailLevel", dl).toInt();
-  d->m_zoomPosition  = zoomPos(g.readEntry("KGraphViewerInterface::PannerPosition",
-            zoomPosString(DEFAULT_ZOOMPOS)));
-  emit(sigViewBevActivated(d->m_zoomPosition));
-}
-
-void DotGraphView::saveViewConfig()
-{
-  Q_D(DotGraphView);
-//   kDebug() << "Saving view config";  
-  KConfigGroup g(KGlobal::config(), "GraphViewLayout");
-
-    writeConfigEntry(&g, "DetailLevel", d->m_detailLevel, DEFAULT_DETAILLEVEL);
-    writeConfigEntry(&g, "KGraphViewerInterface::PannerPosition",
-         zoomPosString(d->m_zoomPosition),
-         zoomPosString(DEFAULT_ZOOMPOS).utf8().data());
-  g.sync();
-}
-
-void DotGraphView::pageSetup()
-{
-  Q_D(DotGraphView);
-  if (d->m_printCommand == 0)
-  {
-    d->m_printCommand = new KGVSimplePrintingCommand(this, 0);
-  }
-  d->m_printCommand->showPageSetup(d->m_graph->dotFileName());
-  return;
-}
-
-void DotGraphView::print()
-{
-  Q_D(DotGraphView);
-  if (d->m_printCommand == 0)
-  {
-    d->m_printCommand = new KGVSimplePrintingCommand(this, 0);
-  }
-  d->m_printCommand->print(d->m_graph->dotFileName());
-  return;
-}
-
-void DotGraphView::printPreview()
-{
-  Q_D(DotGraphView);
-  if (d->m_printCommand == 0)
-  {
-    d->m_printCommand = new KGVSimplePrintingCommand(this, 0);
-  }
-  d->m_printCommand->showPrintPreview(d->m_graph->dotFileName(), false);
-  return;
-}
-
-bool DotGraphView::reload()
-{
-  Q_D(DotGraphView);
-  QString fileName = d->m_graph->dotFileName();
-  if (d->m_graph->useLibrary())
-    return loadLibrary(fileName);
-  else
-    return loadDot(fileName);
-}
-
-void DotGraphView::dirty(const QString& dotFileName)
-{
-  Q_D(DotGraphView);
-//   std::cerr << "SLOT dirty for " << dotFileName << std::endl;
-  if (dotFileName == d->m_graph->dotFileName())
-  {
-    if (KMessageBox::questionYesNo(this, 
-                                i18n("The file %1 has been modified on disk.\nDo you want to reload it?",dotFileName),
-                                i18n("Reload Confirmation"),
-                                KStandardGuiItem::yes(),
-                                KStandardGuiItem::no(),
-                                "reloadOnChangeMode"   ) == KMessageBox::Yes)
-    {
-      if (d->m_graph->useLibrary())
-        loadLibrary(dotFileName);
-      else
-        loadDot(dotFileName);
-    }
-  }
-}
-
-KConfigGroup* DotGraphView::configGroup(KConfig* c,
-                                         const QString& group, const QString& post)
-{
-  QStringList gList = c->groupList();
-  QString res = group;
-  if (gList.contains((group+post).ascii()) ) res += post;
-  return new KConfigGroup(c, res);
-}
-
-void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
-                                     const QString& value, const char* def)
-{
-  if (!c) return;
-  if ((value.isEmpty() && ((def == 0) || (*def == 0))) ||
-      (value == QString(def)))
-    c->deleteEntry(pKey);
-  else
-    c->writeEntry(pKey, value);
-}
-
-void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
-                                     int value, int def)
-{
-  if (!c) return;
-  if (value == def)
-    c->deleteEntry(pKey);
-  else
-    c->writeEntry(pKey, value);
-}
-
-void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
-                                     double value, double def)
-{
-  if (!c) return;
-  if (value == def)
-    c->deleteEntry(pKey);
-  else
-    c->writeEntry(pKey, value);
-}
-
-void DotGraphView::writeConfigEntry(KConfigGroup* c, const char* pKey,
-                                     bool value, bool def)
-{
-  if (!c) return;
-  if (value == def)
-    c->deleteEntry(pKey);
-  else
-    c->writeEntry(pKey, value);
-}
-
-const QString& DotGraphView::dotFileName() 
-{
-  Q_D(DotGraphView);
-  return d->m_graph->dotFileName();
-}
-
-void DotGraphView::hideToolsWindows()
-{
-  Q_D(DotGraphView);
-  if (d->m_printCommand != 0)
-  {
-    d->m_printCommand->hidePageSetup();
-    d->m_printCommand->hidePrintPreview();
-  }
-}
-
-void DotGraphView::slotExportImage()
-{
-  Q_D(DotGraphView);
-  d->exportToImage();
-}
-
-void DotGraphView::slotLayoutSpecify()
-{
-  {
-  Q_D(DotGraphView);
-    bool ok = false;
-    QString currentLayoutCommand = d->m_graph->layoutCommand();
-    QString layoutCommand = 
-    KInputDialog::getText(
-      i18n("Layout Command"), 
-      i18n("Type in a layout command for the current graph:"), 
-      currentLayoutCommand, 
-      &ok, 
-      this, 
-      0, 
-      QString(), 
-      i18n("Specify here the command that will be used to layout the graph.\n"
-      "The command MUST write its results on stdout in xdot format."));
-    //       std::cerr << "Got layout command: " << layoutCommand << std::endl;
-    if (ok && layoutCommand != currentLayoutCommand)
-    {
-      //         std::cerr << "Setting new layout command: " << layoutCommand << std::endl;
-      setLayoutCommand(layoutCommand);
-    }
-  }
-}
-
-void DotGraphView::slotLayoutReset()
-{
-  setLayoutCommand("");
-}
-
-void DotGraphView::slotSelectLayoutAlgo(const QString& ttext)
-{
-  QString text = ttext;//.mid(1);
-  kDebug() << "DotGraphView::slotSelectLayoutAlgo '" << text << "'";
-  if (text == "Dot")
-  {
-    setLayoutCommand("dot");
-  }
-  else if (text == "Neato")
-  {
-    setLayoutCommand("neato");
-  }
-  else if (text == "Twopi")
-  {
-    setLayoutCommand("twopi");
-  }
-  else if (text == "Fdp")
-  {
-    setLayoutCommand("fdp");
-  }
-  else if (text == "Circo")
-  {
-    setLayoutCommand("circo");
-  }
-  else 
-  {
-    setLayoutCommand(text);
-  }
-}
-
-void DotGraphView::slotSelectLayoutDot()
-{
-  kDebug() << "DotGraphView::slotSelectLayoutDot";
-  setLayoutCommand("dot -Txdot");
-}
-
-void DotGraphView::slotSelectLayoutNeato()
-{
-  kDebug() << "DotGraphView::slotSelectLayoutNeato";
-  setLayoutCommand("neato -Txdot");
-}
-
-void DotGraphView::slotSelectLayoutTwopi()
-{
-  kDebug() << "DotGraphView::slotSelectLayoutTwopi";
-  setLayoutCommand("twopi -Txdot");
-}
-
-void DotGraphView::slotSelectLayoutFdp()
-{
-  kDebug() << "DotGraphView::slotSelectLayoutFdp";
-  setLayoutCommand("fdp -Txdot");
-}
-
-void DotGraphView::slotSelectLayoutCirco()
-{
-  kDebug() << "DotGraphView::slotSelectLayoutCirco";
-  setLayoutCommand("circo -Txdot");
-}
-
-void DotGraphView::slotBevToggled()
-{
-  Q_D(DotGraphView);
-  kDebug() << "DotGraphView::slotBevToggled";
-  kDebug() << "    d->m_bevEnabledAction is checked ? " << d->m_bevEnabledAction->isChecked();
-  setPannerEnabled(d->m_bevEnabledAction->isChecked());
-}
-
-void DotGraphView::slotBevTopLeft()
-{
-  viewBevActivated(KGraphViewerInterface::TopLeft);
-}
-
-void DotGraphView::slotBevTopRight()
-{
-  viewBevActivated(KGraphViewerInterface::TopRight);
-}
-
-void DotGraphView::slotBevBottomLeft()
-{
-  viewBevActivated(KGraphViewerInterface::BottomLeft);
-}
-
-void DotGraphView::slotBevBottomRight()
-{
-  viewBevActivated(KGraphViewerInterface::BottomRight); 
-}
-
-void DotGraphView::slotBevAutomatic()
-{
-  viewBevActivated(KGraphViewerInterface::Auto);
-}
-
-void DotGraphView::slotUpdate()
-{
-  Q_D(DotGraphView);
-  kDebug();
-  d->m_graph->update();
-}
-
-void DotGraphView::prepareAddNewElement(QMap<QString,QString> attribs)
-{
-  Q_D(DotGraphView);
-  kDebug() ;
-  d->m_editingMode = AddNewElement;
-  d->m_newElementAttributes = attribs;
-  unsetCursor();
-  setCursor(QCursor(d->m_defaultNewElementPixmap));
-}
-
-void DotGraphView::prepareAddNewEdge(QMap<QString,QString> attribs)
-{
-  Q_D(DotGraphView);
-  kDebug() << attribs;
-  bool anySelected = false;
-  foreach (GraphEdge* edge, d->m_graph->edges())
-  {
-    if (edge->isSelected())
-    {
-      anySelected = true;
-      QMap<QString,QString>::const_iterator it = attribs.constBegin();
-      for(; it != attribs.constEnd(); it++)
-      {
-        edge->attributes()[it.key()] = it.value();
-      }
-    }
-  }
-  if (anySelected)
-  {
-    return;
-  }
-  d->m_editingMode = AddNewEdge;
-  d->m_newElementAttributes = attribs;
-  unsetCursor();
-  QBitmap bm(KGlobal::dirs()->findResource("data","kgraphviewerpart/pics/kgraphviewer-newedge.png"));
-  setCursor(QCursor(bm,bm,32,16));
-}
-
-void DotGraphView::prepareSelectElements()
-{
-  Q_D(DotGraphView);
-  kDebug();
-  d->m_editingMode = SelectingElements;
-  setCursor(Qt::CrossCursor);
-  setDragMode ( RubberBandDrag );
-}
-
-void DotGraphView::createNewEdgeDraftFrom(CanvasElement* node)
-{
-  Q_D(DotGraphView);
-  kDebug() << node->element()->id();
-  d->m_editingMode = DrawNewEdge;
-  unsetCursor();
-  d->m_newEdgeSource = node;
-
-  if (d->m_newEdgeDraft != 0)
-  {
-    kDebug() << "removing new edge draft";
-    d->m_newEdgeDraft->hide();
-    scene()->removeItem(d->m_newEdgeDraft);
-    delete d->m_newEdgeDraft;
-    d->m_newEdgeDraft = 0;
-  }
-  d->m_newEdgeDraft = new QGraphicsLineItem(QLineF(node->boundingRect().center()+node->pos(),node->boundingRect().center()+node->pos()+QPointF(10,10)));
-  scene()->addItem(d->m_newEdgeDraft);
-  d->m_newEdgeDraft->setZValue(1000);
-  d->m_newEdgeDraft->show();
-  kDebug() << d->m_newEdgeDraft->line();
-}
-
-void DotGraphView::finishNewEdgeTo(CanvasElement* node)
-{
-  Q_D(DotGraphView);
-  kDebug() << node->element()->id();
-  d->m_editingMode = None;
-  unsetCursor();
-
-  if (d->m_newEdgeDraft != 0)
-  {
-    kDebug() << "removing new edge draft";
-    d->m_newEdgeDraft->hide();
-    scene()->removeItem(d->m_newEdgeDraft);
-    delete d->m_newEdgeDraft;
-    d->m_newEdgeDraft = 0;
-  }
-
-  emit newEdgeFinished(d->m_newEdgeSource->element()->id(),node->element()->id(),d->m_newElementAttributes);
-
-  d->m_newEdgeSource = 0;
-}
-
-// void DotGraphView::slotFinishNewEdge(
-//       const QString& srcId,
-//       const QString& tgtId,
-//       const QMap<QString, QString> newElementAttributes)
-// {
-//   kDebug() ;
-// 
-//   GraphEdge* gedge  = new GraphEdge();
-//   gedge->setFromNode(d->m_graph->nodes()[srcId]);
-//   gedge->setToNode(d->m_graph->nodes()[tgtId]);
-//   gedge->attributes() = newElementAttributes;
-//   foreach (const QString &attrib, newElementAttributes.keys())
-//   {
-//     if (attrib == "z")
-//     {
-//       bool ok;
-//       gedge->setZ(newElementAttributes[attrib].toDouble(&ok));
-//     }
-//   }
-//   gedge->setId(srcId+tgtId+QString::number(d->m_graph->edges().size()));
-//   d->m_graph->edges().insert(gedge->id(), gedge);
-// 
-//   double scaleX = 1.0, scaleY = 1.0;
-// 
-//   if (d->m_detailLevel == 0)      { scaleX = d->m_graph->scale() * 0.7; scaleY = d->m_graph->scale() * 0.7; }
-//   else if (d->m_detailLevel == 1) { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
-//   else if (d->m_detailLevel == 2) { scaleX = d->m_graph->scale() * 1.3; scaleY = d->m_graph->scale() * 1.3; }
-//   else                        { scaleX = d->m_graph->scale() * 1.0; scaleY = d->m_graph->scale() * 1.0; }
-// 
-//   qreal gh = d->m_graph->height();
-//   CanvasEdge* cedge = new CanvasEdge(this, gedge, scaleX, scaleY, d->m_xMargin,
-//         d->m_yMargin, gh, d->m_graph->wdhcf(), d->m_graph->hdvcf());
-// 
-//   gedge->setCanvasEdge(cedge);
-// //     std::cerr << "setting z = " << gedge->z() << std::endl;
-//   cedge->setZValue(gedge->z());
-//   cedge->show();
-//   scene()->addItem(cedge);
-// 
-//   emit newEdgeAdded(gedge->fromNode()->id(),gedge->toNode()->id());
-// }
-
-void DotGraphView::setReadOnly()
-{
-  Q_D(DotGraphView);
-  kDebug() ;
- d-> m_readWrite = false;
-  if (d->m_graph != 0)
-  {
-    d->m_graph->setReadOnly();
-  }
-}
-
-void DotGraphView::setReadWrite()
-{
-  Q_D(DotGraphView);
-  kDebug() ;
-  d->m_readWrite = true;
-  if (d->m_graph != 0)
-  {
-    d->m_graph->setReadWrite();
-  }
-}
-
-void DotGraphView::slotEdgeSelected(CanvasEdge* edge, Qt::KeyboardModifiers modifiers)
-{
-  Q_D(DotGraphView);
-  kDebug() << edge->edge()->id();
-  QList<QString> selection;
-  selection.push_back(edge->edge()->id());
-  if (!modifiers.testFlag(Qt::ControlModifier))
-  {
-    foreach(GraphEdge* e, d->m_graph->edges())
-    {
-      if (e->canvasEdge() != edge)
-      {
-        e->setSelected(false);
-        e->canvasEdge()->update();
-      }
-    }
-    foreach(GraphNode* n, d->m_graph->nodes())
-    {
-      n->setSelected(false);
-      n->canvasNode()->update();
-    }
-    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
-    {
-      s->setElementSelected(0, false, true);
-    }
-  }
-  else
-  {
-    foreach(GraphEdge* e, d->m_graph->edges())
-    {
-      if (e->canvasEdge() != edge)
-      {
-        if (e->isSelected())
-        {
-          selection.push_back(e->id());
-        }
-      }
-    }
-    foreach(GraphNode* n, d->m_graph->nodes())
-    {
-      if (n->isSelected())
-      {
-        selection.push_back(n->id());
-      }
-    }
-    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
-    {
-      if (s->isSelected())
-      {
-        selection.push_back(s->id());
-      }
-    }
-  }
-  emit selectionIs(selection, QPoint());
-}
-
-void DotGraphView::slotElementSelected(CanvasElement* element, Qt::KeyboardModifiers modifiers)
-{
-  Q_D(DotGraphView);
-  kDebug();
-  QList<QString> selection;
-  selection.push_back(element->element()->id());
-  if (!modifiers.testFlag(Qt::ControlModifier))
-  {
-    foreach(GraphEdge* e, d->m_graph->edges())
-    {
-      if (e->isSelected()) {
-        e->setSelected(false);
-        e->canvasEdge()->update();
-      }
-    }
-    foreach(GraphNode* e, d->m_graph->nodes())
-    {
-      if (e->canvasElement() != element)
-      {
-        if (e->isSelected()) {
-          e->setSelected(false);
-          e->canvasElement()->update();
-        }
-      }
-    }
-    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
-    {
-      s->setElementSelected(element->element(), true, true);
-    }
-  }
-  else
-  {
-    foreach(GraphEdge* e, d->m_graph->edges())
-    {
-      if (e->isSelected())
-      {
-        selection.push_back(e->id());
-      }
-    }
-    foreach(GraphNode* n, d->m_graph->nodes())
-    {
-      if (n->isSelected())
-      {
-        selection.push_back(n->id());
-      }
-    }
-    foreach(GraphSubgraph* s, d->m_graph->subgraphs())
-    {
-      s->retrieveSelectedElementsIds(selection);
-    }
-  }
-  emit selectionIs(selection, QPoint());
-}
-
-void DotGraphView::removeSelectedEdges()
-{
-  Q_D(DotGraphView);
-  kDebug();
-  foreach(GraphEdge* e, d->m_graph->edges())
-  {
-    if (e->isSelected())
-    {
-      kDebug() << "emiting removeEdge " << e->id();
-      d->m_graph->removeEdge(e->id());
-      emit removeEdge(e->id());
-    }
-  }
-}
-
-void DotGraphView::removeSelectedNodes()
-{
-  Q_D(DotGraphView);
-  kDebug();
-  foreach(GraphNode* e, d->m_graph->nodes())
-  {
-    if (e->isSelected())
-    {
-      kDebug() << "emiting removeElement " << e->id();
-      d->m_graph->removeElement(e->id());
-      emit removeElement(e->id());
-    }
-  }
-}
-
-void DotGraphView::removeSelectedSubgraphs()
-{
-  Q_D(DotGraphView);
-  kDebug();
-  foreach(GraphSubgraph* e, d->m_graph->subgraphs())
-  {
-    if (e->isSelected())
-    {
-      kDebug() << "emiting removeElement " << e->id();
-      d->m_graph->removeElement(e->id());
-      emit removeElement(e->id());
-    }
-  }
-}
-
-void DotGraphView::removeSelectedElements()
-{
-  kDebug();
-  removeSelectedNodes();
-  removeSelectedEdges();
-  removeSelectedSubgraphs();
-}
-
-void DotGraphView::timerEvent ( QTimerEvent * event )
-{
-  Q_D(DotGraphView);
-  kDebug() << event->timerId();
-  qreal vpercent = verticalScrollBar()->value()*1.0/100;
-  qreal hpercent = horizontalScrollBar()->value()*1.0/100;
-  if (d->m_scrollDirection == Left)
-  {
-    horizontalScrollBar()->setValue(horizontalScrollBar()->value()-(5*hpercent));
-  }
-  else if (d->m_scrollDirection == Right)
-  {
-    horizontalScrollBar()->setValue(horizontalScrollBar()->value()+(5*hpercent));
-  }
-  else if (d->m_scrollDirection == Top)
-  {
-    verticalScrollBar()->setValue(verticalScrollBar()->value()-(5*vpercent));
-  }
-  else if (d->m_scrollDirection == Bottom)
-  {
-    verticalScrollBar()->setValue(verticalScrollBar()->value()+(5*vpercent));
-  }
-}
-
-void DotGraphView::leaveEvent ( QEvent * /*event*/ )
-{
-  Q_D(DotGraphView);
-  kDebug() << mapFromGlobal(QCursor::pos());
-  if (d->m_editingMode == DrawNewEdge)
-  {
-    d->m_leavedTimer = startTimer(10);
-    if (mapFromGlobal(QCursor::pos()).x() <= 0)
-    {
-      d->m_scrollDirection = Left;
-    }
-    else if (mapFromGlobal(QCursor::pos()).y() <= 0)
-    {
-      d->m_scrollDirection = Top;
-    }
-    else if (mapFromGlobal(QCursor::pos()).x() >= width())
-    {
-      d->m_scrollDirection = Right;
-    }
-    else if (mapFromGlobal(QCursor::pos()).y() >= height())
-    {
-      d->m_scrollDirection = Bottom;
-    }
-  }
-}
-
-void DotGraphView::enterEvent ( QEvent * /*event*/ )
-{
-  Q_D(DotGraphView);
-  kDebug();
-  if (d->m_leavedTimer != std::numeric_limits<int>::max())
-  {
-    killTimer(d->m_leavedTimer);
-    d->m_leavedTimer = std::numeric_limits<int>::max();
-  }
-}
-
-void DotGraphView::slotAGraphReadFinished()
-{
-  Q_D(DotGraphView);
-  QString layoutCommand = (d->m_graph!=0?d->m_graph->layoutCommand():"");
-  if (layoutCommand.isEmpty())
-  {
-    if (!d->m_loadThread.dotFileName().isEmpty())
-      layoutCommand = d->m_graph->chooseLayoutProgramForFile(d->m_loadThread.dotFileName());
-    else
-      layoutCommand = "dot";
-  }
-  d->m_layoutThread.layoutGraph(d->m_loadThread.g(), layoutCommand);
-}
-
-void DotGraphView::slotAGraphLayoutFinished()
-{
-  Q_D(DotGraphView);
-  bool result = loadLibrary(d->m_layoutThread.g(), d->m_layoutThread.layoutCommand());
-  if (result)
-    d->m_graph->dotFileName(d->m_loadThread.dotFileName());
-
-  gvFreeLayout(d->m_layoutThread.gvc(), d->m_layoutThread.g());
-  agclose(d->m_layoutThread.g());
-}
-
-void DotGraphView::slotSelectNode(const QString& nodeName)
-{
-  kDebug() << nodeName;
-  GraphNode* node = dynamic_cast<GraphNode*>(graph()->elementNamed(nodeName));
-  if (node == 0) return;
-  node->setSelected(true);
-  if (node->canvasNode()!=0)
-  {
-    node->canvasNode()->modelChanged();
-    slotElementSelected(node->canvasNode(),Qt::NoModifier);
-  }
-}
-
-void DotGraphView::centerOnNode(const QString& nodeId)
-{
-  GraphNode* node = dynamic_cast<GraphNode*>(graph()->elementNamed(nodeId));
-  if (node == 0) return;
-  if (node->canvasNode()!=0)
-  {
-    centerOn(node->canvasNode());
-  }
-}
-
-
-}
-
-#include "dotgraphview.moc"
-
diff --git a/src/part/dotgraphview.h b/src/part/dotgraphview.h
deleted file mode 100644
index a9e5454..0000000
--- a/src/part/dotgraphview.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Callgraph View
- */
-
-#ifndef DOTGRAPHVIEW_H
-#define DOTGRAPHVIEW_H
-
-#include "kgraphviewer_export.h"
-#include "kgraphviewer_interface.h"
-
-#include <kconfig.h>
-#include <kactioncollection.h>
-#include <kconfiggroup.h>
-
-#include <QGraphicsView>
-#include <QSet>
-
-class Agraph_t;
-
-class KSelectAction;
-class KToggleAction;
-
-class QMenu;
-class QKeyEvent;
-class QMouseEvent;
-class QFocusEvent;
-class QResizeEvent;
-class QWheelEvent;
-class QContextMenuEvent;
-class QWidget;
-
-namespace KGraphViewer
-{
-
-class GraphElement;
-class GraphSubgraph;
-class CanvasElement;
-class CanvasEdge;
-class PannerView;
-class DotGraph;
-class KGVSimplePrintingCommand;
-
-#define DEFAULT_DETAILLEVEL 1
-
-class DotGraphViewPrivate;
-/**
- * A CanvasView showing a part of the call graph
- * and another zoomed out CanvasView in a border acting as
- * a panner to select to visible part (only if needed)
- */
-class KGRAPHVIEWER_EXPORT DotGraphView: public QGraphicsView
-{
- Q_OBJECT
-
-public:
-  enum EditingMode { None, AddNewElement, AddNewEdge, DrawNewEdge, SelectingElements };
-  enum ScrollDirection { Here, Left, Right, Top, Bottom };
-  
-  explicit KGRAPHVIEWER_EXPORT DotGraphView(KActionCollection* actions, QWidget* parent=0);
-  virtual ~DotGraphView();
-
-  bool KGRAPHVIEWER_EXPORT loadDot(const QString& dotFileName);
-  bool KGRAPHVIEWER_EXPORT loadLibrary(const QString& dotFileName);
-  bool loadLibrary(Agraph_t* graph, const QString& layoutCommand = "dot");
-
-  void readViewConfig();
-  void saveViewConfig();
-
-  QWidget* widget() { return this; }
-
-  //TODO: rename zoomPos -> bev / panner, but _please_ make it consistent...
-  KGraphViewerInterface::PannerPosition zoomPos() const;
-  static KGraphViewerInterface::PannerPosition zoomPos(const QString&);
-  static QString zoomPosString(KGraphViewerInterface::PannerPosition);
-  void setPannerEnabled(bool enabled);
-  
-  static KConfigGroup* configGroup(KConfig*, const QString& prefix, const QString& postfix);
-  static void writeConfigEntry(KConfigGroup*, const char* pKey, const QString& value,
-                               const char* def);
-  static void writeConfigEntry(KConfigGroup*, const char* pKey,
-                               int value, int def);
-  static void writeConfigEntry(KConfigGroup*, const char* pKey,
-                               bool value, bool def);
-  static void writeConfigEntry(KConfigGroup*, const char* pKey,
-                               double value, double def);
-
-  virtual void wheelEvent(QWheelEvent* e);
-
-  /// multiplies current zoom factor with @p factor
-  void applyZoom(double factor);
-  /// sets zoom factor to @p factor
-  void setZoomFactor(double factor);
-  
-  void setLayoutCommand(const QString& command);
-    
-  const QString& dotFileName();
-
-  void hideToolsWindows();
-  double zoom() const;
-  KSelectAction* bevPopup();
-
-  DotGraph* graph();
-  const DotGraph* graph() const;
-
-  const GraphElement* defaultNewElement() const;
-  QPixmap defaultNewElementPixmap() const;
-
-  void setDefaultNewElement(GraphElement* elem);
-  void setDefaultNewElementPixmap(const QPixmap& pm);
-
-  void prepareAddNewElement(QMap<QString,QString> attribs);
-  void prepareAddNewEdge(QMap<QString,QString> attribs);
-  void prepareSelectElements();
-  
-  void createNewEdgeDraftFrom(CanvasElement* node);
-  void finishNewEdgeTo(CanvasElement* node);
-
-  EditingMode editingMode() const;
-
-  void KGRAPHVIEWER_EXPORT setReadOnly();
-  void KGRAPHVIEWER_EXPORT setReadWrite();
-  bool isReadWrite() const;
-  bool isReadOnly() const;
-  
-  void removeSelectedNodes();
-  void removeSelectedEdges();
-  void removeSelectedSubgraphs();
-  void removeSelectedElements();
-  
-  bool highlighting();
-  void setHighlighting(bool highlightingValue);
-
-  // public so that the panner view can bubble through
-  void contextMenuEvent(QContextMenuEvent*);
-
-  void setBackgroundColor(const QColor& color);
-  
-Q_SIGNALS:
-  void zoomed(double factor);
-  void sigViewBevEnabledToggled(bool value);
-  void sigViewBevActivated(int newPos);
-  void graphLoaded();
-  void newNodeAdded(const QString&);
-  void newEdgeAdded(const QString&, const QString&);
-  /** signals that the user has activated a remove edge command */
-  void removeEdge(const QString&);
-  /** signals that the user has activated a remove edge command */
-  void removeNodeNamed(const QString&);
-  /** signals that the user has activated a remove element command */
-  void removeElement(const QString&);
-  /** signals the content of the new selection */
-  void selectionIs(const QList<QString>, const QPoint&);
-  /** let the application tweak the created edge if necessary */
-  void newEdgeFinished(
-      const QString&, const QString&,
-      const QMap<QString, QString>&);
-  void contextMenuEvent(const QString&, const QPoint&);
-  void hoverEnter(const QString&);
-  void hoverLeave(const QString&);
-  
-public Q_SLOTS:
-  void zoomIn();
-  void zoomOut();  
-  void zoomRectMovedTo(QPointF newZoomPos);
-  void zoomRectMoveFinished();
-  bool initEmpty();
-  bool slotLoadLibrary(Agraph_t* graph);
-  bool reload();
-  void dirty(const QString& dotFileName);
-  void pageSetup();
-  void print();
-  void printPreview();
-  void viewBevActivated(int newPos);
-  void slotExportImage();
-  void slotSelectLayoutAlgo(const QString& text);
-  void slotLayoutSpecify();
-  void slotLayoutReset();
-  void slotSelectLayoutDot();
-  void slotSelectLayoutNeato();
-  void slotSelectLayoutTwopi();
-  void slotSelectLayoutFdp();
-  void slotSelectLayoutCirco();
-  void slotBevToggled();
-  void slotBevTopLeft();
-  void slotBevTopRight();
-  void slotBevBottomLeft();
-  void slotBevBottomRight();
-  void slotBevAutomatic();
-  void slotUpdate();
-  bool displayGraph();
-  void slotEdgeSelected(CanvasEdge*, Qt::KeyboardModifiers);
-  void slotElementSelected(CanvasElement*, Qt::KeyboardModifiers);
-  void slotSelectionChanged();
-  void slotContextMenuEvent(const QString&, const QPoint&);
-  void slotElementHoverEnter(CanvasElement*);
-  void slotElementHoverLeave(CanvasElement*);
-  void slotElementHoverEnter(CanvasEdge*);
-  void slotElementHoverLeave(CanvasEdge*);
-  void slotSelectNode(const QString& nodeName);
-  void centerOnNode(const QString& nodeId);
-
-protected:
-  void scrollContentsBy(int dx, int dy);
-  void resizeEvent(QResizeEvent*);
-  void mousePressEvent(QMouseEvent*);
-  void mouseMoveEvent(QMouseEvent*);
-  void mouseReleaseEvent(QMouseEvent*);
-  void mouseDoubleClickEvent(QMouseEvent*);
-  void keyPressEvent(QKeyEvent*);
-  void focusInEvent(QFocusEvent*);
-  void focusOutEvent(QFocusEvent*);
-  
-  void timerEvent ( QTimerEvent * event );
-  void leaveEvent ( QEvent * event );
-  void enterEvent ( QEvent * event );
-  
-private Q_SLOTS:
-  void slotAGraphReadFinished();
-  void slotAGraphLayoutFinished();
-  
-protected:
-  DotGraphViewPrivate * const d_ptr;
-
-private:
-  Q_DECLARE_PRIVATE(DotGraphView);
-  
-};
-
-}
-
-#endif // DOTGRAPHVIEW_H
diff --git a/src/part/dotrenderop.h b/src/part/dotrenderop.h
deleted file mode 100644
index 0ef0113..0000000
--- a/src/part/dotrenderop.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-#ifndef DOT_RENDEROP_H
-#define DOT_RENDEROP_H
-
-#include <QString>
-#include <QList>
-#include <QTextStream>
-
-/**
- * members are interpreted in function of render operations definitions given at:
- * @URL http://www.graphviz.org/cvs/doc/info/output.html#d:dot
- */
-struct DotRenderOp
-{
-  QString renderop;
-  QList< int > integers;
-  QString str;
-};
-
-typedef QList< DotRenderOp > DotRenderOpVec;
-
-#endif
diff --git a/src/part/graphedge.cpp b/src/part/graphedge.cpp
deleted file mode 100644
index 0ac7988..0000000
--- a/src/part/graphedge.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.cpp, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-#include "graphedge.h"
-#include "graphnode.h"
-#include "graphsubgraph.h"
-#include "canvasedge.h"
-#include "dotdefaults.h"
-#include "dotgrammar.h"
-
-#include <graphviz/gvc.h>
-
-#include <KDebug>
-
-namespace KGraphViewer
-{
-  
-/*
- * Graph Edge
- */
-
-GraphEdge::GraphEdge() : 
-    GraphElement(),
-    m_fromNode(0),m_toNode(0),
-    m_visible(true),
-    m_colors(),
-    m_dir(DOT_DEFAULT_EDGE_DIR),
-    m_arrowheads()
-{
-//   kDebug() ;
-}
-
-GraphEdge::~GraphEdge()
-{
-//   kDebug() ;
-}
-
-GraphEdge::GraphEdge(const GraphEdge& edge) :
-  GraphElement(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;
-}
-
-void GraphEdge::colors(const QString& cs)
-{
-  m_colors = QStringList::split(":", cs);
-//   kDebug() << fromNode()->id() << " -> " << toNode()->id() << ": nb colors: " << m_colors.size();
-}
-
-const QString GraphEdge::color(uint i) 
-{
-  if (i >= (uint)m_colors.count() && m_attributes.find("color") != m_attributes.end())
-  {
-    colors(m_attributes["color"]);
-  }
-  if (i < (uint)m_colors.count())
-  {
-//     std::cerr << "edge color " << i << " is " << m_colors[i] << std::endl;
-//     kDebug() << fromNode()->id() << " -> " << toNode()->id() << "color" << i << "is" << m_colors[i];
-    return m_colors[i];
-  }
-  else
-  {
-//     kDebug() << fromNode()->id() << " -> " << toNode()->id() << "no edge color " << i << ". returning " << DOT_DEFAULT_EDGE_COLOR;
-    return DOT_DEFAULT_EDGE_COLOR;
-  }
-}
-
-void GraphEdge::updateWithEdge(const GraphEdge& edge)
-{
-  kDebug() << id() << edge.id();
-  m_arrowheads = edge.arrowheads();
-  m_colors = edge.colors();
-  m_dir = edge.dir();
-  GraphElement::updateWithElement(edge);
-  if (canvasEdge())
-  {
-    canvasEdge()->computeBoundingRect();
-    canvasEdge()->modelChanged();
-  }
-}
-
-void GraphEdge::updateWithEdge(edge_t* edge)
-{
-  kDebug();
-  renderOperations().clear();
-  if (agget(edge, (char*)"_draw_") != NULL)
-  {
-    parse_renderop(agget(edge, (char*)"_draw_"), renderOperations());
-    kDebug() << "element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(edge, (char*)"_ldraw_") != NULL)
-  {
-    parse_renderop(agget(edge, (char*)"_ldraw_"), renderOperations());
-    kDebug() << "element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(edge, (char*)"_hdraw_") != NULL)
-  {
-    parse_renderop(agget(edge, (char*)"_hdraw_"), renderOperations());
-    kDebug() << "element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(edge, (char*)"_tdraw_") != NULL)
-  {
-    parse_renderop(agget(edge, (char*)"_tdraw_"), renderOperations());
-    kDebug() << "element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(edge, (char*)"_hldraw_") != NULL)
-  {
-    parse_renderop(agget(edge, (char*)"_hldraw_"), renderOperations());
-    kDebug() << "element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(edge, (char*)"_tldraw_") != NULL)
-  {
-    parse_renderop(agget(edge, (char*)"_tldraw_"), renderOperations());
-    kDebug() << "element renderOperations size is now " << renderOperations().size();
-  }
-  Agsym_t *attr = agfstattr(edge);
-  while(attr)
-  {
-    kDebug() /*<< edge->name*/ << ":" << attr->name << agxget(edge,attr->index);
-    m_attributes[attr->name] = agxget(edge,attr->index);
-    attr = agnxtattr(edge,attr);
-  }
-  
-}
-
-QTextStream& operator<<(QTextStream& s, const GraphEdge& e)
-{
-  QString srcLabel = e.fromNode()->id();
-  if (dynamic_cast<const GraphSubgraph*>(e.fromNode()))
-  {
-    srcLabel = QString("subgraph ") + srcLabel;
-  }
-  QString tgtLabel = e.toNode()->id();
-  if (dynamic_cast<const GraphSubgraph*>(e.toNode()))
-  {
-    tgtLabel = QString("subgraph ") + tgtLabel;
-  }
-  s << srcLabel << " -> " << tgtLabel << "  ["
-    << dynamic_cast<const GraphElement&>(e) << "];" << endl;
-
-  return s;
-}
-
-}
-
-#include "graphedge.moc"
diff --git a/src/part/graphedge.h b/src/part/graphedge.h
deleted file mode 100644
index 94d757e..0000000
--- a/src/part/graphedge.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Graph Edge
- */
-
-#ifndef GRAPH_EDGE_H
-#define GRAPH_EDGE_H
-
-#include "graphelement.h"
-#include "dotrenderop.h"
-
-#include <QStringList>
-#include <QMap>
-#include <QTextStream>
-
-class Agedge_t;
-
-namespace KGraphViewer
-{
-  
-class CanvasEdge;
-class CanvasNode;
-class GraphNode;
-
-class GraphEdge : public GraphElement
-{
-  Q_OBJECT
-
-public:
-  GraphEdge();
-  virtual ~GraphEdge();
-
-  GraphEdge(const GraphEdge& edge);
-  GraphEdge(Agedge_t* edge);
-  
-  CanvasEdge* canvasEdge() { return (CanvasEdge*)canvasElement(); }
-  const CanvasEdge* canvasEdge() const { return (CanvasEdge*)canvasElement(); }
-  void setCanvasEdge(CanvasEdge* ce) { setCanvasElement((CanvasElement*)ce); }
-
-  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; }
-
-  void setFromNode(GraphElement* n) { m_fromNode = n; }
-  void setToNode(GraphElement* n) { m_toNode = n; }
-
-//   inline const QVector< QPair< float, float > >& edgePoints() const {return m_edgePoints;}
-//   inline QVector< QPair< float, float > >& edgePoints() {return m_edgePoints;}
-//   inline void edgePoints(const QVector< QPair< float, float > >& ep) {m_edgePoints = ep;}
-  
-  inline const QStringList& colors() const {return m_colors;}
-  const QString color(uint i);
-  void colors(const QString& cs); 
-  
-/*  inline void labelX(float x) {m_labelX = x;}
-  inline void labelY(float y) {m_labelY = y;}
-  inline float labelX() const {return m_labelX;}
-  inline float labelY() const {return m_labelY;}*/
-  
-  inline const QString& dir() const {return m_dir;}
-  inline void dir(const QString& dir) {m_dir = dir;}
-
-  inline QList< DotRenderOp >&  arrowheads() {return m_arrowheads;}
-  inline const QList< DotRenderOp >&  arrowheads() const {return m_arrowheads;}
-
-  virtual void updateWithEdge(const GraphEdge& edge);
-  virtual void updateWithEdge(Agedge_t* edge);
-
-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;
-//   float m_labelX, m_labelY;
-  
-  QList< DotRenderOp > m_arrowheads;
-};
-
-
-/** A map associating the bounds nodes of a graph's edges to these edges */
-typedef QMap<QString, GraphEdge*> GraphEdgeMap;
-
-QTextStream& operator<<(QTextStream& s, const GraphEdge& e);
-
-}
-
-#endif
-
-
-
diff --git a/src/part/graphelement.cpp b/src/part/graphelement.cpp
deleted file mode 100644
index 52d9fa8..0000000
--- a/src/part/graphelement.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-#include "graphelement.h"
-#include "canvaselement.h"
-#include "dotdefaults.h"
-
-#include <math.h>
-
-#include <kdebug.h>
-
-#include <QRegExp>
-#include <graphviz/gvc.h>
-
-namespace KGraphViewer
-{
-  
-GraphElement::GraphElement() :
-    QObject(),
-    m_attributes(),
-    m_originalAttributes(),
-    m_ce(0),
-    m_z(1.0),
-    m_renderOperations(),
-    m_selected(false)
-{
-/*  label("");
-  id("");
-  style(DOT_DEFAULT_STYLE);
-  shape(DOT_DEFAULT_SHAPE);
-  lineColor(DOT_DEFAULT_LINECOLOR);
-  backColor(DOT_DEFAULT_BACKCOLOR);
-  fontName(DOT_DEFAULT_FONTNAME);
-  fontColor(DOT_DEFAULT_FONTCOLOR);
-  url("");
-  shapeFile("");*/
-  setFontSize(DOT_DEFAULT_FONTSIZE);
-}
-
-GraphElement::GraphElement(const GraphElement& element) : QObject(),
-  m_attributes(),
-  m_originalAttributes(),
-  m_ce(element.m_ce),
-  m_z(element.m_z),
-  m_renderOperations(),
-  m_selected(element.m_selected)
-{
-  kDebug() ;
-  updateWithElement(element);
-}
-
-void GraphElement::updateWithElement(const GraphElement& element)
-{
-  kDebug() << element.id();
-  bool modified = false;
-  if (element.z() != m_z)
-  {
-    m_z = element.z();
-    modified = true;
-  }
-  QMap <QString, QString >::const_iterator it = element.attributes().constBegin();
-  for (;it != element.attributes().constEnd(); it++)
-  {
-    const QString &attrib = it.key();
-    if ( (!m_attributes.contains(attrib)) || (m_attributes[attrib] != it.value()) )
-    {
-      m_attributes[attrib] = it.value();
-      if (attrib == "z")
-      {
-        bool ok;
-        setZ(m_attributes[attrib].toDouble(&ok));
-      }
-      modified = true;
-    }
-  }
-  if (modified)
-  {
-    kDebug() << "modified: update render operations";
-    m_renderOperations = element.m_renderOperations;
-/*    foreach (DotRenderOp op, m_renderOperations)
-    {
-      QString msg;
-      QTextStream dd(&msg);
-      dd << "an op: " << op.renderop << " ";
-      foreach (int i, op.integers)
-      {
-        dd << i << " ";
-      }
-      dd << op.str;
-      kDebug() << msg;
-    }
-    kDebug() << "modified: emiting changed";*/
-    emit changed();
-  }
-  kDebug() << "done" << m_renderOperations.size();
-}
-
-
-QString GraphElement::backColor() const
-{
-  if (m_attributes.find("fillcolor") != m_attributes.end())
-  {
-    return m_attributes["fillcolor"];
-  }
-  else if ( (m_attributes.find("color") != m_attributes.end())
-    && (m_attributes["style"] == "filled") )
-  {
-    return m_attributes["color"];
-  }
-  else
-  {
-    return DOT_DEFAULT_NODE_BACKCOLOR;
-  }
-}
-
-void GraphElement::removeAttribute(const QString& attribName)
-{
-  kDebug() << attribName;
-  m_attributes.remove(attribName);
-  emit changed();
-}
-
-void GraphElement::exportToGraphviz(void* element) const
-{
-  QMap<QString,QString>::const_iterator it, it_end;
-  it = attributes().begin(); it_end = attributes().end();
-  for (;it != it_end; it++)
-  {
-    if (!it.value().isEmpty())
-    {
-      if (it.key() == "label")
-      {
-        QString label = it.value();
-        if (label != "label")
-        {
-          label.replace(QRegExp("\n"),"\\n");
-          //           kDebug() << it.key() << "=\"" << label << "\",";
-          agsafeset(element, it.key().toUtf8().data(), label.toUtf8().data(), QString().toUtf8().data());
-        }
-      }
-      else if (it.key() == "_draw_" || it.key() == "_ldraw_")
-      {
-      }
-      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());
-      }
-    }
-  }
-}
-
-QTextStream& operator<<(QTextStream& s, const GraphElement& n)
-{
-  QMap<QString,QString>::const_iterator it, it_end;
-  it = n.attributes().begin(); it_end = n.attributes().end();
-  for (;it != it_end; it++)
-  {
-    if (!it.value().isEmpty())
-    {
-      if (it.key() == "label")
-      {
-        QString label = it.value();
-        if (label != "label")
-        {
-          label.replace(QRegExp("\n"),"\\n");
-//           kDebug() << it.key() << "=\"" << label << "\",";
-          s << it.key() << "=\"" << label << "\",";
-        }
-      }
-      else if (it.key() == "_draw_" || it.key() == "_ldraw_")
-      {
-      }
-      else if (n.originalAttributes().isEmpty() || n.originalAttributes().contains(it.key()))
-      {
-//         kDebug() << it.key() << it.value();
-        
-          s << it.key() << "=\"" << it.value() << "\",";
-      }
-    }
-  }
-  return s;
-}
-
-}
-
-#include "graphelement.moc"
diff --git a/src/part/graphelement.h b/src/part/graphelement.h
deleted file mode 100644
index 5a65574..0000000
--- a/src/part/graphelement.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-#ifndef GRAPH_ELEMENT_H
-#define GRAPH_ELEMENT_H
-
-#include "dotrenderop.h"
-
-#include <QVector>
-#include <QList>
-#include <QMap>
-#include <QtCore/QTextStream>
-
-namespace KGraphViewer
-{
-  
-class CanvasElement;
-
-/**
- * The base of all GraphViz dot graph elements (nodes, edges, subgraphs,
- * graphs). It is used to store the element attributes
- */
-class GraphElement: public QObject
-{
-  Q_OBJECT
-public:
-  GraphElement();
-  GraphElement(const GraphElement& element);
-  
-  virtual ~GraphElement() {}
-  
-  inline void setId(const QString& id) {m_attributes["id"]=id;}
-  inline void setStyle(const QString& ls) {m_attributes["style"]=ls;}
-  inline void setShape(const QString& lc) {m_attributes["shape"]=lc;}
-  inline void setColor(const QString& nt) {m_attributes["color"]=nt;}
-  inline void setLineColor(const QString& nt) {m_attributes["color"]=nt;}
-  inline void setBackColor(const QString& nc) {m_attributes["bgcolor"]=nc;}
-  
-  inline QString id() const {return m_attributes["id"];}
-  inline QString style() const {return m_attributes["style"];}
-  inline QString shape() const {return m_attributes["shape"];}
-  inline QString color() const {return m_attributes["color"];}
-  inline QString lineColor() const {return m_attributes["color"];}
-  virtual QString backColor() const;
-  
-  inline void setLabel(const QString& label) {m_attributes["label"]=label;}
-  inline const QString label() const {return m_attributes["label"];}
-
-  inline unsigned int fontSize() const {return m_attributes["fontsize"].toUInt();}
-  inline void setFontSize(unsigned int fs) {m_attributes["fontsize"]=QString::number(fs);}
-  inline QString fontName() const {return m_attributes["fontname"];}
-  inline void setFontName(const QString& fn) {m_attributes["fontname"]=fn;}
-  inline QString fontColor() const {return m_attributes["fontcolor"];}
-  inline void setFontColor(const QString& fc) {m_attributes["fontcolor"] = fc;}
-
-  inline DotRenderOpVec& renderOperations() {return m_renderOperations;};
-  inline const DotRenderOpVec& renderOperations() const {return m_renderOperations;};
-  inline void setRenderOperations(DotRenderOpVec& drov) {m_renderOperations = drov;};
-  
-  inline double z() const {return m_z;}
-  inline void setZ(double thez) {m_z = thez;}
-  
-  inline QString shapeFile() const {return m_attributes["shapefile"];}
-  inline void setShapeFile(const QString& sf) {m_attributes["shapefile"] = sf;}
-  
-  inline QString url() const {return m_attributes["URL"];}
-  inline void setUrl(const QString& theUrl) {m_attributes["URL"] = theUrl;}
-
-  virtual void updateWithElement(const GraphElement& element);
-
-  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;}
-
-  virtual inline void storeOriginalAttributes() {m_originalAttributes = m_attributes.keys();}
-
-  virtual void removeAttribute(const QString& attribName);
-
-  inline CanvasElement* canvasElement() {return m_ce;}
-  inline const CanvasElement* canvasElement() const {return m_ce;}
-  inline void setCanvasElement(CanvasElement* ce) {m_ce = ce;}
-
-  inline void setSelected(bool s) {m_selected=s;}
-  inline bool isSelected() {return m_selected;}
-
-  bool isVisible() const { return m_visible; }
-  void setVisible(bool v) { m_visible = v; }
-
-  void exportToGraphviz(void* element)  const;
-
-Q_SIGNALS:
-  void changed();
-
-protected:
-  QMap<QString,QString> m_attributes;
-  QList<QString> m_originalAttributes;
-  
-  CanvasElement* m_ce;
-private:
-  double m_z;
-  bool m_visible;
-
-  DotRenderOpVec m_renderOperations;
-
-  bool m_selected;
-};
-
-
-QTextStream& operator<<(QTextStream& s, const GraphElement& n);
-
-}
-
-#endif
-
-
-
diff --git a/src/part/graphexporter.cpp b/src/part/graphexporter.cpp
deleted file mode 100644
index 4192bf1..0000000
--- a/src/part/graphexporter.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.cpp, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-#include "graphexporter.h"
-#include "dotgraph.h"
-
-#include <graphviz/gvc.h>
-
-#include <QFile>
-#include <QTextStream>
-
-#include <kdebug.h>
-#include <ktemporaryfile.h>
-
-namespace KGraphViewer
-{
-  
-GraphExporter::GraphExporter()
-{
-}
-
-GraphExporter::~GraphExporter()
-{
-}
-
-QString GraphExporter::writeDot(const DotGraph* graph, const QString& fileName)
-{
-  kDebug() << fileName;
-
-  QString actualFileName = fileName;
-
-  if (fileName.isEmpty())
-  {
-    KTemporaryFile tempFile;
-    tempFile.setSuffix(".dot");
-    if (!tempFile.open()) 
-    {
-      kError() << "Unable to open for temp file for writing " << tempFile.name() << endl;
-      exit(2);
-    }
-    actualFileName = tempFile.name();
-    kDebug() << "using " << actualFileName;
-  }
-  
-  QFile f(actualFileName);
-  if (!f.open(QIODevice::WriteOnly | QIODevice::Text))
-  {
-    kError() << "Unable to open file for writing " << fileName << endl;
-    exit(2);
-  }
-  
-  QTextStream stream(&f);
-
-  stream << "digraph \"";
-  if (graph->id()!="\"\"")
-  {
-    stream <<graph->id();
-  }
-  stream <<"\" {\n";
-
-  stream << "graph [" << *graph <<"]" << endl;
-
-  /// @TODO Subgraph are not represented as needed in DotGraph, so it is not
-  /// possible to save them back : to be changed !
-//   kDebug() << "writing subgraphs";
-  GraphSubgraphMap::const_iterator sit;
-  for ( sit = graph->subgraphs().begin();
-  sit != graph->subgraphs().end(); ++sit )
-  {
-    const GraphSubgraph& s = **sit;
-    (stream) << s;
-  }
-
-//   kDebug() << "writing nodes";
-  GraphNodeMap::const_iterator nit;
-  for ( nit = graph->nodes().begin();
-        nit != graph->nodes().end(); ++nit )
-  {
-    (stream) << **nit;
-  }
-
-  kDebug() << "writing edges";
-  GraphEdgeMap::const_iterator eit;
-  for ( eit = graph->edges().begin();
-        eit != graph->edges().end(); ++eit )
-  {
-    kDebug() << "writing edge" << (*eit)->id();
-    stream << **eit;
-  }
-
-  stream << "}\n";
-
-  f.close();
-  return actualFileName;
-}
-
-graph_t* GraphExporter::exportToGraphviz(const DotGraph* graph)
-{
-  int type = graph->directed()
-      ?(graph->strict()?AGDIGRAPHSTRICT:AGDIGRAPH)
-      :(graph->strict()?AGRAPHSTRICT:AGRAPH);
-  
-  graph_t* agraph = agopen((graph->id()!="\"\"")?graph->id().toUtf8().data():QString("unnamed").toUtf8().data(), type);
-
-  QTextStream stream;
-  graph->exportToGraphviz(agraph);
-  /// @TODO Subgraph are not represented as needed in DotGraph, so it is not
-  /// possible to save them back : to be changed !
-  //   kDebug() << "writing subgraphs";
-  GraphSubgraphMap::const_iterator sit;
-  for ( sit = graph->subgraphs().begin();
-  sit != graph->subgraphs().end(); ++sit )
-  {
-    const GraphSubgraph& s = **sit;
-    graph_t* subgraph = agsubg(agraph, s.id().toUtf8().data());
-    s.exportToGraphviz(subgraph);
-  }
-  
-  //   kDebug() << "writing nodes";
-  GraphNodeMap::const_iterator nit;
-  foreach (GraphNode* n, graph->nodes())
-  {
-    node_t* node = agnode(agraph, n->id().toUtf8().data());
-    n->exportToGraphviz(node);
-  }
-  
-  kDebug() << "writing edges";
-  GraphEdgeMap::const_iterator eit;
-  foreach (GraphEdge* e, graph->edges())
-  {
-    kDebug() << "writing edge" << e->id();
-    edge_t* edge = agedge(agraph, agnode(agraph, e->fromNode()->id().toUtf8().data()),
-                          agnode(agraph, e->toNode()->id().toUtf8().data()));
-    e->exportToGraphviz(edge);
-  }
-  
-  return agraph;
-}
-
-}
diff --git a/src/part/graphexporter.h b/src/part/graphexporter.h
deleted file mode 100644
index f6b223e..0000000
--- a/src/part/graphexporter.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-/*
- * Graph Exporter
- */
-
-#ifndef GRAPH_EXPORTER_H
-#define GRAPH_EXPORTER_H
-
-#include <QString>
-
-class Agraph_t;
-
-class KTemporaryFile;
-
-namespace KGraphViewer
-{
-class DotGraph;
-  
-/**
- * GraphExporter
- *
- * Generates a graph file for "dot"
- */
-class GraphExporter
-{
-public:
-  GraphExporter();
-  virtual ~GraphExporter();
-
-  QString writeDot(const DotGraph* graph, const QString& fileName = QString());
-  Agraph_t* exportToGraphviz(const DotGraph* graph);
-};
-
-}
-
-#endif
-
-
-
diff --git a/src/part/graphnode.cpp b/src/part/graphnode.cpp
deleted file mode 100644
index 8f7a0ea..0000000
--- a/src/part/graphnode.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Graph Node
- */
-
-#include "graphnode.h"
-#include "dotgrammar.h"
-#include "dotgraphview.h"
-#include "pannerview.h"
-#include "canvasnode.h"
-#include "dotdefaults.h"
-
-#include <math.h>
-
-#include <graphviz/gvc.h>
-
-#include <kdebug.h>
-
-namespace KGraphViewer
-{
-  
-//
-// GraphNode
-//
-
-GraphNode::GraphNode() :
-    GraphElement()
-{
-//   kDebug() ;
-}
-
-GraphNode::GraphNode(const GraphNode& gn) :
-GraphElement(gn)
-{
-  //   kDebug() ;
-}
-
-GraphNode::GraphNode(node_t* gn) : GraphElement()
-{
-  kDebug();
-  updateWithNode(gn);
-}
-
-void GraphNode::updateWithNode(const GraphNode& node)
-{
-  kDebug() << id() << node.id();
-  GraphElement::updateWithElement(node);
-  if (canvasNode())
-  {
-    canvasNode()->computeBoundingRect();
-    canvasNode()->modelChanged();
-  }
-//   kDebug() << "done";
-}
-
-void GraphNode::updateWithNode(node_t* node)
-{
-  kDebug() << node->name;
-  m_attributes["id"] = node->name;
-  m_attributes["label"] = ND_label(node)->text;
-
-
-  renderOperations().clear();
-  if (agget(node, (char*)"_draw_") != NULL)
-  {
-    parse_renderop(agget(node, (char*)"_draw_"), renderOperations());
-    kDebug() << "_draw_: element renderOperations size is now " << renderOperations().size();
-  }
-  if (agget(node, (char*)"_ldraw_") != NULL)
-  {
-    parse_renderop(agget(node, (char*)"_ldraw_"), renderOperations());
-    kDebug() << "_ldraw_: element renderOperations size is now " << renderOperations().size();
-  }
-
-  Agsym_t *attr = agfstattr(node);
-  while(attr)
-  {
-    kDebug() << node->name << ":" << attr->name << agxget(node,attr->index);
-    m_attributes[attr->name] = agxget(node,attr->index);
-    attr = agnxtattr(node,attr);
-  }
-}
-
-CanvasNode* GraphNode::canvasNode()
-{
-    return dynamic_cast<CanvasNode*>(canvasElement());
-}
-
-const KGraphViewer::CanvasNode* GraphNode::canvasNode() const
-{
-    return dynamic_cast<const CanvasNode*>(canvasElement());
-}
-
-QTextStream& operator<<(QTextStream& s, const GraphNode& n)
-{
-  s << n.id() << "  ["
-    << dynamic_cast<const GraphElement&>(n)
-    <<"];"<<endl;
-  return s;
-}
-
-}
-
-#include "graphnode.moc"
diff --git a/src/part/graphnode.h b/src/part/graphnode.h
deleted file mode 100644
index 6dc470e..0000000
--- a/src/part/graphnode.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Graph Node model
- */
-
-#ifndef GRAPH_NODE_H
-#define GRAPH_NODE_H
-
-#include <QVector>
-#include <QList>
-#include <QMap>
-#include <QtCore/QTextStream>
-
-#include "dotrenderop.h"
-#include "graphelement.h"
-
-class Agnode_t;
-
-namespace KGraphViewer
-{
-
-class CanvasElement;
-class CanvasNode;
-
-/**
- * Colors and styles are dot names
- */
-class GraphNode : public GraphElement
-{
-  Q_OBJECT
-
-public:
-  GraphNode();
-  GraphNode(const GraphNode& gn);
-  GraphNode(Agnode_t* gn);
-  
-  virtual ~GraphNode() {}  
-  
-  CanvasNode* canvasNode();
-  const CanvasNode* canvasNode() const;
-  inline void setCanvasNode(CanvasNode* cn) { setCanvasElement((CanvasElement*)cn); }
-
-  virtual void updateWithNode(const GraphNode& node);
-  virtual void updateWithNode(Agnode_t* node);
-
-  
-private:
-};
-
-/** A map associating the ids of a graph's nodes to these nodes */
-typedef QMap<QString, GraphNode*> GraphNodeMap;
-
-QTextStream& operator<<(QTextStream& s, const GraphNode& n);
-
-}
-
-#endif
-
-
-
diff --git a/src/part/graphsubgraph.cpp b/src/part/graphsubgraph.cpp
deleted file mode 100644
index c8ef11d..0000000
--- a/src/part/graphsubgraph.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005 Gaël de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/*
- * Graph Subgraph
- */
-
-#include "graphsubgraph.h"
-#include "graphnode.h"
-#include "canvassubgraph.h"
-#include "dotdefaults.h"
-#include "dotgrammar.h"
-
-#include "graphviz/gvc.h"
-
-#include <kdebug.h>
-
-namespace KGraphViewer
-{
-  
-//
-// GraphSubgraph
-//
-
-GraphSubgraph::GraphSubgraph() :
-  GraphElement(), m_content()
-{
-}
-
-GraphSubgraph::GraphSubgraph(graph_t* sg) :
-  GraphElement(), m_content()
-{
-  updateWithSubgraph(sg);
-}
-
-void GraphSubgraph::updateWithSubgraph(const GraphSubgraph& subgraph)
-{
-  kDebug() << id() << subgraph.id();
-  GraphElement::updateWithElement(subgraph);
-
-  bool found = false;
-  foreach (GraphElement* updatingge, subgraph.content())
-  {
-    foreach (GraphElement* ge, content())
-    {
-      if (ge->id() == updatingge->id())
-      {
-        found = true;
-        if (dynamic_cast<GraphNode*>(ge) != 0)
-        {
-          dynamic_cast<GraphNode*>(ge)->updateWithNode(*dynamic_cast<GraphNode*>(updatingge));
-        //     kDebug() << "node " << ngn->id();
-        }
-        else if (dynamic_cast<GraphSubgraph*>(ge) != 0)
-        {
-          dynamic_cast<GraphSubgraph*>(ge)->updateWithSubgraph(*dynamic_cast<GraphSubgraph*>(updatingge));
-        }
-        else
-        {
-          kError() << "Updated element is neither a node nor a subgraph";
-        }
-        break;
-      }
-    }
-    if (!found)
-    {
-  //       kDebug() << "new";
-      if (dynamic_cast<GraphNode*>(updatingge) != 0)
-      {
-        GraphNode* newgn = new GraphNode(*dynamic_cast<GraphNode*>(updatingge));
-  //       kDebug() << "new created";
-        content().push_back(newgn);
-  //       kDebug() << "new inserted";
-      }
-      else if (dynamic_cast<GraphSubgraph*>(updatingge) != 0)
-      {
-        GraphSubgraph* newsg = new GraphSubgraph(*dynamic_cast<GraphSubgraph*>(updatingge));
-        content().push_back(newsg);
-      }
-    }
-  }
-
-  if (canvasSubgraph())
-  {
-    canvasSubgraph()->modelChanged();
-    canvasSubgraph()->computeBoundingRect();
-  }
-//   kDebug() << "done";
-}
-
-void GraphSubgraph::updateWithSubgraph(graph_t* subgraph)
-{
-  kDebug() << subgraph->name;
-  m_attributes["id"] = subgraph->name;
-  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);
-  }
-
-
-  for (edge_t* e = agfstout(subgraph->meta_node->graph, subgraph->meta_node); e;
-      e = agnxtout(subgraph->meta_node->graph, e))
-  {
-    graph_t* sg = agusergraph(e->head);
-    kDebug() << "subsubgraph:" << sg->name;
-    if ( subgraphs().contains(sg->name))
-    {
-      kDebug() << "known subsubgraph";
-      // ???
-      //       nodes()[ngn->name]->setZ(ngn->z());
-      subgraphs()[sg->name]->updateWithSubgraph(sg);
-      if (subgraphs()[sg->name]->canvasElement()!=0)
-      {
-        //         nodes()[ngn->id()]->canvasElement()->setGh(m_height);
-      }
-    }
-    else
-    {
-      kDebug() << "new subsubgraph";
-      GraphSubgraph* newsg = new GraphSubgraph(sg);
-      //       kDebug() << "new created";
-      subgraphs().insert(sg->name, newsg);
-      //       kDebug() << "new inserted";
-    }
-    
-  }
-}
-
-
-QString GraphSubgraph::backColor() const
-{
-  if (m_attributes.find("bgcolor") != m_attributes.end())
-  {
-    return m_attributes["bgcolor"];
-  }
-  else if ( (m_attributes.find("style") != m_attributes.end())
-    && (m_attributes["style"] == "filled")
-    && (m_attributes.find("color") != m_attributes.end()) )
-  {
-    return m_attributes["color"];
-  }
-  else if ((m_attributes.find("style") != m_attributes.end())
-    && (m_attributes["style"] == "filled")
-    && (m_attributes.find("fillcolor") != m_attributes.end()))
-  {
-    return m_attributes["fillcolor"];
-  }
-  else
-  {
-    return DOT_DEFAULT_BACKCOLOR;
-  }
-}
-
-void GraphSubgraph::removeElement(GraphElement* element)
-{
-  m_content.removeAll(element);
-}
-
-GraphElement* GraphSubgraph::elementNamed(const QString& id)
-{
-  if (this->id() == id) return this;
-  foreach (GraphElement* element, content())
-  {
-    if (element->id() == id)
-    {
-      return element;
-    }
-    else if (dynamic_cast<GraphSubgraph*>(element))
-    {
-      GraphElement* subgraphElement = dynamic_cast<GraphSubgraph*>(element)->elementNamed(id);
-      if (subgraphElement != 0)
-      {
-        return subgraphElement;
-      }
-    }
-  }
-  return 0;
-}
-
-bool GraphSubgraph::setElementSelected(
-    GraphElement* element,
-    bool selectValue,
-    bool unselectOthers)
-{
-  if (element)
-    kDebug() << element->id() << selectValue << unselectOthers;
-  bool res = false;
-  if (element == this)
-  {
-    if (isSelected() != selectValue)
-    {
-      setSelected(selectValue);
-      canvasElement()->update();
-    }
-    res = true;
-  }
-  else if (isSelected() && unselectOthers)
-  {
-    setSelected(false);
-    canvasElement()->update();
-  }
-  foreach (GraphElement* el, content())
-  {
-    if (dynamic_cast<GraphSubgraph*>(el) != 0)
-    {
-      bool subres = dynamic_cast<GraphSubgraph*>(el)->setElementSelected(element, selectValue, unselectOthers);
-      if (!res) res = subres;
-    }
-    else if (element == el)
-    {
-      res = true;
-      if (el->isSelected() != selectValue)
-      {
-        el->setSelected(selectValue);
-        el->canvasElement()->update();
-      }
-    }
-    else 
-    {
-      if (unselectOthers && el->isSelected())
-      {
-        el->setSelected(false);
-        el->canvasElement()->update();
-      }
-    }
-  }
-  return res;
-}
-
-void GraphSubgraph::retrieveSelectedElementsIds(QList<QString> selection)
-{
-  if (isSelected())
-  {
-    selection.push_back(id());
-  }
-  foreach (GraphElement* el, content())
-  {
-    if (dynamic_cast<GraphSubgraph*>(el) != 0)
-    {
-      dynamic_cast<GraphSubgraph*>(el)->retrieveSelectedElementsIds(selection);
-    }
-    else  if (el->isSelected())
-    {
-      selection.push_back(el->id());
-    }
-  }
-}
-
-QTextStream& operator<<(QTextStream& s, const GraphSubgraph& sg)
-{
-  s << "subgraph " << sg.id() << "  {"
-    << dynamic_cast<const GraphElement&>(sg);
-  foreach (const GraphElement* el, sg.content())
-  {
-    s << *(dynamic_cast<const GraphNode*>(el));
-  }
-  s <<"}"<<endl;
-  return s;
-}
-
-}
-
-#include "graphsubgraph.moc"
diff --git a/src/part/graphsubgraph.h b/src/part/graphsubgraph.h
deleted file mode 100644
index 4b3477d..0000000
--- a/src/part/graphsubgraph.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/*
- * Subgraph model
- */
-
-#ifndef GRAPH_SUBGRAPH_H
-#define GRAPH_SUBGRAPH_H
-
-#include <QMap>
-#include <QTextStream>
-
-#include "graphelement.h"
-
-class Agraph_t;
-
-namespace KGraphViewer
-{
-
-class CanvasSubgraph;
-class GraphSubgraph;
-
-typedef QMap<QString, GraphSubgraph*> GraphSubgraphMap;
-
-
-/**
- * Colors and styles are dot names
- */
-class GraphSubgraph : public GraphElement
-{
-  Q_OBJECT
-
-public:
-  GraphSubgraph();
-  explicit GraphSubgraph(Agraph_t* sg);
-  
-  virtual ~GraphSubgraph() {}  
-
-  inline const GraphSubgraphMap& subgraphs() const {return m_subgraphsMap;}
-  inline GraphSubgraphMap& subgraphs() {return m_subgraphsMap;}
-  
-  void updateWithSubgraph(const GraphSubgraph& subgraph);
-  void updateWithSubgraph(Agraph_t* subgraph);
-  
-  CanvasSubgraph* canvasSubgraph() { return (CanvasSubgraph*)canvasElement();  }
-  void setCanvasSubgraph(CanvasSubgraph* cs) { setCanvasElement((CanvasElement*)cs); }
-
-  virtual QString backColor() const;
-
-  inline const QList<GraphElement*>& content() const {return m_content;}
-  inline QList<GraphElement*>& content() {return m_content;}
-  inline void setContent(QList<GraphElement*>& c) {m_content=c;}
-
-  void removeElement(GraphElement* element);
-
-  /// Recursively walk through this subgraph and its subsubgraphs to find an element named id
-  /// @return the node found or 0 if there is no such node
-  GraphElement* elementNamed(const QString& id);
-
-
-  /// Recursively walk through this subgraph and its subsubgraphs to make
-  /// the given element selected or not depending on the selectValue parameter
-  /// and unselect other elements depending on the  unselect others parameter
-  /// @return true if the given node was found
-  virtual bool setElementSelected(
-      GraphElement* element,
-      bool selectValue,
-      bool unselectOthers);
-
-  void retrieveSelectedElementsIds(QList<QString> selection);
-  
- private:
-  QList<GraphElement*> m_content;
-  GraphSubgraphMap m_subgraphsMap;
-};
-
-QTextStream& operator<<(QTextStream& stream, const GraphSubgraph& s);
-
-}
-
-#endif
-
-
-
diff --git a/src/part/kgraphviewer_export.h b/src/part/kgraphviewer_export.h
deleted file mode 100644
index b171ec4..0000000
--- a/src/part/kgraphviewer_export.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*  This file is part of the KGraphViewer
-    Copyright (C) 2010 Gael de Chalendar <kleag at free.fr>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#ifndef KGRAPHVIEWER_EXPORT_H
-#define KGRAPHVIEWER_EXPORT_H
-
-/* needed for KDE_EXPORT and KDE_IMPORT macros */
-#include <kdemacros.h>
-
-#ifndef KGRAPHVIEWER_EXPORT
-# if defined(MAKE_KGRAPHVIEWER_LIB)
-   /* We are building this library */
-#  define KGRAPHVIEWER_EXPORT KDE_EXPORT
-# else
-   /* We are using this library */
-#  define KGRAPHVIEWER_EXPORT KDE_IMPORT
-# endif
-#endif
-
-# ifndef KGRAPHVIEWER_EXPORT_DEPRECATED
-#  define KGRAPHVIEWER_EXPORT_DEPRECATED KDE_DEPRECATED KGRAPHVIEWER_EXPORT
-# endif
-
-#endif
diff --git a/src/part/kgraphviewer_interface.h b/src/part/kgraphviewer_interface.h
deleted file mode 100644
index d3cd5c8..0000000
--- a/src/part/kgraphviewer_interface.h
+++ /dev/null
@@ -1,139 +0,0 @@
-// interface.h
-// Copyright (C)  2002  Dominique Devriese <devriese at kde.org>
-
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-// 02110-1301  USA
-
-#ifndef KGRAPHVIEWER_INTERFACE_H
-#define KGRAPHVIEWER_INTERFACE_H
-
-#include <QtCore/QObject>
-#include <QtCore/QMap>
-#include <QtGui/QCursor>
-
-namespace KParts
-{
-  class Part;
-}
-
-class QStringList;
-
-namespace KGraphViewer
-{
-class DotGraph;
-/**
- * KGraphViewerInterface is an interface implemented by KGraphViewer to
- * allow developers access to the KGraphViewerPart in ways that are not
- * possible through the normal KPart interface.
- *
- * Note that besides the functions below here, KGraphViewer also has
- * some signals you can connect to.  They aren't in this class cause
- * we can't have signals without having a QObject, which
- * KGraphViewerInterface is not. To see a list of signals, take a look at kgraphviewer_part.h
- * 
- * See the example code below for how to connect to these..
- *
- * Use it like this:
- * \code
- *  // fetch the Part..
- *  KLibFactory *factory = KLibLoader::self()->factory("kgraphviewerpart");
- *  if (factory) {
- *      part = factory->create<KParts::ReadOnlyPart>(this);
- *
- *      // cast the part to the KGraphViewerInterface...
- *      KGraphViewerInterface* graph = qobject_cast<KGraphViewerInterface*>( part );
- *      if( ! graph )
- *      {
- *        // This should not happen
- *        return;
- *      }
- *      // now use the interface in all sorts of ways...
- *  }
- * \endcode
- *
- * @author Milian Wolff <mail at milianw.de>
- * 
- * 
- * WARNING: This is highly experimental and no kind of BC guarantees are given!
- * TODO: documentation
- */
-class KGraphViewerInterface
-{
-public:
-  enum LayoutMethod
-  {
-    ExternalProgram,
-    InternalLibrary
-  };
-
-  virtual void setLayoutMethod(LayoutMethod method) = 0;
-  virtual void zoomIn() = 0;
-  virtual void zoomOut() = 0;
-  virtual void zoomBy(double factor) = 0;
-  virtual void setZoomFactor(double factor) = 0;
-
-  enum PannerPosition { TopLeft, TopRight, BottomLeft, BottomRight, Auto };
-  virtual void setPannerPosition(PannerPosition position) = 0;
-  virtual void setPannerEnabled(bool enabled) = 0;
-
-  virtual void setLayoutCommand(const QString& command) = 0;
-
-  virtual void selectNode(const QString& nodeId) = 0;
-  virtual void centerOnNode(const QString& nodeId) = 0;
-
-  // Slots
-  virtual void slotHide(KParts::Part* part) = 0;
-  virtual void slotUpdate() = 0;
-  virtual void prepareAddNewElement(QMap<QString,QString> attribs) = 0;
-  virtual void prepareAddNewEdge(QMap<QString,QString> attribs) = 0;
-  virtual void setReadOnly() = 0;
-  virtual void setReadWrite() = 0;
-  virtual void saveTo(const QString& fileName) = 0;
-  virtual void slotRemoveNode(const QString&) = 0;
-  virtual void slotRemoveNodeFromSubgraph(const QString& nodeName, const QString& subgraphName) = 0;
-  virtual void slotRemoveSubgraph(const QString&) = 0;
-  virtual void slotAddAttribute(const QString&) = 0;
-  virtual void slotSetAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue) = 0;
-  virtual void slotRemoveAttribute(const QString&,const QString&) = 0;
-  virtual void slotSetGraphAttributes(QMap<QString,QString> attribs) = 0;
-  virtual void slotAddNewNode(QMap<QString,QString> attribs) = 0;
-  virtual void slotAddNewNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph) = 0;
-  virtual void slotAddExistingNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph) = 0;
-  virtual void slotMoveExistingNodeToMainGraph(QMap<QString,QString>) = 0;
-  virtual void slotAddNewSubgraph(QMap<QString,QString> attribs) = 0;
-  virtual void slotAddNewEdge(QString src, QString tgt, QMap<QString,QString> attribs) = 0;
-  virtual void slotRemoveEdge(const QString& id) = 0;
-  virtual void slotRemoveElement(const QString& id) = 0;
-  virtual void slotClose() = 0;
-  virtual void slotSelectNode(const QString&) = 0;
-  virtual void slotSetHighlighting(bool highlightingValue) = 0;
-  virtual void slotPrepareToSelect() = 0;
-  virtual void slotSetCursor(const QCursor& cursor) = 0;
-  virtual void slotUnsetCursor() = 0;
-  virtual void slotSetLayoutMethod(LayoutMethod method) = 0;
-  virtual void slotRenameNode(const QString& oldName, const QString& newName) = 0;
-  virtual void setBackgroundColor(const QColor& color) = 0;
-  
-
-protected:
-  KGraphViewerInterface() {}
-  virtual ~KGraphViewerInterface() {}
-};
-
-}
-
-Q_DECLARE_INTERFACE(KGraphViewer::KGraphViewerInterface, "org.kde.KGraphViewerInterface")
-
-#endif // KGRAPHVIEWER_INTERFACE_H
diff --git a/src/part/kgraphviewer_part.cpp b/src/part/kgraphviewer_part.cpp
index 7829b29..7c12f38 100644
--- a/src/part/kgraphviewer_part.cpp
+++ b/src/part/kgraphviewer_part.cpp
@@ -18,8 +18,9 @@
 
 
 #include "kgraphviewer_part.h"
-#include "dotgraphview.h"
-#include "dotgraph.h"
+
+#include <kgraphviz/dotgraphview.h>
+#include <kgraphviz/dotgraph.h>
 
 #include <KDirWatch>
 #include <kcomponentdata.h>
@@ -37,9 +38,6 @@
 
 #include <iostream>
 
-#include <graphviz/gvc.h>
-
-
 // #include "kgraphviewersettings.h"
 #include "kgraphviewer_partsettings.h"
 
diff --git a/src/part/kgraphviewer_part.h b/src/part/kgraphviewer_part.h
index 28f6f9c..c537248 100644
--- a/src/part/kgraphviewer_part.h
+++ b/src/part/kgraphviewer_part.h
@@ -19,11 +19,12 @@
 #ifndef _KGRAPHVIEWERPART_H_
 #define _KGRAPHVIEWERPART_H_
 
+#include "shared/kgraphviewer_interface.h"
+
 #include <kparts/part.h>
 #include <kparts/genericfactory.h>
 
 #include <graphviz/gvc.h>
-#include "kgraphviewer_interface.h"
 
 class KComponentData;
 class KAboutData;
diff --git a/src/part/layoutagraphthread.cpp b/src/part/layoutagraphthread.cpp
deleted file mode 100644
index a222800..0000000
--- a/src/part/layoutagraphthread.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-    This file is part of KGraphViewer.
-    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
-
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of
-    the License, or (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "layoutagraphthread.h"
-
-#include <kdebug.h>
-
-void LayoutAGraphThread::run()
-{
-  kDebug();
-  m_gvc = gvContext();
-  gvLayout(m_gvc, m_g, m_layoutCommand.toUtf8().data());
-  gvRender (m_gvc, m_g, "xdot", NULL);
-}
-
-void LayoutAGraphThread::layoutGraph(graph_t* graph, const QString& layoutCommand)
-{
-  kDebug();
-  if (isRunning())
-    return;
-  m_g = graph;
-  m_layoutCommand = layoutCommand;
-  start();
-}
-
diff --git a/src/part/layoutagraphthread.h b/src/part/layoutagraphthread.h
deleted file mode 100644
index 1c3955d..0000000
--- a/src/part/layoutagraphthread.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-    This file is part of KGraphViewer.
-    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
-
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of
-    the License, or (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef LAYOUTAGRAPHTHREAD_H
-#define LAYOUTAGRAPHTHREAD_H
-
-#include <QThread>
-
-#include <graphviz/gvc.h>
-
-class LayoutAGraphThread : public QThread
-{
-public:
-  void layoutGraph(graph_t* graph, const QString& layoutCommand);
-  inline graph_t* g() {return m_g;}
-  inline GVC_t* gvc() {return m_gvc;}
-  inline const QString& layoutCommand() const {return m_layoutCommand;}
-  
-protected:
-virtual void run();
-
-private:
-  QString m_layoutCommand;
-  graph_t* m_g;
-  GVC_t *m_gvc;
-};
-
-#endif // LAYOUTAGRAPHTHREAD_H
diff --git a/src/part/loadagraphthread.cpp b/src/part/loadagraphthread.cpp
deleted file mode 100644
index 1d56bdc..0000000
--- a/src/part/loadagraphthread.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-    This file is part of KGraphViewer.
-    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
-
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of
-    the License, or (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#include "loadagraphthread.h"
-
-#include <kdebug.h>
-
-void LoadAGraphThread::run()
-{
-  kDebug() << m_dotFileName;
-  GVC_t *gvc;
-  FILE* fp;
-  gvc = gvContext();
-  fp = fopen(m_dotFileName.toUtf8().data(), "r");
-  m_g = agread(fp);
-}
-
-void LoadAGraphThread::loadFile(const QString& dotFileName)
-{
-  kDebug();
-  if (isRunning())
-    return;
-  m_dotFileName = dotFileName;
-  start();
-}
diff --git a/src/part/loadagraphthread.h b/src/part/loadagraphthread.h
deleted file mode 100644
index 08eb78a..0000000
--- a/src/part/loadagraphthread.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-    This file is part of KGraphViewer.
-    Copyright (C) 2010  Gael de Chalendar <kleag at free.fr>
-
-    This program is free software; you can redistribute it and/or
-    modify it under the terms of the GNU General Public License as
-    published by the Free Software Foundation; either version 2 of
-    the License, or (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-#ifndef LOADAGRAPHTHREAD_H
-#define LOADAGRAPHTHREAD_H
-
-#include <QThread>
-
-#include <graphviz/gvc.h>
-
-class LoadAGraphThread : public QThread
-{
-public:
-  void loadFile(const QString& dotFileName);
-  inline graph_t* g() {return m_g;}
-  inline const QString& dotFileName() {return m_dotFileName;}
-  inline GVC_t* gvc() {return m_gvc;}
-  
-protected:
-  virtual void run();
-
-private:
-  QString m_dotFileName;
-  graph_t *m_g;
-  GVC_t *m_gvc;
-};
-
-#endif // LOADAGRAPHTHREAD_H
diff --git a/src/part/pannerview.cpp b/src/part/pannerview.cpp
deleted file mode 100644
index de7b1a2..0000000
--- a/src/part/pannerview.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.cpp, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Callgraph View
- */
-
-#include "pannerview.h"
-
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-
-#include <QGraphicsScene>
-#include <QPainter>
-#include <QMouseEvent>
-
-#include <kdebug.h>
-#include <klocale.h>
-
-#include "dotgraphview.h"
-
-namespace KGraphViewer
-{
-//
-// PannerView
-//
-PannerView::PannerView(DotGraphView * parent, const char * name)
-  : QGraphicsView(parent), m_drawContents(true), m_parent(parent)
-{
-  m_movingZoomRect = false;
-
-  // why doesn't this avoid flicker ?
-  // viewport()->setBackgroundMode(Qt::NoBackground);
-  setBackgroundMode(Qt::NoBackground);
-
-  // if there are ever graphic glitches to be found, remove this again
-  setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing | QGraphicsView::DontClipPainter |
-                        QGraphicsView::DontSavePainterState);
-
-  setToolTip(i18n("View of the complete graph. Click and drag to move the visible part."));
-  setWhatsThis(i18n("<h1>View of the Complete Graph</h1>"
-    "<p>Single clicking somewhere without the red square will move the center of the "
-    "view to where the mouse was clicked.</p><p>Clicking and dragging within the red square "
-    "will cause the view to follow the movement.</p>"));
-}
-
-void PannerView::setZoomRect(QRectF r)
-{
-//   kDebug() << "PannerView::setZoomRect " << r;
-  if (r == m_zoomRect) {
-    return;
-  }
-  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
-  // get new zoom rect
-  m_zoomRect = r;
-  qreal q = mapToScene(15,0).x();
-  qreal d = mapToScene(10,0).x();
-  if (!m_zoomRect.isValid() || m_zoomRect.width() < q || m_zoomRect.height() < q) 
-  {
-    double factor = ((double)m_zoomRect.width())/m_zoomRect.height();
-    qreal newWidth, newHeight;
-    if (factor > 1.0)
-    {
-      newWidth = q;
-      newHeight = newWidth/factor;
-      if (newHeight < d) newHeight = d;
-    }
-    else
-    {
-      newHeight = q;
-      newWidth = newHeight*factor;
-      if (newWidth < d) newWidth = d;
-    }
-    QRectF newRect = m_zoomRect;
-    qreal newXPos = newRect.x() + (newRect.width()/2) - newWidth/2;
-    newXPos = (newXPos<0)?0:newXPos;
-    newRect.setX(newXPos);
-    qreal newYPos = newRect.y() + (newRect.height()/2) -newHeight/2;
-    newYPos = (newYPos<0)?0:newYPos;
-    newRect.setY(newYPos);
-    newRect.setWidth(newWidth);
-    newRect.setHeight(newHeight);
-    m_zoomRect = newRect;
-  }
-  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
-}
-
-void PannerView::moveZoomRectTo(const QPointF& newPos, bool notify)
-{
-  if (!m_zoomRect.isValid()) {
-    return;
-  }
-
-  if (m_zoomRect.center() == newPos) {
-    kDebug() << "same pos, don't do anything";
-    return;
-  }
-
-  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
-  m_zoomRect.moveCenter(newPos);
-  scene()->invalidate(m_zoomRect, QGraphicsScene::ForegroundLayer);
-
-  if (m_zoomRect.isValid() && notify) {
-    emit zoomRectMovedTo(newPos);
-    m_lastPos = newPos;
-  }
-}
-
-void PannerView::drawForeground(QPainter * p, const QRectF & rect )
-{
-  if (m_zoomRect.isValid() && rect.intersects(m_zoomRect))
-  {
-    p->save();
-    if (m_zoomRect.width() > 10 && m_zoomRect.height() > 10)
-    {
-      p->setPen(Qt::red);
-      // substract pen width, i.e. draw inside
-      qreal penWidth = p->pen().widthF();
-      p->drawRect(m_zoomRect.adjusted(-penWidth, -penWidth, -penWidth, -penWidth));
-    }
-    else
-    {
-      QBrush brush(Qt::red);
-      p->fillRect(m_zoomRect, brush);
-    }
-    p->restore();
-  }
-}
-
-void PannerView::mousePressEvent(QMouseEvent* e)
-{
-  if (e->button() != Qt::LeftButton) {
-    return;
-  }
-/*  kDebug() << "PannerView::mousePressEvent " 
-              << mapToScene(e->pos()) << " / " << m_zoomRect << " / " << m_zoomRect.center() <<endl;*/
-  moveZoomRectTo(mapToScene(e->pos()));
-  m_movingZoomRect = true;
-}
-
-void PannerView::mouseMoveEvent(QMouseEvent* e)
-{
-  if (!m_movingZoomRect) {
-    return;
-  }
-
-//   kDebug() << "PannerView::mouseMoveEvent " << pos;
-  moveZoomRectTo(mapToScene(e->pos()));
-}
-
-void PannerView::mouseReleaseEvent(QMouseEvent* e)
-{
-  if (e->button() != Qt::LeftButton) {
-    return;
-  }
-  moveZoomRectTo(mapToScene(e->pos()));
-//   kDebug() << "PannerView::mouseReleaseEvent " << pos;
-  m_movingZoomRect = false;
-  emit zoomRectMoveFinished();
-}
-
-void PannerView::contextMenuEvent(QContextMenuEvent* event)
-{
-  m_parent->contextMenuEvent(event);
-}
-
-}
-
-#include "pannerview.moc"
diff --git a/src/part/pannerview.h b/src/part/pannerview.h
deleted file mode 100644
index c55a703..0000000
--- a/src/part/pannerview.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* This file is part of KGraphViewer.
-   Copyright (C) 2005-2007 Gael de Chalendar <kleag at free.fr>
-
-   KGraphViewer is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA
-*/
-
-/* This file was callgraphview.h, part of KCachegrind.
-   Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer at gmx.de>
-
-   KCachegrind is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public
-   License as published by the Free Software Foundation, version 2.
-*/
-
-
-/*
- * Callgraph View
- */
-
-#ifndef PANNER_VIEW_H
-#define PANNER_VIEW_H
-
-#include <QGraphicsView>
-#include <QWidget>
-//Added by qt3to4:
-#include <QMouseEvent>
-
-namespace KGraphViewer
-{
-
-class DotGraphView;
-
-/**
- * A panner layed over a QCanvas
- */
-class PannerView: public QGraphicsView
-{
-  Q_OBJECT
-
-public:
-  explicit PannerView(DotGraphView * parent, const char * name = 0);
-
-  inline void setDrawingEnabled(bool val) {m_drawContents = val;}
-
-public slots:
-  void setZoomRect(QRectF r);
-  void moveZoomRectTo(const QPointF& newPos, const bool notify = true);
-
-signals:
-  void zoomRectMovedTo(QPointF newPos);
-  void zoomRectMoveFinished();
-
-protected:
-  virtual void mousePressEvent(QMouseEvent*);
-  virtual void mouseMoveEvent(QMouseEvent*);
-  virtual void mouseReleaseEvent(QMouseEvent*);
-  virtual void drawForeground(QPainter * p, const QRectF & rect );
-  virtual void contextMenuEvent(QContextMenuEvent* event);
-
-  QRectF m_zoomRect;
-  bool m_movingZoomRect;
-  QPointF m_lastPos;
-  bool m_drawContents;
-  DotGraphView* m_parent;
-};
-
-}
-
-#endif
-
-
-
diff --git a/src/part/simpleprintingcommand.h b/src/part/simpleprintingcommand.h
index 95b06ef..a764f5e 100644
--- a/src/part/simpleprintingcommand.h
+++ b/src/part/simpleprintingcommand.h
@@ -29,7 +29,9 @@
 #define KGVSIMPLEPRINTINGCOMMAND_H
 
 #include "simpleprintingengine.h"
-#include <dotgraphview.h>
+
+#include <kgraphviz/dotgraphview.h>
+
 #include <kgraphviewer_part.h>
 
 namespace KGraphViewer
diff --git a/src/part/simpleprintingengine.h b/src/part/simpleprintingengine.h
index 3953823..44d3f6a 100644
--- a/src/part/simpleprintingengine.h
+++ b/src/part/simpleprintingengine.h
@@ -37,7 +37,7 @@
 
 class QPaintDevice;
 
-#include "dotgraphview.h"
+#include <kgraphviz/dotgraphview.h>
 
 namespace KGraphViewer
 {
diff --git a/src/part/simpleprintingpagesetup.cpp b/src/part/simpleprintingpagesetup.cpp
index 128515d..cb27453 100644
--- a/src/part/simpleprintingpagesetup.cpp
+++ b/src/part/simpleprintingpagesetup.cpp
@@ -30,7 +30,8 @@
 #include "simpleprintingsettings.h"
 #include "simpleprintingcommand.h"
 #include "simpleprintpreviewwindow.h"
-#include "dotgraphview.h"
+
+#include <kgraphviz/dotgraphview.h>
 
 #include <kapplication.h>
 #include <kstandarddirs.h>
diff --git a/src/shared/kgraphviewer_export.h b/src/shared/kgraphviewer_export.h
new file mode 100644
index 0000000..b171ec4
--- /dev/null
+++ b/src/shared/kgraphviewer_export.h
@@ -0,0 +1,40 @@
+/*  This file is part of the KGraphViewer
+    Copyright (C) 2010 Gael de Chalendar <kleag at free.fr>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KGRAPHVIEWER_EXPORT_H
+#define KGRAPHVIEWER_EXPORT_H
+
+/* needed for KDE_EXPORT and KDE_IMPORT macros */
+#include <kdemacros.h>
+
+#ifndef KGRAPHVIEWER_EXPORT
+# if defined(MAKE_KGRAPHVIEWER_LIB)
+   /* We are building this library */
+#  define KGRAPHVIEWER_EXPORT KDE_EXPORT
+# else
+   /* We are using this library */
+#  define KGRAPHVIEWER_EXPORT KDE_IMPORT
+# endif
+#endif
+
+# ifndef KGRAPHVIEWER_EXPORT_DEPRECATED
+#  define KGRAPHVIEWER_EXPORT_DEPRECATED KDE_DEPRECATED KGRAPHVIEWER_EXPORT
+# endif
+
+#endif
diff --git a/src/shared/kgraphviewer_interface.h b/src/shared/kgraphviewer_interface.h
new file mode 100644
index 0000000..d3cd5c8
--- /dev/null
+++ b/src/shared/kgraphviewer_interface.h
@@ -0,0 +1,139 @@
+// interface.h
+// Copyright (C)  2002  Dominique Devriese <devriese at kde.org>
+
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+// 02110-1301  USA
+
+#ifndef KGRAPHVIEWER_INTERFACE_H
+#define KGRAPHVIEWER_INTERFACE_H
+
+#include <QtCore/QObject>
+#include <QtCore/QMap>
+#include <QtGui/QCursor>
+
+namespace KParts
+{
+  class Part;
+}
+
+class QStringList;
+
+namespace KGraphViewer
+{
+class DotGraph;
+/**
+ * KGraphViewerInterface is an interface implemented by KGraphViewer to
+ * allow developers access to the KGraphViewerPart in ways that are not
+ * possible through the normal KPart interface.
+ *
+ * Note that besides the functions below here, KGraphViewer also has
+ * some signals you can connect to.  They aren't in this class cause
+ * we can't have signals without having a QObject, which
+ * KGraphViewerInterface is not. To see a list of signals, take a look at kgraphviewer_part.h
+ * 
+ * See the example code below for how to connect to these..
+ *
+ * Use it like this:
+ * \code
+ *  // fetch the Part..
+ *  KLibFactory *factory = KLibLoader::self()->factory("kgraphviewerpart");
+ *  if (factory) {
+ *      part = factory->create<KParts::ReadOnlyPart>(this);
+ *
+ *      // cast the part to the KGraphViewerInterface...
+ *      KGraphViewerInterface* graph = qobject_cast<KGraphViewerInterface*>( part );
+ *      if( ! graph )
+ *      {
+ *        // This should not happen
+ *        return;
+ *      }
+ *      // now use the interface in all sorts of ways...
+ *  }
+ * \endcode
+ *
+ * @author Milian Wolff <mail at milianw.de>
+ * 
+ * 
+ * WARNING: This is highly experimental and no kind of BC guarantees are given!
+ * TODO: documentation
+ */
+class KGraphViewerInterface
+{
+public:
+  enum LayoutMethod
+  {
+    ExternalProgram,
+    InternalLibrary
+  };
+
+  virtual void setLayoutMethod(LayoutMethod method) = 0;
+  virtual void zoomIn() = 0;
+  virtual void zoomOut() = 0;
+  virtual void zoomBy(double factor) = 0;
+  virtual void setZoomFactor(double factor) = 0;
+
+  enum PannerPosition { TopLeft, TopRight, BottomLeft, BottomRight, Auto };
+  virtual void setPannerPosition(PannerPosition position) = 0;
+  virtual void setPannerEnabled(bool enabled) = 0;
+
+  virtual void setLayoutCommand(const QString& command) = 0;
+
+  virtual void selectNode(const QString& nodeId) = 0;
+  virtual void centerOnNode(const QString& nodeId) = 0;
+
+  // Slots
+  virtual void slotHide(KParts::Part* part) = 0;
+  virtual void slotUpdate() = 0;
+  virtual void prepareAddNewElement(QMap<QString,QString> attribs) = 0;
+  virtual void prepareAddNewEdge(QMap<QString,QString> attribs) = 0;
+  virtual void setReadOnly() = 0;
+  virtual void setReadWrite() = 0;
+  virtual void saveTo(const QString& fileName) = 0;
+  virtual void slotRemoveNode(const QString&) = 0;
+  virtual void slotRemoveNodeFromSubgraph(const QString& nodeName, const QString& subgraphName) = 0;
+  virtual void slotRemoveSubgraph(const QString&) = 0;
+  virtual void slotAddAttribute(const QString&) = 0;
+  virtual void slotSetAttribute(const QString& elementId, const QString& attributeName, const QString& attributeValue) = 0;
+  virtual void slotRemoveAttribute(const QString&,const QString&) = 0;
+  virtual void slotSetGraphAttributes(QMap<QString,QString> attribs) = 0;
+  virtual void slotAddNewNode(QMap<QString,QString> attribs) = 0;
+  virtual void slotAddNewNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph) = 0;
+  virtual void slotAddExistingNodeToSubgraph(QMap<QString,QString> attribs, QString subgraph) = 0;
+  virtual void slotMoveExistingNodeToMainGraph(QMap<QString,QString>) = 0;
+  virtual void slotAddNewSubgraph(QMap<QString,QString> attribs) = 0;
+  virtual void slotAddNewEdge(QString src, QString tgt, QMap<QString,QString> attribs) = 0;
+  virtual void slotRemoveEdge(const QString& id) = 0;
+  virtual void slotRemoveElement(const QString& id) = 0;
+  virtual void slotClose() = 0;
+  virtual void slotSelectNode(const QString&) = 0;
+  virtual void slotSetHighlighting(bool highlightingValue) = 0;
+  virtual void slotPrepareToSelect() = 0;
+  virtual void slotSetCursor(const QCursor& cursor) = 0;
+  virtual void slotUnsetCursor() = 0;
+  virtual void slotSetLayoutMethod(LayoutMethod method) = 0;
+  virtual void slotRenameNode(const QString& oldName, const QString& newName) = 0;
+  virtual void setBackgroundColor(const QColor& color) = 0;
+  
+
+protected:
+  KGraphViewerInterface() {}
+  virtual ~KGraphViewerInterface() {}
+};
+
+}
+
+Q_DECLARE_INTERFACE(KGraphViewer::KGraphViewerInterface, "org.kde.KGraphViewerInterface")
+
+#endif // KGRAPHVIEWER_INTERFACE_H


More information about the kgraphviewer-devel mailing list