diff --git a/gui/newrecipedialog.cpp b/gui/newrecipedialog.cpp index 3825ad1..ac3258c 100644 --- a/gui/newrecipedialog.cpp +++ b/gui/newrecipedialog.cpp @@ -40,7 +40,7 @@ Recipe NewRecipeDialog::getRecipe(){ Recipe r(ui->recipeNameEdit->text().toStdString(), this->ingredientListModel.getIngredients(), ui->instructionsTextEdit->toHtml().toStdString(), - this->img,//Image + ui->imageDisplayLabel->pixmap()->toImage(),//Image this->tagsListModel.getTags(),//Tags QDate::currentDate(), ui->prepTimeEdit->time(), @@ -126,7 +126,6 @@ void NewRecipeDialog::on_deleteTagButton_clicked(){ void NewRecipeDialog::on_selectImageButton_clicked(){ QString filename = QFileDialog::getOpenFileName(this, "Open Image", QString(), "Image Files (*.png *.jpg *.bmp)"); if (!filename.isEmpty()){ - this->img = QImage(filename); ui->imageDisplayLabel->setPixmap(QPixmap(filename)); } } diff --git a/gui/newrecipedialog.h b/gui/newrecipedialog.h index 105cd37..5198dd9 100644 --- a/gui/newrecipedialog.h +++ b/gui/newrecipedialog.h @@ -70,7 +70,6 @@ class NewRecipeDialog : public QDialog vector tags; RecipeIngredientListModel ingredientListModel; TagListModel tagsListModel; - QImage img; bool accepted = false; //Helper functions to fill fields. diff --git a/gui/openrecipedialog.cpp b/gui/openrecipedialog.cpp index c0458b8..8f936da 100644 --- a/gui/openrecipedialog.cpp +++ b/gui/openrecipedialog.cpp @@ -72,7 +72,7 @@ void OpenRecipeDialog::on_deleteRecipeButton_clicked(){ } string recipePlural = (rows.size() == 1) ? "recipe" : "recipes"; QString title = QString::fromStdString("Delete " + recipePlural); - QString content = QString::fromStdString("Are you sure you wish to delete the selected "+recipePlural+"?"); + QString content = QString::fromStdString("Are you sure you wish to delete the selected "+recipePlural+"?\nAll deleted recipes are permanently deleted."); QMessageBox::StandardButton reply = QMessageBox::question(this, title, content); if (reply == QMessageBox::Yes){ for (int row : rows){ @@ -135,3 +135,7 @@ void OpenRecipeDialog::on_clearSearchButton_clicked(){ ui->ingredientsListView->selectionModel()->clearSelection(); this->populateRecipesTable(this->recipeDB->retrieveAllRecipes()); } + +void OpenRecipeDialog::on_exitButton_clicked(){ + this->close(); +} diff --git a/gui/openrecipedialog.h b/gui/openrecipedialog.h index f0989da..c6cf23c 100644 --- a/gui/openrecipedialog.h +++ b/gui/openrecipedialog.h @@ -40,6 +40,8 @@ class OpenRecipeDialog : public QDialog void on_clearSearchButton_clicked(); + void on_exitButton_clicked(); + private: Ui::OpenRecipeDialog *ui; RecipeDatabase *recipeDB; diff --git a/gui/openrecipedialog.ui b/gui/openrecipedialog.ui index 460e738..06db1f0 100644 --- a/gui/openrecipedialog.ui +++ b/gui/openrecipedialog.ui @@ -17,13 +17,37 @@ :/images/images/icon.png:/images/images/icon.png + + font: 25 "Noto Sans CJK KR Light"; + true - + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + background-color: rgb(245, 245, 255); + + + 0 + @@ -39,13 +63,35 @@ QTabWidget::Rounded - 2 + 1 - + + + + :/images/images/tag.png:/images/images/tag.png + + + + Tags + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + @@ -74,10 +120,32 @@ + + + :/images/images/ingredients.png:/images/images/ingredients.png + + + + Ingredients + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + @@ -105,11 +173,33 @@ - + + + + :/images/images/foodPyramid.png:/images/images/foodPyramid.png + + + + Food Groups + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + @@ -132,6 +222,9 @@ + + background-color: rgb(240, 240, 255); + @@ -141,16 +234,115 @@ - + + + + 12 + 3 + false + false + + + + background-color: rgb(255, 255, 255); + + + false + + + Qt::AlignCenter + + + Recipe Name + + + + + 0 + 40 + + + + false + + + QPushButton#clearSearchButton { + background-color: rgb(235, 235, 255); + border: 0px; +} +QPushButton#clearSearchButton:hover{ + background-color: rgb(245, 245, 255); +} +QPushButton#clearSearchButton:pressed{ + background-color: rgb(255, 255, 255); +} + Clear search criteria + + false + + + + + + + + 0 + 40 + + + + QPushButton#deleteRecipeButton { + background-color: rgb(225, 225, 255); + border: 0px; +} +QPushButton#deleteRecipeButton:hover{ + background-color: rgb(235, 235, 255); +} +QPushButton#deleteRecipeButton:pressed{ + background-color: rgb(245, 245, 255); +} + + + + + + + :/images/images/trash.png:/images/images/trash.png + + + + + + + + 0 + 40 + + + + QPushButton#exitButton { + background-color: rgb(215, 215, 255); + border: 0px; +} +QPushButton#exitButton:hover{ + background-color: rgb(225, 225, 255); +} +QPushButton#exitButton:pressed{ + background-color: rgb(235, 235, 255); +} + + + Close + @@ -159,34 +351,55 @@ - - - - - - - - - - - :/images/images/trash.png:/images/images/trash.png - - - - - - + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + 14 + 3 + false + false + + + + background-color: rgb(250, 250, 255); + QFrame::NoFrame + + true + QAbstractItemView::SelectRows + + QAbstractItemView::ScrollPerPixel + + + Qt::NoPen + true + + false + false diff --git a/images.qrc b/images.qrc index a5261a4..de44dca 100644 --- a/images.qrc +++ b/images.qrc @@ -6,5 +6,8 @@ images/minus_icon.png images/search_icon.png images/trash.png + images/tag.png + images/foodPyramid.png + images/ingredients.png diff --git a/images/foodPyramid.png b/images/foodPyramid.png new file mode 100644 index 0000000..10ecfa6 Binary files /dev/null and b/images/foodPyramid.png differ diff --git a/images/ingredients.png b/images/ingredients.png new file mode 100644 index 0000000..5d8e207 Binary files /dev/null and b/images/ingredients.png differ diff --git a/images/tag.png b/images/tag.png new file mode 100644 index 0000000..544ec9a Binary files /dev/null and b/images/tag.png differ diff --git a/main.cpp b/main.cpp index 940cd9d..42982af 100644 --- a/main.cpp +++ b/main.cpp @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) w.show(); //TESTING CODE - test(&recipeDB); + //test(&recipeDB); //END TESTING CODE. @@ -24,7 +24,6 @@ int main(int argc, char *argv[]) a.exec(); recipeDB.closeConnection(); - printf("Total queries: %lu\n", recipeDB.getQueryCount()); return 0; } @@ -48,18 +47,4 @@ void test(RecipeDatabase *recipeDB){ bool success = recipeDB->storeRecipe(rec); printf("Storage successful: %d\n", success); -// vector foodGroups = recipeDB->retrieveAllFoodGroups(); -// printf("Food Groups:\n"); -// for (string s : foodGroups){ -// printf("\t%s\n", s.c_str()); -// } - - //Get food groups from recipe. -// Recipe r = recipeDB->retrieveRecipe("Pannenkoeken"); -// vector foodGroupsR = r.getFoodGroups(); -// printf("Pannenkoeken Food Groups:\n"); -// for (string s : foodGroupsR){ -// printf("\t%s\n", s.c_str()); -// } - } diff --git a/model/database/recipedatabase.cpp b/model/database/recipedatabase.cpp index 0ebd528..42bf4ff 100644 --- a/model/database/recipedatabase.cpp +++ b/model/database/recipedatabase.cpp @@ -204,7 +204,7 @@ vector RecipeDatabase::retrieveRecipesWithTags(vector tags){ } vector RecipeDatabase::retrieveRecipesWithSubstring(string s){ - ResultTable t = this->executeSQL("SELECT * FROM recipe WHERE name LIKE '%"+s+"%' COLLATE NOCASE;"); + ResultTable t = this->executeSQL("SELECT * FROM recipe WHERE name LIKE '%"+s+"%' COLLATE NOCASE ORDER BY name;"); return this->readRecipesFromTable(t); } diff --git a/model/recipe/recipe.cpp b/model/recipe/recipe.cpp index a899c1f..fb1e545 100644 --- a/model/recipe/recipe.cpp +++ b/model/recipe/recipe.cpp @@ -12,7 +12,7 @@ Recipe::Recipe(string name, vector ingredients, Instruction in setServings(servings); } -Recipe::Recipe() : Recipe::Recipe("", vector(), Instruction(), QImage(), vector(), QDate::currentDate(), QTime(1, 0), QTime(0, 30), 10.0f){ +Recipe::Recipe() : Recipe::Recipe("", vector(), Instruction(), QImage(), vector(), QDate::currentDate(), QTime(), QTime(), 1.0f){ //Set default values when none are specified. }