[kgraphviewer-devel] [KGraphViewer/libkgraphviz] 82066cc: Remove KConfig stuff from view

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


commit 82066ccab0399efa93627fe6494731ed7bf08e24
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date:   Tue Dec 14 17:01:02 2010 +0100

    Remove KConfig stuff from view
    
    This is not a task of the view, the KGraphViewer interface must handle
    this. To be fixed later.

diff --git a/src/kgraphviz/dotgraphview.cpp b/src/kgraphviz/dotgraphview.cpp
index 0a7472e..6ba94dc 100644
--- a/src/kgraphviz/dotgraphview.cpp
+++ b/src/kgraphviz/dotgraphview.cpp
@@ -541,8 +541,6 @@ DotGraphView::DotGraphView(KActionCollection* actions, QWidget* parent) :
                 "</ul>"
             ) );
 
-  readViewConfig();
-  
   QMatrix m;
   m.scale(d->m_zoom,d->m_zoom);
   setMatrix(m);
@@ -557,9 +555,7 @@ DotGraphView::DotGraphView(KActionCollection* actions, QWidget* parent) :
 
 DotGraphView::~DotGraphView()
 {
-  saveViewConfig();
-  Q_D(DotGraphView);
-  delete d;
+  delete d_ptr;
 }
 
 KGraphViewerInterface::PannerPosition DotGraphView::zoomPos() const { Q_D(const DotGraphView); return d->m_zoomPosition; }
@@ -1286,31 +1282,6 @@ QString DotGraphView::zoomPosString(KGraphViewerInterface::PannerPosition p)
     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()
 {
   /*
@@ -1384,56 +1355,6 @@ void DotGraphView::dirty(const QString& 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);
diff --git a/src/kgraphviz/dotgraphview.h b/src/kgraphviz/dotgraphview.h
index 56ce3c9..1bbb8e5 100644
--- a/src/kgraphviz/dotgraphview.h
+++ b/src/kgraphviz/dotgraphview.h
@@ -31,9 +31,7 @@
 
 #include "shared/kgraphviewer_interface.h"
 
-#include <kconfig.h>
 #include <kactioncollection.h>
-#include <kconfiggroup.h>
 
 #include <QGraphicsView>
 #include <QSet>
@@ -80,27 +78,12 @@ public:
   bool 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...
   KGraphViewer::KGraphViewerInterface::PannerPosition zoomPos() const;
   static KGraphViewer::KGraphViewerInterface::PannerPosition zoomPos(const QString&);
   static QString zoomPosString(KGraphViewer::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);
 
diff --git a/src/kgraphviz/dotgraphview_p.h b/src/kgraphviz/dotgraphview_p.h
index 94ea4d8..48fa140 100644
--- a/src/kgraphviz/dotgraphview_p.h
+++ b/src/kgraphviz/dotgraphview_p.h
@@ -44,7 +44,6 @@ public:
   KActionCollection* actionCollection() {return m_actions;}
   int displaySubgraph(GraphSubgraph* gsubgraph, int zValue, CanvasElement* parent = 0);
 
-
   QSet<QGraphicsSimpleTextItem*> m_labelViews;
   QGraphicsScene* m_canvas;
   QMenu* m_popup;


More information about the kgraphviewer-devel mailing list