From 094dd51a787f152f81639cbc90d9bdc3019d1d15 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Mon, 6 Jul 2020 20:07:58 +0200 Subject: [PATCH] Allow ingredients without specifying an amount Closes #5 --- wikicookbook.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/wikicookbook.py b/wikicookbook.py index fb823d7..dc6622c 100644 --- a/wikicookbook.py +++ b/wikicookbook.py @@ -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())