Improve/redesign ingredients #13

Merged
andrewlalis merged 13 commits from improve/redesignIngredients into development 2018-05-22 21:29:25 +00:00
8 changed files with 3 additions and 434 deletions
Showing only changes of commit b3393266d3 - Show all commits

View File

@ -25,15 +25,12 @@ SOURCES += model/recipe/instruction.cpp \
utils/fileutils.cpp \ utils/fileutils.cpp \
gui/newrecipedialog.cpp \ gui/newrecipedialog.cpp \
model/recipe/tags/taglistmodel.cpp \ model/recipe/tags/taglistmodel.cpp \
gui/newDialogs/newingredientdialog.cpp \
gui/newDialogs/newtagdialog.cpp \ gui/newDialogs/newtagdialog.cpp \
gui/newDialogs/newunitdialog.cpp \
utils/aspectratiopixmaplabel.cpp \ utils/aspectratiopixmaplabel.cpp \
utils/stringutils.cpp \ utils/stringutils.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
HEADERS += model/recipe/instruction.h \ HEADERS += model/recipe/instruction.h \
model/recipe/recipe.h \ model/recipe/recipe.h \
@ -48,24 +45,20 @@ HEADERS += model/recipe/instruction.h \
utils/fileutils.h \ utils/fileutils.h \
gui/newrecipedialog.h \ gui/newrecipedialog.h \
model/recipe/tags/taglistmodel.h \ model/recipe/tags/taglistmodel.h \
gui/newDialogs/newingredientdialog.h \
gui/newDialogs/newtagdialog.h \ gui/newDialogs/newtagdialog.h \
utils/aspectratiopixmaplabel.h \ utils/aspectratiopixmaplabel.h \
utils/stringutils.h \ utils/stringutils.h \
gui/openrecipedialog.h \ gui/openrecipedialog.h \
model/recipe/recipetablemodel.h \ model/recipe/recipetablemodel.h \
gui/mainwindow.h \ gui/mainwindow.h
gui/newDialogs/newfoodgroupdialog.h
LIBS += -ldl \ LIBS += -ldl \
FORMS += gui/mainwindow.ui \ FORMS += gui/mainwindow.ui \
gui/newrecipedialog.ui \ gui/newrecipedialog.ui \
gui/newDialogs/newingredientdialog.ui \
gui/newDialogs/newtagdialog.ui \ gui/newDialogs/newtagdialog.ui \
gui/openrecipedialog.ui \ gui/openrecipedialog.ui \
gui/mainwindow.ui \ gui/mainwindow.ui
gui/newDialogs/newfoodgroupdialog.ui
DISTFILES += \ DISTFILES += \
.gitignore .gitignore

View File

@ -1,18 +0,0 @@
#include "newfoodgroupdialog.h"
#include "ui_newfoodgroupdialog.h"
newFoodGroupDialog::newFoodGroupDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::newFoodGroupDialog)
{
ui->setupUi(this);
}
newFoodGroupDialog::~newFoodGroupDialog()
{
delete ui;
}
string newFoodGroupDialog::getFoodGroup() const{
return ui->lineEdit->text().toStdString();
}

View File

@ -1,27 +0,0 @@
#ifndef NEWFOODGROUPDIALOG_H
#define NEWFOODGROUPDIALOG_H
#include <QDialog>
#include <string>
using namespace std;
namespace Ui {
class newFoodGroupDialog;
}
class newFoodGroupDialog : public QDialog
{
Q_OBJECT
public:
explicit newFoodGroupDialog(QWidget *parent = 0);
~newFoodGroupDialog();
string getFoodGroup() const;
private:
Ui::newFoodGroupDialog *ui;
};
#endif // NEWFOODGROUPDIALOG_H

View File

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>newFoodGroupDialog</class>
<widget class="QDialog" name="newFoodGroupDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>114</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="windowTitle">
<string>New Food Group</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>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Add New Food Group</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</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>newFoodGroupDialog</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>newFoodGroupDialog</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

@ -1,49 +0,0 @@
#include "newingredientdialog.h"
#include "ui_newingredientdialog.h"
NewIngredientDialog::NewIngredientDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NewIngredientDialog)
{
ui->setupUi(this);
}
NewIngredientDialog::NewIngredientDialog(RecipeDatabase *recipeDB, QWidget *parent) : NewIngredientDialog(parent){
this->recipeDB = recipeDB;
this->populateFoodGroupBox();
}
NewIngredientDialog::~NewIngredientDialog()
{
delete ui;
}
Ingredient NewIngredientDialog::getIngredient(){
return Ingredient(ui->nameEdit->text().toLower().toStdString(), ui->foodGroupBox->currentText().toStdString());
}
void NewIngredientDialog::populateFoodGroupBox(){
vector<string> foodGroups = this->recipeDB->retrieveAllFoodGroups();
ui->foodGroupBox->clear();
for (unsigned int i = 0; i < foodGroups.size(); i++){
QString s = QString::fromStdString(foodGroups[i]);
ui->foodGroupBox->insertItem(i, s);
}
}
void NewIngredientDialog::on_addFoodGroupButton_clicked(){
newFoodGroupDialog d(this);
if (d.exec() == QDialog::Accepted){
string s = d.getFoodGroup();
if (!s.empty()){
ui->foodGroupBox->addItem(QString::fromStdString(s));
ui->foodGroupBox->setCurrentText(QString::fromStdString(s));
} else {
QMessageBox::warning(this, "Empty Food Group", "The food group you entered is empty!");
}
}
}
void NewIngredientDialog::on_deleteFoodGroupButton_clicked(){
ui->foodGroupBox->removeItem(ui->foodGroupBox->currentIndex());
}

View File

@ -1,39 +0,0 @@
#ifndef NEWINGREDIENTDIALOG_H
#define NEWINGREDIENTDIALOG_H
#include <QDialog>
#include <QMessageBox>
#include "model/recipe/ingredients/ingredient.h"
#include "model/database/recipedatabase.h"
#include "gui/newDialogs/newfoodgroupdialog.h"
namespace Ui {
class NewIngredientDialog;
}
class NewIngredientDialog : public QDialog
{
Q_OBJECT
public:
explicit NewIngredientDialog(QWidget *parent = 0);
NewIngredientDialog(RecipeDatabase *recipeDB, QWidget *parent = 0);
~NewIngredientDialog();
//Access values.
Ingredient getIngredient();
private slots:
void on_addFoodGroupButton_clicked();
void on_deleteFoodGroupButton_clicked();
private:
Ui::NewIngredientDialog *ui;
RecipeDatabase *recipeDB;
void populateFoodGroupBox();
};
#endif // NEWINGREDIENTDIALOG_H

View File

@ -1,158 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NewIngredientDialog</class>
<widget class="QDialog" name="NewIngredientDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>228</height>
</rect>
</property>
<property name="windowTitle">
<string>New Ingredient</string>
</property>
<property name="windowIcon">
<iconset resource="../../res.qrc">
<normaloff>:/images/images/icon.png</normaloff>:/images/images/icon.png</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="mainContentPanel" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="namePanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nameEdit"/>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="foodGroupPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="foodGroupLabel">
<property name="text">
<string>Food Group</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="foodGroupSelectionWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="foodGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="insertPolicy">
<enum>QComboBox::InsertAlphabetically</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="addFoodGroupButton">
<property name="text">
<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 alignment="Qt::AlignRight">
<widget class="QPushButton" name="deleteFoodGroupButton">
<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>
</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>NewIngredientDialog</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>NewIngredientDialog</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

@ -1,31 +0,0 @@
#include "newunitdialog.h"
#include "ui_newunitdialog.h"
NewUnitDialog::NewUnitDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NewUnitDialog)
{
ui->setupUi(this);
ui->typeComboBox->clear();
QStringList list({"Mass", "Volume", "Length", "Misc"});
ui->typeComboBox->insertItems(0, list);
}
NewUnitDialog::~NewUnitDialog()
{
delete ui;
}
UnitOfMeasure NewUnitDialog::getUnit(){
return UnitOfMeasure(ui->unitNameEdit->text().toLower().toStdString(),
ui->pluralNameEdit->text().toLower().toStdString(),
ui->abbreviationEdit->text().toStdString(),
this->getSelectedType(),
ui->coefficientSpinBox->value());
}
int NewUnitDialog::getSelectedType(){
return ui->typeComboBox->currentIndex();
}