Removed recipeingredient files, and unitofmeasure. These are too restrictive.
This commit is contained in:
parent
a790128646
commit
07774cc349
|
@ -16,10 +16,8 @@ SOURCES += model/recipe/instruction.cpp \
|
||||||
model/recipe/recipe.cpp \
|
model/recipe/recipe.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
model/database/database.cpp \
|
model/database/database.cpp \
|
||||||
model/recipe/ingredients/unitofmeasure.cpp \
|
|
||||||
model/recipe/ingredients/ingredient.cpp \
|
model/recipe/ingredients/ingredient.cpp \
|
||||||
model/recipe/ingredients/ingredientlistmodel.cpp \
|
model/recipe/ingredients/ingredientlistmodel.cpp \
|
||||||
model/recipe/ingredients/recipeingredient.cpp \
|
|
||||||
model/recipe/tags/recipetag.cpp \
|
model/recipe/tags/recipetag.cpp \
|
||||||
SQLite/sqlite3.c \
|
SQLite/sqlite3.c \
|
||||||
model/database/resulttable.cpp \
|
model/database/resulttable.cpp \
|
||||||
|
@ -35,8 +33,7 @@ SOURCES += model/recipe/instruction.cpp \
|
||||||
gui/openrecipedialog.cpp \
|
gui/openrecipedialog.cpp \
|
||||||
model/recipe/recipetablemodel.cpp \
|
model/recipe/recipetablemodel.cpp \
|
||||||
gui/mainwindow.cpp \
|
gui/mainwindow.cpp \
|
||||||
gui/newDialogs/newfoodgroupdialog.cpp \
|
gui/newDialogs/newfoodgroupdialog.cpp
|
||||||
model/recipe/ingredients/recipeingredientlistmodel.cpp
|
|
||||||
|
|
||||||
HEADERS += model/recipe/instruction.h \
|
HEADERS += model/recipe/instruction.h \
|
||||||
model/recipe/recipe.h \
|
model/recipe/recipe.h \
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
#include "model/recipe/ingredients/recipeingredient.h"
|
|
||||||
|
|
||||||
RecipeIngredient::RecipeIngredient(string name, string foodGroup, float quantity, UnitOfMeasure unit, string comment) : Ingredient(name, foodGroup){
|
|
||||||
setQuantity(quantity);
|
|
||||||
setUnit(unit);
|
|
||||||
setComment(comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
RecipeIngredient::RecipeIngredient(Ingredient i, float quantity, UnitOfMeasure unit, string comment){
|
|
||||||
setName(i.getName());
|
|
||||||
setFoodGroup(i.getFoodGroup());
|
|
||||||
setQuantity(quantity);
|
|
||||||
setUnit(unit);
|
|
||||||
setComment(comment);
|
|
||||||
}
|
|
||||||
|
|
||||||
RecipeIngredient::RecipeIngredient(Ingredient &i) : RecipeIngredient(i, 0.0f, UnitOfMeasure("bleh"), "Fuck"){
|
|
||||||
//Constructs recipe ingredient from ingredient which is a hidden recipe ingredient.
|
|
||||||
}
|
|
||||||
|
|
||||||
RecipeIngredient::RecipeIngredient(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
float RecipeIngredient::getQuantity() const{
|
|
||||||
return this->quantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnitOfMeasure RecipeIngredient::getUnit() const{
|
|
||||||
return this->unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
string RecipeIngredient::getComment() const{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
string RecipeIngredient::toString(){
|
|
||||||
string result;
|
|
||||||
if (std::ceil(this->getQuantity()) == this->getQuantity()){
|
|
||||||
result += std::to_string((int)this->getQuantity());
|
|
||||||
} else {
|
|
||||||
result += StringUtils::toString(this->getQuantity());
|
|
||||||
}
|
|
||||||
result += " " + this->getUnit().getAbbreviation() + " " + this->getName();
|
|
||||||
if (!this->getComment().empty()) result += " (" + this->getComment() + ")";
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
#include "recipeingredientlistmodel.h"
|
|
||||||
|
|
||||||
RecipeIngredientListModel::RecipeIngredientListModel(){
|
|
||||||
this->ingredients = vector<RecipeIngredient>();
|
|
||||||
}
|
|
||||||
|
|
||||||
int RecipeIngredientListModel::rowCount(const QModelIndex &parent) const{
|
|
||||||
Q_UNUSED(parent);
|
|
||||||
return this->ingredients.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant RecipeIngredientListModel::data(const QModelIndex &index, int role) const{
|
|
||||||
int row = index.row();
|
|
||||||
RecipeIngredient i = this->ingredients[row];
|
|
||||||
|
|
||||||
string displayStr = i.toString();
|
|
||||||
|
|
||||||
switch(role){
|
|
||||||
case Qt::DisplayRole:
|
|
||||||
return QString::fromStdString(displayStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecipeIngredientListModel::setIngredients(vector<RecipeIngredient> ingredients){
|
|
||||||
this->ingredients = ingredients;
|
|
||||||
QModelIndex index = createIndex(0, 0);
|
|
||||||
QModelIndex bottomIndex = createIndex(ingredients.size()-1, 0);
|
|
||||||
emit dataChanged(index, bottomIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RecipeIngredientListModel::addIngredient(RecipeIngredient ri){
|
|
||||||
//Add only if it doesn't exist already.
|
|
||||||
for (unsigned int i = 0; i < this->ingredients.size(); i++){
|
|
||||||
if (!this->ingredients[i].getName().compare(ri.getName())){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->ingredients.push_back(ri);
|
|
||||||
QModelIndex index = createIndex(this->ingredients.size()-1, 0);
|
|
||||||
QModelIndex bottomIndex = createIndex(this->ingredients.size()-1, 0);
|
|
||||||
emit dataChanged(index, bottomIndex);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecipeIngredientListModel::deleteIngredient(int index){
|
|
||||||
this->ingredients.erase(this->ingredients.begin() + index);
|
|
||||||
emit dataChanged(createIndex(0, 0), createIndex(this->ingredients.size()-1, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<RecipeIngredient> RecipeIngredientListModel::getIngredients(){
|
|
||||||
return this->ingredients;
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
#include "unitofmeasure.h"
|
|
||||||
|
|
||||||
UnitOfMeasure::UnitOfMeasure(string name, string plural, string abbreviation, int type, double coef){
|
|
||||||
this->name = name;
|
|
||||||
this->plural = plural;
|
|
||||||
this->abbreviation = abbreviation;
|
|
||||||
this->type = type;
|
|
||||||
this->metricCoefficient = coef;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnitOfMeasure::UnitOfMeasure(string name){
|
|
||||||
this->name = name;
|
|
||||||
this->plural = name + "s";
|
|
||||||
this->abbreviation = "NULL";
|
|
||||||
this->type = MISC;
|
|
||||||
this->metricCoefficient = 1;
|
|
||||||
///TODO: Make actual guessing of this stuff.
|
|
||||||
}
|
|
||||||
|
|
||||||
UnitOfMeasure::UnitOfMeasure() : UnitOfMeasure::UnitOfMeasure("", "", "", MISC, 1.0){
|
|
||||||
//Default constructor initializes all fields to empty strings.
|
|
||||||
}
|
|
||||||
|
|
||||||
string UnitOfMeasure::getName() const{
|
|
||||||
return this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
string UnitOfMeasure::getNamePlural() const{
|
|
||||||
return this->plural;
|
|
||||||
}
|
|
||||||
|
|
||||||
string UnitOfMeasure::getAbbreviation() const{
|
|
||||||
return this->abbreviation;
|
|
||||||
}
|
|
||||||
|
|
||||||
int UnitOfMeasure::getType() const{
|
|
||||||
return this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
double UnitOfMeasure::getMetricCoefficient() const{
|
|
||||||
return this->metricCoefficient;
|
|
||||||
}
|
|
Loading…
Reference in New Issue