From 33208b4ecb04e5380e6674d71c58e085f803d409 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 29 Mar 2012 23:43:46 +0000 Subject: [PATCH] Remove nonsensical custom comparison code from wxDataViewIndexListModel. This model was comparing its items by their positions in the list instead of their values for some reason. This broke sorting in wxDataViewListCtrl using this model and simply didn't make any sense. Just remove the comparison code from wxDataViewIndexListModel entirely, the base class version works just fine for it. Closes #14116. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71055 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dataview.h | 6 ------ src/common/datavcmn.cpp | 27 --------------------------- 2 files changed, 33 deletions(-) diff --git a/include/wx/dataview.h b/include/wx/dataview.h index ba69d16a7d..c0aed4734b 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -376,12 +376,6 @@ public: virtual unsigned GetRow( const wxDataViewItem &item ) const; wxDataViewItem GetItem( unsigned int row ) const; - // compare based on index - - virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, - unsigned int column, bool ascending ) const; - virtual bool HasDefaultCompare() const; - // implement base methods virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const; diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 6dcf50fb56..8fbe034293 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -500,33 +500,6 @@ wxDataViewItem wxDataViewIndexListModel::GetItem( unsigned int row ) const return wxDataViewItem( m_hash[row] ); } -bool wxDataViewIndexListModel::HasDefaultCompare() const -{ - return !m_ordered; -} - -int wxDataViewIndexListModel::Compare(const wxDataViewItem& item1, - const wxDataViewItem& item2, - unsigned int WXUNUSED(column), - bool ascending) const -{ - if (m_ordered) - { - unsigned int pos1 = wxPtrToUInt(item1.GetID()); // -1 not needed here - unsigned int pos2 = wxPtrToUInt(item2.GetID()); // -1 not needed here - - if (ascending) - return pos1 - pos2; - else - return pos2 - pos1; - } - - if (ascending) - return GetRow(item1) - GetRow(item2); - - return GetRow(item2) - GetRow(item1); -} - unsigned int wxDataViewIndexListModel::GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const { if (item.IsOk()) -- 2.45.2