diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 6b424f00..5762422e 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1065,6 +1065,7 @@ void MainWindow::activateFields(bool enable) ui->buttonPrevious->setEnabled(enable); ui->executeQueryButton->setEnabled(enable); ui->scrollAreaWidgetContents->setEnabled(enable); + ui->buttonBoxPragmas->setEnabled(enable); ui->buttonGoto->setEnabled(enable); ui->editGoto->setEnabled(enable); ui->buttonRefresh->setEnabled(enable); @@ -1091,58 +1092,77 @@ void MainWindow::resizeEvent(QResizeEvent*) void MainWindow::loadPragmas() { - ui->comboboxPragmaAutoVacuum->setCurrentIndex(db.getPragma("auto_vacuum").toInt()); - ui->checkboxPragmaAutomaticIndex->setChecked(db.getPragma("automatic_index").toInt()); - ui->spinPragmaBusyTimeout->setValue(db.getPragma("busy_timeout").toInt()); - ui->spinPragmaCacheSize->setValue(db.getPragma("cache_size").toInt()); - ui->checkboxPragmaCheckpointFullFsync->setChecked(db.getPragma("checkpoint_fullfsync").toInt()); - ui->comboboxPragmaEncoding->setCurrentIndex(db.getPragma("encoding").toInt()); - ui->checkboxPragmaForeignKeys->setChecked(db.getPragma("foreign_keys").toInt()); - ui->checkboxPragmaFullFsync->setChecked(db.getPragma("fullfsync").toInt()); - ui->checkboxPragmaIgnoreCheckConstraints->setChecked(db.getPragma("ignore_check_constraints").toInt()); - ui->comboboxPragmaJournalMode->setCurrentIndex(db.getPragma("journal_mode").toInt()); - ui->spinPragmaJournalSizeLimit->setValue(db.getPragma("journal_size_limit").toInt()); - ui->checkboxPragmaLegacyFileFormat->setChecked(db.getPragma("legacy_file_format").toInt()); - ui->comboboxPragmaLockingMode->setCurrentIndex(db.getPragma("locking_mode").toInt()); - ui->spinPragmaMaxPageCount->setValue(db.getPragma("max_page_count").toInt()); - ui->spinPragmaPageSize->setValue(db.getPragma("page_size").toInt()); - ui->checkboxPragmaReadUncommitted->setChecked(db.getPragma("read_uncommitted").toInt()); - ui->checkboxPragmaRecursiveTriggers->setChecked(db.getPragma("recursive_triggers").toInt()); - ui->checkboxPragmaReverseUnorderedSelects->setChecked(db.getPragma("reverse_unordered_selects").toInt()); - ui->spinPragmaSchemaVersion->setValue(db.getPragma("schema_version").toInt()); - ui->checkboxPragmaSecureDelete->setChecked(db.getPragma("secure_delete").toInt()); - ui->comboboxPragmaSynchronous->setCurrentIndex(db.getPragma("synchronous").toInt()); - ui->comboboxPragmaTempStore->setCurrentIndex(db.getPragma("temp_store").toInt()); - ui->spinPragmaUserVersion->setValue(db.getPragma("user_version").toInt()); - ui->spinPragmaWalAutoCheckpoint->setValue(db.getPragma("wal_autocheckpoint").toInt()); + pragmaValues.autovacuum = db.getPragma("auto_vacuum").toInt(); + pragmaValues.automatic_index = db.getPragma("automatic_index").toInt(); + pragmaValues.checkpoint_fullsync = db.getPragma("checkpoint_fullfsync").toInt(); + pragmaValues.foreign_keys = db.getPragma("foreign_keys").toInt(); + pragmaValues.fullfsync = db.getPragma("fullfsync").toInt(); + pragmaValues.ignore_check_constraints = db.getPragma("ignore_check_constraints").toInt(); + pragmaValues.journal_mode = db.getPragma("journal_mode").toUpper(); + pragmaValues.journal_size_limit = db.getPragma("journal_size_limit").toInt(); + pragmaValues.locking_mode = db.getPragma("locking_mode").toUpper(); + pragmaValues.max_page_count = db.getPragma("max_page_count").toInt(); + pragmaValues.page_size = db.getPragma("page_size").toInt(); + pragmaValues.recursive_triggers = db.getPragma("recursive_triggers").toInt(); + pragmaValues.secure_delete = db.getPragma("secure_delete").toInt(); + pragmaValues.synchronous = db.getPragma("synchronous").toInt(); + pragmaValues.temp_store = db.getPragma("temp_store").toInt(); + pragmaValues.user_version = db.getPragma("user_version").toInt(); + pragmaValues.wal_autocheckpoint = db.getPragma("wal_autocheckpoint").toInt(); + + updatePragmaUi(); +} + +void MainWindow::updatePragmaUi() +{ + ui->comboboxPragmaAutoVacuum->setCurrentIndex(pragmaValues.autovacuum); + ui->checkboxPragmaAutomaticIndex->setChecked(pragmaValues.automatic_index); + ui->checkboxPragmaCheckpointFullFsync->setChecked(pragmaValues.checkpoint_fullsync); + ui->checkboxPragmaForeignKeys->setChecked(pragmaValues.foreign_keys); + ui->checkboxPragmaFullFsync->setChecked(pragmaValues.fullfsync); + ui->checkboxPragmaIgnoreCheckConstraints->setChecked(pragmaValues.ignore_check_constraints); + ui->comboboxPragmaJournalMode->setCurrentIndex(ui->comboboxPragmaJournalMode->findText(pragmaValues.journal_mode, Qt::MatchFixedString)); + ui->spinPragmaJournalSizeLimit->setValue(pragmaValues.journal_size_limit); + ui->comboboxPragmaLockingMode->setCurrentIndex(ui->comboboxPragmaLockingMode->findText(pragmaValues.locking_mode, Qt::MatchFixedString)); + ui->spinPragmaMaxPageCount->setValue(pragmaValues.max_page_count); + ui->spinPragmaPageSize->setValue(pragmaValues.page_size); + ui->checkboxPragmaRecursiveTriggers->setChecked(pragmaValues.recursive_triggers); + ui->checkboxPragmaSecureDelete->setChecked(pragmaValues.secure_delete); + ui->comboboxPragmaSynchronous->setCurrentIndex(pragmaValues.synchronous); + ui->comboboxPragmaTempStore->setCurrentIndex(pragmaValues.temp_store); + ui->spinPragmaUserVersion->setValue(pragmaValues.user_version); + ui->spinPragmaWalAutoCheckpoint->setValue(pragmaValues.wal_autocheckpoint); } void MainWindow::savePragmas() { - db.setPragma("auto_vacuum", QString::number(ui->comboboxPragmaAutoVacuum->currentIndex())); - db.setPragma("automatic_index", QString::number(ui->checkboxPragmaAutomaticIndex->isChecked())); - db.setPragma("busy_timeout", QString::number(ui->spinPragmaBusyTimeout->value())); - db.setPragma("cache_size", QString::number(ui->spinPragmaCacheSize->value())); - db.setPragma("checkpoint_fullfsync", QString::number(ui->checkboxPragmaCheckpointFullFsync->isChecked())); - db.setPragma("encoding", QString::number(ui->comboboxPragmaEncoding->currentIndex())); - db.setPragma("foreign_keys", QString::number(ui->checkboxPragmaForeignKeys->isChecked())); - db.setPragma("fullfsync", QString::number(ui->checkboxPragmaFullFsync->isChecked())); - db.setPragma("ignore_check_constraints", QString::number(ui->checkboxPragmaIgnoreCheckConstraints->isChecked())); - db.setPragma("journal_mode", QString::number(ui->comboboxPragmaJournalMode->currentIndex())); - db.setPragma("journal_size_limit", QString::number(ui->spinPragmaJournalSizeLimit->value())); - db.setPragma("legacy_file_format", QString::number(ui->checkboxPragmaLegacyFileFormat->isChecked())); - db.setPragma("locking_mode", QString::number(ui->comboboxPragmaLockingMode->currentIndex())); - db.setPragma("max_page_count", QString::number(ui->spinPragmaMaxPageCount->value())); - db.setPragma("page_size", QString::number(ui->spinPragmaPageSize->value())); - db.setPragma("read_uncommitted", QString::number(ui->checkboxPragmaReadUncommitted->isChecked())); - db.setPragma("recursive_triggers", QString::number(ui->checkboxPragmaRecursiveTriggers->isChecked())); - db.setPragma("reverse_unordered_selects", QString::number(ui->checkboxPragmaReverseUnorderedSelects->isChecked())); - db.setPragma("schema_version", QString::number(ui->spinPragmaSchemaVersion->value())); - db.setPragma("secure_delete", QString::number(ui->checkboxPragmaSecureDelete->isChecked())); - db.setPragma("synchronous", QString::number(ui->comboboxPragmaSynchronous->currentIndex())); - db.setPragma("temp_store", QString::number(ui->comboboxPragmaTempStore->currentIndex())); - db.setPragma("user_version", QString::number(ui->spinPragmaUserVersion->value())); - db.setPragma("wal_autocheckpoint", QString::number(ui->spinPragmaWalAutoCheckpoint->value())); + if( db.getDirty() ) + { + QString msg = tr("Setting PRAGMA values will commit your current transaction.\nAre you sure?"); + if(QMessageBox::question(this, QApplication::applicationName(), msg, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape) == QMessageBox::No) + { + return; // abort + } + } + db.setPragma("auto_vacuum", ui->comboboxPragmaAutoVacuum->currentIndex(), pragmaValues.autovacuum); + db.setPragma("automatic_index", ui->checkboxPragmaAutomaticIndex->isChecked(), pragmaValues.automatic_index); + db.setPragma("checkpoint_fullfsync", ui->checkboxPragmaCheckpointFullFsync->isChecked(), pragmaValues.checkpoint_fullsync); + db.setPragma("foreign_keys", ui->checkboxPragmaForeignKeys->isChecked(), pragmaValues.foreign_keys); + db.setPragma("fullfsync", ui->checkboxPragmaFullFsync->isChecked(), pragmaValues.fullfsync); + db.setPragma("ignore_check_constraints", ui->checkboxPragmaIgnoreCheckConstraints->isChecked(), pragmaValues.ignore_check_constraints); + db.setPragma("journal_mode", ui->comboboxPragmaJournalMode->currentText().toUpper(), pragmaValues.journal_mode); + db.setPragma("journal_size_limit", ui->spinPragmaJournalSizeLimit->value(), pragmaValues.journal_size_limit); + db.setPragma("locking_mode", ui->comboboxPragmaLockingMode->currentText().toUpper(), pragmaValues.locking_mode); + db.setPragma("max_page_count", ui->spinPragmaMaxPageCount->value(), pragmaValues.max_page_count); + db.setPragma("page_size", ui->spinPragmaPageSize->value(), pragmaValues.page_size); + db.setPragma("recursive_triggers", ui->checkboxPragmaRecursiveTriggers->isChecked(), pragmaValues.recursive_triggers); + db.setPragma("secure_delete", ui->checkboxPragmaSecureDelete->isChecked(), pragmaValues.secure_delete); + db.setPragma("synchronous", ui->comboboxPragmaSynchronous->currentIndex(), pragmaValues.synchronous); + db.setPragma("temp_store", ui->comboboxPragmaTempStore->currentIndex(), pragmaValues.temp_store); + db.setPragma("user_version", ui->spinPragmaUserVersion->value(), pragmaValues.user_version); + db.setPragma("wal_autocheckpoint", ui->spinPragmaWalAutoCheckpoint->value(), pragmaValues.wal_autocheckpoint); + + updatePragmaUi(); } void MainWindow::logSql(const QString& sql, int msgtype) diff --git a/src/MainWindow.h b/src/MainWindow.h index 4018bc6c..daab7c85 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -27,6 +27,27 @@ public: ~MainWindow(); private: + struct PragmaValues + { + int autovacuum; + int automatic_index; + int checkpoint_fullsync; + int foreign_keys; + int fullfsync; + int ignore_check_constraints; + QString journal_mode; + int journal_size_limit; + QString locking_mode; + int max_page_count; + int page_size; + int recursive_triggers; + int secure_delete; + int synchronous; + int temp_store; + int user_version; + int wal_autocheckpoint; + } pragmaValues; + Ui::MainWindow* ui; QStandardItemModel *queryResultListModel; @@ -116,6 +137,7 @@ private slots: virtual void updatePreferences(); virtual void openRecentFile(); virtual void loadPragmas(); + virtual void updatePragmaUi(); virtual void savePragmas(); virtual void mainTabSelected( int tabindex ); virtual void browseTableHeaderClicked(int logicalindex); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 451c561d..d73e1a22 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -19,7 +19,7 @@ - 0 + 2 @@ -303,9 +303,9 @@ 0 - 0 + -182 763 - 653 + 524 @@ -315,7 +315,13 @@ - Auto Vacuum + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_auto_vacuum"><span style=" text-decoration: underline; color:#0000ff;">Auto Vacuum</span></a></p></body></html> + + + true + + + Qt::LinksAccessibleByMouse comboboxPragmaAutoVacuum @@ -344,7 +350,10 @@ - <html><head/><body><p>Automatic Index</p></body></html> + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_automatic_index"><span style=" text-decoration: underline; color:#0000ff;">Automatic Index</span></a></p></body></html> + + + true checkboxPragmaAutomaticIndex @@ -359,114 +368,99 @@ - - - Busy Timeout - - - spinPragmaBusyTimeout - - - - - - - Cache Size - - - spinPragmaCacheSize - - - - - Checkpoint Full FSYNC + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_checkpoint_fullfsync"><span style=" text-decoration: underline; color:#0000ff;">Checkpoint Full FSYNC</span></a></p></body></html> + + + true checkboxPragmaCheckpointFullFsync - + - - - - Encoding - - - comboboxPragmaEncoding - - - - + - Foreign Keys + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_foreign_keys"><span style=" text-decoration: underline; color:#0000ff;">Foreign Keys</span></a></p></body></html> + + + true checkboxPragmaForeignKeys - + - + - Full FSYNC + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_fullfsync"><span style=" text-decoration: underline; color:#0000ff;">Full FSYNC</span></a></p></body></html> + + + true checkboxPragmaFullFsync - + - + - Ignore Check Constraints + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_ignore_check_constraints"><span style=" text-decoration: underline; color:#0000ff;">Ignore Check Constraints</span></a></p></body></html> + + + true checkboxPragmaIgnoreCheckConstraints - + - + - Journal Mode + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_journal_mode"><span style=" text-decoration: underline; color:#0000ff;">Journal Mode</span></a></p></body></html> + + + true comboboxPragmaJournalMode - + @@ -500,44 +494,43 @@ - + - Journal Size Limit + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_journal_size_limit"><span style=" text-decoration: underline; color:#0000ff;">Journal Size Limit</span></a></p></body></html> + + + true spinPragmaJournalSizeLimit - - - - Legacy File Format + + + + -1 - - checkboxPragmaLegacyFileFormat + + 100000 - - - - - - - - + - Locking Mode + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_locking_mode"><span style=" text-decoration: underline; color:#0000ff;">Locking Mode</span></a></p></body></html> + + + true comboboxPragmaLockingMode - + @@ -551,115 +544,103 @@ - + - Max Page Count + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_max_page_count"><span style=" text-decoration: underline; color:#0000ff;">Max Page Count</span></a></p></body></html> + + + true spinPragmaMaxPageCount - + + + + 2000000000 + + + + - Page Size + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_page_size"><span style=" text-decoration: underline; color:#0000ff;">Page Size</span></a></p></body></html> + + + true spinPragmaPageSize - - - - Read Uncommitted + + + + 512 - - checkboxPragmaReadUncommitted + + 65536 - - - - - - - - + - Recursive Triggers + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_recursive_triggers"><span style=" text-decoration: underline; color:#0000ff;">Recursive Triggers</span></a></p></body></html> + + + true checkboxPragmaRecursiveTriggers - + - - - - Reverse Unordered Selects - - - checkboxPragmaReverseUnorderedSelects - - - - - - - - - - - - - - Schema Version - - - spinPragmaSchemaVersion - - - - + - Secure Delete + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_secure_delete"><span style=" text-decoration: underline; color:#0000ff;">Secure Delete</span></a></p></body></html> + + + true checkboxPragmaSecureDelete - + - + - Synchronous + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_synchronous"><span style=" text-decoration: underline; color:#0000ff;">Synchronous</span></a></p></body></html> + + + true comboboxPragmaSynchronous - + @@ -678,17 +659,20 @@ - + - Temp Store + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_temp_store"><span style=" text-decoration: underline; color:#0000ff;">Temp Store</span></a></p></body></html> + + + true comboboxPragmaTempStore - + @@ -707,129 +691,60 @@ - + - User Version + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_schema_version"><span style=" text-decoration: underline; color:#0000ff;">User Version</span></a></p></body></html> + + + true spinPragmaUserVersion - - - - WAL Auto Checkpoint - - - spinPragmaWalAutoCheckpoint - - - - - - - 10000 - - - - - - - -100000 - - - 100000 - - - - - - - - UTF-8 - - - - - UTF-16 - - - - - UTF-16le - - - - - UTF-16be - - - - - - - - -1 - - - 100000 - - - - - - - 2000000000 - - - - - - - 512 - - - 65536 - - - - - - - 10000 - - - - + 10000 - + + + + <html><head/><body><p><a href="http://www.sqlite.org/pragma.html#pragma_wal_autocheckpoint"><span style=" text-decoration: underline; color:#0000ff;">WAL Auto Checkpoint</span></a></p></body></html> + + + true + + + spinPragmaWalAutoCheckpoint + + + + 10000 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Save - - - false - - - + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + false + + + @@ -943,7 +858,7 @@ 0 0 800 - 20 + 23 @@ -1485,29 +1400,21 @@ scrollareaPragmas comboboxPragmaAutoVacuum checkboxPragmaAutomaticIndex - spinPragmaBusyTimeout - spinPragmaCacheSize checkboxPragmaCheckpointFullFsync - comboboxPragmaEncoding checkboxPragmaForeignKeys checkboxPragmaFullFsync checkboxPragmaIgnoreCheckConstraints comboboxPragmaJournalMode spinPragmaJournalSizeLimit - checkboxPragmaLegacyFileFormat comboboxPragmaLockingMode spinPragmaMaxPageCount spinPragmaPageSize - checkboxPragmaReadUncommitted checkboxPragmaRecursiveTriggers - checkboxPragmaReverseUnorderedSelects - spinPragmaSchemaVersion checkboxPragmaSecureDelete comboboxPragmaSynchronous comboboxPragmaTempStore spinPragmaUserVersion spinPragmaWalAutoCheckpoint - buttonBoxPragmas comboLogSubmittedBy buttonLogClear diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index b04fc189..534c21fc 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -1014,7 +1014,7 @@ QStringList DBBrowserDB::decodeCSV(const QString & csvfilename, char sep, char q return result; } -QString DBBrowserDB::getPragma(QString pragma) +QString DBBrowserDB::getPragma(const QString& pragma) { if(!isOpen()) return ""; @@ -1025,111 +1025,63 @@ QString DBBrowserDB::getPragma(QString pragma) QString retval = ""; // Get value from DB - int err = sqlite3_prepare(_db, sql.toStdString().c_str(), sql.length(), &vm, &tail); + int err = sqlite3_prepare(_db, sql.toUtf8(), sql.toUtf8().length(), &vm, &tail); if(err == SQLITE_OK){ logSQL(sql, kLogMsg_App); if(sqlite3_step(vm) == SQLITE_ROW) { retval = QString((const char *) sqlite3_column_text(vm, 0)); - sqlite3_finalize(vm); + //qDebug((pragma + ": " + retval).toStdString().c_str()); } else { - sqlite3_finalize(vm); qDebug(QObject::tr("didn't receive any output from pragma %1").arg(pragma).toStdString().c_str()); } + sqlite3_finalize(vm); } else { qDebug(QObject::tr("could not execute pragma command: %1, %2").arg(err).arg(sqlite3_errmsg(_db)).toStdString().c_str()); } - // Make changes to the value when needed - if(pragma == "journal_mode") - { - retval = retval.toLower(); - if(retval == "delete") - retval = "0"; - else if(retval == "truncate") - retval = "1"; - else if(retval == "persist") - retval = "2"; - else if(retval == "memory") - retval = "3"; - else if(retval == "wal") - retval = "4"; - else if(retval == "off") - retval = "5"; - else - retval = "0"; - } else if(pragma == "locking_mode") { - retval = retval.toLower(); - if(retval == "normal") - retval = "0"; - else if(retval == "exclusive") - retval = "1"; - else - retval = "0"; - } else if(pragma == "encoding") { - retval = retval.toLower(); - if(retval == "utf-8") - retval = "0"; - else if(retval == "utf-16") - retval = "1"; - else if(retval == "utf-16le") - retval = "2"; - else if(retval == "utf-16be") - retval = "3"; - else - retval = "0"; - } - // Return it return retval; } -bool DBBrowserDB::setPragma(QString pragma, QString value) +bool DBBrowserDB::setPragma(const QString& pragma, const QString& value) { - // Make changes to the value when needed - if(pragma == "journal_mode") - { - if(value == "0") - value = "\"delete\""; - else if(value == "1") - value = "\"truncate\""; - else if(value == "2") - value = "\"persist\""; - else if(value == "3") - value = "\"memory\""; - else if(value == "4") - value = "\"wal\""; - else if(value == "5") - value = "\"off\""; - else - value = "\"delete\""; - } else if(value == "locking_mode") { - if(value == "0") - value = "\"normal\""; - else if(value == "1") - value = "\"exclusive\""; - else - value = "\"normal\""; - } else if(pragma == "encoding") { - if(value == "0") - value = "\"utf-8\""; - else if(value == "1") - value = "\"utf-16\""; - else if(value == "2") - value = "\"utf-16le\""; - else if(value == "3") - value = "\"utf-16be\""; - else - value = "\"utf-8\""; - } - // Set the pragma value - QString sql = QString("PRAGMA %1 = %2;").arg(pragma).arg(value); - if(!executeSQL(sql)) - { + QString sql = QString("PRAGMA %1 = \"%2\";").arg(pragma).arg(value); + //qDebug(sql.toStdString().c_str()); + + setDirty(false); + executeSQL("COMMIT;", false, false); // commit the current transaction + bool res = executeSQL(sql, false, true); // PRAGMA statements are usually not transaction bound, so we can't revert + setRestorePoint(); + if( !res ) qDebug(QObject::tr("Error setting pragma %1 to %2: %3").arg(pragma).arg(value).arg(lastErrorMessage).toStdString().c_str()); - return false; - } else { - return true; - } + return res; +} + +bool DBBrowserDB::setPragma(const QString& pragma, const QString& value, QString& originalvalue) +{ + if( originalvalue != value ) + { + if( setPragma(pragma, value)) + { + originalvalue = value; + return true; + } + } + return false; +} + +bool DBBrowserDB::setPragma(const QString& pragma, int value, int& originalvalue) +{ + if( originalvalue != value ) + { + QString val = QString::number(value); + QString origval = QString::number(originalvalue); + if( setPragma(pragma, val, origval)) + { + originalvalue = value; + } + } + return false; } diff --git a/src/sqlitedb.h b/src/sqlitedb.h index 96f1f9cb..cbef39f1 100644 --- a/src/sqlitedb.h +++ b/src/sqlitedb.h @@ -122,8 +122,10 @@ public: char * GetEncodedQStringAsPointer( const QString & input); QString GetEncodedQString( const QString & input); QString GetDecodedQString( const QString & input); - QString getPragma(QString pragma); - bool setPragma(QString pragma, QString value); + QString getPragma(const QString& pragma); + bool setPragma(const QString& pragma, const QString& value); + bool setPragma(const QString& pragma, const QString& value, QString& originalvalue); + bool setPragma(const QString& pragma, int value, int& originalvalue); sqlite3 * _db;