diff --git a/RecipeDB.pro b/RecipeDB.pro index cfc7f09..7c40f21 100644 --- a/RecipeDB.pro +++ b/RecipeDB.pro @@ -13,24 +13,27 @@ TEMPLATE = app SOURCES += SQLite/sqlite3.c \ - model/recipe/ingredient.cpp \ model/recipe/instruction.cpp \ model/recipe/recipe.cpp \ - model/recipe/recipeingredient.cpp \ userInterface/mainwindow.cpp \ main.cpp \ model/database/database.cpp \ - model/recipe/ingredientlistmodel.cpp + model/recipe/ingredients/unitofmeasure.cpp \ + model/recipe/ingredients/ingredient.cpp \ + model/recipe/ingredients/ingredientlistmodel.cpp \ + model/recipe/ingredients/recipeingredient.cpp HEADERS += SQLite/sqlite3.h \ SQLite/sqlite3ext.h \ - model/recipe/ingredient.h \ model/recipe/instruction.h \ model/recipe/recipe.h \ - model/recipe/recipeingredient.h \ userInterface/mainwindow.h \ model/database/database.h \ - model/recipe/ingredientlistmodel.h + model/recipe/ingredientlistmodel.h \ + model/recipe/ingredients/unitofmeasure.h \ + model/recipe/ingredients/ingredient.h \ + model/recipe/ingredients/ingredientlistmodel.h \ + model/recipe/ingredients/recipeingredient.h FORMS += gui/mainwindow.ui diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 2dcf446..8d7b0c5 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -432,6 +432,9 @@ QAbstractScrollArea::AdjustToContents + + QTextEdit::AutoNone + QTextEdit::WidgetWidth diff --git a/model/database/database.h b/model/database/database.h index 12a294e..dce935a 100644 --- a/model/database/database.h +++ b/model/database/database.h @@ -5,7 +5,7 @@ #include #include "SQLite/sqlite3.h" -#include "model/recipe/ingredient.h" +#include "model/recipe/ingredients/ingredient.h" using namespace std; diff --git a/model/recipe/ingredient.cpp b/model/recipe/ingredients/ingredient.cpp similarity index 92% rename from model/recipe/ingredient.cpp rename to model/recipe/ingredients/ingredient.cpp index 5cdcc53..f0d2cf0 100644 --- a/model/recipe/ingredient.cpp +++ b/model/recipe/ingredients/ingredient.cpp @@ -1,4 +1,4 @@ -#include "headers/ingredient.h" +#include "model/recipe/ingredients/ingredient.h" Ingredient::Ingredient(){ setId(-1); diff --git a/model/recipe/ingredient.h b/model/recipe/ingredients/ingredient.h similarity index 64% rename from model/recipe/ingredient.h rename to model/recipe/ingredients/ingredient.h index 2f4b0d0..1b58c49 100644 --- a/model/recipe/ingredient.h +++ b/model/recipe/ingredients/ingredient.h @@ -5,6 +5,10 @@ using namespace std; +/** + * @brief The Ingredient class represents an ingredient, which is classified by a food group, and has a name and an ID. An ingredient cannot be included on its own in a recipe, and must be paired with a Unit in a RecipeIngredient Object. + */ + class Ingredient { public: diff --git a/model/recipe/ingredientlistmodel.cpp b/model/recipe/ingredients/ingredientlistmodel.cpp similarity index 86% rename from model/recipe/ingredientlistmodel.cpp rename to model/recipe/ingredients/ingredientlistmodel.cpp index d837125..edf629c 100644 --- a/model/recipe/ingredientlistmodel.cpp +++ b/model/recipe/ingredients/ingredientlistmodel.cpp @@ -1,4 +1,4 @@ -#include "model/recipe/ingredientlistmodel.h" +#include "model/recipe/ingredients/ingredientlistmodel.h" IngredientListModel::IngredientListModel(){ this->ingredients = vector(); diff --git a/model/recipe/ingredientlistmodel.h b/model/recipe/ingredients/ingredientlistmodel.h similarity index 91% rename from model/recipe/ingredientlistmodel.h rename to model/recipe/ingredients/ingredientlistmodel.h index b71d21c..b995210 100644 --- a/model/recipe/ingredientlistmodel.h +++ b/model/recipe/ingredients/ingredientlistmodel.h @@ -3,7 +3,7 @@ #include -#include "model/recipe/ingredient.h" +#include "model/recipe/ingredients/ingredient.h" class IngredientListModel : public QAbstractListModel { diff --git a/model/recipe/recipeingredient.cpp b/model/recipe/ingredients/recipeingredient.cpp similarity index 92% rename from model/recipe/recipeingredient.cpp rename to model/recipe/ingredients/recipeingredient.cpp index ad43dfa..d697293 100644 --- a/model/recipe/recipeingredient.cpp +++ b/model/recipe/ingredients/recipeingredient.cpp @@ -1,4 +1,4 @@ -#include "headers/recipeingredient.h" +#include "model/recipe/ingredients/recipeingredient.h" RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit) : Ingredient(id, name, foodGroup){ setQuantity(quantity); diff --git a/model/recipe/recipeingredient.h b/model/recipe/ingredients/recipeingredient.h similarity index 92% rename from model/recipe/recipeingredient.h rename to model/recipe/ingredients/recipeingredient.h index 388a1a3..be5369d 100644 --- a/model/recipe/recipeingredient.h +++ b/model/recipe/ingredients/recipeingredient.h @@ -3,7 +3,7 @@ #include -#include "headers/ingredient.h" +#include "model/recipe/ingredients/ingredient.h" using namespace std; diff --git a/model/recipe/ingredients/unitofmeasure.cpp b/model/recipe/ingredients/unitofmeasure.cpp new file mode 100644 index 0000000..4f5fafe --- /dev/null +++ b/model/recipe/ingredients/unitofmeasure.cpp @@ -0,0 +1,6 @@ +#include "unitofmeasure.h" + +UnitOfMeasure::UnitOfMeasure() +{ + +} diff --git a/model/recipe/ingredients/unitofmeasure.h b/model/recipe/ingredients/unitofmeasure.h new file mode 100644 index 0000000..988618d --- /dev/null +++ b/model/recipe/ingredients/unitofmeasure.h @@ -0,0 +1,22 @@ +#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: + UnitOfMeasure(); +private: + string name; + string plural; + string abbreviation; +}; + +#endif // UNITOFMEASURE_H diff --git a/model/recipe/instruction.cpp b/model/recipe/instruction.cpp index 4da0c44..2914bd7 100644 --- a/model/recipe/instruction.cpp +++ b/model/recipe/instruction.cpp @@ -1,4 +1,4 @@ -#include "headers/instruction.h" +#include "model/recipe/instruction.h" Instruction::Instruction() { diff --git a/model/recipe/recipe.cpp b/model/recipe/recipe.cpp index 948e231..2b73e5d 100644 --- a/model/recipe/recipe.cpp +++ b/model/recipe/recipe.cpp @@ -2,24 +2,25 @@ Recipe::Recipe(){ this->name = "NULL"; - this->ingredients = vector(); - this->instructions = vector(); + this->ingredients = vector(); + this->instruction = Instruction(); } -Recipe::Recipe(string name, vector ingredients, vector instructions){ +Recipe::Recipe(string name, vector ingredients, Instruction instruction) +{ this->name = name; this->ingredients = ingredients; - this->instructions = instructions; + this->instruction = instruction; } string Recipe::getName(){ return this->name; } -vector Recipe::getIngredients(){ +vector Recipe::getIngredients(){ return this->ingredients; } -vector Recipe::getInstructions(){ - return this->instructions; +Instruction Recipe::getInstruction(){ + return this->instruction; } diff --git a/model/recipe/recipe.h b/model/recipe/recipe.h index 4cf3b9f..47b8e32 100644 --- a/model/recipe/recipe.h +++ b/model/recipe/recipe.h @@ -3,27 +3,40 @@ #include #include -#include -#include "model/recipe/ingredient.h" +#include "model/recipe/ingredients/recipeingredient.h" #include "model/recipe/instruction.h" using namespace std; +/** + * @brief The Recipe class represents all the data of a recipe: + * - A name. + * - List of ingredients. + * - An instruction object, which represents a block of HTML text which forms the instructions. + * - An image, if possible. + * - Created Date + * - A list of tags. + * - Makes X Servings. + * - Prep time. + * - Cook time. + * The recipe object can be used to populate the window with a full recipe. Prep time, cook time, servings, will be displayed at the beginning of the instructions block. + */ + class Recipe { public: Recipe(); - Recipe(string name, vector ingredients, vector instructions); + Recipe(string name, vector ingredients, Instruction instruction); string getName(); - vector getIngredients(); - vector getInstructions(); + vector getIngredients(); + Instruction getInstruction(); private: string name; vector tags; - vector ingredients; - vector instructions; + vector ingredients; + Instruction instruction; }; diff --git a/userInterface/mainwindow.cpp b/userInterface/mainwindow.cpp index eacb5ba..59f2c18 100644 --- a/userInterface/mainwindow.cpp +++ b/userInterface/mainwindow.cpp @@ -13,7 +13,7 @@ MainWindow::~MainWindow(){ void MainWindow::loadFromRecipe(Recipe recipe){ setRecipeName(recipe.getName()); - setInstructions(recipe.getInstructions()); + setInstruction(recipe.getInstruction()); setIngredients(recipe.getIngredients()); } @@ -21,10 +21,10 @@ void MainWindow::setRecipeName(string name){ ui->recipeNameLabel->setText(QString::fromStdString(name)); } -void MainWindow::setInstructions(vector instructions){ +void MainWindow::setInstruction(Instruction instruction){ } -void MainWindow::setIngredients(vector ingredients){ +void MainWindow::setIngredients(vector ingredients){ } diff --git a/userInterface/mainwindow.h b/userInterface/mainwindow.h index eae9892..86f7910 100644 --- a/userInterface/mainwindow.h +++ b/userInterface/mainwindow.h @@ -3,6 +3,7 @@ #include #include +#include #include "model/recipe/recipe.h" @@ -24,11 +25,12 @@ public: void loadFromRecipe(Recipe recipe); private: Ui::MainWindow *ui; + QAbstractListModel *ingredientsListModel; //Hidden manipulation methods. void setRecipeName(string name); - void setInstructions(vector instructions); - void setIngredients(vector ingredients); + void setInstruction(Instruction instruction); + void setIngredients(vector ingredients); }; #endif // MAINWINDOW_H