diff --git a/src/EditTableDialog.cpp b/src/EditTableDialog.cpp index 8968ba13..bd84cf02 100644 --- a/src/EditTableDialog.cpp +++ b/src/EditTableDialog.cpp @@ -107,7 +107,6 @@ void EditTableDialog::accept() if(m_bNewTable) { // Creation of new table - // we commit immediatly so no need to setdirty if(!pdb->executeSQL(m_table.sql())) { QMessageBox::warning( diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 5f38a785..d84c019c 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -20,16 +20,9 @@ bool DBBrowserDB::isOpen ( ) const return _db!=0; } -void DBBrowserDB::setDirty(bool dirtyval) -{ - dirty = dirtyval; - if(mainWindow) - mainWindow->dbState(dirtyval); -} - bool DBBrowserDB::getDirty() const { - return dirty; + return !savepointList.empty(); } bool DBBrowserDB::open ( const QString & db) @@ -77,7 +70,6 @@ bool DBBrowserDB::open ( const QString & db) if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA show_datatypes = ON;", NULL,NULL,NULL)){ ok=true; - setDirty(false); } curDBFilename = db; } @@ -101,7 +93,7 @@ bool DBBrowserDB::setRestorePoint(const QString& pointname) QString query = QString("SAVEPOINT %1;").arg(pointname); sqlite3_exec(_db, query.toUtf8(), NULL, NULL, NULL); savepointList.append(pointname); - setDirty(true); + if(mainWindow) mainWindow->dbState(getDirty()); } return true; } @@ -116,7 +108,7 @@ bool DBBrowserDB::save(const QString& pointname) QString query = QString("RELEASE %1;").arg(pointname); sqlite3_exec(_db, query.toUtf8(), NULL,NULL,NULL); savepointList.removeAll(pointname); - setDirty(!savepointList.empty()); + if(mainWindow) mainWindow->dbState(getDirty()); } return true; } @@ -133,7 +125,7 @@ bool DBBrowserDB::revert(const QString& pointname) query = QString("RELEASE %1;").arg(pointname); sqlite3_exec(_db, query.toUtf8(), NULL, NULL, NULL); savepointList.removeAll(pointname); - setDirty(!savepointList.empty()); + if(mainWindow) mainWindow->dbState(getDirty()); } return true; } @@ -191,7 +183,6 @@ bool DBBrowserDB::create ( const QString & db) if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA show_datatypes = ON;", NULL,NULL,NULL)){ ok=true; - setDirty(false); } curDBFilename = db; } @@ -223,6 +214,7 @@ void DBBrowserDB::close (){ _db = 0; objMap.clear(); savepointList.clear(); + if(mainWindow) mainWindow->dbState(getDirty()); } bool DBBrowserDB::dump(const QString& filename) diff --git a/src/sqlitedb.h b/src/sqlitedb.h index 0ba25d7b..3b5c9a85 100644 --- a/src/sqlitedb.h +++ b/src/sqlitedb.h @@ -101,7 +101,6 @@ public: objectMap getBrowsableObjects() const; DBBrowserObject getObjectByName(const QString& name) const; bool isOpen() const; - void setDirty(bool dirtyval); bool getDirty() const; void logSQL(const QString& statement, int msgtype); @@ -123,9 +122,8 @@ public: MainWindow* mainWindow; - QStringList savepointList; private: - bool dirty; + QStringList savepointList; }; #endif