mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-09 13:18:33 -06:00
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
This commit is contained in:
@@ -514,24 +514,32 @@ bool ImportCsvDialog::importCsv(const QString& fileName, const QString& name)
|
||||
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));
|
||||
return true;
|
||||
} else {
|
||||
// Only ask whether to import into the existing table if the 'Yes all' button has not been clicked (yet)
|
||||
if(!dontAskForExistingTableAgain.contains(tableName))
|
||||
// Only ask whether to import into any table if the 'Yes to All' button has not been clicked (yet) (empty string is included).
|
||||
// Only ask whether to import into the existing table if the 'Yes' button has not been clicked (yet) for that table.
|
||||
if(!dontAskForExistingTableAgain.contains("") && !dontAskForExistingTableAgain.contains(tableName))
|
||||
{
|
||||
int answer = QMessageBox::question(this, QApplication::applicationName(),
|
||||
tr("There is already a table named '%1'. Do you want to import the data into it?").arg(tableName),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::YesAll | QMessageBox::Cancel, QMessageBox::No);
|
||||
|
||||
// Stop now if the No button has been clicked
|
||||
if(answer == QMessageBox::No)
|
||||
switch (answer) {
|
||||
case QMessageBox::No:
|
||||
return true;
|
||||
|
||||
|
||||
// Stop now if the Cancel button has been clicked. But also indicate, that the entire import process should be stopped.
|
||||
if(answer == QMessageBox::Cancel)
|
||||
case QMessageBox::Cancel:
|
||||
return false;
|
||||
|
||||
// If the 'Yes all' button has been clicked, save that for later
|
||||
if(answer == QMessageBox::YesAll)
|
||||
// If the 'Yes' button has been clicked, save the answer for that table for later
|
||||
case QMessageBox::Yes:
|
||||
dontAskForExistingTableAgain.append(tableName);
|
||||
break;
|
||||
// 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.
|
||||
case QMessageBox::YesAll:
|
||||
dontAskForExistingTableAgain.append("");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user