2018-03-29 07:58:25 +00:00
|
|
|
#include "gui/mainwindow.h"
|
2018-03-04 09:19:32 +00:00
|
|
|
#include "gui/newrecipedialog.h"
|
2018-02-02 09:00:46 +00:00
|
|
|
#include <QApplication>
|
2018-02-02 10:41:36 +00:00
|
|
|
|
2018-02-12 13:24:11 +00:00
|
|
|
#include "model/database/database.h"
|
2018-03-01 16:19:13 +00:00
|
|
|
#include "model/database/recipedatabase.h"
|
2018-03-29 15:17:07 +00:00
|
|
|
#include "utils/fileutils.h"
|
2018-02-02 09:00:46 +00:00
|
|
|
|
2018-03-30 10:29:10 +00:00
|
|
|
void test(RecipeDatabase *recipeDB);
|
|
|
|
|
2018-02-02 09:00:46 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2018-03-29 15:17:07 +00:00
|
|
|
RecipeDatabase recipeDB(QString(FileUtils::appDataPath+"recipes.db").toStdString());
|
2018-02-02 09:00:46 +00:00
|
|
|
QApplication a(argc, argv);
|
2018-03-10 14:32:26 +00:00
|
|
|
MainWindow w(&recipeDB);
|
2018-02-02 09:00:46 +00:00
|
|
|
w.show();
|
|
|
|
|
2018-03-01 16:19:13 +00:00
|
|
|
//TESTING CODE
|
2018-03-30 10:29:10 +00:00
|
|
|
test(&recipeDB);
|
|
|
|
|
|
|
|
//END TESTING CODE.
|
|
|
|
|
|
|
|
w.loadFromRecipe(recipeDB.retrieveRandomRecipe());
|
|
|
|
|
|
|
|
a.exec();
|
|
|
|
recipeDB.closeConnection();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void test(RecipeDatabase *recipeDB){
|
2018-03-29 14:09:58 +00:00
|
|
|
vector<RecipeIngredient> ri;
|
|
|
|
ri.push_back(RecipeIngredient("flour", "grains", 3.0f, UnitOfMeasure("cup", "cups", "c", UnitOfMeasure::VOLUME, 1.0), ""));
|
|
|
|
ri.push_back(RecipeIngredient("baking powder", "additives", 1.0f, UnitOfMeasure("teaspoon", "teaspoons", "tsp", UnitOfMeasure::VOLUME, 1.0), ""));
|
|
|
|
|
|
|
|
Recipe rec("Example",
|
|
|
|
ri,
|
2018-03-30 09:05:17 +00:00
|
|
|
Instruction("Placeholder Text"),
|
2018-03-29 14:09:58 +00:00
|
|
|
QImage(),
|
|
|
|
vector<RecipeTag>({RecipeTag("testing"),
|
|
|
|
RecipeTag("fake")}),
|
|
|
|
QDate::currentDate(),
|
|
|
|
QTime(0, 30),
|
|
|
|
QTime(0, 25),
|
|
|
|
10.0f);
|
|
|
|
|
2018-03-30 10:29:10 +00:00
|
|
|
bool success = recipeDB->storeRecipe(rec);
|
2018-03-29 14:09:58 +00:00
|
|
|
printf("Storage successful: %d\n", success);
|
|
|
|
|
2018-03-30 10:29:10 +00:00
|
|
|
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());
|
|
|
|
}
|
2018-03-29 14:09:58 +00:00
|
|
|
|
2018-02-02 09:00:46 +00:00
|
|
|
}
|