Skip to content

Commit 035a541

Browse files
committed
Import: "Yes to All" to skip all further prompts
"Yes" to not be prompted next time for the same table, but yes for different tables. "Yes to All" to not be prompted again for any existent tables. See issue #2633
1 parent a686b85 commit 035a541

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

src/ImportCsvDialog.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -514,24 +514,32 @@ bool ImportCsvDialog::importCsv(const QString& fileName, const QString& name)
514514
tr("There is already a table named '%1' and an import into an existing table is only possible if the number of columns match.").arg(tableName));
515515
return true;
516516
} else {
517-
// Only ask whether to import into the existing table if the 'Yes all' button has not been clicked (yet)
518-
if(!dontAskForExistingTableAgain.contains(tableName))
517+
// Only ask whether to import into any table if the 'Yes to All' button has not been clicked (yet) (empty string is included).
518+
// Only ask whether to import into the existing table if the 'Yes' button has not been clicked (yet) for that table.
519+
if(!dontAskForExistingTableAgain.contains("") && !dontAskForExistingTableAgain.contains(tableName))
519520
{
520521
int answer = QMessageBox::question(this, QApplication::applicationName(),
521522
tr("There is already a table named '%1'. Do you want to import the data into it?").arg(tableName),
522523
QMessageBox::Yes | QMessageBox::No | QMessageBox::YesAll | QMessageBox::Cancel, QMessageBox::No);
523524

524525
// Stop now if the No button has been clicked
525-
if(answer == QMessageBox::No)
526+
switch (answer) {
527+
case QMessageBox::No:
526528
return true;
527-
529+
528530
// Stop now if the Cancel button has been clicked. But also indicate, that the entire import process should be stopped.
529-
if(answer == QMessageBox::Cancel)
531+
case QMessageBox::Cancel:
530532
return false;
531533

532-
// If the 'Yes all' button has been clicked, save that for later
533-
if(answer == QMessageBox::YesAll)
534+
// If the 'Yes' button has been clicked, save the answer for that table for later
535+
case QMessageBox::Yes:
534536
dontAskForExistingTableAgain.append(tableName);
537+
break;
538+
// If the 'Yes to All' button has been clicked, save the answer for any future table name. An empty string is used in that case.
539+
case QMessageBox::YesAll:
540+
dontAskForExistingTableAgain.append("");
541+
break;
542+
}
535543
}
536544

537545
// If we reached this point, this means that either the 'Yes' or the 'Yes all' button has been clicked or that no message box was shown at all

0 commit comments

Comments
 (0)