From a1c2aca84bb5f77240af9e1f4f973ea91208c47a Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 4 Jan 2013 17:53:10 +0100 Subject: [PATCH] Do not allow empty tables in EditTableForm Do not allow the creation of a table without any columns as this would lead to an SQL error. --- src/EditTableForm.cpp | 5 +++++ src/EditTableForm.ui | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/EditTableForm.cpp b/src/EditTableForm.cpp index 6c8ccb08..89a2b9ce 100644 --- a/src/EditTableForm.cpp +++ b/src/EditTableForm.cpp @@ -129,6 +129,8 @@ void editTableForm::checkInput() bool valid = true; if(ui->editTableName->text().isEmpty() || ui->editTableName->text().contains(" ")) valid = false; + if(ui->treeWidget->topLevelItemCount() == 0) + valid = false; ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); } @@ -167,6 +169,7 @@ void editTableForm::addField() tbitem->setText(1, dialog.field_type); modified = true; ui->treeWidget->addTopLevelItem(tbitem); + checkInput(); } } @@ -194,6 +197,8 @@ void editTableForm::removeField() QMessageBox::information(this, QApplication::applicationName(), tr("Sorry! This function is currently not implemented as SQLite does not support the deletion of columns yet.")); // } } + + checkInput(); } void editTableForm::fieldSelectionChanged() diff --git a/src/EditTableForm.ui b/src/EditTableForm.ui index 15a5ca43..3e0108d8 100644 --- a/src/EditTableForm.ui +++ b/src/EditTableForm.ui @@ -270,6 +270,22 @@ + + treeWidget + itemChanged(QTreeWidgetItem*,int) + editTableForm + checkInput() + + + 138 + 197 + + + 412 + 135 + + + fieldSelectionChanged()