Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77150 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-03-02 11:06:15


Author: jofaber
Date: 2012-03-02 11:06:14 EST (Fri, 02 Mar 2012)
New Revision: 77150
URL: http://svn.boost.org/trac/boost/changeset/77150

Log:
Populating a DAG model from sql. Bug fixes.
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql | 3 ++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 9 ++++++++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp | 7 ++++++-
   3 files changed, 16 insertions(+), 3 deletions(-)

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/ExtensibleObjectModel.sql 2012-03-02 11:06:14 EST (Fri, 02 Mar 2012)
@@ -54,7 +54,8 @@
 
 
 -- ----------------------------------------------------------------------------
-create view Collections as
+create view Collections as
+-- This part works for: void fromSql()
 select Dag.Parent as ParentId, Dag.Child as ChildId, Types.Id as TypeId,
   (select Objects.name from Objects where Objects.id = Dag.Parent) as Parent,
   Objects.name as Child, Types.name as Type

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp 2012-03-02 11:06:14 EST (Fri, 02 Mar 2012)
@@ -80,14 +80,21 @@
 
     QStringList headers;
     headers << tr("Title") << tr("Description");
- DagModel* dagmo = new DagModel(headers);
+ DagModel* dagmo = new DagModel(headers); // Dag-Model
 
     QSqlQuery xpQuery = QSqlQuery("", connectionWidget->currentDatabase());
     QString dbg_query = QString(sqlEdit->toPlainText());
     xpQuery.exec(sqlEdit->toPlainText());
+
     int dbg_size = xpQuery.size();
+ // Populate the Dag Model from an sql-Query
     dagmo->fromSql(xpQuery);
 
+ QMessageBox msgBox;
+ QString dagStr = dagmo->toString();
+ msgBox.setText(dagStr);
+ msgBox.exec();
+
     model->setQuery(curQuery);
     //REV? model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
 

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp 2012-03-02 11:06:14 EST (Fri, 02 Mar 2012)
@@ -312,7 +312,11 @@
         data[childName] = query.value(childName);
         data[childType] = query.value(childType);
 
- DagItem* curNode = new DagItem(data, parent);
+ DagItem* curNode = (depth==0) ? new DagItem(data, 0) //curNode==rootItem
+ : new DagItem(data, parent);
+ if(depth == 0)
+ rootItem = curNode;
+
         //if the new node is not a leaf, create children.
         //JODO if(!curNode->IsLeaf())
         if(data[typeId] != 2)
@@ -322,6 +326,7 @@
             while((curChild = fromSql(query, curNode, depth+1)) != NULL)
             {
                 curNode->addChild(curChild);
+ int dbg_childCount = curNode->childCount(); //CL
             }
         }
 


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