Stable first release #10

Merged
andrewlalis merged 3 commits from development into master 2018-03-31 18:36:02 +00:00
12 changed files with 249 additions and 44 deletions
Showing only changes of commit 9e3c59e415 - Show all commits

View File

@ -40,7 +40,7 @@ Recipe NewRecipeDialog::getRecipe(){
Recipe r(ui->recipeNameEdit->text().toStdString(), Recipe r(ui->recipeNameEdit->text().toStdString(),
this->ingredientListModel.getIngredients(), this->ingredientListModel.getIngredients(),
ui->instructionsTextEdit->toHtml().toStdString(), ui->instructionsTextEdit->toHtml().toStdString(),
this->img,//Image ui->imageDisplayLabel->pixmap()->toImage(),//Image
this->tagsListModel.getTags(),//Tags this->tagsListModel.getTags(),//Tags
QDate::currentDate(), QDate::currentDate(),
ui->prepTimeEdit->time(), ui->prepTimeEdit->time(),
@ -126,7 +126,6 @@ void NewRecipeDialog::on_deleteTagButton_clicked(){
void NewRecipeDialog::on_selectImageButton_clicked(){ void NewRecipeDialog::on_selectImageButton_clicked(){
QString filename = QFileDialog::getOpenFileName(this, "Open Image", QString(), "Image Files (*.png *.jpg *.bmp)"); QString filename = QFileDialog::getOpenFileName(this, "Open Image", QString(), "Image Files (*.png *.jpg *.bmp)");
if (!filename.isEmpty()){ if (!filename.isEmpty()){
this->img = QImage(filename);
ui->imageDisplayLabel->setPixmap(QPixmap(filename)); ui->imageDisplayLabel->setPixmap(QPixmap(filename));
} }
} }

View File

@ -70,7 +70,6 @@ class NewRecipeDialog : public QDialog
vector<RecipeTag> tags; vector<RecipeTag> tags;
RecipeIngredientListModel ingredientListModel; RecipeIngredientListModel ingredientListModel;
TagListModel tagsListModel; TagListModel tagsListModel;
QImage img;
bool accepted = false; bool accepted = false;
//Helper functions to fill fields. //Helper functions to fill fields.

View File

@ -72,7 +72,7 @@ void OpenRecipeDialog::on_deleteRecipeButton_clicked(){
} }
string recipePlural = (rows.size() == 1) ? "recipe" : "recipes"; string recipePlural = (rows.size() == 1) ? "recipe" : "recipes";
QString title = QString::fromStdString("Delete " + recipePlural); 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); QMessageBox::StandardButton reply = QMessageBox::question(this, title, content);
if (reply == QMessageBox::Yes){ if (reply == QMessageBox::Yes){
for (int row : rows){ for (int row : rows){
@ -135,3 +135,7 @@ void OpenRecipeDialog::on_clearSearchButton_clicked(){
ui->ingredientsListView->selectionModel()->clearSelection(); ui->ingredientsListView->selectionModel()->clearSelection();
this->populateRecipesTable(this->recipeDB->retrieveAllRecipes()); this->populateRecipesTable(this->recipeDB->retrieveAllRecipes());
} }
void OpenRecipeDialog::on_exitButton_clicked(){
this->close();
}

View File

@ -40,6 +40,8 @@ class OpenRecipeDialog : public QDialog
void on_clearSearchButton_clicked(); void on_clearSearchButton_clicked();
void on_exitButton_clicked();
private: private:
Ui::OpenRecipeDialog *ui; Ui::OpenRecipeDialog *ui;
RecipeDatabase *recipeDB; RecipeDatabase *recipeDB;

View File

@ -17,13 +17,37 @@
<iconset resource="../images.qrc"> <iconset resource="../images.qrc">
<normaloff>:/images/images/icon.png</normaloff>:/images/images/icon.png</iconset> <normaloff>:/images/images/icon.png</normaloff>:/images/images/icon.png</iconset>
</property> </property>
<property name="styleSheet">
<string notr="true">font: 25 &quot;Noto Sans CJK KR Light&quot;;</string>
</property>
<property name="modal"> <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item alignment="Qt::AlignLeft|Qt::AlignTop"> <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 alignment="Qt::AlignLeft">
<widget class="QWidget" name="searchPanel" native="true"> <widget class="QWidget" name="searchPanel" native="true">
<property name="styleSheet">
<string notr="true">background-color: rgb(245, 245, 255);</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item alignment="Qt::AlignLeft"> <item alignment="Qt::AlignLeft">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="minimumSize"> <property name="minimumSize">
@ -39,13 +63,35 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tagsTab"> <widget class="QWidget" name="Tags">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/images/tag.png</normaloff>:/images/images/tag.png</iconset>
</attribute>
<attribute name="title"> <attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>Tags</string> <string>Tags</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<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> <item>
<widget class="QListView" name="tagsListView"> <widget class="QListView" name="tagsListView">
<property name="sizePolicy"> <property name="sizePolicy">
@ -74,10 +120,32 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="ingredientsTab"> <widget class="QWidget" name="ingredientsTab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/images/ingredients.png</normaloff>:/images/images/ingredients.png</iconset>
</attribute>
<attribute name="title"> <attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>Ingredients</string> <string>Ingredients</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<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> <item>
<widget class="QListView" name="ingredientsListView"> <widget class="QListView" name="ingredientsListView">
<property name="sizePolicy"> <property name="sizePolicy">
@ -105,11 +173,33 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="foodGroups">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/images/foodPyramid.png</normaloff>:/images/images/foodPyramid.png</iconset>
</attribute>
<attribute name="title"> <attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>Food Groups</string> <string>Food Groups</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<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> <item>
<widget class="QListWidget" name="foodGroupsListWidget"> <widget class="QListWidget" name="foodGroupsListWidget">
<property name="frameShape"> <property name="frameShape">
@ -132,6 +222,9 @@
</item> </item>
<item> <item>
<widget class="QWidget" name="nameSearchPanel" native="true"> <widget class="QWidget" name="nameSearchPanel" native="true">
<property name="styleSheet">
<string notr="true">background-color: rgb(240, 240, 255);</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QLabel" name="nameLabel"> <widget class="QLabel" name="nameLabel">
@ -141,15 +234,26 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="nameEdit"/> <widget class="QLineEdit" name="nameEdit">
</item> <property name="font">
</layout> <font>
</widget> <pointsize>12</pointsize>
</item> <weight>3</weight>
<item> <italic>false</italic>
<widget class="QPushButton" name="clearSearchButton"> <bold>false</bold>
<property name="text"> </font>
<string>Clear search criteria</string> </property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText">
<string>Recipe Name</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -157,13 +261,56 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QWidget" name="contentPanel" native="true"> <widget class="QPushButton" name="clearSearchButton">
<layout class="QVBoxLayout" name="verticalLayout_2"> <property name="minimumSize">
<item alignment="Qt::AlignLeft"> <size>
<widget class="QWidget" name="interactionPanel" native="true"> <width>0</width>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <height>40</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">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);
}</string>
</property>
<property name="text">
<string>Clear search criteria</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="deleteRecipeButton"> <widget class="QPushButton" name="deleteRecipeButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">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);
}</string>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -173,20 +320,86 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="exitButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">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);
}</string>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QWidget" name="contentPanel" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<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> <item>
<widget class="QTableView" name="recipeTableView"> <widget class="QTableView" name="recipeTableView">
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>3</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(250, 250, 255);</string>
</property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum> <enum>QAbstractItemView::SelectRows</enum>
</property> </property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="gridStyle">
<enum>Qt::NoPen</enum>
</property>
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible"> <attribute name="verticalHeaderVisible">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>

View File

@ -6,5 +6,8 @@
<file>images/minus_icon.png</file> <file>images/minus_icon.png</file>
<file>images/search_icon.png</file> <file>images/search_icon.png</file>
<file>images/trash.png</file> <file>images/trash.png</file>
<file>images/tag.png</file>
<file>images/foodPyramid.png</file>
<file>images/ingredients.png</file>
</qresource> </qresource>
</RCC> </RCC>

BIN
images/foodPyramid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
images/ingredients.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/tag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -16,7 +16,7 @@ int main(int argc, char *argv[])
w.show(); w.show();
//TESTING CODE //TESTING CODE
test(&recipeDB); //test(&recipeDB);
//END TESTING CODE. //END TESTING CODE.
@ -24,7 +24,6 @@ int main(int argc, char *argv[])
a.exec(); a.exec();
recipeDB.closeConnection(); recipeDB.closeConnection();
printf("Total queries: %lu\n", recipeDB.getQueryCount());
return 0; return 0;
} }
@ -48,18 +47,4 @@ void test(RecipeDatabase *recipeDB){
bool success = recipeDB->storeRecipe(rec); bool success = recipeDB->storeRecipe(rec);
printf("Storage successful: %d\n", success); printf("Storage successful: %d\n", success);
// vector<string> 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<string> foodGroupsR = r.getFoodGroups();
// printf("Pannenkoeken Food Groups:\n");
// for (string s : foodGroupsR){
// printf("\t%s\n", s.c_str());
// }
} }

View File

@ -204,7 +204,7 @@ vector<Recipe> RecipeDatabase::retrieveRecipesWithTags(vector<RecipeTag> tags){
} }
vector<Recipe> RecipeDatabase::retrieveRecipesWithSubstring(string s){ vector<Recipe> 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); return this->readRecipesFromTable(t);
} }

View File

@ -12,7 +12,7 @@ Recipe::Recipe(string name, vector<RecipeIngredient> ingredients, Instruction in
setServings(servings); setServings(servings);
} }
Recipe::Recipe() : Recipe::Recipe("", vector<RecipeIngredient>(), Instruction(), QImage(), vector<RecipeTag>(), QDate::currentDate(), QTime(1, 0), QTime(0, 30), 10.0f){ Recipe::Recipe() : Recipe::Recipe("", vector<RecipeIngredient>(), Instruction(), QImage(), vector<RecipeTag>(), QDate::currentDate(), QTime(), QTime(), 1.0f){
//Set default values when none are specified. //Set default values when none are specified.
} }