diff --git a/src/EditTableDialog.cpp b/src/EditTableDialog.cpp
index 295c116c..94ed88db 100644
--- a/src/EditTableDialog.cpp
+++ b/src/EditTableDialog.cpp
@@ -20,6 +20,7 @@ EditTableDialog::EditTableDialog(DBBrowserDB* db, const QString& tableName, QWid
{
// Create UI
ui->setupUi(this);
+ ui->widgetExtension->setVisible(false);
connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*,int)),this,SLOT(itemChanged(QTreeWidgetItem*,int)));
m_sqliteSyntaxHighlighter = new SQLiteSyntaxHighlighter(ui->sqlTextEdit->document());
@@ -32,6 +33,7 @@ EditTableDialog::EditTableDialog(DBBrowserDB* db, const QString& tableName, QWid
// Existing table, so load and set the current layout
QString sTablesql = pdb->getObjectByName(curTable).getsql();
m_table = sqlb::Table::parseSQL(sTablesql).first;
+ ui->checkWithoutRowid->setChecked(m_table.isWithoutRowidTable());
populateFields();
}
@@ -490,3 +492,33 @@ void EditTableDialog::moveCurrentField(bool down)
// Update the SQL preview
updateSqlText();
}
+
+void EditTableDialog::setWithoutRowid(bool without_rowid)
+{
+ if(without_rowid)
+ {
+ // Before setting the without rowid flag, first perform a check to see if the table meets all thr required criteria for without rowid tables
+ int pk = m_table.findPk();
+ if(pk == -1 || m_table.fields().at(pk)->isInteger() == false || m_table.fields().at(pk)->autoIncrement())
+ {
+ QMessageBox::information(this, QApplication::applicationName(),
+ tr("Please add a field which meets the following criteria before setting the without rowid flag:\n"
+ " - Primary key flag set\n"
+ " - Auto incremenct disabled\n"
+ " - Type INTEGER"));
+ ui->checkWithoutRowid->setChecked(false);
+ return;
+ }
+
+ // If it does, override the the rowid column name of the table object with the name of the primary key.
+ m_table.setRowidColumn(m_table.fields().at(pk)->name());
+ } else {
+ // If the without rowid flag is unset no further checks are required. Just set the rowid column name back to "_rowid_"
+ m_table.setRowidColumn("_rowid_");
+ }
+
+ // Update the SQL preview
+ updateSqlText();
+
+ // TODO: Update table if we're editing an existing table
+}
diff --git a/src/EditTableDialog.h b/src/EditTableDialog.h
index 7769caf2..e4b10418 100644
--- a/src/EditTableDialog.h
+++ b/src/EditTableDialog.h
@@ -50,6 +50,7 @@ private slots:
virtual void updateTypes();
virtual void moveUp();
virtual void moveDown();
+ virtual void setWithoutRowid(bool without_rowid);
private:
Ui::EditTableDialog* ui;
diff --git a/src/EditTableDialog.ui b/src/EditTableDialog.ui
index ea2fefe1..ae99f514 100644
--- a/src/EditTableDialog.ui
+++ b/src/EditTableDialog.ui
@@ -37,6 +37,38 @@
+ -
+
+
+ Advanced
+
+
+ true
+
+
+ Qt::ToolButtonTextBesideIcon
+
+
+ Qt::DownArrow
+
+
+
+ -
+
+
+
-
+
+
+ Make this a 'WITHOUT rowid' table. Setting this flag requires a field of type INTEGER with the primary key flag set and the auto increment flag unset.
+
+
+ Without Rowid
+
+
+
+
+
+
@@ -265,9 +297,14 @@
editTableName
+ buttonMore
+ checkWithoutRowid
addFieldButton
removeFieldButton
- buttonBox
+ buttonMoveUp
+ buttonMoveDown
+ treeWidget
+ sqlTextEdit
@@ -280,8 +317,8 @@
accept()
- 252
- 400
+ 261
+ 590
157
@@ -296,8 +333,8 @@
reject()
- 320
- 400
+ 329
+ 590
286
@@ -312,8 +349,8 @@
fieldSelectionChanged()
- 116
- 193
+ 137
+ 367
411
@@ -328,8 +365,8 @@
addField()
- 57
- 106
+ 79
+ 203
79
@@ -344,8 +381,8 @@
removeField()
- 276
- 111
+ 232
+ 203
249
@@ -376,8 +413,8 @@
moveUp()
- 282
- 107
+ 356
+ 203
308
@@ -392,8 +429,8 @@
moveDown()
- 413
- 107
+ 497
+ 203
308
@@ -401,6 +438,38 @@
+
+ buttonMore
+ toggled(bool)
+ widgetExtension
+ setVisible(bool)
+
+
+ 97
+ 78
+
+
+ 103
+ 98
+
+
+
+
+ checkWithoutRowid
+ toggled(bool)
+ EditTableDialog
+ setWithoutRowid(bool)
+
+
+ 324
+ 113
+
+
+ 324
+ 299
+
+
+
fieldSelectionChanged()
@@ -411,5 +480,6 @@
itemChanged()
moveUp()
moveDown()
+ setWithoutRowid(bool)