add a foreign key setting

to open database with foreign keys enabled
This commit is contained in:
Peinthor Rene
2013-01-29 18:26:29 +01:00
parent 9c9e1a61f3
commit f8e51cc07a
4 changed files with 58 additions and 3 deletions

View File

@@ -6,6 +6,7 @@
#include <QProgressDialog>
#include <QApplication>
#include <QTextStream>
#include <QSettings>
void DBBrowserObject::addField(int order, const QString& wfield,const QString& wtype)
{
@@ -97,6 +98,12 @@ bool DBBrowserDB::open ( const QString & db)
}
if (_db){
// set preference defaults
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
settings.sync();
bool foreignkeys = settings.value( "/db/foreignkeys", false ).toBool();
setPragma("foreign_keys", foreignkeys ? "1" : "0");
if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA empty_result_callbacks = ON;",
NULL,NULL,NULL)){
if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA show_datatypes = ON;",