Skip to content

Commit 34f0f6f

Browse files
author
mhugent
committed
Use non-native dialog in case the cancel all dialog is needed. Fixes bug #1317
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11808 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 178065b commit 34f0f6f

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/app/qgisapp.cpp

+30-2
Original file line numberDiff line numberDiff line change
@@ -2297,6 +2297,8 @@ static void buildSupportedVectorFileFilter_( QString & fileFilters )
22972297
the current working directory if this is the first time invoked
22982298
with the current filter name.
22992299
2300+
This method returns true if cancel all was clicked, otherwise false
2301+
23002302
*/
23012303

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

23192321
QgsDebugMsg( "Opening file dialog with filters: " + filters );
2320-
selectedFiles = QFileDialog::getOpenFileNames( 0, title, lastUsedDir, filters, &lastUsedFilter );
2322+
if ( !cancelAll )
2323+
{
2324+
selectedFiles = QFileDialog::getOpenFileNames( 0, title, lastUsedDir, filters, &lastUsedFilter );
2325+
}
2326+
else //we have to use non-native dialog to add cancel all button
2327+
{
2328+
QgsEncodingFileDialog* openFileDialog = new QgsEncodingFileDialog( 0, title, lastUsedDir, filters, QString( "" ) );
2329+
// allow for selection of more than one file
2330+
openFileDialog->setFileMode( QFileDialog::ExistingFiles );
2331+
if ( haveLastUsedFilter ) // set the filter to the last one used
2332+
{
2333+
openFileDialog->selectFilter( lastUsedFilter );
2334+
}
2335+
openFileDialog->addCancelAll();
2336+
if ( openFileDialog->exec() == QDialog::Accepted )
2337+
{
2338+
selectedFiles = openFileDialog->selectedFiles();
2339+
}
2340+
else
2341+
{
2342+
//cancel or cancel all?
2343+
if ( openFileDialog->cancelAll() )
2344+
{
2345+
return true;
2346+
}
2347+
}
2348+
}
2349+
23212350
if ( !selectedFiles.isEmpty() )
23222351
{
23232352
// Fix by Tim - getting the dirPath from the dialog
@@ -2331,7 +2360,6 @@ static bool openFilesRememberingFilter_( QString const &filterName,
23312360

23322361
settings.setValue( "/UI/" + filterName, lastUsedFilter );
23332362
settings.setValue( "/UI/" + filterName + "Dir", myPath );
2334-
return true;
23352363
}
23362364
return false;
23372365
} // openFilesRememberingFilter_

0 commit comments

Comments
 (0)