Improve/redesign ingredients #13

Merged
andrewlalis merged 13 commits from improve/redesignIngredients into development 2018-05-22 21:29:25 +00:00
5 changed files with 1 additions and 291 deletions
Showing only changes of commit 55a222967b - Show all commits

View File

@ -50,7 +50,6 @@ HEADERS += model/recipe/instruction.h \
model/recipe/tags/taglistmodel.h \
gui/newDialogs/newingredientdialog.h \
gui/newDialogs/newtagdialog.h \
gui/newDialogs/newunitdialog.h \
utils/aspectratiopixmaplabel.h \
utils/stringutils.h \
gui/openrecipedialog.h \
@ -64,7 +63,6 @@ FORMS += gui/mainwindow.ui \
gui/newrecipedialog.ui \
gui/newDialogs/newingredientdialog.ui \
gui/newDialogs/newtagdialog.ui \
gui/newDialogs/newunitdialog.ui \
gui/openrecipedialog.ui \
gui/mainwindow.ui \
gui/newDialogs/newfoodgroupdialog.ui

View File

@ -1,27 +0,0 @@
#ifndef NEWUNITDIALOG_H
#define NEWUNITDIALOG_H
#include <QDialog>
#include "model/recipe/ingredients/unitofmeasure.h"
namespace Ui {
class NewUnitDialog;
}
class NewUnitDialog : public QDialog
{
Q_OBJECT
public:
explicit NewUnitDialog(QWidget *parent = 0);
~NewUnitDialog();
UnitOfMeasure getUnit();
private:
Ui::NewUnitDialog *ui;
int getSelectedType();
};
#endif // NEWUNITDIALOG_H

View File

@ -1,228 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NewUnitDialog</class>
<widget class="QDialog" name="NewUnitDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>195</width>
<height>340</height>
</rect>
</property>
<property name="windowTitle">
<string>New Unit</string>
</property>
<property name="windowIcon">
<iconset resource="../../res.qrc">
<normaloff>:/images/images/icon.png</normaloff>:/images/images/icon.png</iconset>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="contentPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Unit Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="unitNameEdit"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Plural Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="pluralNameEdit"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Abbreviation</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="abbreviationEdit"/>
</item>
<item>
<widget class="QWidget" name="unitTypePanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<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 alignment="Qt::AlignLeft">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="typeComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="coefficientPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Metric Coefficient</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="coefficientSpinBox">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../res.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>NewUnitDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>NewUnitDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -8,34 +8,11 @@
#include "model/database/recipedatabase.h"
#include "utils/fileutils.h"
void test(RecipeDatabase *recipeDB){
vector<RecipeIngredient> ri;
ri.push_back(RecipeIngredient("flour", "grains", 3.0f, UnitOfMeasure("cup", "cups", "c", UnitOfMeasure::VOLUME, 1.0), ""));
ri.push_back(RecipeIngredient("baking powder", "additives", 1.0f, UnitOfMeasure("teaspoon", "teaspoons", "tsp", UnitOfMeasure::VOLUME, 1.0), ""));
Recipe rec("Example",
"Andrew Lalis",
ri,
Instruction("Placeholder Text"),
QImage(),
vector<RecipeTag>({RecipeTag("testing"),
RecipeTag("fake")}),
QDate::currentDate(),
QTime(0, 30),
QTime(0, 25),
10.0f);
bool success = recipeDB->storeRecipe(rec);
printf("Storage successful: %d\n", success);
}
Recipe checkForFirstRun(RecipeDatabase *recipeDB){
Recipe r = recipeDB->retrieveRandomRecipe();
if (r.isEmpty()){//There are no recipes in the database.
//Add some basic units to the units, and some basic ingredients.
recipeDB->addBasicUnits();
recipeDB->addBasicIngredients();
}
return r;
}

View File

@ -29,16 +29,6 @@ vector<Ingredient> Recipe::getIngredients() const{
return this->ingredients;
}
vector<string> Recipe::getFoodGroups() const{
vector<string> foodGroups;
for (Ingredient i : this->ingredients){
if (find(foodGroups.begin(), foodGroups.end(), i.getFoodGroup()) == foodGroups.end()){
foodGroups.push_back(i.getFoodGroup());
}
}
return foodGroups;
}
Instruction Recipe::getInstruction() const{
return this->instruction;
}