@@ -2297,6 +2297,8 @@ static void buildSupportedVectorFileFilter_( QString & fileFilters )
2297
2297
the current working directory if this is the first time invoked
2298
2298
with the current filter name.
2299
2299
2300
+ This method returns true if cancel all was clicked, otherwise false
2301
+
2300
2302
*/
2301
2303
2302
2304
static bool openFilesRememberingFilter_ ( QString const &filterName,
@@ -2317,7 +2319,34 @@ static bool openFilesRememberingFilter_( QString const &filterName,
2317
2319
QString lastUsedDir = settings.value ( " /UI/" + filterName + " Dir" , " ." ).toString ();
2318
2320
2319
2321
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
+
2321
2350
if ( !selectedFiles.isEmpty () )
2322
2351
{
2323
2352
// Fix by Tim - getting the dirPath from the dialog
@@ -2331,7 +2360,6 @@ static bool openFilesRememberingFilter_( QString const &filterName,
2331
2360
2332
2361
settings.setValue ( " /UI/" + filterName, lastUsedFilter );
2333
2362
settings.setValue ( " /UI/" + filterName + " Dir" , myPath );
2334
- return true ;
2335
2363
}
2336
2364
return false ;
2337
2365
} // openFilesRememberingFilter_
0 commit comments