Code for creating recipe

This commit is contained in:
Marcel Kapfer 2020-05-03 17:22:24 +02:00
parent 8bf1600f50
commit 47bb261a5e
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09

View file

@ -185,6 +185,53 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def rating_remove(self): def rating_remove(self):
self.v_ratings.takeItem(self.v_ratings.currentRow()) self.v_ratings.takeItem(self.v_ratings.currentRow())
def create_recipe(self):
current_recipe = recipe.Recipe(self.e_recipe_name.text(),
self.e_servings.text(),
self.e_time.text(),
self.e_rating_overall.value(),
self.e_url.text())
# Categories
for row in range(self.v_categories.count()):
current_recipe.add_category(self.v_categories.item(row).text())
# Ingredients
for row in range(self.v_ingredients.rowCount()):
current_recipe.add_ingredient(
self.v_ingredients.item(row, 0).text(),
self.v_ingredients.item(row, 1).text()
)
# Utensils
for row in range(self.v_utensils.count()):
current_recipe.add_utensil(self.v_utensils.item(row).text())
# Steps
for row in range(self.v_steps.count()):
current_recipe.add_step(self.v_steps.item(row).text())
# Notes
for row in range(self.v_notes.count()):
current_recipe.add_note(self.v_notes.item(row).text())
# Tips
for row in range(self.v_tips.count()):
current_recipe.add_tip(self.v_tips.item(row).text())
# Variations
for row in range(self.v_variations.count()):
current_recipe.add_variation(self.v_variations.item(row).text())
# Ratings
for row in range(self.v_ratings.count()):
current_recipe.add_rating(self.v_ratings.item(row).text())
writer = MoinMoinWriter()
code = current_recipe.wikicode(writer)
dialog = WikiCodeDialog(code)
dialog.exec_()
def close(self): def close(self):
""" """
Close the application. A warning is shown before. Close the application. A warning is shown before.