First ability to create recipe in gui #5
|
@ -138,7 +138,31 @@ void NewRecipeDialog::on_newIngredientButton_clicked(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewRecipeDialog::on_newTagButton_clicked(){
|
void NewRecipeDialog::on_newTagButton_clicked(){
|
||||||
newTagDialog
|
NewTagDialog d(this);
|
||||||
d.show();
|
d.show();
|
||||||
|
if (d.exec() == QDialog::Accepted){
|
||||||
|
RecipeTag tag = d.getTag();
|
||||||
|
//Temporarily add this to the tags list, and it will be saved if the recipe is saved.
|
||||||
|
this->tags.push_back(tag);
|
||||||
|
ui->tagsComboBox->clear();
|
||||||
|
for (unsigned int i = 0; i < this->tags.size(); i++){
|
||||||
|
QString s = QString::fromStdString(this->tags[i].getValue());
|
||||||
|
ui->tagsComboBox->insertItem(i, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewRecipeDialog::on_removeTagButton_clicked(){
|
||||||
|
int index = ui->tagsComboBox->currentIndex();
|
||||||
|
if (index < 0 || index >= this->tags.size()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RecipeTag tag = this->tags[ui->tagsComboBox->currentIndex()];
|
||||||
|
string content = "Are you sure you wish to delete the following tag:\n"+tag.getValue();
|
||||||
|
QMessageBox::StandardButton reply = QMessageBox::question(this, QString("Delete Tag"), QString(content.c_str()));
|
||||||
|
if (reply == QMessageBox::Yes){
|
||||||
|
this->recipeDB->deleteTag(tag);
|
||||||
|
this->populateTagsBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "model/database/recipedatabase.h"
|
#include "model/database/recipedatabase.h"
|
||||||
#include "model/recipe/ingredients/ingredientlistmodel.h"
|
#include "model/recipe/ingredients/ingredientlistmodel.h"
|
||||||
|
@ -51,6 +52,8 @@ class NewRecipeDialog : public QDialog
|
||||||
|
|
||||||
void on_newTagButton_clicked();
|
void on_newTagButton_clicked();
|
||||||
|
|
||||||
|
void on_removeTagButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NewRecipeDialog *ui;
|
Ui::NewRecipeDialog *ui;
|
||||||
RecipeDatabase *recipeDB;
|
RecipeDatabase *recipeDB;
|
||||||
|
|
|
@ -279,12 +279,34 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="tagsComboBox"/>
|
<widget class="QComboBox" name="tagsComboBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item alignment="Qt::AlignRight">
|
||||||
<widget class="QPushButton" name="newTagButton">
|
<widget class="QPushButton" name="newTagButton">
|
||||||
<property name="text">
|
<property name="toolTip">
|
||||||
<string>New</string>
|
<string>Create a new tag</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/images/plus_icon.png</normaloff>:/images/images/plus_icon.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QPushButton" name="removeTagButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Permanently delete this tag</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/images/minus_icon.png</normaloff>:/images/images/minus_icon.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -460,6 +482,9 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="currentText">
|
<property name="currentText">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
@ -467,8 +492,12 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="newIngredientButton">
|
<widget class="QPushButton" name="newIngredientButton">
|
||||||
<property name="text">
|
<property name="toolTip">
|
||||||
<string>New</string>
|
<string>Create a new ingredient</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/images/plus_icon.png</normaloff>:/images/images/plus_icon.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -532,12 +561,20 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="unitComboBox"/>
|
<widget class="QComboBox" name="unitComboBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item alignment="Qt::AlignRight">
|
||||||
<widget class="QPushButton" name="newUnitButton">
|
<widget class="QPushButton" name="newUnitButton">
|
||||||
<property name="text">
|
<property name="icon">
|
||||||
<string>New</string>
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/images/plus_icon.png</normaloff>:/images/images/plus_icon.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
<qresource prefix="/images">
|
<qresource prefix="/images">
|
||||||
<file>images/no_image.png</file>
|
<file>images/no_image.png</file>
|
||||||
<file>images/icon.png</file>
|
<file>images/icon.png</file>
|
||||||
|
<file>images/plus_icon.png</file>
|
||||||
|
<file>images/minus_icon.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 480 B |
Binary file not shown.
After Width: | Height: | Size: 912 B |
|
@ -223,6 +223,10 @@ vector<RecipeTag> RecipeDatabase::retrieveAllTags(){
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecipeDatabase::deleteTag(RecipeTag tag){
|
||||||
|
ResultTable t = this->executeSQL("DELETE FROM recipeTag WHERE tagName="+surroundString(tag.getValue(), "'"));
|
||||||
|
}
|
||||||
|
|
||||||
void RecipeDatabase::ensureTablesExist(){
|
void RecipeDatabase::ensureTablesExist(){
|
||||||
//Make sure that foreign keys are enabled.
|
//Make sure that foreign keys are enabled.
|
||||||
this->executeSQL("PRAGMA foreign_keys = ON;");
|
this->executeSQL("PRAGMA foreign_keys = ON;");
|
||||||
|
|
|
@ -37,6 +37,9 @@ class RecipeDatabase : public Database
|
||||||
vector<UnitOfMeasure> retrieveAllUnitsOfMeasure();
|
vector<UnitOfMeasure> retrieveAllUnitsOfMeasure();
|
||||||
vector<RecipeTag> retrieveTags(int recipeId);
|
vector<RecipeTag> retrieveTags(int recipeId);
|
||||||
vector<RecipeTag> retrieveAllTags();
|
vector<RecipeTag> retrieveAllTags();
|
||||||
|
|
||||||
|
//Deletion.
|
||||||
|
void deleteTag(RecipeTag tag);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//Utility methods.
|
//Utility methods.
|
||||||
|
|
Loading…
Reference in New Issue