git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48139
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void SetSortingColumn( unsigned int col ) { m_sortingColumn = col; }
unsigned int GetSortingColumn() { return m_sortingColumn; }
void SetSortingColumn( unsigned int col ) { m_sortingColumn = col; }
unsigned int GetSortingColumn() { return m_sortingColumn; }
- void SetSortOrderAscending( bool ascending ) { m_ascending = ascending; }
- bool GetSortOrderAscending() { return m_ascending; }
-
protected:
// the user should not delete this class directly: he should use DecRef() instead!
protected:
// the user should not delete this class directly: he should use DecRef() instead!
wxDataViewModelNotifiers m_notifiers;
unsigned int m_sortingColumn;
wxDataViewModelNotifiers m_notifiers;
unsigned int m_sortingColumn;
};
// ---------------------------------------------------------
};
// ---------------------------------------------------------
{
m_notifiers.DeleteContents( true );
m_sortingColumn = 0;
{
m_notifiers.DeleteContents( true );
m_sortingColumn = 0;
}
bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item )
}
bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item )
GetValue( value1, item1, m_sortingColumn );
GetValue( value2, item2, m_sortingColumn );
GetValue( value1, item1, m_sortingColumn );
GetValue( value2, item2, m_sortingColumn );
- if (!m_ascending)
- {
- wxVariant temp = value1;
- value1 = value2;
- value2 = temp;
- }
-
if (value1.GetType() == wxT("string"))
{
wxString str1 = value1.GetString();
if (value1.GetType() == wxT("string"))
{
wxString str1 = value1.GetString();
unsigned long litem1 = (unsigned long) item1.GetID();
unsigned long litem2 = (unsigned long) item2.GetID();
unsigned long litem1 = (unsigned long) item1.GetID();
unsigned long litem2 = (unsigned long) item2.GetID();
- if (!m_ascending)
- return litem2-litem1;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-wxDataViewModel *g_model = NULL;
+class wxDataViewCtrlInternal;
+
+wxDataViewCtrlInternal *g_internal = NULL;
class wxGtkTreeModelNode;
class wxGtkTreeModelNode;
bool Cleared();
void Resort();
bool Cleared();
void Resort();
+ void SetSortOrder( GtkSortType sort_order ) { m_sort_order = sort_order; }
+ GtkSortType GetSortOrder() { return m_sort_order; }
+
protected:
void InitTree();
wxGtkTreeModelNode *FindNode( const wxDataViewItem &item );
protected:
void InitTree();
wxGtkTreeModelNode *FindNode( const wxDataViewItem &item );
wxDataViewModel *m_wx_model;
GtkWxTreeModel *m_gtk_model;
wxDataViewCtrl *m_owner;
wxDataViewModel *m_wx_model;
GtkWxTreeModel *m_gtk_model;
wxDataViewCtrl *m_owner;
+ GtkSortType m_sort_order;
m_parent = parent;
m_item = item;
m_internal = internal;
m_parent = parent;
m_item = item;
m_internal = internal;
- g_model = internal->GetDataViewModel();
m_children = new wxGtkTreeModelChildren( wxGtkTreeModelNodeCmp );
}
~wxGtkTreeModelNode()
{
m_children = new wxGtkTreeModelChildren( wxGtkTreeModelNodeCmp );
}
~wxGtkTreeModelNode()
{
- g_model = m_internal->GetDataViewModel();
+ g_internal = m_internal;
size_t count = m_children->GetCount();
size_t i;
for (i = 0; i < count; i++)
size_t count = m_children->GetCount();
size_t i;
for (i = 0; i < count; i++)
unsigned int AddNode( wxGtkTreeModelNode* child )
{
unsigned int AddNode( wxGtkTreeModelNode* child )
{
- g_model = m_internal->GetDataViewModel();
+ g_internal = m_internal;
m_nodes.Add( child );
return m_children->Add( child->GetItem().GetID() );
}
unsigned int AddLeave( void* id )
{
m_nodes.Add( child );
return m_children->Add( child->GetItem().GetID() );
}
unsigned int AddLeave( void* id )
{
- g_model = m_internal->GetDataViewModel();
+ g_internal = m_internal;
return m_children->Add( id );
}
void DeleteChild( void* id )
{
return m_children->Add( id );
}
void DeleteChild( void* id )
{
- g_model = m_internal->GetDataViewModel();
+ g_internal = m_internal;
size_t pos;
size_t count = m_children->GetCount();
for (pos = 0; pos < count; pos++)
size_t pos;
size_t count = m_children->GetCount();
for (pos = 0; pos < count; pos++)
int LINKAGEMODE wxGtkTreeModelNodeCmp( void* id1, void* id2 )
{
int LINKAGEMODE wxGtkTreeModelNodeCmp( void* id1, void* id2 )
{
- return g_model->Compare( id1, id2 );
+ int ret = g_internal->GetDataViewModel()->Compare( id1, id2 );
+ if (g_internal->GetSortOrder() == GTK_SORT_DESCENDING)
+ return -ret;
+ return ret;
}
//-----------------------------------------------------------------------------
}
//-----------------------------------------------------------------------------
*sort_column_id = tree_model->internal->GetDataViewModel()->GetSortingColumn();
if (order)
*sort_column_id = tree_model->internal->GetDataViewModel()->GetSortingColumn();
if (order)
- {
- bool ascending = tree_model->internal->GetDataViewModel()->GetSortOrderAscending();
- if (ascending)
- *order = GTK_SORT_ASCENDING;
- else
- *order = GTK_SORT_DESCENDING;
- }
+ *order = tree_model->internal->GetSortOrder();
-void wxgtk_tree_model_set_sort_column_id (GtkTreeSortable *sortable,
+void wxgtk_tree_model_set_sort_column_id (GtkTreeSortable *sortable,
gint sort_column_id,
GtkSortType order)
{
GtkWxTreeModel *tree_model = (GtkWxTreeModel *) sortable;
g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable) );
gint sort_column_id,
GtkSortType order)
{
GtkWxTreeModel *tree_model = (GtkWxTreeModel *) sortable;
g_return_if_fail (GTK_IS_WX_TREE_MODEL (sortable) );
- bool ascending = TRUE;
- if (order != GTK_SORT_ASCENDING)
- ascending = FALSE;
-
if ((sort_column_id == (gint) tree_model->internal->GetDataViewModel()->GetSortingColumn()) &&
if ((sort_column_id == (gint) tree_model->internal->GetDataViewModel()->GetSortingColumn()) &&
- (ascending == tree_model->internal->GetDataViewModel()->GetSortOrderAscending()))
+ (order == tree_model->internal->GetSortOrder()))
return;
tree_model->internal->GetDataViewModel()->SetSortingColumn( sort_column_id );
return;
tree_model->internal->GetDataViewModel()->SetSortingColumn( sort_column_id );
- tree_model->internal->GetDataViewModel()->SetSortOrderAscending( ascending );
+ tree_model->internal->SetSortOrder( order );
gtk_tree_sortable_sort_column_changed (sortable);
gtk_tree_sortable_sort_column_changed (sortable);
void wxGtkTreeModelNode::Resort()
{
void wxGtkTreeModelNode::Resort()
{
- g_model = m_internal->GetDataViewModel();
+ g_internal = m_internal;
size_t child_count = GetChildCount();
if (child_count == 0)
size_t child_count = GetChildCount();
if (child_count == 0)
m_wx_model = wx_model;
m_gtk_model = gtk_model;
m_root = NULL;
m_wx_model = wx_model;
m_gtk_model = gtk_model;
m_root = NULL;
+ m_sort_order = GTK_SORT_ASCENDING;
gboolean wxDataViewCtrlInternal::get_iter( GtkTreeIter *iter, GtkTreePath *path )
{
gboolean wxDataViewCtrlInternal::get_iter( GtkTreeIter *iter, GtkTreePath *path )
{
int depth = gtk_tree_path_get_depth( path );
int depth = gtk_tree_path_get_depth( path );
GtkTreePath *wxDataViewCtrlInternal::get_path( GtkTreeIter *iter )
{
GtkTreePath *wxDataViewCtrlInternal::get_path( GtkTreeIter *iter )
{
GtkTreePath *retval = gtk_tree_path_new ();
void *id = iter->user_data;
GtkTreePath *retval = gtk_tree_path_new ();
void *id = iter->user_data;
GtkTreePath *wxDataViewCtrlInternal::get_path_safe( GtkTreeIter *iter )
{
GtkTreePath *wxDataViewCtrlInternal::get_path_safe( GtkTreeIter *iter )
{
GtkTreePath *retval = gtk_tree_path_new ();
void *id = iter->user_data;
GtkTreePath *retval = gtk_tree_path_new ();
void *id = iter->user_data;
gboolean wxDataViewCtrlInternal::iter_next( GtkTreeIter *iter )
{
gboolean wxDataViewCtrlInternal::iter_next( GtkTreeIter *iter )
{
wxGtkTreeModelNode *parent = FindParentNode( iter );
if( parent == NULL )
wxGtkTreeModelNode *parent = FindParentNode( iter );
if( parent == NULL )
gboolean wxDataViewCtrlInternal::iter_children( GtkTreeIter *iter, GtkTreeIter *parent )
{
gboolean wxDataViewCtrlInternal::iter_children( GtkTreeIter *iter, GtkTreeIter *parent )
{
wxDataViewItem item( (void*) parent->user_data );
wxDataViewItem item( (void*) parent->user_data );
gboolean wxDataViewCtrlInternal::iter_has_child( GtkTreeIter *iter )
{
gboolean wxDataViewCtrlInternal::iter_has_child( GtkTreeIter *iter )
{
wxDataViewItem item( (void*) iter->user_data );
bool is_container = m_wx_model->IsContainer( item );
wxDataViewItem item( (void*) iter->user_data );
bool is_container = m_wx_model->IsContainer( item );
gint wxDataViewCtrlInternal::iter_n_children( GtkTreeIter *iter )
{
gint wxDataViewCtrlInternal::iter_n_children( GtkTreeIter *iter )
{
wxDataViewItem item( (void*) iter->user_data );
wxDataViewItem item( (void*) iter->user_data );
gboolean wxDataViewCtrlInternal::iter_nth_child( GtkTreeIter *iter, GtkTreeIter *parent, gint n )
{
gboolean wxDataViewCtrlInternal::iter_nth_child( GtkTreeIter *iter, GtkTreeIter *parent, gint n )
{
void* id = NULL;
if (parent) id = (void*) parent->user_data;
void* id = NULL;
if (parent) id = (void*) parent->user_data;
gboolean wxDataViewCtrlInternal::iter_parent( GtkTreeIter *iter, GtkTreeIter *child )
{
gboolean wxDataViewCtrlInternal::iter_parent( GtkTreeIter *iter, GtkTreeIter *child )
{
wxGtkTreeModelNode *node = FindParentNode( child );
if (!node)
wxGtkTreeModelNode *node = FindParentNode( child );
if (!node)