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.
This commit is contained in:
Martin Kleusberg
2013-01-04 17:53:10 +01:00
parent 88ee12a1ab
commit a1c2aca84b
2 changed files with 21 additions and 0 deletions

View File

@@ -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()

View File

@@ -270,6 +270,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>treeWidget</sender>
<signal>itemChanged(QTreeWidgetItem*,int)</signal>
<receiver>editTableForm</receiver>
<slot>checkInput()</slot>
<hints>
<hint type="sourcelabel">
<x>138</x>
<y>197</y>
</hint>
<hint type="destinationlabel">
<x>412</x>
<y>135</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>fieldSelectionChanged()</slot>