From 041d56e1a9a2628fc3dfeb62967b0eaeb28f72d8 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Sat, 10 Mar 2018 12:58:31 +0100 Subject: [PATCH] Adding support for image selection in add recipe dialog. --- RecipeDB.pro | 3 +- gui/newrecipedialog.cpp | 8 + gui/newrecipedialog.ui | 437 ++++++++++-------- images.qrc | 5 + images/no_image.png | Bin 0 -> 3079 bytes .../ingredients/ingredientlistmodel.cpp | 4 + model/recipe/tags/taglistmodel.cpp | 4 + 7 files changed, 269 insertions(+), 192 deletions(-) create mode 100644 images.qrc create mode 100644 images/no_image.png diff --git a/RecipeDB.pro b/RecipeDB.pro index 0071690..c2c8a98 100644 --- a/RecipeDB.pro +++ b/RecipeDB.pro @@ -54,4 +54,5 @@ FORMS += gui/mainwindow.ui \ DISTFILES += \ .gitignore -RESOURCES += +RESOURCES += \ + images.qrc diff --git a/gui/newrecipedialog.cpp b/gui/newrecipedialog.cpp index 7405d09..2b4123f 100644 --- a/gui/newrecipedialog.cpp +++ b/gui/newrecipedialog.cpp @@ -101,3 +101,11 @@ void NewRecipeDialog::on_addTagButton_clicked(){ //Add a tag to the list of those prepared to be added. 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()); + } +} diff --git a/gui/newrecipedialog.ui b/gui/newrecipedialog.ui index 78e7f57..0a0875c 100644 --- a/gui/newrecipedialog.ui +++ b/gui/newrecipedialog.ui @@ -336,23 +336,11 @@ - - - - 0 - 0 - - - - background-color: rgb(245, 245, 255); - - + + 0 - - QLayout::SetMaximumSize - 0 @@ -366,64 +354,53 @@ 0 - - - Ingredients + + + + 0 + 0 + - - Qt::AlignCenter + + background-color: rgb(245, 245, 255); - - - - - + + + 0 + + + QLayout::SetMaximumSize + + + 0 + + + 0 + + + 0 + + + 0 + - - - background-color: rgb(255, 255, 255); + + + Ingredients - - QFrame::NoFrame - - - 100 + + Qt::AlignCenter - - - - - 5 - - - 0 - - - 0 - - - 0 - - - 0 - + + + - - - Add Ingredient - - - Qt::AlignCenter - - - - - - + + - 2 + 5 0 @@ -438,149 +415,193 @@ 0 - - - - 0 - 0 - + + + Add Ingredient - - + + Qt::AlignCenter - - - New + + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + + + + + New + + + + + + + + + + + 0 + 36 + + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Noto Sans CJK KR + 14 + 50 + false + false + + + + Amount + + + + + + + + 0 + 0 + + + + 10000.000000000000000 + + + 1.000000000000000 + + + + + + + + + + New + + + + + + + + + + + 0 + 0 + + + + false + + + Qt::AlignCenter + + + Comments + + + false + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Add + + + + + + + Delete + + + + - - - - 0 - 36 - + + + background-color: rgb(255, 255, 255); - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - Noto Sans CJK KR - 14 - 50 - false - false - - - - Amount - - - - - - - - 0 - 0 - - - - 10000.000000000000000 - - - 1.000000000000000 - - - - - - - - - - New - - - - - - - - - - - 0 - 0 - + + QFrame::NoFrame - - false + + 100 - - Qt::AlignCenter - - - Comments - - - false - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Add - - - - - - - Delete - - - - @@ -589,6 +610,40 @@ + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + diff --git a/images.qrc b/images.qrc new file mode 100644 index 0000000..6634926 --- /dev/null +++ b/images.qrc @@ -0,0 +1,5 @@ + + + images/no_image.png + + diff --git a/images/no_image.png b/images/no_image.png new file mode 100644 index 0000000000000000000000000000000000000000..d9a708d29045595ae77cedc07b3de6234c49855a GIT binary pat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K3$0-{)u+gC*e2QmlYwLv8mrl9|<@@@+>jz^Fh+EPE#+&t{gqcCjTA13P z@#g!<`GtjTX>j*Iu*e0BjI6A8E_J)GhRKZZ6`;j`^h`5ykYpH9btU;2J2oe#`AS8b2&MqEsk9IRLF;Pld9A~@J9zA?` zY}YOMg#LamG?6#vR{6aX`djE@5@OtZv*g3Vv<*$h) z76%>{@EG12dU{U9j-{Ns;7O!nEh}4WlY3=i@!0hAG{~z}hb}ieyL>BO_xglBX?AC0 z+zAj=nHUA< z1E|#c^YX+`L>l<`_yAIK=K6|jZvG>RiFQqRP_W3}+bxOKAldd6_ht`&qXJF92%0RuKcAl_7a;9#WWJ<=T_x|j7LLMD4RKYn$=Z_1HUL%njPLO6#mAcm3*3{I{3Y4jvhTqrc?J$`5z^1i+>z-vBbX-|yAD0Wo zAVa@&x?6{?FOIu|zWBO3Pj!RFN?zoU)T88yBXz+U7rg$u5w&a*Fvh}lb#)=b=N|o) zkg(QkgEq-xH#Fb@A|?<|Lmc;e*Ey^CP=sHsVUEn&dzFVzA5hR-FlEw zW?AJd)(EHvmNdxm^RIF!>p1d!&4B-_-+oYS+fP(LGhOn!U@4%#%*`(~H8m|G!uaY3tj!8Bhx=s~Qf6b6?i{=pax7`x_$`mzF^-dIh*%T2*yHc-cBbr!7hG(vQKc z$#==agOwguG>Gz*5g@Lns_I+P#sa0+^*!YAsO6>ci`1Ppr|GFFH8k2?N=Ea#l~p1j z$#WX*$F5908|7$Wa0L9=fMI$xW-oeqZNU92n2oehKcjQ!lL18W;&l+lp&CD@P0gPI zsY1O)gt@sn4H__5afs~uNUG;G~(UDPQ_J!V{o$ingredients.erase(this->ingredients.begin() + index); +} + vector IngredientListModel::getIngredients(){ return this->ingredients; } diff --git a/model/recipe/tags/taglistmodel.cpp b/model/recipe/tags/taglistmodel.cpp index dd70b3f..4555cd7 100644 --- a/model/recipe/tags/taglistmodel.cpp +++ b/model/recipe/tags/taglistmodel.cpp @@ -39,6 +39,10 @@ bool TagListModel::addTag(RecipeTag tag){ return true; } +void TagListModel::deleteTag(int index){ + this->tags.erase(this->tags.begin() + index); +} + vector TagListModel::getTags(){ return this->tags; }