Optimize changing sort indicator in wxGenericListCtrl

Don't do anything at all if nothing changes and if the indicator does
change, refresh only the header window and not the whole list control,
which seems unnecessary.
This commit is contained in:
Vadim Zeitlin
2021-12-13 14:29:59 +00:00
parent 58290168e5
commit c287840faa

View File

@@ -5086,10 +5086,10 @@ bool wxGenericListCtrl::IsItemChecked(long item) const
void wxGenericListCtrl::EnableSortIndicator(bool enable)
{
if ( m_headerWin )
if ( m_headerWin && enable != m_headerWin->m_enableSortCol )
{
m_headerWin->m_enableSortCol = enable;
Refresh();
m_headerWin->Refresh();
}
}
@@ -5104,21 +5104,23 @@ void wxGenericListCtrl::ShowSortIndicator(int idx, bool ascending)
{
RemoveSortIndicator();
}
else if ( m_headerWin )
else if ( m_headerWin &&
(idx != m_headerWin->m_sortCol ||
ascending != m_headerWin->m_sortAsc) )
{
m_headerWin->m_sortCol = idx;
m_headerWin->m_sortAsc = ascending;
Refresh();
m_headerWin->Refresh();
}
}
void wxGenericListCtrl::RemoveSortIndicator()
{
if ( m_headerWin )
if ( m_headerWin && m_headerWin->m_sortCol != -1 )
{
m_headerWin->m_sortCol = -1;
m_headerWin->m_sortAsc = true;
Refresh();
m_headerWin->Refresh();
}
}