First Interaction with User Interface #1

Merged
andrewlalis merged 11 commits from development into master 2018-02-12 19:40:45 +00:00
16 changed files with 86 additions and 32 deletions
Showing only changes of commit 05a18d6a9a - Show all commits

View File

@ -13,24 +13,27 @@ 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
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
FORMS += gui/mainwindow.ui FORMS += gui/mainwindow.ui

View File

@ -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>

View File

@ -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;

View File

@ -1,4 +1,4 @@
#include "headers/ingredient.h" #include "model/recipe/ingredients/ingredient.h"
Ingredient::Ingredient(){ Ingredient::Ingredient(){
setId(-1); setId(-1);

View File

@ -5,6 +5,10 @@
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:

View File

@ -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>();

View File

@ -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
{ {

View File

@ -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){ RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit) : Ingredient(id, name, foodGroup){
setQuantity(quantity); setQuantity(quantity);

View File

@ -3,7 +3,7 @@
#include <string> #include <string>
#include "headers/ingredient.h" #include "model/recipe/ingredients/ingredient.h"
using namespace std; using namespace std;

View File

@ -0,0 +1,6 @@
#include "unitofmeasure.h"
UnitOfMeasure::UnitOfMeasure()
{
}

View File

@ -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

View File

@ -1,4 +1,4 @@
#include "headers/instruction.h" #include "model/recipe/instruction.h"
Instruction::Instruction() Instruction::Instruction()
{ {

View File

@ -2,24 +2,25 @@
Recipe::Recipe(){ Recipe::Recipe(){
this->name = "NULL"; this->name = "NULL";
this->ingredients = vector<Ingredient>(); this->ingredients = vector<RecipeIngredient>();
this->instructions = vector<Instruction>(); 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->name = name;
this->ingredients = ingredients; this->ingredients = ingredients;
this->instructions = instructions; this->instruction = instruction;
} }
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;
} }

View File

@ -3,27 +3,40 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <hash_map>
#include "model/recipe/ingredient.h" #include "model/recipe/ingredients/recipeingredient.h"
#include "model/recipe/instruction.h" #include "model/recipe/instruction.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:
Recipe(); Recipe();
Recipe(string name, vector<Ingredient> ingredients, vector<Instruction> instructions); Recipe(string name, vector<RecipeIngredient> ingredients, Instruction instruction);
string getName(); string getName();
vector<Ingredient> getIngredients(); vector<RecipeIngredient> getIngredients();
vector<Instruction> getInstructions(); Instruction getInstruction();
private: private:
string name; string name;
vector<string> tags; vector<string> tags;
vector<Ingredient> ingredients; vector<RecipeIngredient> ingredients;
vector<Instruction> instructions; Instruction instruction;
}; };

View File

@ -13,7 +13,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 +21,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){
} }
void MainWindow::setIngredients(vector<Ingredient> ingredients){ void MainWindow::setIngredients(vector<RecipeIngredient> ingredients){
} }

View File

@ -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