]> git.saurik.com Git - wxWidgets.git/commitdiff
Getting closer to working tree/list wxDataViewCtrl.
authorRobert Roebling <robert@roebling.de>
Thu, 5 Jul 2007 19:15:03 +0000 (19:15 +0000)
committerRobert Roebling <robert@roebling.de>
Thu, 5 Jul 2007 19:15:03 +0000 (19:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/dataview/dataview.cpp
src/gtk/dataview.cpp

index 457c81f1d9ed493552dbc2c114c3babaf1fd0402..d9c9acb851b3417f23c0c03ac98a1ae5fce003d3 100644 (file)
@@ -191,6 +191,15 @@ public:
     }
     virtual wxDataViewItem GetNthChild(  const wxDataViewItem &parent, unsigned int n ) const
     {
+        if (!parent.IsOk())
+        {
+            // root node
+            if (n == 0)
+                return wxDataViewItem( 1 );
+                
+            return wxDataViewItem( 0 );
+        }
+    
         int ID = parent.GetID();
         switch (ID)
         {
index 17b3a894eeb058b421e41e89453ee2c777d9e257..74ac9a4dba3a3b2e96d04b35c954f3cf76a71280 100644 (file)
@@ -267,15 +267,19 @@ wxgtk_tree_model_get_iter (GtkTreeModel *tree_model,
 
     wxDataViewItem item;
 
+    wxPrintf( "get_iter depth: %d\n", depth );
+
     int i;
     for (i = 0; i < depth; i++)    
     {
         gint pos = gtk_tree_path_get_indices (path)[i];
         item = model->GetNthChild( item, (unsigned int) pos );
 
+        wxPrintf( "pos %d\n", pos );
+
         if (!item.IsOk())
         {
-            wxPrintf( wxT("wrong item from path\n") );
+            wxPrintf( "wrong item from path\n" );
             return FALSE;
         }
     }
@@ -438,18 +442,32 @@ wxgtk_tree_model_iter_nth_child (GtkTreeModel *tree_model,
     GtkWxTreeModel *wxtree_model = (GtkWxTreeModel *) tree_model;
     g_return_val_if_fail (GTK_IS_WX_TREE_MODEL (wxtree_model), FALSE);
 
-    g_return_val_if_fail (wxtree_model->stamp == parent->stamp, FALSE);
-    
     wxDataViewModel *model = wxtree_model->model;
     
-    wxDataViewItem item( (wxUint32) parent->user_data );
-    item = model->GetNthChild( item, n );
+    if (!parent)
+    {
+        wxDataViewItem item;
+        item = model->GetNthChild( item, n );
+        
+        if (!item.IsOk())
+            return FALSE;
     
-    if (!item.IsOk())
-        return FALSE;
+        iter->stamp = wxtree_model->stamp;
+        iter->user_data = (gpointer) item.GetID();
+    }
+    else
+    {
+        g_return_val_if_fail (wxtree_model->stamp == parent->stamp, FALSE);
     
-    iter->stamp = wxtree_model->stamp;
-    iter->user_data = (gpointer) item.GetID();
+        wxDataViewItem item( (wxUint32) parent->user_data );
+        item = model->GetNthChild( item, n );
+    
+        if (!item.IsOk())
+            return FALSE;
+    
+        iter->stamp = wxtree_model->stamp;
+        iter->user_data = (gpointer) item.GetID();
+    }
 
     return TRUE;
 }