First Interaction with User Interface #1
15
RecipeDB.pro
15
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
|
||||
|
||||
|
|
|
@ -432,6 +432,9 @@
|
|||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="autoFormatting">
|
||||
<set>QTextEdit::AutoNone</set>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QTextEdit::WidgetWidth</enum>
|
||||
</property>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "SQLite/sqlite3.h"
|
||||
#include "model/recipe/ingredient.h"
|
||||
#include "model/recipe/ingredients/ingredient.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "headers/ingredient.h"
|
||||
#include "model/recipe/ingredients/ingredient.h"
|
||||
|
||||
Ingredient::Ingredient(){
|
||||
setId(-1);
|
|
@ -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:
|
|
@ -1,4 +1,4 @@
|
|||
#include "model/recipe/ingredientlistmodel.h"
|
||||
#include "model/recipe/ingredients/ingredientlistmodel.h"
|
||||
|
||||
IngredientListModel::IngredientListModel(){
|
||||
this->ingredients = vector<Ingredient>();
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "model/recipe/ingredient.h"
|
||||
#include "model/recipe/ingredients/ingredient.h"
|
||||
|
||||
class IngredientListModel : public QAbstractListModel
|
||||
{
|
|
@ -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);
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "headers/ingredient.h"
|
||||
#include "model/recipe/ingredients/ingredient.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#include "unitofmeasure.h"
|
||||
|
||||
UnitOfMeasure::UnitOfMeasure()
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#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:
|
||||
UnitOfMeasure();
|
||||
private:
|
||||
string name;
|
||||
string plural;
|
||||
string abbreviation;
|
||||
};
|
||||
|
||||
#endif // UNITOFMEASURE_H
|
|
@ -1,4 +1,4 @@
|
|||
#include "headers/instruction.h"
|
||||
#include "model/recipe/instruction.h"
|
||||
|
||||
Instruction::Instruction()
|
||||
{
|
||||
|
|
|
@ -2,24 +2,25 @@
|
|||
|
||||
Recipe::Recipe(){
|
||||
this->name = "NULL";
|
||||
this->ingredients = vector<Ingredient>();
|
||||
this->instructions = vector<Instruction>();
|
||||
this->ingredients = vector<RecipeIngredient>();
|
||||
this->instruction = Instruction();
|
||||
}
|
||||
|
||||
Recipe::Recipe(string name, vector<Ingredient> ingredients, vector<Instruction> instructions){
|
||||
Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction)
|
||||
{
|
||||
this->name = name;
|
||||
this->ingredients = ingredients;
|
||||
this->instructions = instructions;
|
||||
this->instruction = instruction;
|
||||
}
|
||||
|
||||
string Recipe::getName(){
|
||||
return this->name;
|
||||
}
|
||||
|
||||
vector<Ingredient> Recipe::getIngredients(){
|
||||
vector<RecipeIngredient> Recipe::getIngredients(){
|
||||
return this->ingredients;
|
||||
}
|
||||
|
||||
vector<Instruction> Recipe::getInstructions(){
|
||||
return this->instructions;
|
||||
Instruction Recipe::getInstruction(){
|
||||
return this->instruction;
|
||||
}
|
||||
|
|
|
@ -3,27 +3,40 @@
|
|||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <hash_map>
|
||||
|
||||
#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<Ingredient> ingredients, vector<Instruction> instructions);
|
||||
Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction);
|
||||
|
||||
string getName();
|
||||
vector<Ingredient> getIngredients();
|
||||
vector<Instruction> getInstructions();
|
||||
vector<RecipeIngredient> getIngredients();
|
||||
Instruction getInstruction();
|
||||
private:
|
||||
string name;
|
||||
vector<string> tags;
|
||||
vector<Ingredient> ingredients;
|
||||
vector<Instruction> instructions;
|
||||
vector<RecipeIngredient> ingredients;
|
||||
Instruction instruction;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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<Instruction> instructions){
|
||||
void MainWindow::setInstruction(Instruction instruction){
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::setIngredients(vector<Ingredient> ingredients){
|
||||
void MainWindow::setIngredients(vector<RecipeIngredient> ingredients){
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
#include <string>
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#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<Instruction> instructions);
|
||||
void setIngredients(vector<Ingredient> ingredients);
|
||||
void setInstruction(Instruction instruction);
|
||||
void setIngredients(vector<RecipeIngredient> ingredients);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
Loading…
Reference in New Issue