From 32778491211ec007334db8d1cbafda1079403b0c Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Thu, 6 Nov 2014 18:33:19 +0100 Subject: [PATCH] Add column to EditTableDialog to allow setting foreign key constraints Add a new column to the fiel table in the Edit Table Dialog to allow the user to add and edit foreign key constraints. --- src/EditTableDialog.cpp | 6 ++++++ src/EditTableDialog.h | 3 ++- src/EditTableDialog.ui | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/EditTableDialog.cpp b/src/EditTableDialog.cpp index cf27503d..bb337a72 100644 --- a/src/EditTableDialog.cpp +++ b/src/EditTableDialog.cpp @@ -112,6 +112,7 @@ void EditTableDialog::populateFields() tbitem->setCheckState(kUnique, f->unique() ? Qt::Checked : Qt::Unchecked); tbitem->setText(kDefault, f->defaultValue()); tbitem->setText(kCheck, f->check()); + tbitem->setText(kForeignKey, f->foreignKey()); ui->treeWidget->addTopLevelItem(tbitem); } @@ -365,6 +366,11 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column) if(!m_bNewTable) callRenameColumn = true; break; + case kForeignKey: + field->setForeignKey(item->text(column)); + if(!m_bNewTable) + callRenameColumn = true; + break; } if(callRenameColumn) diff --git a/src/EditTableDialog.h b/src/EditTableDialog.h index ebb61231..561fe537 100644 --- a/src/EditTableDialog.h +++ b/src/EditTableDialog.h @@ -33,7 +33,8 @@ private: kAutoIncrement = 4, kUnique = 5, kDefault = 6, - kCheck = 7 + kCheck = 7, + kForeignKey = 8 }; void updateColumnWidth(); diff --git a/src/EditTableDialog.ui b/src/EditTableDialog.ui index ae99f514..c68551d8 100644 --- a/src/EditTableDialog.ui +++ b/src/EditTableDialog.ui @@ -269,6 +269,11 @@ Check constraint + + + Foreign Key + +