mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-17 01:09:36 -06:00
Allow undoing also the last SQL execution performed in Execute SQL tabs
Some clean-up of the code, so there is only references to the undo savepoint name in a single file. See issue #3345.
This commit is contained in:
@@ -1490,7 +1490,7 @@ void MainWindow::fileRevert()
|
||||
void MainWindow::undo()
|
||||
{
|
||||
if (db.isOpen()) {
|
||||
db.revertToSavepoint("DB4S_UNDO");
|
||||
db.revertToUndoSavepoint();
|
||||
refreshTableBrowsers();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1271,13 +1271,13 @@ You can drag SQL statements from the Schema column and drop them into the SQL ed
|
||||
<string>&Undo</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Undo last change to a cell in the browser</string>
|
||||
<string>Undo last change to the database</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Undo last change to a cell in the browser</string>
|
||||
<string>Undo last change to the database</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>This action is used to undo the last change performed to a cell in the database browser. Redoing is not possible.</string>
|
||||
<string>This action undoes the last change performed to the database in the Database Browser or in Execute SQL. Redoing is not possible.</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
|
||||
@@ -148,6 +148,9 @@ bool RunSql::executeNextStatement()
|
||||
// We have to start a transaction before we create the prepared statement otherwise every executed
|
||||
// statement will get committed after the prepared statement gets finalized
|
||||
releaseDbAccess();
|
||||
// Allow later undoing of this single execution with a non-unique savepoint.
|
||||
db.setUndoSavepoint();
|
||||
// And set the unique savepoint (if not already set) for the full current transaction.
|
||||
db.setSavepoint();
|
||||
acquireDbAccess();
|
||||
savepoint_created = true;
|
||||
|
||||
@@ -129,6 +129,10 @@ public:
|
||||
bool releaseAllSavepoints();
|
||||
bool revertAll();
|
||||
|
||||
// Set a non-unique savepoint for the general undoing mechanism (undoing only last write).
|
||||
bool setUndoSavepoint() { return setSavepoint("UNDOPOINT", /* unique */ false); };
|
||||
bool revertToUndoSavepoint() { return revertToSavepoint("UNDOPOINT"); };
|
||||
|
||||
bool dump(const QString& filename, const std::vector<std::string>& tablesToDump,
|
||||
bool insertColNames, bool insertNew, bool keepOriginal, bool exportSchema, bool exportData, bool keepOldSchema) const;
|
||||
|
||||
|
||||
@@ -484,7 +484,7 @@ bool SqliteTableModel::setTypedData(const QModelIndex& index, bool isBlob, const
|
||||
return false;
|
||||
}
|
||||
|
||||
m_db.setSavepoint("DB4S_UNDO", false);
|
||||
m_db.setUndoSavepoint();
|
||||
|
||||
if(index.isValid() && role == Qt::EditRole)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user