assume that all directories have children by default, it can take too long to check if they really do and it's better to do it on demand only, i.e. when the user really tries to open them (patch 1830527)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1d243ee084
commit
d9c98a9aad
@ -747,6 +747,10 @@ void wxGenericDirCtrl::OnExpandItem(wxTreeEvent &event)
|
||||
m_rootId = m_treeCtrl->GetRootItem();
|
||||
|
||||
ExpandDir(parentId);
|
||||
if ( m_treeCtrl->GetChildrenCount(parentId, false) == 0 )
|
||||
{
|
||||
m_treeCtrl->SetItemHasChildren(parentId, false);
|
||||
}
|
||||
}
|
||||
|
||||
void wxGenericDirCtrl::OnCollapseItem(wxTreeEvent &event )
|
||||
@ -846,7 +850,7 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId)
|
||||
dirs.Sort(wxDirCtrlStringCompareFunction);
|
||||
|
||||
// Now do the filenames -- but only if we're allowed to
|
||||
if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0)
|
||||
if (!HasFlag(wxDIRCTRL_DIR_ONLY))
|
||||
{
|
||||
d.Open(dirName);
|
||||
|
||||
@ -893,20 +897,16 @@ void wxGenericDirCtrl::ExpandDir(wxTreeItemId parentId)
|
||||
m_treeCtrl->SetItemImage( id, wxFileIconsTable::folder_open,
|
||||
wxTreeItemIcon_Expanded );
|
||||
|
||||
// Has this got any children? If so, make it expandable.
|
||||
// (There are two situations when a dir has children: either it
|
||||
// has subdirectories or it contains files that weren't filtered
|
||||
// out. The latter only applies to dirctrl with files.)
|
||||
if ( dir_item->HasSubDirs() ||
|
||||
(((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0) &&
|
||||
dir_item->HasFiles(m_currentFilterStr)) )
|
||||
{
|
||||
m_treeCtrl->SetItemHasChildren(id);
|
||||
}
|
||||
// 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
|
||||
// the user really tries to open this item
|
||||
m_treeCtrl->SetItemHasChildren(id);
|
||||
}
|
||||
|
||||
// Add the sorted filenames
|
||||
if ((GetWindowStyle() & wxDIRCTRL_DIR_ONLY) == 0)
|
||||
if (!HasFlag(wxDIRCTRL_DIR_ONLY))
|
||||
{
|
||||
for (i = 0; i < filenames.GetCount(); i++)
|
||||
{
|
||||
@ -1021,7 +1021,7 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path)
|
||||
{
|
||||
m_treeCtrl->Expand(lastId);
|
||||
}
|
||||
if ((GetWindowStyle() & wxDIRCTRL_SELECT_FIRST) && data->m_isDir)
|
||||
if (HasFlag(wxDIRCTRL_SELECT_FIRST) && data->m_isDir)
|
||||
{
|
||||
// Find the first file in this directory
|
||||
wxTreeItemIdValue cookie;
|
||||
|
Loading…
Reference in New Issue
Block a user