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
// of the special values in this enum:
enum
{
// of the special values in this enum:
enum
{
+ // Sort when we're thawed later.
+ SortColumn_OnThaw = -3,
+
// Don't sort at all.
SortColumn_None = -2,
// Don't sort at all.
SortColumn_None = -2,
+ // 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()
{
g_model = GetModel();
void SortPrepare()
{
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();
if( !col )
{
wxDataViewColumn* col = GetOwner()->GetSortingColumn();
if( !col )
{