From: Vadim Zeitlin Date: Sat, 11 Aug 2012 23:09:33 +0000 (+0000) Subject: Update the icon of a parent item without children in wxDataViewCtrl. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c3b504ad03fc6c90f5a00b2b90dea35adfa7327c?ds=inline Update the icon of a parent item without children in wxDataViewCtrl. Ensure that a parent item that doesn't have any children any more isn't left with a "-" expander icon, it can't be collapsed any more but only expanded again (possibly adding children under it dynamically). This results in better behaviour in e.g. the last page of the dataview sample where the container item remained with a "+" icon even after its both children were deleted. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72325 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index b1ce9f1162..7fef06b83b 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -2339,7 +2339,17 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent, // If this was the last child to be removed, it's possible the parent // node became a leaf. Let's ask the model about it. if ( parentNode->GetChildNodes().empty() ) - parentNode->SetHasChildren(GetModel()->IsContainer(parent)); + { + bool isContainer = GetModel()->IsContainer(parent); + parentNode->SetHasChildren(isContainer); + if ( isContainer ) + { + // If it's still a container, make sure we show "+" icon for it + // and not "-" one as there is nothing to collapse any more. + if ( parentNode->IsOpen() ) + parentNode->ToggleOpen(); + } + } // Update selection by removing 'item' and its entire children tree from the selection. if ( !m_selection.empty() )