$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r76334 - sandbox/icl/libs/xplore/br1/editabletreemodel
From: afojgo_at_[hidden]
Date: 2012-01-06 11:10:53
Author: jofaber
Date: 2012-01-06 11:10:51 EST (Fri, 06 Jan 2012)
New Revision: 76334
URL: http://svn.boost.org/trac/boost/changeset/76334
Log:
Explorations on tree models and modelindices.
Added:
   sandbox/icl/libs/xplore/br1/editabletreemodel/editabletreemodel.qrc   (contents, props changed)
Text files modified: 
   sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.cpp |    28 ++++++++++++++++------------            
   sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.h   |     3 +++                                     
   2 files changed, 19 insertions(+), 12 deletions(-)
Added: sandbox/icl/libs/xplore/br1/editabletreemodel/editabletreemodel.qrc
==============================================================================
--- (empty file)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/editabletreemodel.qrc	2012-01-06 11:10:51 EST (Fri, 06 Jan 2012)
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/" >
+        <file>default.txt</file>
+    </qresource>
+</RCC>
Modified: sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.cpp
==============================================================================
--- sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.cpp	(original)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.cpp	2012-01-06 11:10:51 EST (Fri, 06 Jan 2012)
@@ -291,19 +291,23 @@
 //JOFA Iteration example: The container as String
 QString TreeModel::toString()const
 {
-    QString repr;
-    QModelIndex curIndex = QModelIndex();
-    for(int row = 0; row < rowCount(); row++)
-    {
-        repr += tr("(%1").arg(row);
-        //QModelIndex curIndex = QModelIndex(row, curIndex);
-        int colEnd = columnCount();
+    return nodeToString(rootItem, 0);
+}
 
-        if(hasChildren(curIndex))
-            repr += tr(" %1").arg(1);
+QString TreeModel::nodeToString(TreeItem* node, int depth)const
+{
+    if(node->childCount()==0)
+        return tr("(%1)").arg(depth); //Print only structure and depth.
+        //return tr("(%1)").arg(node->data(0));
+    else
+    {
+        QString nodeRepr(tr("["));
+        for(int idx=0; idx<node->childCount(); idx++)
+            nodeRepr += nodeToString(node->child(idx), depth+1);
 
-        repr += ")";
+        nodeRepr += tr("]");
+        return nodeRepr;
     }
-
-    return repr;
 }
+
+
Modified: sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.h
==============================================================================
--- sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.h	(original)
+++ sandbox/icl/libs/xplore/br1/editabletreemodel/treemodel.h	2012-01-06 11:10:51 EST (Fri, 06 Jan 2012)
@@ -90,6 +90,9 @@
     //JOFA Iteration example: The container as String
     QString toString()const;
 
+    QString nodeToString(TreeItem* node, int depth)const;
+
+
 private:
     void setupModelData(const QStringList &lines, TreeItem *parent);
     TreeItem *getItem(const QModelIndex &index) const;