Adding support for image selection in add recipe dialog.

This commit is contained in:
Andrew Lalis 2018-03-10 12:58:31 +01:00
parent cb3be5e1e2
commit 041d56e1a9
7 changed files with 269 additions and 192 deletions

View File

@ -54,4 +54,5 @@ FORMS += gui/mainwindow.ui \
DISTFILES += \ DISTFILES += \
.gitignore .gitignore
RESOURCES += RESOURCES += \
images.qrc

View File

@ -101,3 +101,11 @@ void NewRecipeDialog::on_addTagButton_clicked(){
//Add a tag to the list of those prepared to be added. //Add a tag to the list of those prepared to be added.
this->tagsListModel.addTag(this->tags[ui->tagsComboBox->currentIndex()]); this->tagsListModel.addTag(this->tags[ui->tagsComboBox->currentIndex()]);
} }
void NewRecipeDialog::on_deleteTagButton_clicked(){
QModelIndexList indexList = ui->tagsListView->selectedIndexes();
for (QModelIndexList::iterator it = indexList.begin(); it != indexList.end(); ++it){
QModelIndex i = *it;
this->tagsListModel.deleteTag(i.row());
}
}

View File

@ -336,23 +336,11 @@
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignTop"> <item alignment="Qt::AlignTop">
<widget class="QWidget" name="ingredientsPanel" native="true"> <widget class="QWidget" name="ingredientsAndImagePanel" native="true">
<property name="sizePolicy"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(245, 245, 255);</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@ -366,64 +354,53 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="ingredientsPanelLabel"> <widget class="QWidget" name="ingredientsPanel" native="true">
<property name="text"> <property name="sizePolicy">
<string>Ingredients</string> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="alignment"> <property name="styleSheet">
<set>Qt::AlignCenter</set> <string notr="true">background-color: rgb(245, 245, 255);</string>
</property> </property>
</widget> <layout class="QVBoxLayout" name="verticalLayout_6">
</item> <property name="spacing">
<item> <number>0</number>
<widget class="QWidget" name="ingredientsSubPanel" native="true"> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</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> <item>
<widget class="QListView" name="ingredientsListView"> <widget class="QLabel" name="ingredientsPanelLabel">
<property name="styleSheet"> <property name="text">
<string notr="true">background-color: rgb(255, 255, 255);</string> <string>Ingredients</string>
</property> </property>
<property name="frameShape"> <property name="alignment">
<enum>QFrame::NoFrame</enum> <set>Qt::AlignCenter</set>
</property>
<property name="batchSize">
<number>100</number>
</property> </property>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignRight|Qt::AlignTop"> <item>
<widget class="QWidget" name="addIngredientPanel" native="true"> <widget class="QWidget" name="ingredientsSubPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_12">
<property name="spacing">
<number>5</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> <item>
<widget class="QLabel" name="addIngredientLabel"> <widget class="QWidget" name="addIngredientPanel" native="true">
<property name="text"> <layout class="QVBoxLayout" name="verticalLayout_7">
<string>Add Ingredient</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ingredientNamePanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing"> <property name="spacing">
<number>2</number> <number>5</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
@ -438,149 +415,193 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QComboBox" name="ingredientNameBox"> <widget class="QLabel" name="addIngredientLabel">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <string>Add Ingredient</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="currentText"> <property name="alignment">
<string/> <set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="newIngredientButton"> <widget class="QWidget" name="ingredientNamePanel" native="true">
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<string>New</string> <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="currentText">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newIngredientButton">
<property name="text">
<string>New</string>
</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> </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>
<family>Noto Sans CJK KR</family>
<pointsize>14</pointsize>
<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"/>
</item>
<item>
<widget class="QPushButton" name="newUnitButton">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLineEdit" name="commentsLineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText">
<string>Comments</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ingredientsListControlPanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<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="QPushButton" name="addIngredientButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteIngredientButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QWidget" name="quantityPanel" native="true"> <widget class="QListView" name="ingredientsListView">
<property name="minimumSize"> <property name="styleSheet">
<size> <string notr="true">background-color: rgb(255, 255, 255);</string>
<width>0</width>
<height>36</height>
</size>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <property name="frameShape">
<property name="spacing"> <enum>QFrame::NoFrame</enum>
<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>
<family>Noto Sans CJK KR</family>
<pointsize>14</pointsize>
<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"/>
</item>
<item>
<widget class="QPushButton" name="newUnitButton">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLineEdit" name="commentsLineEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property> </property>
<property name="frame"> <property name="batchSize">
<bool>false</bool> <number>100</number>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText">
<string>Comments</string>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="ingredientsListControlPanel" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<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="QPushButton" name="addIngredientButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteIngredientButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -589,6 +610,40 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignTop">
<widget class="QWidget" name="imagePanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_13">
<property name="spacing">
<number>0</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="imageDisplayLabel">
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

5
images.qrc Normal file
View File

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

BIN
images/no_image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -53,6 +53,10 @@ bool IngredientListModel::addIngredient(RecipeIngredient ri){
return true; return true;
} }
void IngredientListModel::deleteIngredient(int index){
this->ingredients.erase(this->ingredients.begin() + index);
}
vector<RecipeIngredient> IngredientListModel::getIngredients(){ vector<RecipeIngredient> IngredientListModel::getIngredients(){
return this->ingredients; return this->ingredients;
} }

View File

@ -39,6 +39,10 @@ bool TagListModel::addTag(RecipeTag tag){
return true; return true;
} }
void TagListModel::deleteTag(int index){
this->tags.erase(this->tags.begin() + index);
}
vector<RecipeTag> TagListModel::getTags(){ vector<RecipeTag> TagListModel::getTags(){
return this->tags; return this->tags;
} }