diff --git a/src/gui/confirm_dialog.hpp b/src/gui/confirm_dialog.hpp index 38a0044..1b930b1 100644 --- a/src/gui/confirm_dialog.hpp +++ b/src/gui/confirm_dialog.hpp @@ -19,7 +19,7 @@ class ConfirmDialog : public QDialog ~ConfirmDialog() override; static DialogCode display(QString const& title, QString const& question, - QString const& cards); + QString const& cards); private: std::unique_ptr ui; diff --git a/src/gui/database_editor_widget.cpp b/src/gui/database_editor_widget.cpp index ec90942..5e199a8 100644 --- a/src/gui/database_editor_widget.cpp +++ b/src/gui/database_editor_widget.cpp @@ -246,7 +246,7 @@ class FilteringHeader final : public QHeaderView w->setVisible(true); filters.push_back(w); connect(w, &QLineEdit::textEdited, this, - &FilteringHeader::updateTableFilters); + &FilteringHeader::updateTableFilters); } setRegexValidator(*filters[0], "[1-9][0-9]*"); connect(this, &FilteringHeader::sectionResized, this, @@ -433,7 +433,7 @@ DatabaseEditorWidget::DatabaseEditorWidget(QTabWidget& parent, db.setPassword(QString("%1").arg(pass, 0, 16)); } fillCardList(db); - QSqlQuery q(SQL_QUERY_FIRST_ROW_CODE, db); + auto q = buildQuery(db, SQL_QUERY_FIRST_ROW_CODE); execQuery(q); if(q.first()) updateUiWithCode(q.value(0).toUInt()); diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp index 81df9f6..f2f24d9 100644 --- a/src/gui/main_window.cpp +++ b/src/gui/main_window.cpp @@ -219,8 +219,6 @@ void MainWindow::newDatabase() auto db = QSqlDatabase::addDatabase(SQL_DB_DRIVER, file); db.setDatabaseName(file); setupCleanDatabase(db); - bool const isDbOpen = db.open(); - Q_ASSERT(isDbOpen); addTab(file); } @@ -240,7 +238,8 @@ void MainWindow::openDatabase() { auto verify_table = [&](const auto& query_and_result) { - auto q = db.exec(query_and_result[0]); + auto q = buildQuery(db, query_and_result[0]); + execQuery(q); auto record = q.record(); auto name_index = record.indexOf("name"); auto pk_index = record.indexOf("pk"); @@ -597,8 +596,10 @@ QSqlDatabase MainWindow::clipboardDatabase(bool clear) const Q_ASSERT(db.isValid()); if(clear) { - db.exec("DELETE FROM datas;"); - db.exec("DELETE FROM texts;"); + auto q1 = buildQuery(db, "DELETE FROM datas;"); + execQuery(q1); + auto q2 = buildQuery(db, "DELETE FROM texts;"); + execQuery(q2); } return db; } @@ -607,8 +608,12 @@ void MainWindow::setupCleanDatabase(QSqlDatabase& db) const { bool const isDbOpen = db.open(); Q_ASSERT(isDbOpen); - db.exec(SQL_QUERY_CREATE_DATAS_TABLE); - db.exec(SQL_QUERY_CREATE_TEXTS_TABLE); + auto q1 = buildQuery(db, "PRAGMA page_size = 4096;"); + execQuery(q1); + auto q2 = buildQuery(db, SQL_QUERY_CREATE_DATAS_TABLE); + execQuery(q2); + auto q3 = buildQuery(db, SQL_QUERY_CREATE_TEXTS_TABLE); + execQuery(q3); } void MainWindow::closeDatabaseImpl(int index, bool askForUnsavedData)