Disable sorting of generic wxDataViewCtrl while it is frozen.

Don't sort the contents of wxDataViewCtrl while it is frozen and resort it
only when it is thawed. This dramatically speeds up adding items to the
control when sorting is used as we only sort it once now instead of doing it
after adding every item.

Closes #14073.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73635 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2013-03-10 01:09:41 +00:00
parent c4864c0446
commit 0c5a056a84

View File

@ -85,6 +85,9 @@ static wxDataViewModel* g_model;
// of the special values in this enum: // of the special values in this enum:
enum enum
{ {
// Sort when we're thawed later.
SortColumn_OnThaw = -3,
// Don't sort at all. // Don't sort at all.
SortColumn_None = -2, SortColumn_None = -2,
@ -593,9 +596,32 @@ public:
UpdateDisplay(); UpdateDisplay();
} }
// Override the base class method to resort if needed, i.e. if
// SortPrepare() was called -- and ignored -- while we were frozen.
virtual void DoThaw()
{
if ( g_column == SortColumn_OnThaw )
{
Resort();
g_column = SortColumn_None;
}
wxWindow::DoThaw();
}
void SortPrepare() void SortPrepare()
{ {
g_model = GetModel(); g_model = GetModel();
// Avoid sorting while the window is frozen, this allows to quickly add
// many items without resorting after each addition and only resort
// them all at once when the window is finally thawed, see above.
if ( IsFrozen() )
{
g_column = SortColumn_OnThaw;
return;
}
wxDataViewColumn* col = GetOwner()->GetSortingColumn(); wxDataViewColumn* col = GetOwner()->GetSortingColumn();
if( !col ) if( !col )
{ {