Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77744 - sandbox/icl/libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-04-03 13:10:21


Author: jofaber
Date: 2012-04-03 13:10:19 EDT (Tue, 03 Apr 2012)
New Revision: 77744
URL: http://svn.boost.org/trac/boost/changeset/77744

Log:
Insertion into dag 2.
Text files modified:
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.cpp | 29 +++++++++++++++++++++++++++++
   sandbox/icl/libs/xplore/br1/sqlbrowser/browser.h | 4 ++++
   sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.cpp | 11 ++++++++++-
   sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.h | 10 ++++++++++
   4 files changed, 53 insertions(+), 1 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-03 13:10:19 EDT (Tue, 03 Apr 2012)
@@ -84,13 +84,42 @@
 
     //QTreeWidgetItem* curItem = ext_tree->model()->item(idx);
     QAbstractItemModel* absmo = ext_tree->model();
+ DagModel* dagmo = dynamic_cast<DagModel*>(ext_tree->model());
+
     QVariant variDat = absmo->data(idx);
 
+ //TMP Insert a fixed vertex.
+ // 1. Get the object id of the current
+ //(2. Insert a new object (vertex))
+ // 3. Insert a new edge. [Erst mal nur in den Graph.]
+ // 4. Refresh the dag model: Reload it from db.
+
+
+
     QMessageBox msgBox;
     QString msg = "Insertion. ";
     msg += variDat.toString();
     msgBox.setText(msg);
     msgBox.exec();
+
+ insertNewVertex(dagmo, idx);
+}
+
+
+// Insert a new Vertex and Edge at node refered by index in the boost::graph.
+// Then update the DagModel.
+void Browser::insertNewVertex(DagModel* pDagModel, const QModelIndex& index)
+{
+ Q_ASSERT(index.isValid());
+ // Get the id.
+ QModelIndex idIndex = index.sibling(index.row(), dag::node::posId);
+
+ //create an edge, fill as dummy and append.
+ QVector<QVariant> data(dag::edge::sizeOf_edge);
+ pDagModel->fillDummyData(data, idIndex.data().toInt());
+ pDagModel->appendEdge(data);
+
+ pDagModel->setupDag();
 }
 
 

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-03 13:10:19 EDT (Tue, 03 Apr 2012)
@@ -54,6 +54,8 @@
 QT_FORWARD_DECLARE_CLASS(QTextEdit)
 QT_FORWARD_DECLARE_CLASS(QSqlError)
 
+class DagModel;
+
 class Browser: public QWidget, private Ui::Browser
 {
     Q_OBJECT
@@ -115,6 +117,8 @@
 
 private:
     void deselectFirstCell(int selectedRow);
+
+ void insertNewVertex(DagModel* pDagModel, const QModelIndex& index);
 };
 
 #endif

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-03 13:10:19 EDT (Tue, 03 Apr 2012)
@@ -413,7 +413,6 @@
         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);
@@ -444,3 +443,13 @@
     data[m_childType] = query.value(m_childType);
 }
 
+void DagModel::fillDummyData(QVector<QVariant>& data, int nodeId)
+{
+ data[m_parentId] = QVariant(nodeId);
+ data[m_childId] = QVariant(num_edges());
+ data[m_typeId] = QVariant(-9);
+ data[m_parentName] = QVariant("Parent Name");
+ data[m_childName] = QVariant("Child Name");
+ data[m_childType] = QVariant(-9);
+}
+

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.h (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/dagmodel.h 2012-04-03 13:10:19 EDT (Tue, 03 Apr 2012)
@@ -82,6 +82,9 @@
 
     DagItem* rootItem()const { return m_rootItem; } //CL DBG
 
+ //--------------------------------------------------------------------------
+ int num_edges()const { return boost::num_edges(m_dag); }
+
 private:
     void setupModelData(const QStringList &lines, DagItem *parent);
 
@@ -89,6 +92,13 @@
 
     void fillData(QVector<QVariant>& data, QSqlQuery& query);
 
+public:
+ // Fill edge with dummy data. JODO CL later
+ void fillDummyData(QVector<QVariant>& data, int nodeId);
+
+ void appendEdge(QVector<QVariant>& data){ m_edges.append(data);}
+
+private:
     DagItem *m_rootItem;
 
     int m_parentId ;


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