mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-25 08:54:19 +08:00
Fix handling filters in wxFileDialog in wxOSX
As allowedTypes were restricted to the first filter expression, choosing another filter only showed the files conforming to both expressions instead of only applying the selected filter. This commit is best viewed ignoring whitespace-only changes. Fixes wxWidgets/Phoenix/issues#2806 Closes #25918. Closes #25922.
This commit is contained in:
committed by
Vadim Zeitlin
parent
f5e4a3e230
commit
b153aafee9
+23
-21
@@ -260,7 +260,7 @@ void wxFileDialog::ShowWindowModal()
|
||||
|
||||
wxCHECK_RET(parentWindow, "Window modal display requires parent.");
|
||||
|
||||
NSArray* types = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions, m_currentExtensions ) ;
|
||||
NSArray* allTypes = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions, m_currentExtensions ) ;
|
||||
|
||||
m_useFileTypeFilter = m_filterExtensions.GetCount() > 1;
|
||||
|
||||
@@ -286,7 +286,6 @@ void wxFileDialog::ShowWindowModal()
|
||||
else if ( m_useFileTypeFilter )
|
||||
{
|
||||
m_firstFileTypeFilter = GetMatchingFilterExtension(m_fileName);
|
||||
types = GetTypesFromExtension(m_filterExtensions[m_firstFileTypeFilter], m_currentExtensions);
|
||||
}
|
||||
|
||||
if ( HasFlag(wxFD_SAVE) )
|
||||
@@ -302,7 +301,7 @@ void wxFileDialog::ShowWindowModal()
|
||||
// be able to pass this in
|
||||
[sPanel setTreatsFilePackagesAsDirectories:NO];
|
||||
[sPanel setCanSelectHiddenExtension:YES];
|
||||
[sPanel setAllowedFileTypes:types];
|
||||
[sPanel setAllowedFileTypes:allTypes];
|
||||
[sPanel setAllowsOtherFileTypes:NO];
|
||||
[sPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||
|
||||
@@ -316,14 +315,17 @@ void wxFileDialog::ShowWindowModal()
|
||||
*/
|
||||
if(m_firstFileTypeFilter > 0)
|
||||
{
|
||||
DoOnFilterSelected(m_firstFileTypeFilter);
|
||||
DoOnFilterSelected(m_firstFileTypeFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_delegate )
|
||||
[(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
||||
else
|
||||
[sPanel setAllowedFileTypes: types];
|
||||
NSArray* types = GetTypesFromExtension(m_filterExtensions[m_firstFileTypeFilter], m_currentExtensions);
|
||||
if ( m_delegate )
|
||||
[(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
||||
else
|
||||
{
|
||||
[sPanel setAllowedFileTypes: types];
|
||||
}
|
||||
}
|
||||
|
||||
NSWindow* nativeParent = parentWindow->GetWXWindow();
|
||||
@@ -351,7 +353,7 @@ void wxFileDialog::ShowWindowModal()
|
||||
[oPanel setCanChooseFiles:YES];
|
||||
[oPanel setMessage:cf.AsNSString()];
|
||||
[oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
|
||||
[oPanel setAllowedFileTypes:types];
|
||||
[oPanel setAllowedFileTypes:allTypes];
|
||||
[oPanel setAllowsOtherFileTypes:NO];
|
||||
[oPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||
|
||||
@@ -367,8 +369,6 @@ void wxFileDialog::ShowWindowModal()
|
||||
{
|
||||
if ( m_delegate )
|
||||
[(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
||||
else
|
||||
[oPanel setAllowedFileTypes: types];
|
||||
}
|
||||
|
||||
NSWindow* nativeParent = parentWindow->GetWXWindow();
|
||||
@@ -463,7 +463,9 @@ void wxFileDialog::DoOnFilterSelected(int index)
|
||||
[panel validateVisibleColumns];
|
||||
}
|
||||
else
|
||||
{
|
||||
[panel setAllowedFileTypes:types];
|
||||
}
|
||||
|
||||
m_currentlySelectedFilterIndex = index;
|
||||
|
||||
@@ -578,7 +580,7 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
int returnCode = -1;
|
||||
|
||||
NSArray* types = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions, m_currentExtensions ) ;
|
||||
NSArray* allTypes = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions, m_currentExtensions ) ;
|
||||
|
||||
m_useFileTypeFilter = m_filterExtensions.GetCount() > 1;
|
||||
|
||||
@@ -604,7 +606,6 @@ int wxFileDialog::ShowModal()
|
||||
else if ( m_useFileTypeFilter )
|
||||
{
|
||||
m_firstFileTypeFilter = GetMatchingFilterExtension(m_fileName);
|
||||
types = GetTypesFromExtension(m_filterExtensions[m_firstFileTypeFilter], m_currentExtensions);
|
||||
}
|
||||
|
||||
OSXBeginModalDialog();
|
||||
@@ -622,7 +623,7 @@ int wxFileDialog::ShowModal()
|
||||
// be able to pass this in
|
||||
[sPanel setTreatsFilePackagesAsDirectories:NO];
|
||||
[sPanel setCanSelectHiddenExtension:YES];
|
||||
[sPanel setAllowedFileTypes:types];
|
||||
[sPanel setAllowedFileTypes:allTypes];
|
||||
[sPanel setAllowsOtherFileTypes:NO];
|
||||
[sPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||
|
||||
@@ -644,10 +645,11 @@ int wxFileDialog::ShowModal()
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( m_delegate )
|
||||
[(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
||||
else
|
||||
[sPanel setAllowedFileTypes: types];
|
||||
NSArray* types = GetTypesFromExtension(m_filterExtensions[m_firstFileTypeFilter], m_currentExtensions);
|
||||
if ( m_delegate )
|
||||
[(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
||||
else
|
||||
[sPanel setAllowedFileTypes: types];
|
||||
}
|
||||
|
||||
if ( !m_dir.IsEmpty() )
|
||||
@@ -676,7 +678,7 @@ int wxFileDialog::ShowModal()
|
||||
[oPanel setCanChooseFiles:YES];
|
||||
[oPanel setMessage:cf.AsNSString()];
|
||||
[oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
|
||||
[oPanel setAllowedFileTypes:types];
|
||||
[oPanel setAllowedFileTypes:allTypes];
|
||||
[oPanel setAllowsOtherFileTypes:NO];
|
||||
[oPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||
|
||||
@@ -692,9 +694,9 @@ int wxFileDialog::ShowModal()
|
||||
{
|
||||
if ( m_delegate )
|
||||
[(wxOpenSavePanelDelegate*) m_delegate setAllowedExtensions: m_currentExtensions];
|
||||
else
|
||||
[oPanel setAllowedFileTypes: types];
|
||||
}
|
||||
|
||||
|
||||
if ( !m_dir.IsEmpty() )
|
||||
[oPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString()
|
||||
isDirectory:YES]];
|
||||
|
||||
Reference in New Issue
Block a user