src/gui/graphicsview/qgraph_p.h
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   199         if (row)
   199         if (row)
   200             l = row->keys();
   200             l = row->keys();
   201         return l;
   201         return l;
   202     }
   202     }
   203 
   203 
   204     void setRootVertex(Vertex *vertex)
       
   205     {
       
   206         userVertex = vertex;
       
   207     }
       
   208 
       
   209     QSet<Vertex*> vertices() const {
   204     QSet<Vertex*> vertices() const {
   210         QSet<Vertex *> setOfVertices;
   205         QSet<Vertex *> setOfVertices;
   211         for (const_iterator it = constBegin(); it != constEnd(); ++it) {
   206         for (const_iterator it = constBegin(); it != constEnd(); ++it) {
   212             setOfVertices.insert(*it);
   207             setOfVertices.insert(*it);
   213         }
   208         }
   239             for (int i = 0; i < adjacents.count(); ++i) {
   234             for (int i = 0; i < adjacents.count(); ++i) {
   240                 Vertex *v1 = adjacents.at(i);
   235                 Vertex *v1 = adjacents.at(i);
   241                 EdgeData *data = edgeData(v, v1);
   236                 EdgeData *data = edgeData(v, v1);
   242                 bool forward = data->from == v;
   237                 bool forward = data->from == v;
   243                 if (forward) {
   238                 if (forward) {
   244                     edges += QString::fromAscii("%1->%2 [label=\"[%3,%4,%5]\" dir=both color=\"#000000:#a0a0a0\"] \n")
   239                     edges += QString::fromAscii("\"%1\"->\"%2\" [label=\"[%3,%4,%5,%6,%7]\" color=\"#000000\"] \n")
   245                         .arg(v->toString())
   240                         .arg(v->toString())
   246                         .arg(v1->toString())
   241                         .arg(v1->toString())
   247                         .arg(data->minSize)
   242                         .arg(data->minSize)
       
   243                         .arg(data->minPrefSize)
   248                         .arg(data->prefSize)
   244                         .arg(data->prefSize)
       
   245                         .arg(data->maxPrefSize)
   249                         .arg(data->maxSize)
   246                         .arg(data->maxSize)
   250                         ;
   247                         ;
   251                 }
   248                 }
   252             }
   249             }
   253             strVertices += QString::fromAscii("%1 [label=\"%2\"]\n").arg(v->toString()).arg(v->toString());
   250             strVertices += QString::fromAscii("\"%1\" [label=\"%2\"]\n").arg(v->toString()).arg(v->toString());
   254         }
   251         }
   255         return QString::fromAscii("%1\n%2\n").arg(strVertices).arg(edges);
   252         return QString::fromAscii("%1\n%2\n").arg(strVertices).arg(edges);
   256     }
   253     }
   257 #endif
   254 #endif
   258 
       
   259     Vertex *rootVertex() const
       
   260     {
       
   261         return userVertex;
       
   262     }
       
   263 
   255 
   264 protected:
   256 protected:
   265     void createDirectedEdge(Vertex *from, Vertex *to, EdgeData *data)
   257     void createDirectedEdge(Vertex *from, Vertex *to, EdgeData *data)
   266     {
   258     {
   267         QHash<Vertex *, EdgeData *> *adjacentToFirst = m_graph.value(from);
   259         QHash<Vertex *, EdgeData *> *adjacentToFirst = m_graph.value(from);
   284             delete adjacentToFirst;
   276             delete adjacentToFirst;
   285         }
   277         }
   286     }
   278     }
   287 
   279 
   288 private:
   280 private:
   289     Vertex *userVertex;
       
   290 
       
   291     QHash<Vertex *, QHash<Vertex *, EdgeData *> *> m_graph;
   281     QHash<Vertex *, QHash<Vertex *, EdgeData *> *> m_graph;
   292 };
   282 };
   293 
   283 
   294 QT_END_NAMESPACE
   284 QT_END_NAMESPACE
   295 
   285