Improve/redesign ingredients #13
|
@ -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 \
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef RECIPEINGREDIENT_H
|
||||
#define RECIPEINGREDIENT_H
|
||||
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
#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
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef RECIPEINGREDIENTLISTMODEL_H
|
||||
#define RECIPEINGREDIENTLISTMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#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<RecipeIngredient> ingredients);
|
||||
bool addIngredient(RecipeIngredient ri);
|
||||
void deleteIngredient(int index);
|
||||
vector<RecipeIngredient> getIngredients();
|
||||
|
||||
private:
|
||||
vector<RecipeIngredient> ingredients;
|
||||
|
||||
};
|
||||
|
||||
#endif // RECIPEINGREDIENTLISTMODEL_H
|
|
@ -1,42 +0,0 @@
|
|||
#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:
|
||||
//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
|
|
@ -8,7 +8,7 @@
|
|||
#include <QImage>
|
||||
#include <algorithm>
|
||||
|
||||
#include "model/recipe/ingredients/recipeingredient.h"
|
||||
#include "model/recipe/ingredients/ingredient.h"
|
||||
#include "model/recipe/instruction.h"
|
||||
#include "model/recipe/tags/recipetag.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue