Change some function parameters with negated name

Change some function parameters which are named like "dont..." to make a
positive statement. This should hopefully avoid some confisions with
double negation.
This commit is contained in:
Martin Kleusberg
2021-01-22 17:52:32 +01:00
parent 06200bfb44
commit e54664dd03
12 changed files with 29 additions and 29 deletions
+6 -6
View File
@@ -106,7 +106,7 @@ Application::Application(int& argc, char** argv) :
std::vector<QString> tableToBrowse;
QStringList sqlToExecute;
bool readOnly = false;
m_dontShowMainWindow = false;
m_showMainWindow = true;
for(int i=1;i<arguments().size();i++)
{
// Check next command line argument
@@ -130,10 +130,10 @@ Application::Application(int& argc, char** argv) :
qWarning() << qPrintable(tr(" -v, --version Display the current version"));
qWarning() << qPrintable(tr(" <database> Open this SQLite database"));
qWarning() << qPrintable(tr(" <project> Open this project file (*.sqbpro)"));
m_dontShowMainWindow = true;
m_showMainWindow = false;
} else if(arguments().at(i) == "-v" || arguments().at(i) == "--version") {
qWarning() << qPrintable(versionInformation());
m_dontShowMainWindow = true;
m_showMainWindow = false;
} else if(arguments().at(i) == "-s" || arguments().at(i) == "--sql") {
// Run SQL file: If file exists add it to list of scripts to execute
if(++i >= arguments().size())
@@ -148,7 +148,7 @@ Application::Application(int& argc, char** argv) :
else
tableToBrowse.push_back(arguments().at(i));
} else if(arguments().at(i) == "-q" || arguments().at(i) == "--quit") {
m_dontShowMainWindow = true;
m_showMainWindow = false;
} else if(arguments().at(i) == "-R" || arguments().at(i) == "--read-only") {
readOnly = true;
} else if(arguments().at(i) == "-S" || arguments().at(i) == "--settings") {
@@ -177,7 +177,7 @@ Application::Application(int& argc, char** argv) :
value = option.at(1).split(",");
else
value = option.at(1);
Settings::setValue(setting.at(0).toStdString(), setting.at(1).toStdString(), value, !saveToDisk);
Settings::setValue(setting.at(0).toStdString(), setting.at(1).toStdString(), value, saveToDisk);
}
}
}
@@ -190,7 +190,7 @@ Application::Application(int& argc, char** argv) :
}
}
if(m_dontShowMainWindow) {
if(!m_showMainWindow) {
m_mainWindow = nullptr;
return;
}
+2 -2
View File
@@ -17,7 +17,7 @@ public:
explicit Application(int& argc, char** argv);
~Application() override;
bool dontShowMainWindow() const { return m_dontShowMainWindow; }
bool showMainWindow() const { return m_showMainWindow; }
MainWindow* mainWindow() { return m_mainWindow; }
@@ -32,7 +32,7 @@ protected:
bool event(QEvent* event) override;
private:
bool m_dontShowMainWindow;
bool m_showMainWindow;
MainWindow* m_mainWindow;
QTranslator* m_translatorQt;
QTranslator* m_translatorApp;
+1 -1
View File
@@ -70,7 +70,7 @@ void FileDialog::setFileDialogPath(const FileDialogTypes dialogType, const QStri
Settings::setValue("db", "lastlocations", lastLocations);
break;
case 2: // Remember last location for current session only
Settings::setValue("db", "lastlocations", lastLocations, true);
Settings::setValue("db", "lastlocations", lastLocations, false);
break;
case 1: // Always use this locations
break; // Do nothing
+2 -2
View File
@@ -2791,7 +2791,7 @@ bool MainWindow::loadProject(QString filename, bool readOnly)
"it completely, please use DB Browser for SQLite version 3.12 to convert it to the new file format."));
msgBox.exec();
if(msgBox.clickedButton() == idontcarebutton)
Settings::setValue("idontcare", "projectBrowseTable", true);
Settings::setValue("idontcare", "projectBrowseTable", false);
}
xml.skipCurrentElement();
@@ -3334,7 +3334,7 @@ void MainWindow::requestCollation(const QString& name, int eTextRep)
// Cancel here if the No button was clicked
if(msgbox.clickedButton() == button_dont_ask_again)
{
Settings::setValue("db", "dont_ask_collation", true);
Settings::setValue("db", "dont_ask_collation", false);
} else if(reply == QMessageBox::No) {
return;
}
+2 -2
View File
@@ -104,11 +104,11 @@ QVariant Settings::getValue(const std::string& group, const std::string& name)
}
}
void Settings::setValue(const std::string& group, const std::string& name, const QVariant& value, bool dont_save_to_disk)
void Settings::setValue(const std::string& group, const std::string& name, const QVariant& value, bool save_to_disk)
{
// Sometime the value has to be saved for the current session only but get discarded when the application exits.
// In order to achieve this this flag can be set which disables the save to disk mechanism and only leaves the save to cache part active.
if(dont_save_to_disk == false)
if(save_to_disk == false)
{
setSettingsObject();
// Set the group and save the given value
+1 -1
View File
@@ -17,7 +17,7 @@ public:
static void setUserSettingsFile(const QString& userSettingsFileArg);
static QVariant getValue(const std::string& group, const std::string& name);
static void setValue(const std::string& group, const std::string& name, const QVariant& value, bool dont_save_to_disk = false);
static void setValue(const std::string& group, const std::string& name, const QVariant& value, bool save_to_disk = true);
static void clearValue(const std::string& group, const std::string& name);
static void restoreDefaults();
+2 -2
View File
@@ -44,10 +44,10 @@ SqlExecutionArea::SqlExecutionArea(DBBrowserDB& _db, QWidget* parent) :
// Save to settings when sppliter is moved, but only to memory.
connect(ui->splitter, &QSplitter::splitterMoved, this, [this]() {
Settings::setValue("editor", "splitter1_sizes", ui->splitter->saveState(), /* dont_save_to_disk */ true);
Settings::setValue("editor", "splitter1_sizes", ui->splitter->saveState(), /* save_to_disk */ false);
});
connect(ui->splitter_2, &QSplitter::splitterMoved, this, [this]() {
Settings::setValue("editor", "splitter2_sizes", ui->splitter_2->saveState(), /* dont_save_to_disk */ true);
Settings::setValue("editor", "splitter2_sizes", ui->splitter_2->saveState(), /* save_to_disk */ false);
});
// Set collapsible the editErrors panel
+1 -1
View File
@@ -56,7 +56,7 @@ int main( int argc, char ** argv )
}
// Quit application now if user doesn't want to see the UI
if(a.dontShowMainWindow())
if(!a.showMainWindow())
return 0;
qInstallMessageHandler(db4sMessageOutput);
+4 -4
View File
@@ -99,7 +99,7 @@ DBBrowserDB::DBBrowserDB() :
db_used(false),
isEncrypted(false),
isReadOnly(false),
dontCheckForStructureUpdates(false)
disableStructureUpdateChecks(false)
{
// Register error log callback. This needs to be done before SQLite is first used
Callback<void(void*, int, const char*)>::func = std::bind(&DBBrowserDB::errorLogCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
@@ -183,7 +183,7 @@ bool DBBrowserDB::open(const QString& db, bool readOnly)
if (isOpen()) close();
isEncrypted = false;
dontCheckForStructureUpdates = false;
disableStructureUpdateChecks = false;
// Get encryption settings for database file
CipherSettings* cipherSettings = nullptr;
@@ -1086,7 +1086,7 @@ bool DBBrowserDB::executeSQL(const std::string& statement, bool dirtyDB, bool lo
if (SQLITE_OK == sqlite3_exec(_db, statement.c_str(), callback ? callbackWrapper : nullptr, &callback, &errmsg))
{
// Update DB structure after executing an SQL statement. But try to avoid doing unnecessary updates.
if(!dontCheckForStructureUpdates && (starts_with_ci(statement, "ALTER") ||
if(!disableStructureUpdateChecks && (starts_with_ci(statement, "ALTER") ||
starts_with_ci(statement, "CREATE") ||
starts_with_ci(statement, "DROP") ||
starts_with_ci(statement, "ROLLBACK")))
@@ -1186,7 +1186,7 @@ bool DBBrowserDB::executeMultiSQL(QByteArray query, bool dirty, bool log)
}
// Check whether the DB structure is changed by this statement
if(!dontCheckForStructureUpdates && !structure_updated)
if(!disableStructureUpdateChecks && !structure_updated)
{
// Check if it's a modifying statement
if(next_statement.compare(0, 5, "ALTER") == 0 ||
+3 -3
View File
@@ -284,13 +284,13 @@ private:
bool tryEncryptionSettings(const QString& filename, bool* encrypted, CipherSettings*& cipherSettings) const;
bool dontCheckForStructureUpdates;
bool disableStructureUpdateChecks;
class NoStructureUpdateChecks
{
public:
explicit NoStructureUpdateChecks(DBBrowserDB& db) : m_db(db) { m_db.dontCheckForStructureUpdates = true; }
~NoStructureUpdateChecks() { m_db.dontCheckForStructureUpdates = false; }
explicit NoStructureUpdateChecks(DBBrowserDB& db) : m_db(db) { m_db.disableStructureUpdateChecks = true; }
~NoStructureUpdateChecks() { m_db.disableStructureUpdateChecks = false; }
private:
DBBrowserDB& m_db;
+4 -4
View File
@@ -171,10 +171,10 @@ void SqliteTableModel::setQuery(const sqlb::Query& query)
buildQuery();
}
void SqliteTableModel::setQuery(const QString& sQuery, const QString& sCountQuery, bool dontClearHeaders)
void SqliteTableModel::setQuery(const QString& sQuery, const QString& sCountQuery, bool clearHeaders)
{
// clear
if(!dontClearHeaders)
if(clearHeaders)
reset();
else
clearCache();
@@ -187,7 +187,7 @@ void SqliteTableModel::setQuery(const QString& sQuery, const QString& sCountQuer
worker->setQuery(m_sQuery, sCountQuery);
if(!dontClearHeaders)
if(clearHeaders)
{
auto columns = getColumns(worker->getDb(), sQuery.toStdString(), m_vDataTypes);
m_headers.insert(m_headers.end(), columns.begin(), columns.end());
@@ -730,7 +730,7 @@ QModelIndex SqliteTableModel::dittoRecord(int old_row)
void SqliteTableModel::buildQuery()
{
setQuery(QString::fromStdString(m_query.buildQuery(true)), QString::fromStdString(m_query.buildCountQuery()), true);
setQuery(QString::fromStdString(m_query.buildQuery(true)), QString::fromStdString(m_query.buildCountQuery()), false);
}
void SqliteTableModel::removeCommentsFromQuery(QString& query)
+1 -1
View File
@@ -80,7 +80,7 @@ public:
QModelIndex dittoRecord(int old_row);
/// configure for browsing results of specified query
void setQuery(const QString& sQuery, const QString& sCountQuery = QString(), bool dontClearHeaders = false);
void setQuery(const QString& sQuery, const QString& sCountQuery = QString(), bool clearHeaders = true);
std::string query() const { return m_sQuery.toStdString(); }
std::string customQuery(bool withRowid) const { return m_query.buildQuery(withRowid); }