[kgraphviewer-devel] [KGraphViewer/libkgraphviz] 70202af: Move DotGraphViewPrivate decl to own file

Kevin Funk krf at electrostorm.net
Tue Dec 14 18:13:29 CET 2010


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

commit 70202af9ea457660a10e883dd44ea737dee057b3
Author: Kevin Funk <krf at electrostorm.net>
Date:   Tue Dec 14 16:04:43 2010 +0100

    Move DotGraphViewPrivate decl to own file

diff --git a/src/kgraphviz/dotgraphview.cpp b/src/kgraphviz/dotgraphview.cpp
index 2124376..7d50f03 100644
--- a/src/kgraphviz/dotgraphview.cpp
+++ b/src/kgraphviz/dotgraphview.cpp
@@ -24,12 +24,8 @@
    License as published by the Free Software Foundation, version 2.
 */
 
-
-/*
- * Callgraph View
- */
-
 #include "dotgraphview.h"
+#include "dotgraphview_p.h"
 
 #include "dotgraph.h"
 #include "graphelement.h"
@@ -43,11 +39,8 @@
 // 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>
@@ -87,135 +80,56 @@
 #define DEFAULT_ZOOMPOS      KGraphViewerInterface::Auto
 #define KGV_MAX_PANNER_NODES 100
 
-namespace KGraphViz
-{
-
-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 setupCanvas();
-  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;
+using namespace KGraphViz;
+using namespace KGraphViewer;
+
+DotGraphViewPrivate::DotGraphViewPrivate(KActionCollection* actions, DotGraphView* parent) :
+  m_labelViews(),
+  m_popup(0),
+  m_zoom(1),
+  m_isMoving(false),
+  m_exporter(),
+  m_zoomPosition(DEFAULT_ZOOMPOS),
+  m_lastAutoPosition(KGraphViewer::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 )
+{
+}
+
+DotGraphViewPrivate::~DotGraphViewPrivate()
+{
+  Q_Q(DotGraphView);
 
-  /// A thread to load graphviz agraph files
-  LoadAGraphThread m_loadThread;
+  delete m_birdEyeView;
+  m_birdEyeView = 0;
 
-  /// A thread to layout graphviz agraph files
-  LayoutAGraphThread m_layoutThread;
+  if (m_popup != 0) {
+    delete m_popup;
+  }
 
-  /// The graph background color
-  QColor m_backgroundColor;
+  if (m_canvas) {
+    q->setScene(0);
+    delete m_canvas;
+  }
+  if (m_graph != 0) {
+    delete m_graph;
+  }
+}
 
-  DotGraphView * const q_ptr;
-  Q_DECLARE_PUBLIC(DotGraphView);
-};
-  
 void DotGraphViewPrivate::updateSizes(QSizeF s)
 {
   kDebug();
@@ -2052,8 +1966,4 @@ void DotGraphView::centerOnNode(const QString& nodeId)
   }
 }
 
-
-}
-
 #include "dotgraphview.moc"
-
diff --git a/src/kgraphviz/dotgraphview.h b/src/kgraphviz/dotgraphview.h
index c09367d..56ce3c9 100644
--- a/src/kgraphviz/dotgraphview.h
+++ b/src/kgraphviz/dotgraphview.h
@@ -24,11 +24,6 @@
    License as published by the Free Software Foundation, version 2.
 */
 
-
-/*
- * Callgraph View
- */
-
 #ifndef DOTGRAPHVIEW_H
 #define DOTGRAPHVIEW_H
 
@@ -49,15 +44,6 @@ class KSelectAction;
 class KToggleAction;
 
 class QMenu;
-class QKeyEvent;
-class QMouseEvent;
-class QFocusEvent;
-class QResizeEvent;
-class QWheelEvent;
-class QContextMenuEvent;
-class QWidget;
-
-using namespace KGraphViewer;
 
 namespace KGraphViz
 {
@@ -73,12 +59,13 @@ 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 KGRAPHVIZ_EXPORT DotGraphView: public QGraphicsView
+class KGRAPHVIZ_EXPORT DotGraphView : public QGraphicsView
 {
  Q_OBJECT
 
@@ -99,9 +86,9 @@ public:
   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);
+  KGraphViewer::KGraphViewerInterface::PannerPosition zoomPos() const;
+  static KGraphViewer::KGraphViewerInterface::PannerPosition zoomPos(const QString&);
+  static QString zoomPosString(KGraphViewer::KGraphViewerInterface::PannerPosition);
 
   void setPannerEnabled(bool enabled);
   
diff --git a/src/kgraphviz/dotgraphview_p.h b/src/kgraphviz/dotgraphview_p.h
new file mode 100644
index 0000000..94ea4d8
--- /dev/null
+++ b/src/kgraphviz/dotgraphview_p.h
@@ -0,0 +1,116 @@
+/*
+    Copyright (C) 2010 Kevin Funk <krf at electrostorm.net>
+
+    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 DOTGRAPHVIEW_P_H
+#define DOTGRAPHVIEW_P_H
+
+#include "dotgraphview.h"
+
+#include "graphexporter.h"
+#include "support/loadagraphthread.h"
+#include "support/layoutagraphthread.h"
+
+namespace KGraphViz
+{
+
+class DotGraphViewPrivate
+{
+
+public:
+  DotGraphViewPrivate(KActionCollection* actions, DotGraphView* parent);
+  virtual ~DotGraphViewPrivate();
+
+  void updateSizes(QSizeF s = QSizeF(0,0));
+  void updateBirdEyeView();
+  void setupCanvas();
+  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
+  KGraphViewer::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;
+
+private:
+  DotGraphView * const q_ptr;
+  Q_DECLARE_PUBLIC(DotGraphView);
+};
+
+}
+
+#endif
diff --git a/src/shared/kgraphviewer_interface.h b/src/shared/kgraphviewer_interface.h
index d3cd5c8..358b06b 100644
--- a/src/shared/kgraphviewer_interface.h
+++ b/src/shared/kgraphviewer_interface.h
@@ -32,7 +32,7 @@ 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


More information about the kgraphviewer-devel mailing list