Added window icons, add new ingredient and add new tag dialogs.

This commit is contained in:
Andrew Lalis 2018-03-10 14:06:24 +01:00
parent cbb2079a7f
commit 4f78b37460
15 changed files with 381 additions and 5 deletions

View File

@ -27,7 +27,9 @@ SOURCES += model/recipe/instruction.cpp \
model/database/recipedatabase.cpp \
utils/fileutils.cpp \
gui/newrecipedialog.cpp \
model/recipe/tags/taglistmodel.cpp
model/recipe/tags/taglistmodel.cpp \
gui/newDialogs/newingredientdialog.cpp \
gui/newDialogs/newtagdialog.cpp
HEADERS += model/recipe/instruction.h \
model/recipe/recipe.h \
@ -44,12 +46,16 @@ HEADERS += model/recipe/instruction.h \
model/database/recipedatabase.h \
utils/fileutils.h \
gui/newrecipedialog.h \
model/recipe/tags/taglistmodel.h
model/recipe/tags/taglistmodel.h \
gui/newDialogs/newingredientdialog.h \
gui/newDialogs/newtagdialog.h
LIBS += -ldl \
FORMS += gui/mainwindow.ui \
gui/newrecipedialog.ui
gui/newrecipedialog.ui \
gui/newDialogs/newingredientdialog.ui \
gui/newDialogs/newtagdialog.ui
DISTFILES += \
.gitignore

View File

@ -25,6 +25,10 @@
<property name="windowTitle">
<string>RecipeDB</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/images/icon.png</normaloff>:/images/images/icon.png</iconset>
</property>
<property name="windowOpacity">
<double>1.000000000000000</double>
</property>
@ -556,6 +560,8 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<resources>
<include location="../images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,18 @@
#include "newingredientdialog.h"
#include "ui_newingredientdialog.h"
NewIngredientDialog::NewIngredientDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NewIngredientDialog)
{
ui->setupUi(this);
}
NewIngredientDialog::~NewIngredientDialog()
{
delete ui;
}
Ingredient NewIngredientDialog::getIngredient(){
return Ingredient(ui->nameEdit->text().toLower().toStdString(), ui->foodGroupEdit->text().toLower().toStdString());
}

View File

@ -0,0 +1,26 @@
#ifndef NEWINGREDIENTDIALOG_H
#define NEWINGREDIENTDIALOG_H
#include <QDialog>
#include "model/recipe/ingredients/ingredient.h"
namespace Ui {
class NewIngredientDialog;
}
class NewIngredientDialog : public QDialog
{
Q_OBJECT
public:
explicit NewIngredientDialog(QWidget *parent = 0);
~NewIngredientDialog();
//Access values.
Ingredient getIngredient();
private:
Ui::NewIngredientDialog *ui;
};
#endif // NEWINGREDIENTDIALOG_H

View File

@ -0,0 +1,120 @@
<?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>240</width>
<height>320</height>
</rect>
</property>
<property name="windowTitle">
<string>New Ingredient</string>
</property>
<property name="windowIcon">
<iconset resource="../../images.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="QLineEdit" name="foodGroupEdit"/>
</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="../../images.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

@ -0,0 +1,18 @@
#include "newtagdialog.h"
#include "ui_newtagdialog.h"
NewTagDialog::NewTagDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::newTagDialog)
{
ui->setupUi(this);
}
NewTagDialog::~NewTagDialog()
{
delete ui;
}
RecipeTag NewTagDialog::getTag(){
return RecipeTag(ui->tagEdit->text().toLower().toStdString());
}

View File

@ -0,0 +1,26 @@
#ifndef NEWTAGDIALOG_H
#define NEWTAGDIALOG_H
#include <QDialog>
#include "model/recipe/tags/recipetag.h"
namespace Ui {
class newTagDialog;
}
class NewTagDialog : public QDialog
{
Q_OBJECT
public:
explicit NewTagDialog(QWidget *parent = 0);
~NewTagDialog();
//Access values
RecipeTag getTag();
private:
Ui::newTagDialog *ui;
};
#endif // NEWTAGDIALOG_H

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>newTagDialog</class>
<widget class="QDialog" name="newTagDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>320</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="../../images.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">
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="tagEditWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="tagLabel">
<property name="text">
<string>New Tag</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tagEdit"/>
</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="../../images.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>newTagDialog</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>newTagDialog</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

@ -118,3 +118,27 @@ void NewRecipeDialog::on_selectImageButton_clicked(){
ui->imageDisplayLabel->setPixmap(QPixmap(filename));
}
}
void NewRecipeDialog::on_deleteIngredientButton_clicked(){
QModelIndexList indexList = ui->ingredientsListView->selectionModel()->selectedIndexes();
for (QModelIndexList::iterator it = indexList.begin(); it != indexList.end(); ++it){
QModelIndex i = *it;
this->ingredientListModel.deleteIngredient(i.row());
}
}
void NewRecipeDialog::on_newIngredientButton_clicked(){
NewIngredientDialog d(this);
d.show();
if (d.exec() == QDialog::Accepted){
Ingredient i = d.getIngredient();
this->recipeDB->storeIngredient(i);
this->populateIngredientsBox();
}
}
void NewRecipeDialog::on_newTagButton_clicked(){
newTagDialog
d.show();
}

View File

@ -10,6 +10,9 @@
#include "model/recipe/ingredients/ingredientlistmodel.h"
#include "model/recipe/tags/taglistmodel.h"
#include "gui/newDialogs/newingredientdialog.h"
#include "gui/newDialogs/newtagdialog.h"
namespace Ui {
class NewRecipeDialog;
}
@ -42,6 +45,12 @@ class NewRecipeDialog : public QDialog
void on_selectImageButton_clicked();
void on_deleteIngredientButton_clicked();
void on_newIngredientButton_clicked();
void on_newTagButton_clicked();
private:
Ui::NewRecipeDialog *ui;
RecipeDatabase *recipeDB;

View File

@ -22,6 +22,13 @@
<property name="windowTitle">
<string>New Recipe</string>
</property>
<property name="windowIcon">
<iconset resource="../images.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">
<property name="spacing">
<number>0</number>
@ -327,6 +334,9 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
</layout>
@ -599,6 +609,9 @@
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="batchSize">
<number>100</number>
</property>
@ -610,7 +623,7 @@
</layout>
</widget>
</item>
<item alignment="Qt::AlignTop">
<item>
<widget class="QWidget" name="imagePanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_13">
<property name="spacing">
@ -665,6 +678,9 @@
</item>
<item>
<widget class="QWidget" name="instructionsPanel" native="true">
<property name="styleSheet">
<string notr="true">background-color: rgb(250, 250, 255);</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="instructionsLabel">
@ -728,6 +744,12 @@
</item>
<item>
<widget class="QTextEdit" name="instructionsTextEdit">
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="placeholderText">
<string>Enter instructions here.</string>
</property>
@ -741,9 +763,15 @@
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>

View File

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/images">
<file>images/no_image.png</file>
<file>images/icon.png</file>
</qresource>
</RCC>

BIN
images/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

View File

@ -55,6 +55,7 @@ bool IngredientListModel::addIngredient(RecipeIngredient ri){
void IngredientListModel::deleteIngredient(int index){
this->ingredients.erase(this->ingredients.begin() + index);
emit dataChanged(createIndex(0, 0), createIndex(this->ingredients.size()-1, 0));
}
vector<RecipeIngredient> IngredientListModel::getIngredients(){

View File

@ -41,6 +41,7 @@ bool TagListModel::addTag(RecipeTag tag){
void TagListModel::deleteTag(int index){
this->tags.erase(this->tags.begin() + index);
emit dataChanged(createIndex(0, 0), createIndex(this->tags.size()-1, 0));
}
vector<RecipeTag> TagListModel::getTags(){