mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 10:20:17 -06:00
DBBrowserDB: Remove the dirty flag
Remove the dirty flag as it is no longer needed. Because we track the savepoints currently held open we can just use that list to see wether there are changes to be committed. So there is no need to track this in a separate variable.
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user