diff --git a/src/EditTableDialog.cpp b/src/EditTableDialog.cpp
index 48ee674a..2648537d 100644
--- a/src/EditTableDialog.cpp
+++ b/src/EditTableDialog.cpp
@@ -40,10 +40,11 @@ EditTableDialog::EditTableDialog(DBBrowserDB& db, const QString& tableName, bool
m_table.setTemporary(obj.isTemporary());
ui->labelEditWarning->setVisible(!parse_result.second);
- // Set without rowid checkbox. No need to trigger any events here as we're only loading a table exactly as it is stored by SQLite, so no need
+ // Set without rowid and temporary checkboxex. No need to trigger any events here as we're only loading a table exactly as it is stored by SQLite, so no need
// for error checking etc.
ui->checkWithoutRowid->blockSignals(true);
ui->checkWithoutRowid->setChecked(m_table.isWithoutRowidTable());
+ ui->checkTemporary->setChecked(m_table.isTemporary());
ui->checkWithoutRowid->blockSignals(false);
populateFields();
@@ -716,6 +717,25 @@ void EditTableDialog::setWithoutRowid(bool without_rowid)
}
}
+void EditTableDialog::setTemporary(bool is_temp)
+{
+ // Set the temporary flag in the table definition
+ m_table.setTemporary(is_temp);
+
+ // Update the SQL preview
+ updateSqlText();
+
+ // Update table if we're editing an existing table
+ if(!m_bNewTable)
+ {
+ if(!pdb.renameColumn(curTable, m_table, QString(), sqlb::FieldPtr(), 0))
+ {
+ QMessageBox::warning(this, QApplication::applicationName(),
+ tr("Setting the temporary flag for the table failed. Error message:\n%1").arg(pdb.lastErrorMessage));
+ }
+ }
+}
+
bool EditTableDialog::fieldNameExists(const QString& name)
{
foreach(const sqlb::FieldPtr& ptr, m_table.fields())
diff --git a/src/EditTableDialog.h b/src/EditTableDialog.h
index 33f7bc21..15829ba9 100644
--- a/src/EditTableDialog.h
+++ b/src/EditTableDialog.h
@@ -58,6 +58,7 @@ private slots:
void moveUp();
void moveDown();
void setWithoutRowid(bool without_rowid);
+ void setTemporary(bool is_temp);
private:
Ui::EditTableDialog* ui;
diff --git a/src/EditTableDialog.ui b/src/EditTableDialog.ui
index 5e58d1f7..ecaf0eb2 100644
--- a/src/EditTableDialog.ui
+++ b/src/EditTableDialog.ui
@@ -66,6 +66,16 @@
+ -
+
+
+ Set this to create a temporary table that is deleted when closing the database.
+
+
+ Temporary table
+
+
+
@@ -322,6 +332,7 @@
editTableName
buttonMore
checkWithoutRowid
+ checkTemporary
addFieldButton
removeFieldButton
buttonMoveUp
@@ -388,8 +399,8 @@
addField()
- 79
- 203
+ 94
+ 253
79
@@ -404,8 +415,8 @@
removeField()
- 232
- 203
+ 222
+ 253
249
@@ -436,8 +447,8 @@
moveUp()
- 356
- 203
+ 343
+ 253
308
@@ -452,8 +463,8 @@
moveDown()
- 497
- 203
+ 481
+ 253
308
@@ -472,8 +483,8 @@
78
- 103
- 98
+ 117
+ 176
@@ -484,8 +495,8 @@
setWithoutRowid(bool)
- 324
- 113
+ 344
+ 143
324
@@ -509,6 +520,22 @@
+
+ checkTemporary
+ toggled(bool)
+ EditTableDialog
+ setTemporary(bool)
+
+
+ 186
+ 155
+
+
+ 647
+ 157
+
+
+
fieldSelectionChanged()
@@ -520,5 +547,6 @@
moveUp()
moveDown()
setWithoutRowid(bool)
+ setTemporary(bool)
diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp
index c74cee05..973d4170 100644
--- a/src/sqlitedb.cpp
+++ b/src/sqlitedb.cpp
@@ -1026,6 +1026,7 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const sqlb::Table& tabl
newSchema.setName("sqlitebrowser_rename_column_new_table");
newSchema.setConstraints(table.allConstraints());
newSchema.setRowidColumn(table.rowidColumn());
+ newSchema.setTemporary(table.isTemporary());
QString select_cols;
if(to.isNull())
{