Skip to content

Commit

Permalink
Use non-native dialog in case the cancel all dialog is needed. Fixes …
Browse files Browse the repository at this point in the history
…bug #1317

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11808 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Oct 15, 2009
1 parent 178065b commit 34f0f6f
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -2297,6 +2297,8 @@ static void buildSupportedVectorFileFilter_( QString & fileFilters )
the current working directory if this is the first time invoked the current working directory if this is the first time invoked
with the current filter name. with the current filter name.
This method returns true if cancel all was clicked, otherwise false
*/ */


static bool openFilesRememberingFilter_( QString const &filterName, static bool openFilesRememberingFilter_( QString const &filterName,
Expand All @@ -2317,7 +2319,34 @@ static bool openFilesRememberingFilter_( QString const &filterName,
QString lastUsedDir = settings.value( "/UI/" + filterName + "Dir", "." ).toString(); QString lastUsedDir = settings.value( "/UI/" + filterName + "Dir", "." ).toString();


QgsDebugMsg( "Opening file dialog with filters: " + filters ); QgsDebugMsg( "Opening file dialog with filters: " + filters );
selectedFiles = QFileDialog::getOpenFileNames( 0, title, lastUsedDir, filters, &lastUsedFilter ); if ( !cancelAll )
{
selectedFiles = QFileDialog::getOpenFileNames( 0, title, lastUsedDir, filters, &lastUsedFilter );
}
else //we have to use non-native dialog to add cancel all button
{
QgsEncodingFileDialog* openFileDialog = new QgsEncodingFileDialog( 0, title, lastUsedDir, filters, QString( "" ) );
// allow for selection of more than one file
openFileDialog->setFileMode( QFileDialog::ExistingFiles );
if ( haveLastUsedFilter ) // set the filter to the last one used
{
openFileDialog->selectFilter( lastUsedFilter );
}
openFileDialog->addCancelAll();
if ( openFileDialog->exec() == QDialog::Accepted )
{
selectedFiles = openFileDialog->selectedFiles();
}
else
{
//cancel or cancel all?
if ( openFileDialog->cancelAll() )
{
return true;
}
}
}

if ( !selectedFiles.isEmpty() ) if ( !selectedFiles.isEmpty() )
{ {
// Fix by Tim - getting the dirPath from the dialog // Fix by Tim - getting the dirPath from the dialog
Expand All @@ -2331,7 +2360,6 @@ static bool openFilesRememberingFilter_( QString const &filterName,


settings.setValue( "/UI/" + filterName, lastUsedFilter ); settings.setValue( "/UI/" + filterName, lastUsedFilter );
settings.setValue( "/UI/" + filterName + "Dir", myPath ); settings.setValue( "/UI/" + filterName + "Dir", myPath );
return true;
} }
return false; return false;
} // openFilesRememberingFilter_ } // openFilesRememberingFilter_
Expand Down

0 comments on commit 34f0f6f

Please sign in to comment.