From ef399d17708be25d0d6c1cb90720e53cb08a4639 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 22 Jan 2017 12:17:01 +0100 Subject: [PATCH] Save foreign keys settings in the project files Save the value of the foreign keys PRAGMA in the project files and restore it when loading a project file. See issue #848. --- src/MainWindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 3c555aa1..3f0bb4c4 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1890,6 +1890,10 @@ bool MainWindow::loadProject(QString filename, bool readOnly) dbfilename = QFileInfo(filename).absolutePath() + QDir::separator() + dbfilename; fileOpen(dbfilename, true, readOnly); ui->dbTreeWidget->collapseAll(); + + // PRAGMAs + if(xml.attributes().hasAttribute("foreign_keys")) + db.setPragma("foreign_keys", xml.attributes().value("foreign_keys").toString()); } else if(xml.name() == "window") { // Window settings while(xml.readNext() != QXmlStreamReader::EndElement && xml.name() != "window") @@ -2015,6 +2019,7 @@ void MainWindow::saveProject() // Database file name xml.writeStartElement("db"); xml.writeAttribute("path", db.currentFile()); + xml.writeAttribute("foreign_keys", db.getPragma("foreign_keys")); xml.writeEndElement(); // Window settings