Updated new recipe dialog, Ingredient class.

This commit is contained in:
Andrew Lalis 2018-05-22 21:02:08 +02:00
parent e6fa247c5c
commit cd501d27cb
3 changed files with 18 additions and 203 deletions

View File

@ -175,7 +175,7 @@
<second>0</second> <second>0</second>
<year>1999</year> <year>1999</year>
<month>12</month> <month>12</month>
<day>21</day> <day>20</day>
</datetime> </datetime>
</property> </property>
<property name="currentSection"> <property name="currentSection">
@ -530,176 +530,7 @@ QPushButton#deleteTagButton:pressed{
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QWidget" name="ingredientNamePanel" native="true"> <widget class="QLineEdit" name="ingredientLineEdit">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="ingredientNameBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(113, 119, 255);</string>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string/>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAlphabetically</enum>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newIngredientButton">
<property name="toolTip">
<string>Create a new ingredient</string>
</property>
<property name="icon">
<iconset resource="../res.qrc">
<normaloff>:/images/images/plus_icon.png</normaloff>:/images/images/plus_icon.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteIngredientButton">
<property name="toolTip">
<string>Delete this ingredient</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../res.qrc">
<normaloff>:/images/images/minus_icon.png</normaloff>:/images/images/minus_icon.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="quantityPanel" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="amountLabel">
<property name="font">
<font>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Amount</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="quantitySpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<double>10000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="unitComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(113, 119, 255);</string>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAlphabetically</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="newUnitButton">
<property name="toolTip">
<string>Create a new unit of measure</string>
</property>
<property name="icon">
<iconset resource="../res.qrc">
<normaloff>:/images/images/plus_icon.png</normaloff>:/images/images/plus_icon.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteUnitButton">
<property name="toolTip">
<string>Delete this unit of measure</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../res.qrc">
<normaloff>:/images/images/minus_icon.png</normaloff>:/images/images/minus_icon.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLineEdit" name="commentsLineEdit">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@ -710,10 +541,10 @@ QPushButton#deleteTagButton:pressed{
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
<property name="placeholderText"> <property name="placeholderText">
<string>Comments</string> <string>Write ingredient here...</string>
</property> </property>
<property name="clearButtonEnabled"> <property name="clearButtonEnabled">
<bool>false</bool> <bool>false</bool>

View File

@ -1,31 +1,18 @@
#include "model/recipe/ingredients/ingredient.h" #include "model/recipe/ingredients/ingredient.h"
Ingredient::Ingredient(){ Ingredient::Ingredient(){
setName("NULL"); setContent("NULL");
setFoodGroup("NULL");
} }
Ingredient::Ingredient(string name, string foodGroup){ Ingredient::Ingredient(string content){
setName(name); setContent(content);
setFoodGroup(foodGroup);
} }
string Ingredient::getName() const{ string Ingredient::getContent() const{
return this->name; return this->content;
} }
string Ingredient::getFoodGroup() const{ void Ingredient::setContent(string newContent){
return this->foodGroup; this->content = newContent;
} }
void Ingredient::setName(string newName){
this->name = newName;
}
void Ingredient::setFoodGroup(string newFoodGroup){
this->foodGroup = newFoodGroup;
}
string Ingredient::toString(){
return this->getName();
}

View File

@ -6,28 +6,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. * @brief The Ingredient class represents an ingredient, which is a string representing one component of a recipe.
* An ingredient cannot be included on its own in a recipe, and must be paired with a Unit in a RecipeIngredient Object. * The user is free to compose a recipe string however they like. However, the program will restrict obviously
* invalid input, and try to be smart about determining if an ingredient is valid.
*/ */
class Ingredient class Ingredient
{ {
public: public:
Ingredient(); Ingredient();
Ingredient(string name, string foodGroup); Ingredient(string content);
//Getters //Getters
string getName() const; string getContent() const;
string getFoodGroup() const;
//Setters //Setters
void setName(string newName); void setContent(string newContent);
void setFoodGroup(string newFoodGroup);
string toString();
protected: protected:
string name; string content;
string foodGroup;
}; };
#endif // INGREDIENT_H #endif // INGREDIENT_H