2018-03-10 13:06:24 +00:00
|
|
|
#include "newingredientdialog.h"
|
|
|
|
#include "ui_newingredientdialog.h"
|
|
|
|
|
|
|
|
NewIngredientDialog::NewIngredientDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::NewIngredientDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
2018-03-30 10:56:42 +00:00
|
|
|
NewIngredientDialog::NewIngredientDialog(RecipeDatabase *recipeDB, QWidget *parent) : NewIngredientDialog(parent){
|
|
|
|
this->recipeDB = recipeDB;
|
|
|
|
this->populateFoodGroupBox();
|
|
|
|
}
|
|
|
|
|
2018-03-10 13:06:24 +00:00
|
|
|
NewIngredientDialog::~NewIngredientDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ingredient NewIngredientDialog::getIngredient(){
|
2018-03-30 10:56:42 +00:00
|
|
|
return Ingredient(ui->nameEdit->text().toLower().toStdString(), ui->foodGroupBox->currentText().toStdString());
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewIngredientDialog::populateFoodGroupBox(){
|
|
|
|
vector<string> foodGroups = this->recipeDB->retrieveAllFoodGroups();
|
|
|
|
printf("Found %ld food Groups.\n", foodGroups.size());
|
|
|
|
ui->foodGroupBox->clear();
|
|
|
|
for (unsigned int i = 0; i < foodGroups.size(); i++){
|
|
|
|
QString s = QString::fromStdString(foodGroups[i]);
|
|
|
|
ui->foodGroupBox->insertItem(i, s);
|
|
|
|
}
|
2018-03-10 13:06:24 +00:00
|
|
|
}
|