Allow ingredients without specifying an amount

Closes #5
This commit is contained in:
Marcel Kapfer 2020-07-06 20:07:58 +02:00
parent 01f8bdd8d3
commit 094dd51a78
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09

View file

@ -136,16 +136,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.v_categories.takeItem(self.v_categories.currentRow())
def ingredient_add(self):
if self.c_heading.checkState() == 2 or self.e_amount.text():
if self.e_ingredient.text():
if self.c_heading.checkState() == 2:
current_amount = QTableWidgetItem("----------")
else:
current_amount = QTableWidgetItem(self.e_amount.text())
current_ingredient = QTableWidgetItem(self.e_ingredient.text())
self.v_ingredients.setRowCount(self.v_ingredients.rowCount() + 1)
self.v_ingredients.setItem(self.v_ingredients.rowCount() - 1, 0, current_amount)
self.v_ingredients.setItem(self.v_ingredients.rowCount() - 1, 1, current_ingredient)
if self.e_ingredient.text():
if self.c_heading.checkState() == 2:
current_amount = QTableWidgetItem("----------")
else:
current_amount = QTableWidgetItem(self.e_amount.text())
current_ingredient = QTableWidgetItem(self.e_ingredient.text())
self.v_ingredients.setRowCount(self.v_ingredients.rowCount() + 1)
self.v_ingredients.setItem(self.v_ingredients.rowCount() - 1, 0, current_amount)
self.v_ingredients.setItem(self.v_ingredients.rowCount() - 1, 1, current_ingredient)
def ingredient_remove(self):
self.v_ingredients.removeRow(self.v_ingredients.currentRow())