X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8b7b087775eb1136789dcd7ff6419fc038a01d6..628f87da565360ec2fce102c9b46341cf42cd3d3:/src/common/datavcmn.cpp diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index f069a30756..1572f8c75f 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -42,7 +42,6 @@ WX_DEFINE_LIST(wxDataViewModelNotifiers); wxDataViewModel::wxDataViewModel() { m_notifiers.DeleteContents( true ); - m_sortingColumn = 0; } bool wxDataViewModel::ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) @@ -141,7 +140,8 @@ void wxDataViewModel::RemoveNotifier( wxDataViewModelNotifier *notifier ) m_notifiers.DeleteObject( notifier ); } -int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2 ) +int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, + unsigned int column, bool ascending ) { // sort branches before leaves bool item1_is_container = IsContainer(item1); @@ -153,8 +153,15 @@ int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem return -1; wxVariant value1,value2; - GetValue( value1, item1, m_sortingColumn ); - GetValue( value2, item2, m_sortingColumn ); + GetValue( value1, item1, column ); + GetValue( value2, item2, column ); + + if (!ascending) + { + wxVariant temp = value1; + value1 = value2; + value2 = temp; + } if (value1.GetType() == wxT("string")) { @@ -188,6 +195,9 @@ int wxDataViewModel::Compare( const wxDataViewItem &item1, const wxDataViewItem // items must be different unsigned long litem1 = (unsigned long) item1.GetID(); unsigned long litem2 = (unsigned long) item2.GetID(); + + if (!ascending) + return litem2-litem2; return litem1-litem2; } @@ -261,9 +271,13 @@ wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const return wxDataViewItem( m_hash[row] ); } -int wxDataViewIndexListModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2 ) +int wxDataViewIndexListModel::Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, + unsigned int column, bool ascending ) { - return GetRow(item1) - GetRow(item2); + if (ascending) + return GetRow(item1) - GetRow(item2); + + return GetRow(item2) - GetRow(item1); } void wxDataViewIndexListModel::GetValue( wxVariant &variant, @@ -679,7 +693,12 @@ wxDataViewColumn* wxDataViewCtrlBase::GetColumn( unsigned int pos ) IMPLEMENT_DYNAMIC_CLASS(wxDataViewEvent,wxNotifyEvent) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_SELECTED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_DESELECTED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK) DEFINE_EVENT_TYPE(wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED)