|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77708 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-04-01 19:53:42
Author: jofaber
Date: 2012-04-01 19:53:40 EDT (Sun, 01 Apr 2012)
New Revision: 77708
URL: http://svn.boost.org/trac/boost/changeset/77708
Log:
Initializing Dag Model on startup.
Text files modified:
sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 68 ++++++++++++++++++++++++++++++++++++++-
sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h | 1
sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp | 8 ++-
sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 3 +
4 files changed, 74 insertions(+), 6 deletions(-)
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-04-01 19:53:40 EDT (Sun, 01 Apr 2012)
@@ -73,6 +73,12 @@
void Browser::exec()
{
+ if(sqlEdit->toPlainText().isEmpty())
+ {
+ rexec();
+ return;
+ }
+
QSqlQueryModel *model = new QSqlQueryModel(ext_table);
@@ -87,11 +93,10 @@
xpQuery.exec(sqlEdit->toPlainText());
// Populate the Dag Model from an sql-Query
- //JODO dagmo->fromSql(xpQuery);
-
dagmo->getEdges(xpQuery); //Read edges from database
dagmo->makeDag(); //Make a boost::graph internally
+ /*CL DBG Controlling the Dag via string output
QMessageBox msgBox;
//QString dagStr = dagmo->toString();
//QString dagStr = dagmo->dagToString();
@@ -103,6 +108,63 @@
msgBox.exec();
msgBox.setText(dagStr2);
msgBox.exec();
+ */
+
+ QString dagStr = dagmo->setupDag(); //Build a tree representation from the boost::dag
+
+ model->setQuery(curQuery);
+ //REV? model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
+
+ ext_table->setModel(model);
+ ext_tree->setModel(dagmo);//JOFA
+
+ //JOFA additions ----------------------------------------------------------
+ ext_table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
+
+ //ext_table->setSortingEnabled(true);
+ ext_table->setAlternatingRowColors(true);
+ ext_table->resizeColumnsToContents();
+ //JOFA additions ----------------------------------------------------------
+
+
+ if (model->lastError().type() != QSqlError::NoError)
+ emit statusMessage(model->lastError().text());
+ else if (model->query().isSelect())
+ emit statusMessage(tr("Query OK."));
+ else
+ emit statusMessage(tr("Query OK, number of affected rows: %1").arg(
+ model->query().numRowsAffected()));
+
+ updateActions();
+}
+
+void Browser::rexec()
+{
+ QSqlQueryModel *model = new QSqlQueryModel(ext_table);
+
+
+ QString dagSql;
+ dagSql += "select Dag.Parent as ParentId, Dag.Child as ChildId, Types.Id as TypeId, \n";
+ dagSql += " (select Objects.name from Objects where Objects.id = Dag.Parent) as Parent, \n";
+ dagSql += " Objects.name as Child, Types.name as Type \n";
+ dagSql += " from Dag \n";
+ dagSql += " inner join Objects on Dag.Child = Objects.id \n";
+ dagSql += " inner join Types on Objects.TypeOf = Types.id ";
+
+ QSqlQuery curQuery = QSqlQuery(dagSql, connectionWidget->currentDatabase());
+
+ QStringList headers;
+ headers << tr("Title") << tr("Description");
+ DagModel* dagmo = new DagModel(headers); // Dag-Model
+
+ QSqlQuery xpQuery = QSqlQuery("", connectionWidget->currentDatabase());
+ xpQuery.exec(dagSql);
+
+ // Populate the Dag Model from an sql-Query
+ dagmo->getEdges(xpQuery); //Read edges from database
+ dagmo->makeDag(); //Make a boost::graph internally
+
+ QString dagStr = dagmo->setupDag(); //Build a tree representation from the boost::dag
model->setQuery(curQuery);
//REV? model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
@@ -188,6 +250,8 @@
if (err.type() != QSqlError::NoError)
QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
"opening the connection: ") + err.text());
+ else
+ rexec();
}
}
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h 2012-04-01 19:53:40 EDT (Sun, 01 Apr 2012)
@@ -71,6 +71,7 @@
public slots:
void exec();
+ void rexec();
QSqlTableModel* showTable(const QString &table);
void showTree(QSqlTableModel *model);
void showMetaData(const QString &table);
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-04-01 19:53:40 EDT (Sun, 01 Apr 2012)
@@ -410,9 +410,11 @@
{
QString indent = indentation(depth);
- QVariant parentNameV = node->data(m_childName);
- QString parentName = parentNameV.toString();
- QString nodeRepr( tr("%1[%2\n").arg(indentation(depth), parentName) ); //, node->data[m_parentName]);
+ QVariant childNameV = node->data(m_childName);
+ QString childName = childNameV.toString();
+ QString nodeRepr( tr("%1[%2\n").arg(indentation(depth), childName) );
+ int nodeCount = node->childCount();
+
for(int idx=0; idx<node->childCount(); idx++)
nodeRepr += nodeToString(node->child(idx), depth+1);
Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro 2012-04-01 19:53:40 EDT (Sun, 01 Apr 2012)
@@ -3,7 +3,8 @@
QT += sql
-INCLUDEPATH += /NIBuild/3rdparty/boost-1.48.0
+#INCLUDEPATH += /NIBuild/3rdparty/boost-1.48.0
+INCLUDEPATH += /cygwin/home/jofa/dev/boost/trunk
HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h \
exttableview.h \
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