[kgraphviewer-devel] [KGraphViewer/libkgraphviz] b5e0eea: Hide last attributes of DotGraph interface

Kevin Funk krf at electrostorm.net
Wed Dec 15 15:41:50 CET 2010


commit b5e0eea95b27dcd0b8e24e9d0e88dcca25b04863
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date:   Wed Dec 15 10:14:26 2010 +0100

    Hide last attributes of DotGraph interface

diff --git a/src/kgraphviz/dotgraph.cpp b/src/kgraphviz/dotgraph.cpp
index 731f868..e3517c0 100644
--- a/src/kgraphviz/dotgraph.cpp
+++ b/src/kgraphviz/dotgraph.cpp
@@ -62,7 +62,8 @@ DotGraphPrivate::DotGraphPrivate() :
   m_directed(true), m_strict(false),
   m_horizCellFactor(0), m_vertCellFactor(0),
   m_wdhcf(0), m_hdvcf(0),
-  m_useLibrary(false)
+  m_useLibrary(false),
+  m_readWrite(false)
 {
 }
 
@@ -78,16 +79,14 @@ void DotGraphPrivate::init()
 
 DotGraph::DotGraph() :
   GraphElement(),
-  d_ptr(new DotGraphPrivate),
-  m_readWrite(false)
+  d_ptr(new DotGraphPrivate)
 {
   setId("unnamed");
 }
 
 DotGraph::DotGraph(const QString& layoutCommand, const QString& fileName) :
   GraphElement(),
-  d_ptr(new DotGraphPrivate),
-  m_readWrite(false)
+  d_ptr(new DotGraphPrivate)
 {
   setId("unnamed");
 
@@ -266,6 +265,18 @@ void DotGraph::setUseLibrary(bool value)
   d->m_useLibrary = value;
 }
 
+void DotGraph::setReadWrite()
+{
+  Q_D(DotGraph);
+  d->m_readWrite = true;
+}
+
+void DotGraph::setReadOnly()
+{
+  Q_D(DotGraph);
+  d->m_readWrite = false;
+}
+
 bool DotGraph::parseDot(const QString& fileName)
 {
   kDebug() << fileName;
@@ -278,8 +289,6 @@ bool DotGraph::parseDot(const QString& fileName)
 
 bool DotGraph::update()
 {
-  Q_D(DotGraph);
-  
   GraphExporter exporter;
   if (!useLibrary())
   {
@@ -305,24 +314,25 @@ bool DotGraph::update()
   }
 }
 
-unsigned int DotGraph::cellNumber(int x, int y)
+unsigned int DotGraphPrivate::cellNumber(int x, int y) const
 {
 /*  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(wdhcf()) ) ) / wdhcf());
-  unsigned int ny = (unsigned int)(( y - ( y % int(hdvcf()) ) ) / hdvcf());
+  const unsigned int nx = (unsigned int)(( x - ( x % int(m_wdhcf) ) ) / m_wdhcf);
+  const 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 * horizCellFactor() + nx;
+  const unsigned int res = ny * m_horizCellFactor + nx;
   return res;
 }
 
 #define MAXCELLWEIGHT 800
 
-void DotGraph::computeCells()
+void DotGraphPrivate::computeCells()
 {
+  kWarning() << "Not implemented";
   return;
   
 /* FIXME: Is this used?
@@ -410,6 +420,7 @@ void DotGraph::saveTo(const QString& fileName)
 
 void DotGraph::updateWithGraph(graph_t* newGraph)
 {
+  Q_D(DotGraph);
   kDebug();
 
   // copy global graph render operations and attributes
@@ -535,7 +546,7 @@ void DotGraph::updateWithGraph(graph_t* newGraph)
   }
   kDebug() << "Done";
   emit readyToDisplay();
-  computeCells();
+  d->computeCells();
 }
 
 void DotGraph::updateWithGraph(const DotGraph& newGraph)
@@ -549,7 +560,7 @@ void DotGraph::updateWithGraph(const DotGraph& newGraph)
   d->m_directed = newGraph.directed();
   d->m_strict = newGraph.strict();
 
-  computeCells();
+  d->computeCells();
   foreach (GraphSubgraph* nsg, newGraph.subgraphs())
   {
     kDebug() << "subgraph" << nsg->id();
@@ -620,7 +631,7 @@ void DotGraph::updateWithGraph(const DotGraph& newGraph)
     }
   }
   kDebug() << "Done";
-  computeCells();
+  d->computeCells();
 }
 
 void DotGraph::removeNodeNamed(const QString& nodeName)
diff --git a/src/kgraphviz/dotgraph.h b/src/kgraphviz/dotgraph.h
index ca3d599..962888e 100644
--- a/src/kgraphviz/dotgraph.h
+++ b/src/kgraphviz/dotgraph.h
@@ -97,8 +97,8 @@ public:
 
   bool update();
 
-  void setReadWrite() {m_readWrite = true;}
-  void setReadOnly() {m_readWrite = false;}
+  void setReadWrite();
+  void setReadOnly();
 
   virtual void storeOriginalAttributes();
 
@@ -136,11 +136,6 @@ Q_SIGNALS:
 private:
   Q_DECLARE_PRIVATE(DotGraph);
   DotGraphPrivate* d_ptr;
-
-  unsigned int cellNumber(int x, int y);
-  void computeCells();
-
-  bool m_readWrite;
 };
 
 }
diff --git a/src/kgraphviz/dotgraph_p.h b/src/kgraphviz/dotgraph_p.h
index 78e93c3..509798a 100644
--- a/src/kgraphviz/dotgraph_p.h
+++ b/src/kgraphviz/dotgraph_p.h
@@ -35,6 +35,9 @@ public:
 
   void init();
 
+  unsigned int cellNumber(int x, int y) const;
+  void computeCells();
+
   GraphIO m_graphIO;
 
   QString m_fileName;
@@ -43,6 +46,7 @@ public:
   GraphSubgraphMap m_subgraphsMap;
   GraphNodeMap m_nodesMap;
   GraphEdgeMap m_edgesMap;
+
   double m_width, m_height;
   double m_scale;
   bool m_directed;
@@ -52,9 +56,11 @@ public:
   double m_wdhcf, m_hdvcf;
 
   QVector< QSet< GraphNode* > > m_cells;
-  
+
   bool m_useLibrary;
 
+  bool m_readWrite;
+
 private:
   Q_DECLARE_PUBLIC(DotGraph);
   DotGraph* q_ptr;


More information about the kgraphviewer-devel mailing list