From 3da05f71f7c46dd4d220aec59d7da49186dcd775 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Tue, 22 May 2018 21:16:54 +0200 Subject: [PATCH] Removed recipeingredient headers, removed recipeingredient from recipe object. --- RecipeDB.pro | 5 +-- model/recipe/ingredients/recipeingredient.h | 43 ------------------- .../ingredients/recipeingredientlistmodel.h | 28 ------------ model/recipe/ingredients/unitofmeasure.h | 42 ------------------ model/recipe/recipe.h | 2 +- 5 files changed, 2 insertions(+), 118 deletions(-) delete mode 100644 model/recipe/ingredients/recipeingredient.h delete mode 100644 model/recipe/ingredients/recipeingredientlistmodel.h delete mode 100644 model/recipe/ingredients/unitofmeasure.h diff --git a/RecipeDB.pro b/RecipeDB.pro index a07dd60..eac8ff6 100644 --- a/RecipeDB.pro +++ b/RecipeDB.pro @@ -38,10 +38,8 @@ SOURCES += model/recipe/instruction.cpp \ HEADERS += model/recipe/instruction.h \ model/recipe/recipe.h \ model/database/database.h \ - model/recipe/ingredients/unitofmeasure.h \ model/recipe/ingredients/ingredient.h \ model/recipe/ingredients/ingredientlistmodel.h \ - model/recipe/ingredients/recipeingredient.h \ model/recipe/tags/recipetag.h \ SQLite/sqlite3.h \ SQLite/sqlite3ext.h \ @@ -58,8 +56,7 @@ HEADERS += model/recipe/instruction.h \ gui/openrecipedialog.h \ model/recipe/recipetablemodel.h \ gui/mainwindow.h \ - gui/newDialogs/newfoodgroupdialog.h \ - model/recipe/ingredients/recipeingredientlistmodel.h + gui/newDialogs/newfoodgroupdialog.h LIBS += -ldl \ diff --git a/model/recipe/ingredients/recipeingredient.h b/model/recipe/ingredients/recipeingredient.h deleted file mode 100644 index 8c1dd45..0000000 --- a/model/recipe/ingredients/recipeingredient.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef RECIPEINGREDIENT_H -#define RECIPEINGREDIENT_H - -#include -#include - -#include "model/recipe/ingredients/ingredient.h" -#include "model/recipe/ingredients/unitofmeasure.h" -#include "utils/stringutils.h" - -using namespace std; - -/** - * @brief The RecipeIngredient class represents both an ingredient and a unit of measure, to be used in a recipe object. - */ - -class RecipeIngredient : public Ingredient -{ -public: - //Constructor for new RecipeIngredient without starting child ingredient. - RecipeIngredient(string name, string foodGroup, float quantity, UnitOfMeasure unit, string comment); - //Constructor using data from a child ingredient. - RecipeIngredient(Ingredient i, float quantity, UnitOfMeasure unit, string comment); - RecipeIngredient(Ingredient &i); - RecipeIngredient(); - - //Getters - float getQuantity() const; - UnitOfMeasure getUnit() const; - string getComment() const; - - //Setters - void setQuantity(float newQuantity); - void setUnit(UnitOfMeasure newUnit); - void setComment(string newComment); - string toString(); -private: - float quantity; - UnitOfMeasure unit; - string comment; -}; - -#endif // RECIPEINGREDIENT_H diff --git a/model/recipe/ingredients/recipeingredientlistmodel.h b/model/recipe/ingredients/recipeingredientlistmodel.h deleted file mode 100644 index 5ba9da0..0000000 --- a/model/recipe/ingredients/recipeingredientlistmodel.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef RECIPEINGREDIENTLISTMODEL_H -#define RECIPEINGREDIENTLISTMODEL_H - -#include - -#include "model/recipe/ingredients/recipeingredient.h" - -class RecipeIngredientListModel : public QAbstractListModel -{ - public: - RecipeIngredientListModel(); - - //Overridden methods. - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - //Custom methods to handle ingredient data. - void setIngredients(vector ingredients); - bool addIngredient(RecipeIngredient ri); - void deleteIngredient(int index); - vector getIngredients(); - - private: - vector ingredients; - -}; - -#endif // RECIPEINGREDIENTLISTMODEL_H diff --git a/model/recipe/ingredients/unitofmeasure.h b/model/recipe/ingredients/unitofmeasure.h deleted file mode 100644 index 96022fc..0000000 --- a/model/recipe/ingredients/unitofmeasure.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef UNITOFMEASURE_H -#define UNITOFMEASURE_H - -#include - -using namespace std; - -/** - * @brief The UnitOfMeasure class represents a way to measure an ingredient. It contains a name, an abbreviation, plural name, and some information on conversion. - */ - -class UnitOfMeasure -{ -public: - //Constants Declarations. - static const int MASS = 0; - static const int VOLUME = 1; - static const int LENGTH = 2; - static const int MISC = 3; - - //Full constructor. - UnitOfMeasure(string name, string plural, string abbreviation, int type, double coef); - //Attempt to guess unit from just a string. - UnitOfMeasure(string name); - //Constructor with default values. - UnitOfMeasure(); - - //Getters - string getName() const; - string getNamePlural() const; - string getAbbreviation() const; - int getType() const; - double getMetricCoefficient() const; -private: - string name; //The name of the unit of measure. - string plural; //The plural name. - string abbreviation; //A short version of the unit. - int type; //The type of unit, as one of the constants above. - double metricCoefficient; //The conversion from this unit to the standard metric unit. -}; - -#endif // UNITOFMEASURE_H diff --git a/model/recipe/recipe.h b/model/recipe/recipe.h index 4d8dca3..12143e0 100644 --- a/model/recipe/recipe.h +++ b/model/recipe/recipe.h @@ -8,7 +8,7 @@ #include #include -#include "model/recipe/ingredients/recipeingredient.h" +#include "model/recipe/ingredients/ingredient.h" #include "model/recipe/instruction.h" #include "model/recipe/tags/recipetag.h"