From e882acc864c69dcc08f021c96848fdc1b04abd4e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 23 Dec 2024 22:46:05 +0100 Subject: [PATCH] Add wxGtkTreeModelNode::ResortChildrenIfNeeded() No real changes, just factor out a common fragment into a function. --- src/gtk/dataview.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 5768117ede..1c7eafcb63 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -355,11 +355,7 @@ public: m_children.Add( id ); - if ( !m_internal->IsSortFrozen() && m_internal->ShouldBeSorted() ) - { - gs_internal = m_internal; - m_children.Sort( &wxGtkTreeModelChildCmp ); - } + ResortChildrenIfNeeded(); } void InsertNode( wxGtkTreeModelNode* child, unsigned pos ) @@ -402,11 +398,7 @@ public: { m_children.Insert( id, pos ); - if ( !m_internal->IsSortFrozen() && m_internal->ShouldBeSorted() ) - { - gs_internal = m_internal; - m_children.Sort( &wxGtkTreeModelChildCmp ); - } + ResortChildrenIfNeeded(); } void DeleteChild( void* id ) @@ -458,6 +450,15 @@ public: void Resort(); private: + void ResortChildrenIfNeeded() + { + if ( !m_internal->IsSortFrozen() && m_internal->ShouldBeSorted() ) + { + gs_internal = m_internal; + m_children.Sort( &wxGtkTreeModelChildCmp ); + } + } + // Only null for the root node, i.e. wxDataViewCtrlInternal::m_root. wxGtkTreeModelNode *m_parent;