Reset previous sort column in generic wxDataViewColumn::SetSortOrder().
The sort indicator on the column previously used for sorting was only reset when the user clicked on the column header (by wxDataViewHeaderWindow code that explicitly called wxDataViewCtrl::SetSortingColumnIndex()) but not when wxDataViewCtrl::SetSortOrder() was called directly. Fix this and take care of updating everything in SetSortOrder() itself. This makes the code simpler and also means that calling SetSortOrder() from the program now works as expected (it resulted in having sort indicators in two columns at once before). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69175 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
aadbdd1699
commit
15b8afdcb8
@ -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; }
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user