|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79856 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-08-03 02:45:43
Author: jofaber
Date: 2012-08-03 02:45:39 EDT (Fri, 03 Aug 2012)
New Revision: 79856
URL: http://svn.boost.org/trac/boost/changeset/79856
Log:
Depth first search of dag to construct QTreeModel.
Text files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h | 28 ++++++++++++++++------------
sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.cpp | 11 +++++++++++
sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.h | 2 ++
sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel2.h | 2 +-
4 files changed, 30 insertions(+), 13 deletions(-)
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/CreatorVisitor2.h 2012-08-03 02:45:39 EDT (Fri, 03 Aug 2012)
@@ -106,7 +106,7 @@
p_curItem = sourceDagItem;
if(targetDagItem)
- sourceDagItem->addChild(targetDagItem);
+ ; //CL sourceDagItem->addChild(targetDagItem);
else
{
tVariVector itemData(dag::node::sizeOf_node);
@@ -151,9 +151,20 @@
vertex_descriptor targetVertex = target(edge, graph);
Vertex2AttributesMap::iterator sourceVertex_ = r_attrs.find(sourceVertex);
- int sourceDepth = depth(sourceVertex);
+ int sourceDepth = r_attrs[sourceVertex].depth();
int targetDepth = sourceDepth + 1;
+ r_attrs[targetVertex].setDepth(targetDepth);
+ DagItem* sourceDagItem = r_attrs[sourceVertex].dagItem();
+ DagItem* targetDagItem = r_attrs[targetVertex].dagItem();
+
+ Q_ASSERT(sourceDagItem);
+ Q_ASSERT(targetDagItem);
+
+ DagItem* newSubTree = targetDagItem->clone(sourceDagItem);
+ sourceDagItem->addChild(newSubTree);
+ *p_result += targetDagItem->toString();
+
*p_result += indentation(targetDepth)
+ QString("[%1<%2>%3]\n").arg(graph[sourceVertex].key())
.arg(graph[edge].typeName())
@@ -162,17 +173,10 @@
// graph[targetVertex] (e.g. graph[targetVertex].QtModel
}
- template<class Vertex>
- int depth(Vertex& node)
- {
- Vertex2AttributesMap::iterator node_ = r_attrs.find(node);
- return node_ == r_attrs.end() ? 0 : (*node_).second.depth();
- }
-
- DagItem* p_curItem;
- QString* p_result;
+ DagItem* p_curItem;
+ QString* p_result;
Vertex2AttributesMap& r_attrs;
- QString dbg_str;//CL
+ QString dbg_str;//CL
};
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.cpp 2012-08-03 02:45:39 EDT (Fri, 03 Aug 2012)
@@ -169,3 +169,14 @@
return children;
}
}
+
+DagItem* DagItem::clone(DagItem* parent)
+{
+ DagItem* newDagItem = new DagItem(data(), parent);
+ if(childCount())
+ for(int idx=0; idx<childCount(); idx++)
+ newDagItem->addChild(child(idx)->clone(newDagItem));
+
+ return newDagItem;
+}
+
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/dagitem.h 2012-08-03 02:45:39 EDT (Fri, 03 Aug 2012)
@@ -36,6 +36,8 @@
void addChild(DagItem* child);
bool isLeaf(int TypeId)const { return itemData[TypeId] == NodeType_Object; }
+ DagItem* clone(DagItem* parent);
+
tVariVector data()const { return itemData; }
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel2.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel2.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel2.h 2012-08-03 02:45:39 EDT (Fri, 03 Aug 2012)
@@ -55,7 +55,7 @@
bool removeRows(int position, int rows,
const QModelIndex &parent = QModelIndex());
- //--------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
//JOFA Populating a DAG from an Sql-query
void getEdges(QSqlQuery& query);
void fromSql(QSqlQuery& query);
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk