From e0b40ad90e585efb9594b290582a97d090f493da Mon Sep 17 00:00:00 2001 From: mgrojo Date: Sun, 20 Dec 2020 14:58:27 +0100 Subject: [PATCH] CSV Import: fixes of the local convention option Added default value for new setting. Avoid second call to ui->checkLocalConventions->isChecked(). See issue #2140. --- src/ImportCsvDialog.cpp | 7 +++---- src/Settings.cpp | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ImportCsvDialog.cpp b/src/ImportCsvDialog.cpp index ca12e85c..bfaa5569 100644 --- a/src/ImportCsvDialog.cpp +++ b/src/ImportCsvDialog.cpp @@ -655,14 +655,13 @@ bool ImportCsvDialog::importCsv(const QString& fileName, const QString& name) // This is a non-empty value, or we want to insert the empty string. Just add it to the statement. bool convert_ok = false; if(ui->checkLocalConventions->isChecked()) { - // Find the correct data type taken into account the locale. + // Find the correct data type taking into account the locale. QString content = QString::fromUtf8(rowData.fields[i].data, static_cast(rowData.fields[i].data_length)); - const QLocale &locale = ui->checkLocalConventions->isChecked() ? QLocale::system() : QLocale::c(); - sqlite_int64 int64_value = locale.toLongLong(content, &convert_ok); + sqlite_int64 int64_value = QLocale::system().toLongLong(content, &convert_ok); if(convert_ok) { sqlite3_bind_int64(stmt, static_cast(i)+1, int64_value); } else { - double value = locale.toDouble(content, &convert_ok); + double value = QLocale::system().toDouble(content, &convert_ok); if(convert_ok) sqlite3_bind_double(stmt, static_cast(i)+1, value); } diff --git a/src/Settings.cpp b/src/Settings.cpp index 249de44a..ceed5570 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -186,6 +186,8 @@ QVariant Settings::getDefaultValue(const std::string& group, const std::string& return '"'; if(name == "encoding") return "UTF-8"; + if(name == "localconventions") + return false; } // exportsql group?