X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5276b0a53cef4815230e39b54d2ecda14f72cbd1..65fe93d8a500833e0acd3ff64161b85a204b8dbf:/src/generic/dirctrlg.cpp diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 46b72cf08a..dbaaf19a54 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -1095,6 +1095,22 @@ bool wxGenericDirCtrl::CollapsePath(const wxString& path) wxString wxGenericDirCtrl::GetPath() const { + // Allow calling GetPath() in multiple selection from OnSelFilter + if (m_treeCtrl->HasFlag(wxTR_MULTIPLE)) + { + wxArrayTreeItemIds items; + m_treeCtrl->GetSelections(items); + if (items.size() > 0) + { + // return first string only + wxTreeItemId id = items[0]; + wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(id); + return data->m_path; + } + + return wxEmptyString; + } + wxTreeItemId id = m_treeCtrl->GetSelection(); if (id) { @@ -1379,16 +1395,33 @@ void wxDirFilterListCtrl::OnSelFilter(wxCommandEvent& WXUNUSED(event)) { int sel = GetSelection(); - wxString currentPath = m_dirCtrl->GetPath(); + if (m_dirCtrl->HasFlag(wxDIRCTRL_MULTIPLE)) + { + wxArrayString paths; + m_dirCtrl->GetPaths(paths); + + m_dirCtrl->SetFilterIndex(sel); - m_dirCtrl->SetFilterIndex(sel); + // If the filter has changed, the view is out of date, so + // collapse the tree. + m_dirCtrl->ReCreateTree(); - // If the filter has changed, the view is out of date, so - // collapse the tree. - m_dirCtrl->ReCreateTree(); + // Expand and select the previously selected paths + for (unsigned int i = 0; i < paths.GetCount(); i++) + { + m_dirCtrl->ExpandPath(paths.Item(i)); + } + } + else + { + wxString currentPath = m_dirCtrl->GetPath(); - // Try to restore the selection, or at least the directory - m_dirCtrl->ExpandPath(currentPath); + m_dirCtrl->SetFilterIndex(sel); + m_dirCtrl->ReCreateTree(); + + // Try to restore the selection, or at least the directory + m_dirCtrl->ExpandPath(currentPath); + } } void wxDirFilterListCtrl::FillFilterList(const wxString& filter, int defaultFilter)