diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index 0fac7af910..ed3d11eb69 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -72,12 +72,7 @@ public: virtual void UnsetAsSortKey() { m_sort = false; UpdateDisplay(); } - virtual void SetSortOrder(bool ascending) - { - m_sort = true; - m_sortAscending = ascending; - UpdateDisplay(); - } + virtual void SetSortOrder(bool ascending); virtual bool IsSortOrderAscending() const { return m_sortAscending; } diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index f5fcf0d5e3..7faab77e67 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -146,6 +146,30 @@ void wxDataViewColumn::UpdateDisplay() } } +void wxDataViewColumn::SetSortOrder(bool ascending) +{ + if ( !m_owner ) + return; + + // First unset the old sort column if any. + int oldSortKey = m_owner->GetSortingColumnIndex(); + if ( oldSortKey != wxNOT_FOUND ) + { + m_owner->GetColumn(oldSortKey)->UnsetAsSortKey(); + } + + // Now set this one as the new sort column. + const int idx = m_owner->GetColumnIndex(this); + m_owner->SetSortingColumnIndex(idx); + + m_sort = true; + m_sortAscending = ascending; + + // Call this directly instead of using UpdateDisplay() as we already have + // the column index, no need to look it up again. + m_owner->OnColumnChange(idx); +} + //----------------------------------------------------------------------------- // wxDataViewHeaderWindow //----------------------------------------------------------------------------- @@ -221,15 +245,6 @@ private: } else // not using this column for sorting yet { - // first unset the old sort column if any - int oldSortKey = owner->GetSortingColumnIndex(); - if ( oldSortKey != wxNOT_FOUND ) - { - owner->GetColumn(oldSortKey)->UnsetAsSortKey(); - owner->OnColumnChange(oldSortKey); - } - - owner->SetSortingColumnIndex(idx); col->SetSortOrder(true); }