Update the directory icon in wxGenericDirCtrl::ExpandDir().

Calling ExpandDir() to notify the control that a new item was added in a
previously empty directory didn't work as wxTreeCtrl::SetItemHasChildren()
wasn't called.

Fix this by moving SetItemHasChildren() to ExpandDir() from OnExpandItem(), it
must be always done and not just in response to an interactive action.

Closes #12735.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66311 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-12-03 12:40:15 +00:00
parent c892ae145c
commit c72fa1cd62

View File

@@ -761,14 +761,9 @@ void wxGenericDirCtrl::OnExpandItem(wxTreeEvent &event)
// ctor when wxTR_HIDE_ROOT was specified
if (!m_rootId.IsOk())
m_rootId = m_treeCtrl->GetRootItem();
ExpandDir(parentId);
if ( m_treeCtrl->GetChildrenCount(parentId, false) == 0 )
{
m_treeCtrl->SetItemHasChildren(parentId, false);
}
}
void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent &event )
@@ -892,6 +887,10 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId)
filenames.Sort(wxDirCtrlStringCompareFunction);
}
// Now we really know whether we have any children so tell the tree control
// about it.
m_treeCtrl->SetItemHasChildren(parentId, !dirs.empty() || !filenames.empty());
// Add the sorted dirs
size_t i;
for (i = 0; i < dirs.GetCount(); i++)
@@ -911,7 +910,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId)
// assume that it does have children by default as it can take a long
// time to really check for this (think remote drives...)
//
// and if we're wrong, we'll correct it later in OnExpandItem() if
// and if we're wrong, we'll correct the icon later if
// the user really tries to open this item
m_treeCtrl->SetItemHasChildren(id);
}