First Interaction with User Interface #1
|
@ -1,2 +1,3 @@
|
||||||
*.pro
|
*.pro
|
||||||
*.pro.user
|
*.pro.user
|
||||||
|
*.autosave
|
17
RecipeDB.pro
17
RecipeDB.pro
|
@ -13,24 +13,29 @@ TEMPLATE = app
|
||||||
|
|
||||||
|
|
||||||
SOURCES += SQLite/sqlite3.c \
|
SOURCES += SQLite/sqlite3.c \
|
||||||
model/recipe/ingredient.cpp \
|
|
||||||
model/recipe/instruction.cpp \
|
model/recipe/instruction.cpp \
|
||||||
model/recipe/recipe.cpp \
|
model/recipe/recipe.cpp \
|
||||||
model/recipe/recipeingredient.cpp \
|
|
||||||
userInterface/mainwindow.cpp \
|
userInterface/mainwindow.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
model/database/database.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 \
|
||||||
|
model/recipe/tags/recipetag.cpp
|
||||||
|
|
||||||
HEADERS += SQLite/sqlite3.h \
|
HEADERS += SQLite/sqlite3.h \
|
||||||
SQLite/sqlite3ext.h \
|
SQLite/sqlite3ext.h \
|
||||||
model/recipe/ingredient.h \
|
|
||||||
model/recipe/instruction.h \
|
model/recipe/instruction.h \
|
||||||
model/recipe/recipe.h \
|
model/recipe/recipe.h \
|
||||||
model/recipe/recipeingredient.h \
|
|
||||||
userInterface/mainwindow.h \
|
userInterface/mainwindow.h \
|
||||||
model/database/database.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 \
|
||||||
|
model/recipe/tags/recipetag.h
|
||||||
|
|
||||||
FORMS += gui/mainwindow.ui
|
FORMS += gui/mainwindow.ui
|
||||||
|
|
||||||
|
|
|
@ -432,6 +432,9 @@
|
||||||
<property name="sizeAdjustPolicy">
|
<property name="sizeAdjustPolicy">
|
||||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoFormatting">
|
||||||
|
<set>QTextEdit::AutoNone</set>
|
||||||
|
</property>
|
||||||
<property name="lineWrapMode">
|
<property name="lineWrapMode">
|
||||||
<enum>QTextEdit::WidgetWidth</enum>
|
<enum>QTextEdit::WidgetWidth</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SQLite/sqlite3.h"
|
#include "SQLite/sqlite3.h"
|
||||||
#include "model/recipe/ingredient.h"
|
#include "model/recipe/ingredients/ingredient.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
#include "headers/ingredient.h"
|
#include "model/recipe/ingredients/ingredient.h"
|
||||||
|
|
||||||
Ingredient::Ingredient(){
|
Ingredient::Ingredient(){
|
||||||
setId(-1);
|
|
||||||
setName("NULL");
|
setName("NULL");
|
||||||
setFoodGroup("NULL");
|
setFoodGroup("NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ingredient::Ingredient(int id, string name, string foodGroup){
|
Ingredient::Ingredient(string name, string foodGroup){
|
||||||
setId(id);
|
|
||||||
setName(name);
|
setName(name);
|
||||||
setFoodGroup(foodGroup);
|
setFoodGroup(foodGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Ingredient::getId(){
|
|
||||||
return this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
string Ingredient::getName(){
|
string Ingredient::getName(){
|
||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
@ -24,10 +18,6 @@ string Ingredient::getFoodGroup(){
|
||||||
return this->foodGroup;
|
return this->foodGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ingredient::setId(int newId){
|
|
||||||
this->id = newId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Ingredient::setName(string newName){
|
void Ingredient::setName(string newName){
|
||||||
this->name = newName;
|
this->name = newName;
|
||||||
}
|
}
|
|
@ -5,21 +5,25 @@
|
||||||
|
|
||||||
using namespace std;
|
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
|
class Ingredient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Ingredient();
|
Ingredient();
|
||||||
Ingredient(int id, string name, string foodGroup);
|
Ingredient(string name, string foodGroup);
|
||||||
|
|
||||||
int getId();
|
//Getters
|
||||||
string getName();
|
string getName();
|
||||||
string getFoodGroup();
|
string getFoodGroup();
|
||||||
|
|
||||||
void setId(int newId);
|
//Setters
|
||||||
void setName(string newName);
|
void setName(string newName);
|
||||||
void setFoodGroup(string newFoodGroup);
|
void setFoodGroup(string newFoodGroup);
|
||||||
protected:
|
protected:
|
||||||
int id;
|
|
||||||
string name;
|
string name;
|
||||||
string foodGroup;
|
string foodGroup;
|
||||||
};
|
};
|
|
@ -1,4 +1,4 @@
|
||||||
#include "model/recipe/ingredientlistmodel.h"
|
#include "model/recipe/ingredients/ingredientlistmodel.h"
|
||||||
|
|
||||||
IngredientListModel::IngredientListModel(){
|
IngredientListModel::IngredientListModel(){
|
||||||
this->ingredients = vector<Ingredient>();
|
this->ingredients = vector<Ingredient>();
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "model/recipe/ingredient.h"
|
#include "model/recipe/ingredients/ingredient.h"
|
||||||
|
|
||||||
class IngredientListModel : public QAbstractListModel
|
class IngredientListModel : public QAbstractListModel
|
||||||
{
|
{
|
|
@ -0,0 +1,37 @@
|
||||||
|
#include "model/recipe/ingredients/recipeingredient.h"
|
||||||
|
|
||||||
|
RecipeIngredient::RecipeIngredient(string name, string foodGroup, float quantity, UnitOfMeasure unit) : Ingredient(name, foodGroup){
|
||||||
|
setQuantity(quantity);
|
||||||
|
setUnit(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
RecipeIngredient::RecipeIngredient(Ingredient i, float quantity, UnitOfMeasure unit){
|
||||||
|
setName(i.getName());
|
||||||
|
setFoodGroup(i.getFoodGroup());
|
||||||
|
setQuantity(quantity);
|
||||||
|
setUnit(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
float RecipeIngredient::getQuantity(){
|
||||||
|
return this->quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnitOfMeasure RecipeIngredient::getUnit(){
|
||||||
|
return this->unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
string RecipeIngredient::getComment(){
|
||||||
|
return this->comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecipeIngredient::setQuantity(float newQuantity){
|
||||||
|
this->quantity = newQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecipeIngredient::setUnit(UnitOfMeasure newUnit){
|
||||||
|
this->unit = newUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecipeIngredient::setComment(string newComment){
|
||||||
|
this->comment = newComment;
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef RECIPEINGREDIENT_H
|
||||||
|
#define RECIPEINGREDIENT_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "model/recipe/ingredients/ingredient.h"
|
||||||
|
#include "model/recipe/ingredients/unitofmeasure.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);
|
||||||
|
//Constructor using data from a child ingredient.
|
||||||
|
RecipeIngredient(Ingredient i, float quantity, UnitOfMeasure unit);
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
float getQuantity();
|
||||||
|
UnitOfMeasure getUnit();
|
||||||
|
string getComment();
|
||||||
|
|
||||||
|
//Setters
|
||||||
|
void setQuantity(float newQuantity);
|
||||||
|
void setUnit(UnitOfMeasure newUnit);
|
||||||
|
void setComment(string newComment);
|
||||||
|
private:
|
||||||
|
float quantity;
|
||||||
|
UnitOfMeasure unit;
|
||||||
|
string comment;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RECIPEINGREDIENT_H
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include "unitofmeasure.h"
|
||||||
|
|
||||||
|
UnitOfMeasure::UnitOfMeasure(string name, string plural, string abbreviation){
|
||||||
|
this->name = name;
|
||||||
|
this->plural = plural;
|
||||||
|
this->abbreviation = abbreviation;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnitOfMeasure::UnitOfMeasure() : UnitOfMeasure::UnitOfMeasure("", "", ""){
|
||||||
|
//Default constructor initializes all fields to empty strings.
|
||||||
|
}
|
||||||
|
|
||||||
|
string UnitOfMeasure::getName(){
|
||||||
|
return this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
string UnitOfMeasure::getNamePlural(){
|
||||||
|
return this->plural;
|
||||||
|
}
|
||||||
|
|
||||||
|
string UnitOfMeasure::getAbbreviation(){
|
||||||
|
return this->abbreviation;
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#ifndef UNITOFMEASURE_H
|
||||||
|
#define UNITOFMEASURE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
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:
|
||||||
|
//Full constructor.
|
||||||
|
UnitOfMeasure(string name, string plural, string abbreviation);
|
||||||
|
//Constructor with default values.
|
||||||
|
UnitOfMeasure();
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
string getName();
|
||||||
|
string getNamePlural();
|
||||||
|
string getAbbreviation();
|
||||||
|
private:
|
||||||
|
string name; //The name of the unit of measure.
|
||||||
|
string plural; //The plural name.
|
||||||
|
string abbreviation; //A short version of the unit.
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // UNITOFMEASURE_H
|
|
@ -1,6 +1,17 @@
|
||||||
#include "headers/instruction.h"
|
#include "model/recipe/instruction.h"
|
||||||
|
|
||||||
Instruction::Instruction()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
Instruction::Instruction(){
|
||||||
|
setHTML("");
|
||||||
|
}
|
||||||
|
|
||||||
|
Instruction::Instruction(string text){
|
||||||
|
setHTML(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
string Instruction::getHTML(){
|
||||||
|
return this->htmlText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instruction::setHTML(string newText){
|
||||||
|
this->htmlText = newText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,27 @@
|
||||||
#ifndef INSTRUCTION_H
|
#ifndef INSTRUCTION_H
|
||||||
#define INSTRUCTION_H
|
#define INSTRUCTION_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Instruction class is meant to hold an HTML document in string form, which holds formatted text as the instructions for the recipe.
|
||||||
|
*/
|
||||||
|
|
||||||
class Instruction
|
class Instruction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Instruction();
|
Instruction();
|
||||||
|
Instruction(string text);
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
string getHTML();
|
||||||
|
|
||||||
|
//Setters
|
||||||
|
void setHTML(string newText);
|
||||||
|
private:
|
||||||
|
string htmlText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INSTRUCTION_H
|
#endif // INSTRUCTION_H
|
|
@ -1,25 +1,93 @@
|
||||||
#include "model/recipe/recipe.h"
|
#include "model/recipe/recipe.h"
|
||||||
|
|
||||||
Recipe::Recipe(){
|
Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<RecipeTag> tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings){
|
||||||
this->name = "NULL";
|
setName(name);
|
||||||
this->ingredients = vector<Ingredient>();
|
setIngredients(ingredients);
|
||||||
this->instructions = vector<Instruction>();
|
setInstruction(instruction);
|
||||||
|
setImage(image);
|
||||||
|
setTags(tags);
|
||||||
|
setCreatedDate(createdDate);
|
||||||
|
setPrepTime(prepTime);
|
||||||
|
setCookTime(cookTime);
|
||||||
|
setServings(servings);
|
||||||
}
|
}
|
||||||
|
|
||||||
Recipe::Recipe(string name, vector<Ingredient> ingredients, vector<Instruction> instructions){
|
Recipe::Recipe() : Recipe::Recipe("Unnamed Recipe", vector<RecipeIngredient>(), Instruction(), QImage(), vector<RecipeTag>(), QDate::currentDate(), QTime(1, 0), QTime(0, 30), 10.0f){
|
||||||
this->name = name;
|
//Set default values when none are specified.
|
||||||
this->ingredients = ingredients;
|
|
||||||
this->instructions = instructions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string Recipe::getName(){
|
string Recipe::getName(){
|
||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Ingredient> Recipe::getIngredients(){
|
vector<RecipeIngredient> Recipe::getIngredients(){
|
||||||
return this->ingredients;
|
return this->ingredients;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Instruction> Recipe::getInstructions(){
|
Instruction Recipe::getInstruction(){
|
||||||
return this->instructions;
|
return this->instruction;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage Recipe::getImage(){
|
||||||
|
return this->image;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDate Recipe::getCreatedDate(){
|
||||||
|
return this->createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime Recipe::getPrepTime(){
|
||||||
|
return this->prepTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime Recipe::getCookTime(){
|
||||||
|
return this->cookTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime Recipe::getTotalTime(){
|
||||||
|
return QTime(this->cookTime.hour() + this->prepTime.hour(), this->cookTime.minute() + this->prepTime.minute(), this->cookTime.second() + this->prepTime.second());
|
||||||
|
}
|
||||||
|
|
||||||
|
float Recipe::getServings(){
|
||||||
|
return this->servings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setName(string newName){
|
||||||
|
this->name = newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setIngredients(vector<RecipeIngredient> ingredients){
|
||||||
|
this->ingredients = ingredients;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setTags(vector<RecipeTag> tags){
|
||||||
|
this->tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::addIngredient(RecipeIngredient newIngredient){
|
||||||
|
this->ingredients.push_back(newIngredient);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setInstruction(Instruction newInstruction){
|
||||||
|
this->instruction = newInstruction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setImage(QImage newImage){
|
||||||
|
this->image = newImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setCreatedDate(QDate newDate){
|
||||||
|
this->createdDate = newDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setPrepTime(QTime newTime){
|
||||||
|
this->prepTime = newTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setCookTime(QTime newTime){
|
||||||
|
this->cookTime = newTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Recipe::setServings(float newServingsCount){
|
||||||
|
this->servings = newServingsCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,28 +3,73 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <hash_map>
|
#include <QDate>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
#include "model/recipe/ingredient.h"
|
#include "model/recipe/ingredients/recipeingredient.h"
|
||||||
#include "model/recipe/instruction.h"
|
#include "model/recipe/instruction.h"
|
||||||
|
#include "model/recipe/tags/recipetag.h"
|
||||||
|
|
||||||
using namespace std;
|
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
|
class Recipe
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
//Full constructor
|
||||||
|
Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction, QImage image, vector<RecipeTag> tags, QDate createdDate, QTime prepTime, QTime cookTime, float servings);
|
||||||
|
//Constructor with default values.
|
||||||
Recipe();
|
Recipe();
|
||||||
Recipe(string name, vector<Ingredient> ingredients, vector<Instruction> instructions);
|
|
||||||
|
|
||||||
|
//Getters
|
||||||
string getName();
|
string getName();
|
||||||
vector<Ingredient> getIngredients();
|
vector<RecipeIngredient> getIngredients();
|
||||||
vector<Instruction> getInstructions();
|
Instruction getInstruction();
|
||||||
private:
|
QImage getImage();
|
||||||
string name;
|
vector<RecipeTag> getTags();
|
||||||
vector<string> tags;
|
QDate getCreatedDate();
|
||||||
vector<Ingredient> ingredients;
|
QTime getPrepTime();
|
||||||
vector<Instruction> instructions;
|
QTime getCookTime();
|
||||||
|
QTime getTotalTime(); //Derived method to add prep and cook times.
|
||||||
|
float getServings();
|
||||||
|
|
||||||
|
//Setters
|
||||||
|
void setName(string newName);
|
||||||
|
void setIngredients(vector<RecipeIngredient> ingredients);
|
||||||
|
void setTags(vector<RecipeTag> tags);
|
||||||
|
void addIngredient(RecipeIngredient newIngredient);
|
||||||
|
void setInstruction(Instruction newInstruction);
|
||||||
|
void setImage(QImage newImage);
|
||||||
|
void setCreatedDate(QDate newDate);
|
||||||
|
void setPrepTime(QTime newTime);
|
||||||
|
void setCookTime(QTime newTime);
|
||||||
|
void setServings(float newServingsCount);
|
||||||
|
private:
|
||||||
|
//Main information.
|
||||||
|
string name; //The name of the recipe.
|
||||||
|
vector<RecipeIngredient> ingredients; //The list of ingredients in the recipe.
|
||||||
|
Instruction instruction; //The instruction HTML document.
|
||||||
|
QImage image; //An image displayed alongside the recipe.
|
||||||
|
//Auxiliary Information.
|
||||||
|
vector<RecipeTag> tags; //The list of tags which can be used to categorize the recipe.
|
||||||
|
QDate createdDate; //The date the recipe was created.
|
||||||
|
QTime prepTime; //The time taken for preparation.
|
||||||
|
QTime cookTime; //The time taken to cook.
|
||||||
|
float servings; //The number of servings which this recipe produces.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECIPE_H
|
#endif // RECIPE_H
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
#include "headers/recipeingredient.h"
|
|
||||||
|
|
||||||
RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit) : Ingredient(id, name, foodGroup){
|
|
||||||
setQuantity(quantity);
|
|
||||||
setUnit(unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
RecipeIngredient::RecipeIngredient(Ingredient i, int quantity, string unit){
|
|
||||||
setId(i.getId());
|
|
||||||
setName(i.getName());
|
|
||||||
setFoodGroup(i.getFoodGroup());
|
|
||||||
setQuantity(quantity);
|
|
||||||
setUnit(unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
string RecipeIngredient::getComment(){
|
|
||||||
return this->comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecipeIngredient::setQuantity(int newQuantity){
|
|
||||||
this->quantity = newQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecipeIngredient::setUnit(string newUnit){
|
|
||||||
this->unit = newUnit;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecipeIngredient::setComment(string newComment){
|
|
||||||
this->comment = newComment;
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
#ifndef RECIPEINGREDIENT_H
|
|
||||||
#define RECIPEINGREDIENT_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "headers/ingredient.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class RecipeIngredient : public Ingredient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit);
|
|
||||||
RecipeIngredient(Ingredient i, int quantity, string unit);
|
|
||||||
|
|
||||||
int getQuantity();
|
|
||||||
string getUnit();
|
|
||||||
string getComment();
|
|
||||||
|
|
||||||
void setQuantity(int newQuantity);
|
|
||||||
void setUnit(string newUnit);
|
|
||||||
void setComment(string newComment);
|
|
||||||
private:
|
|
||||||
int quantity;
|
|
||||||
string unit;
|
|
||||||
string comment;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // RECIPEINGREDIENT_H
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#include "recipetag.h"
|
||||||
|
|
||||||
|
RecipeTag::RecipeTag() : RecipeTag(""){
|
||||||
|
//Default constructor sets value to empty string.
|
||||||
|
}
|
||||||
|
|
||||||
|
RecipeTag::RecipeTag(string val){
|
||||||
|
this->value = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
string RecipeTag::getValue(){
|
||||||
|
return this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RecipeTag::setValue(string newValue){
|
||||||
|
this->value = newValue;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef RECIPETAG_H
|
||||||
|
#define RECIPETAG_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The RecipeTag class is used to represent tags which can be used to categorize recipes for easy retrieval.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class RecipeTag
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RecipeTag();
|
||||||
|
RecipeTag(string val);
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
string getValue();
|
||||||
|
//Setters
|
||||||
|
void setValue(string newValue);
|
||||||
|
private:
|
||||||
|
string value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RECIPETAG_H
|
|
@ -5,6 +5,14 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow){
|
ui(new Ui::MainWindow){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
//TESTING CODE
|
||||||
|
vector<RecipeIngredient> ri;
|
||||||
|
ri.push_back(RecipeIngredient("flour", "grains", 3.0f, UnitOfMeasure("cup", "cups", "c")));
|
||||||
|
|
||||||
|
Recipe rec("Example", ri, Instruction("<b>BOLD</b><i>iTaLiCs</i>"), QImage(), vector<RecipeTag>(), QDate::currentDate(), QTime(0, 30), QTime(0, 25), 10.0f);
|
||||||
|
|
||||||
|
this->loadFromRecipe(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow(){
|
MainWindow::~MainWindow(){
|
||||||
|
@ -13,7 +21,7 @@ MainWindow::~MainWindow(){
|
||||||
|
|
||||||
void MainWindow::loadFromRecipe(Recipe recipe){
|
void MainWindow::loadFromRecipe(Recipe recipe){
|
||||||
setRecipeName(recipe.getName());
|
setRecipeName(recipe.getName());
|
||||||
setInstructions(recipe.getInstructions());
|
setInstruction(recipe.getInstruction());
|
||||||
setIngredients(recipe.getIngredients());
|
setIngredients(recipe.getIngredients());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +29,10 @@ void MainWindow::setRecipeName(string name){
|
||||||
ui->recipeNameLabel->setText(QString::fromStdString(name));
|
ui->recipeNameLabel->setText(QString::fromStdString(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setInstructions(vector<Instruction> instructions){
|
void MainWindow::setInstruction(Instruction instruction){
|
||||||
|
ui->instructionsTextEdit->setHtml(QString::fromStdString(instruction.getHTML()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setIngredients(vector<Ingredient> ingredients){
|
void MainWindow::setIngredients(vector<RecipeIngredient> ingredients){
|
||||||
|
///TODO: Implement this.
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "model/recipe/recipe.h"
|
#include "model/recipe/recipe.h"
|
||||||
|
|
||||||
|
@ -24,11 +25,12 @@ public:
|
||||||
void loadFromRecipe(Recipe recipe);
|
void loadFromRecipe(Recipe recipe);
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
QAbstractListModel *ingredientsListModel;
|
||||||
|
|
||||||
//Hidden manipulation methods.
|
//Hidden manipulation methods.
|
||||||
void setRecipeName(string name);
|
void setRecipeName(string name);
|
||||||
void setInstructions(vector<Instruction> instructions);
|
void setInstruction(Instruction instruction);
|
||||||
void setIngredients(vector<Ingredient> ingredients);
|
void setIngredients(vector<RecipeIngredient> ingredients);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
Loading…
Reference in New Issue