{
public:
wxGtkTreeModelNode( wxGtkTreeModelNode* parent, const wxDataViewItem &item,
- wxDataViewModel *model ) :
- m_children( wxGtkTreeModelNodeCmp )
+ wxDataViewModel *model )
{
m_parent = parent;
m_item = item;
m_model = model;
+ m_children = new wxGtkTreeModelNodes( wxGtkTreeModelNodeCmp );
}
~wxGtkTreeModelNode()
{
- size_t count = m_children.GetCount();
+ size_t count = m_children->GetCount();
size_t i;
for (i = 0; i < count; i++)
{
- wxGtkTreeModelNode *child = m_children[i];
+ wxGtkTreeModelNode *child = m_children->Item( i );
delete child;
}
+ delete m_children;
}
wxGtkTreeModelNode* GetParent()
{ return m_parent; }
wxGtkTreeModelNodes &GetChildren()
- { return m_children; }
+ { return *m_children; }
wxGtkTreeModelNode* GetNthChild( unsigned int n )
- { return m_children.Item( n ); }
+ { return m_children->Item( n ); }
unsigned int Add( wxGtkTreeModelNode* child )
- { return m_children.Add( child ); }
-
- unsigned int GetChildCount() { return m_children.GetCount(); }
+ { return m_children->Add( child ); }
+
+ unsigned int GetChildCount() { return m_children->GetCount(); }
wxDataViewItem &GetItem() { return m_item; }
wxDataViewModel *GetModel() { return m_model; }
bool HasChildren() { return m_hasChildren; }
void SetHasChildren( bool has ) { m_hasChildren = has; }
+ void Resort();
+
private:
wxGtkTreeModelNode *m_parent;
- wxGtkTreeModelNodes m_children;
+ wxGtkTreeModelNodes *m_children;
wxDataViewItem m_item;
bool m_hasChildren;
wxDataViewModel *m_model;
bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
bool ItemDeleted( const wxDataViewItem &item );
+ void Resort();
+
protected:
void InitTree();
wxGtkTreeModelNode *FindNode( const wxDataViewItem &item );
// TODO check for equality
- return;
-
gtk_tree_sortable_sort_column_changed (sortable);
tree_model->internal->GetDataViewModel()->SetSortingColumn( sort_column_id );
virtual bool ItemChanged( const wxDataViewItem &item );
virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col );
virtual bool Cleared();
+ virtual void Resort();
GtkWxTreeModel *m_wxgtk_model;
wxDataViewModel *m_wx_model;
return true;
}
+void wxGtkDataViewModelNotifier::Resort()
+{
+ m_owner->GtkGetInternal()->Resort();
+}
+
bool wxGtkDataViewModelNotifier::ItemChanged( const wxDataViewItem &item )
{
GtkTreeIter iter;
}
+//-----------------------------------------------------------------------------
+// wxGtkTreeModelNode
+//-----------------------------------------------------------------------------
+
+void wxGtkTreeModelNode::Resort()
+{
+ wxGtkTreeModelNodes *new_array = new wxGtkTreeModelNodes( wxGtkTreeModelNodeCmp );
+
+ size_t pos;
+ size_t count = m_children->GetCount();
+
+ for (pos = 0; pos < count; pos++)
+ {
+ new_array->Add( m_children->Item( 0 ) );
+ m_children->RemoveAt( 0 );
+ }
+
+ delete m_children;
+ m_children = new_array;
+
+ for (pos = 0; pos < count; pos++)
+ {
+ wxGtkTreeModelNode *node = m_children->Item( pos );
+ node->Resort();
+ }
+}
+
//-----------------------------------------------------------------------------
// wxDataViewCtrlInternal
//-----------------------------------------------------------------------------
}
}
+void wxDataViewCtrlInternal::Resort()
+{
+ m_root->Resort();
+}
+
bool wxDataViewCtrlInternal::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item )
{
wxGtkTreeModelNode *parent_node = FindNode( parent );