[kgraphviewer-devel] [KGraphViewer/libkgraphviz] f3c2a59: Fix positioning of birds-eye-view again

Kevin Funk krf at electrostorm.net
Tue Jan 11 17:46:02 CET 2011


commit f3c2a59176c4cec62ba9c7a6a784077febddfeea
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date:   Tue Jan 11 17:42:07 2011 +0100

    Fix positioning of birds-eye-view again

diff --git a/src/kgraphviz/dotgraphview.cpp b/src/kgraphviz/dotgraphview.cpp
index f5916a6..a13f8c1 100644
--- a/src/kgraphviz/dotgraphview.cpp
+++ b/src/kgraphviz/dotgraphview.cpp
@@ -1257,16 +1257,19 @@ void DotGraphView::setPannerEnabled(bool enabled)
   emit(sigViewBevEnabledToggled(enabled));
 }
 
-void DotGraphView::viewBevActivated(int newZoomPos)
+void DotGraphView::setPannerPosition(DotGraphView::PannerPosition position)
 {
-  kDebug() << "Zoom position:" << newZoomPos;
-  
   Q_D(DotGraphView);
+  if (d->m_zoomPosition == position)
+    return;
+
+  kDebug() << toString(position);
+  d->m_zoomPosition = position;
   d->updateSizes();
-  emit(sigViewBevActivated(newZoomPos));
+  emit(sigViewBevActivated(position));
 }
 
-QString DotGraphView::zoomPosString(DotGraphView::PannerPosition position)
+QString DotGraphView::toString(DotGraphView::PannerPosition position)
 {
     if (position == TopRight)
       return QString("KGraphViewerInterface::TopRight");
@@ -1407,27 +1410,27 @@ void DotGraphView::slotBevToggled()
 
 void DotGraphView::slotBevTopLeft()
 {
-  viewBevActivated(TopLeft);
+  setPannerPosition(TopLeft);
 }
 
 void DotGraphView::slotBevTopRight()
 {
-  viewBevActivated(TopRight);
+  setPannerPosition(TopRight);
 }
 
 void DotGraphView::slotBevBottomLeft()
 {
-  viewBevActivated(BottomLeft);
+  setPannerPosition(BottomLeft);
 }
 
 void DotGraphView::slotBevBottomRight()
 {
-  viewBevActivated(BottomRight);
+  setPannerPosition(BottomRight);
 }
 
 void DotGraphView::slotBevAutomatic()
 {
-  viewBevActivated(Auto);
+  setPannerPosition(Auto);
 }
 
 void DotGraphView::slotUpdate()
diff --git a/src/kgraphviz/dotgraphview.h b/src/kgraphviz/dotgraphview.h
index 24bfb71..91a3c26 100644
--- a/src/kgraphviz/dotgraphview.h
+++ b/src/kgraphviz/dotgraphview.h
@@ -54,7 +54,9 @@ class DotGraphViewPrivate;
  */
 class KGRAPHVIZ_EXPORT DotGraphView : public QGraphicsView
 {
- Q_OBJECT
+  Q_OBJECT
+
+  Q_ENUMS(PannerPosition);
 
 public:
   enum EditingMode { None, AddNewElement, AddNewEdge, DrawNewEdge, SelectingElements };
@@ -67,7 +69,7 @@ public:
     //TODO: rename zoomPos -> bev / panner, but _please_ make it consistent...
   DotGraphView::PannerPosition zoomPos() const;
   static DotGraphView::PannerPosition zoomPos(const QString&);
-  static QString zoomPosString(DotGraphView::PannerPosition);
+  static QString toString(DotGraphView::PannerPosition);
 
   bool loadDot(const QString& dotFileName);
   bool loadLibrary(const QString& dotFileName);
@@ -128,7 +130,7 @@ public Q_SLOTS:
   void initEmpty();
   void print();
   void printPreview();
-  void viewBevActivated(int newPos);
+  void setPannerPosition(DotGraphView::PannerPosition pos);
   void setPannerEnabled(bool enabled);
   void slotExportImage();
   void slotSelectLayoutAlgo(const QString& text);
diff --git a/src/part/kgraphviewer_part.cpp b/src/part/kgraphviewer_part.cpp
index 190e016..f6849d8 100644
--- a/src/part/kgraphviewer_part.cpp
+++ b/src/part/kgraphviewer_part.cpp
@@ -384,7 +384,7 @@ void KGraphViewerPart::setLayoutCommand(const QString& command)
 
 void KGraphViewerPart::setPannerPosition(KGraphViz::DotGraphView::PannerPosition position)
 {
-  d->m_widget->viewBevActivated(position);
+  d->m_widget->setPannerPosition(position);
 }
 
 void KGraphViewerPart::setPannerEnabled(bool enabled)


More information about the kgraphviewer-devel mailing list