mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Add basic and shaky pragma editing
Since quite a few problems are fixed by now and the program is moving towards rudeimentary usability again it's time to add some new features and problems!
This commit is contained in:
@@ -81,6 +81,7 @@ MainWindow::MainWindow(QWidget* parent)
|
||||
setAcceptDrops(true);
|
||||
|
||||
(void)statusBar();
|
||||
activateFields(false);
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -166,6 +167,8 @@ void MainWindow::fileOpen(const QString & fileName)
|
||||
}
|
||||
populateStructure();
|
||||
resetBrowser();
|
||||
if(ui->mainTab->currentIndex() == 2)
|
||||
loadPragmas();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +325,7 @@ void MainWindow::fileClose()
|
||||
this->setWindowTitle(QApplication::applicationName());
|
||||
resetBrowser();
|
||||
populateStructure();
|
||||
loadPragmas();
|
||||
activateFields(false);
|
||||
}
|
||||
|
||||
@@ -895,6 +899,8 @@ void MainWindow::mainTabSelected(int tabindex)
|
||||
populateStructure();
|
||||
else if(tabindex == 1)
|
||||
resetBrowser();
|
||||
else if(tabindex == 2)
|
||||
loadPragmas();
|
||||
}
|
||||
|
||||
void MainWindow::importTableFromCSV()
|
||||
@@ -1316,6 +1322,12 @@ void MainWindow::activateFields(bool enable)
|
||||
ui->buttonNext->setEnabled(enable);
|
||||
ui->buttonPrevious->setEnabled(enable);
|
||||
ui->executeQueryButton->setEnabled(enable);
|
||||
ui->scrollareaPragmas->setEnabled(enable);
|
||||
ui->buttonGoto->setEnabled(enable);
|
||||
ui->editGoto->setEnabled(enable);
|
||||
ui->buttonRefresh->setEnabled(enable);
|
||||
ui->buttonDeleteRecord->setEnabled(enable);
|
||||
ui->buttonNewRecord->setEnabled(enable);
|
||||
}
|
||||
|
||||
void MainWindow::browseTableHeaderClicked(int logicalindex)
|
||||
@@ -1334,3 +1346,59 @@ void MainWindow::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
setRecordsetLabel();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
@@ -117,6 +117,8 @@ public slots:
|
||||
virtual void openPreferences();
|
||||
virtual void updatePreferences();
|
||||
virtual void openRecentFile();
|
||||
virtual void loadPragmas();
|
||||
virtual void savePragmas();
|
||||
|
||||
protected:
|
||||
DBBrowserDB db;
|
||||
|
||||
@@ -276,6 +276,549 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pragmas">
|
||||
<attribute name="title">
|
||||
<string>Edit &Pragmas</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollareaPragmas">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-165</y>
|
||||
<width>763</width>
|
||||
<height>653</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelPragmaAutoVacuum">
|
||||
<property name="text">
|
||||
<string>Auto Vacuum</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboboxPragmaAutoVacuum</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboboxPragmaAutoVacuum">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Full</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Incremental</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelPragmaAutomaticIndex">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>Automatic Index</p></body></html></string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaAutomaticIndex</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaAutomaticIndex">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelPragmaBusyTimeout">
|
||||
<property name="text">
|
||||
<string>Busy Timeout</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaBusyTimeout</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelPragmaCacheSize">
|
||||
<property name="text">
|
||||
<string>Cache Size</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaCacheSize</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelPragmaCheckpointFullFsync">
|
||||
<property name="text">
|
||||
<string>Checkpoint Full FSYNC</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaCheckpointFullFsync</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaCheckpointFullFsync">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelPragmaEncoding">
|
||||
<property name="text">
|
||||
<string>Encoding</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboboxPragmaEncoding</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="labelPragmaForeignKeys">
|
||||
<property name="text">
|
||||
<string>Foreign Keys</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaForeignKeys</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaForeignKeys">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="labelPragmaFullFsync">
|
||||
<property name="text">
|
||||
<string>Full FSYNC</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaFullFsync</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaFullFsync">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="labelPragmaIgnoreCheckConstraints">
|
||||
<property name="text">
|
||||
<string>Ignore Check Constraints</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaIgnoreCheckConstraints</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaIgnoreCheckConstraints">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="labelPragmaJournalMode">
|
||||
<property name="text">
|
||||
<string>Journal Mode</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboboxPragmaJournalMode</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QComboBox" name="comboboxPragmaJournalMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Truncate</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Persist</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Memory</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>WAL</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="labelJournalSizeLimit">
|
||||
<property name="text">
|
||||
<string>Journal Size Limit</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaJournalSizeLimit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="labelPragmaLegacyFileFormat">
|
||||
<property name="text">
|
||||
<string>Legacy File Format</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaLegacyFileFormat</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaLegacyFileFormat">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="labelPragmaLockingMode">
|
||||
<property name="text">
|
||||
<string>Locking Mode</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboboxPragmaLockingMode</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QComboBox" name="comboboxPragmaLockingMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Exclusive</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0">
|
||||
<widget class="QLabel" name="labelPragmaMaxPageCount">
|
||||
<property name="text">
|
||||
<string>Max Page Count</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaMaxPageCount</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="0">
|
||||
<widget class="QLabel" name="labelPragmaPageSize">
|
||||
<property name="text">
|
||||
<string>Page Size</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaPageSize</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="0">
|
||||
<widget class="QLabel" name="labelPragmaReadUncommitted">
|
||||
<property name="text">
|
||||
<string>Read Uncommitted</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaReadUncommitted</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="15" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaReadUncommitted">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="0">
|
||||
<widget class="QLabel" name="labelPragmaRecursiveTriggers">
|
||||
<property name="text">
|
||||
<string>Recursive Triggers</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaRecursiveTriggers</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="16" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaRecursiveTriggers">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="17" column="0">
|
||||
<widget class="QLabel" name="labelPragmaReverseUnorderedSelects">
|
||||
<property name="text">
|
||||
<string>Reverse Unordered Selects</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaReverseUnorderedSelects</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="17" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaReverseUnorderedSelects">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="0">
|
||||
<widget class="QLabel" name="labelPragmaSchemaVersion">
|
||||
<property name="text">
|
||||
<string>Schema Version</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaSchemaVersion</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="19" column="0">
|
||||
<widget class="QLabel" name="labelPragmaSecureDelete">
|
||||
<property name="text">
|
||||
<string>Secure Delete</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>checkboxPragmaSecureDelete</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="19" column="1">
|
||||
<widget class="QCheckBox" name="checkboxPragmaSecureDelete">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="20" column="0">
|
||||
<widget class="QLabel" name="labelPragmaSynchronous">
|
||||
<property name="text">
|
||||
<string>Synchronous</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboboxPragmaSynchronous</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="20" column="1">
|
||||
<widget class="QComboBox" name="comboboxPragmaSynchronous">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Off</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Full</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="21" column="0">
|
||||
<widget class="QLabel" name="labelPragmaTempStore">
|
||||
<property name="text">
|
||||
<string>Temp Store</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboboxPragmaTempStore</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="21" column="1">
|
||||
<widget class="QComboBox" name="comboboxPragmaTempStore">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>File</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Memory</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="22" column="0">
|
||||
<widget class="QLabel" name="labelPragmaUserVersion">
|
||||
<property name="text">
|
||||
<string>User Version</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaUserVersion</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="23" column="0">
|
||||
<widget class="QLabel" name="labelPragmaWalAutoCheckpoint">
|
||||
<property name="text">
|
||||
<string>WAL Auto Checkpoint</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>spinPragmaWalAutoCheckpoint</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaBusyTimeout">
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaCacheSize">
|
||||
<property name="minimum">
|
||||
<number>-100000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="comboboxPragmaEncoding">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>UTF-8</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>UTF-16</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>UTF-16le</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>UTF-16be</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaJournalSizeLimit">
|
||||
<property name="minimum">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaMaxPageCount">
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="14" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaPageSize">
|
||||
<property name="minimum">
|
||||
<number>512</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="18" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaSchemaVersion">
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="22" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaUserVersion">
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="23" column="1">
|
||||
<widget class="QSpinBox" name="spinPragmaWalAutoCheckpoint">
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="24" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBoxPragmas">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="query">
|
||||
<attribute name="title">
|
||||
<string>E&xecute SQL</string>
|
||||
@@ -874,6 +1417,32 @@
|
||||
<tabstop>executeQueryButton</tabstop>
|
||||
<tabstop>queryErrorLineEdit</tabstop>
|
||||
<tabstop>queryResultTableView</tabstop>
|
||||
<tabstop>scrollareaPragmas</tabstop>
|
||||
<tabstop>comboboxPragmaAutoVacuum</tabstop>
|
||||
<tabstop>checkboxPragmaAutomaticIndex</tabstop>
|
||||
<tabstop>spinPragmaBusyTimeout</tabstop>
|
||||
<tabstop>spinPragmaCacheSize</tabstop>
|
||||
<tabstop>checkboxPragmaCheckpointFullFsync</tabstop>
|
||||
<tabstop>comboboxPragmaEncoding</tabstop>
|
||||
<tabstop>checkboxPragmaForeignKeys</tabstop>
|
||||
<tabstop>checkboxPragmaFullFsync</tabstop>
|
||||
<tabstop>checkboxPragmaIgnoreCheckConstraints</tabstop>
|
||||
<tabstop>comboboxPragmaJournalMode</tabstop>
|
||||
<tabstop>spinPragmaJournalSizeLimit</tabstop>
|
||||
<tabstop>checkboxPragmaLegacyFileFormat</tabstop>
|
||||
<tabstop>comboboxPragmaLockingMode</tabstop>
|
||||
<tabstop>spinPragmaMaxPageCount</tabstop>
|
||||
<tabstop>spinPragmaPageSize</tabstop>
|
||||
<tabstop>checkboxPragmaReadUncommitted</tabstop>
|
||||
<tabstop>checkboxPragmaRecursiveTriggers</tabstop>
|
||||
<tabstop>checkboxPragmaReverseUnorderedSelects</tabstop>
|
||||
<tabstop>spinPragmaSchemaVersion</tabstop>
|
||||
<tabstop>checkboxPragmaSecureDelete</tabstop>
|
||||
<tabstop>comboboxPragmaSynchronous</tabstop>
|
||||
<tabstop>comboboxPragmaTempStore</tabstop>
|
||||
<tabstop>spinPragmaUserVersion</tabstop>
|
||||
<tabstop>spinPragmaWalAutoCheckpoint</tabstop>
|
||||
<tabstop>buttonBoxPragmas</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="icons/icons.qrc"/>
|
||||
@@ -1503,6 +2072,38 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBoxPragmas</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>loadPragmas()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>243</x>
|
||||
<y>551</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>470</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBoxPragmas</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>MainWindow</receiver>
|
||||
<slot>savePragmas()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>715</x>
|
||||
<y>550</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>802</x>
|
||||
<y>522</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>fileOpen()</slot>
|
||||
@@ -1543,5 +2144,7 @@
|
||||
<slot>fileNew()</slot>
|
||||
<slot>helpAbout()</slot>
|
||||
<slot>on_delete_field()</slot>
|
||||
<slot>loadPragmas()</slot>
|
||||
<slot>savePragmas()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
||||
115
src/sqlitedb.cpp
115
src/sqlitedb.cpp
@@ -778,7 +778,122 @@ QStringList DBBrowserDB::decodeCSV(const QString & csvfilename, char sep, char q
|
||||
return result;
|
||||
}
|
||||
|
||||
QString DBBrowserDB::getPragma(QString pragma)
|
||||
{
|
||||
if(!isOpen())
|
||||
return "";
|
||||
|
||||
QString sql = QString("PRAGMA %1").arg(pragma);
|
||||
sqlite3_stmt* vm;
|
||||
const char* tail;
|
||||
QString retval = "";
|
||||
|
||||
// Get value from DB
|
||||
int err = sqlite3_prepare(_db, sql.toStdString().c_str(), sql.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);
|
||||
} else {
|
||||
sqlite3_finalize(vm);
|
||||
qDebug("didn't receive any output from pragma %s", pragma.toStdString().c_str());
|
||||
}
|
||||
} else {
|
||||
qDebug ("could not execute pragma command: %d, %s", err, sqlite3_errmsg(_db));
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
qDebug("Error setting pragma %s to %s: %s", pragma.toStdString().c_str(), value.toStdString().c_str(), lastErrorMessage.toStdString().c_str());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,8 @@ 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);
|
||||
sqlite3 * _db;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user