diff --git a/RecipeDB.pro b/RecipeDB.pro index 557202f..235d559 100644 --- a/RecipeDB.pro +++ b/RecipeDB.pro @@ -12,16 +12,28 @@ TARGET = RecipeDB TEMPLATE = app -SOURCES += sources/main.cpp \ - sources/mainwindow.cpp \ - SQLite/sqlite3.c +SOURCES += SQLite/sqlite3.c \ + model/recipe/ingredient.cpp \ + model/recipe/instruction.cpp \ + model/recipe/recipe.cpp \ + model/recipe/recipeingredient.cpp \ + userInterface/mainwindow.cpp \ + main.cpp \ + model/database/database.cpp -HEADERS += \ - headers/mainwindow.h \ - SQLite/sqlite3.h \ - SQLite/sqlite3ext.h +HEADERS += SQLite/sqlite3.h \ + SQLite/sqlite3ext.h \ + model/recipe/ingredient.h \ + model/recipe/instruction.h \ + model/recipe/recipe.h \ + model/recipe/recipeingredient.h \ + userInterface/mainwindow.h \ + model/database/database.h FORMS += gui/mainwindow.ui DISTFILES += \ .gitignore + +RESOURCES += \ + gui/menubuttonstylesheet.qrc diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 6050363..365f358 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -1,24 +1,205 @@ + MainWindow - - + + 0 0 - 400 - 300 + 1000 + 500 - - MainWindow + + + 0 + 0 + - - - - + + false + + + RecipeDB + + + 1.000000000000000 + + + + + + 0 + 0 + 150 + 500 + + + + false + + + background-color: rgb(0, 0, 104) + + + + + 0 + -1 + 151 + 51 + + + + + Source Sans Pro Light + 24 + 75 + true + + + + false + + + color: rgb(255, 255, 255); + + + Recipe DB + + + Qt::RichText + + + Qt::AlignCenter + + + + + + 0 + 53 + 151 + 451 + + + + + 6 + + + QLayout::SetDefaultConstraint + + + + + + Source Sans Pro Light + 16 + + + + false + + + background-color: rgb(255, 255, 255); +color: rgb(0, 0, 104); + + + New + + + false + + + false + + + false + + + false + + + + + + + + Source Sans Pro Light + 16 + + + + background-color: rgb(255, 255, 255); +color: rgb(0, 0, 104); + + + Open + + + false + + + + + + + + Source Sans Pro Light + 16 + + + + background-color: rgb(255, 255, 255); +color: rgb(0, 0, 104); + + + Browse + + + + + + + + + + 149 + -1 + 861 + 511 + + + + background-color: qlineargradient(spread:pad, x1:0, y1:0.466, x2:1, y2:0.534, stop:0 rgba(0, 55, 104, 255), stop:1 rgba(0, 0, 0, 255)); + + + QFrame::Plain + + + 0 + + + Qt::ScrollBarAsNeeded + + + false + + + + + 0 + 0 + 859 + 509 + + + + + - - + diff --git a/gui/menubuttonstylesheet.qrc b/gui/menubuttonstylesheet.qrc new file mode 100644 index 0000000..7801296 --- /dev/null +++ b/gui/menubuttonstylesheet.qrc @@ -0,0 +1,4 @@ + + + + diff --git a/sources/main.cpp b/main.cpp similarity index 94% rename from sources/main.cpp rename to main.cpp index 23847b0..4ec32ba 100644 --- a/sources/main.cpp +++ b/main.cpp @@ -1,12 +1,12 @@ -#include "headers/mainwindow.h" +#include "userInterface/mainwindow.h" #include #include #include "SQLite/sqlite3.h" -static int callback(void* data, int argc, char** argv, char** azColName){ +static int callback(void* data, int rows, char** argv, char** azColName){ int i; fprintf(stderr, "%s: ", (const char*)data); - for(i=0; ireturnCode = sqlite3_open(this->filename.c_str(), &this->db); + if (this->returnCode){ + fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db)); + exit(EXIT_FAILURE); + } +} diff --git a/model/database/database.h b/model/database/database.h new file mode 100644 index 0000000..a0c5548 --- /dev/null +++ b/model/database/database.h @@ -0,0 +1,29 @@ +#ifndef DATABASE_H +#define DATABASE_H + +#include +#include + +#include "SQLite/sqlite3.h" +#include "model/recipe/ingredient.h" + +using namespace std; + +class Database +{ +public: + Database(string filename); + + void insertIngredient(Ingredient); + vector getIngredients(); +private: + string filename; + sqlite3* db; + int returnCode; + string sql; + char* errorMsg; + + void openConnection(); +}; + +#endif // DATABASE_H diff --git a/model/recipe/ingredient.cpp b/model/recipe/ingredient.cpp new file mode 100644 index 0000000..5cdcc53 --- /dev/null +++ b/model/recipe/ingredient.cpp @@ -0,0 +1,37 @@ +#include "headers/ingredient.h" + +Ingredient::Ingredient(){ + setId(-1); + setName("NULL"); + setFoodGroup("NULL"); +} + +Ingredient::Ingredient(int id, string name, string foodGroup){ + setId(id); + setName(name); + setFoodGroup(foodGroup); +} + +int Ingredient::getId(){ + return this->id; +} + +string Ingredient::getName(){ + return this->name; +} + +string Ingredient::getFoodGroup(){ + return this->foodGroup; +} + +void Ingredient::setId(int newId){ + this->id = newId; +} + +void Ingredient::setName(string newName){ + this->name = newName; +} + +void Ingredient::setFoodGroup(string newFoodGroup){ + this->foodGroup = newFoodGroup; +} diff --git a/model/recipe/ingredient.h b/model/recipe/ingredient.h new file mode 100644 index 0000000..2f4b0d0 --- /dev/null +++ b/model/recipe/ingredient.h @@ -0,0 +1,27 @@ +#ifndef INGREDIENT_H +#define INGREDIENT_H + +#include + +using namespace std; + +class Ingredient +{ +public: + Ingredient(); + Ingredient(int id, string name, string foodGroup); + + int getId(); + string getName(); + string getFoodGroup(); + + void setId(int newId); + void setName(string newName); + void setFoodGroup(string newFoodGroup); +protected: + int id; + string name; + string foodGroup; +}; + +#endif // INGREDIENT_H diff --git a/model/recipe/instruction.cpp b/model/recipe/instruction.cpp new file mode 100644 index 0000000..4da0c44 --- /dev/null +++ b/model/recipe/instruction.cpp @@ -0,0 +1,6 @@ +#include "headers/instruction.h" + +Instruction::Instruction() +{ + +} diff --git a/model/recipe/instruction.h b/model/recipe/instruction.h new file mode 100644 index 0000000..3698c64 --- /dev/null +++ b/model/recipe/instruction.h @@ -0,0 +1,11 @@ +#ifndef INSTRUCTION_H +#define INSTRUCTION_H + + +class Instruction +{ +public: + Instruction(); +}; + +#endif // INSTRUCTION_H \ No newline at end of file diff --git a/model/recipe/recipe.cpp b/model/recipe/recipe.cpp new file mode 100644 index 0000000..e510e52 --- /dev/null +++ b/model/recipe/recipe.cpp @@ -0,0 +1,6 @@ +#include "headers/recipe.h" + +Recipe::Recipe() +{ + +} diff --git a/model/recipe/recipe.h b/model/recipe/recipe.h new file mode 100644 index 0000000..bcdee54 --- /dev/null +++ b/model/recipe/recipe.h @@ -0,0 +1,26 @@ +#ifndef RECIPE_H +#define RECIPE_H + +#include +#include +#include + +#include "headers/ingredient.h" +#include "headers/instruction.h" + +using namespace std; + +class Recipe +{ +public: + Recipe(); + + string getName(); +private: + string name; + vector tags; + vector ingredients; + vector instructions; +}; + +#endif // RECIPE_H diff --git a/model/recipe/recipeingredient.cpp b/model/recipe/recipeingredient.cpp new file mode 100644 index 0000000..ad43dfa --- /dev/null +++ b/model/recipe/recipeingredient.cpp @@ -0,0 +1,30 @@ +#include "headers/recipeingredient.h" + +RecipeIngredient::RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit) : Ingredient(id, name, foodGroup){ + setQuantity(quantity); + setUnit(unit); +} + +RecipeIngredient::RecipeIngredient(Ingredient i, int quantity, string unit){ + setId(i.getId()); + setName(i.getName()); + setFoodGroup(i.getFoodGroup()); + setQuantity(quantity); + setUnit(unit); +} + +string RecipeIngredient::getComment(){ + return this->comment; +} + +void RecipeIngredient::setQuantity(int newQuantity){ + this->quantity = newQuantity; +} + +void RecipeIngredient::setUnit(string newUnit){ + this->unit = newUnit; +} + +void RecipeIngredient::setComment(string newComment){ + this->comment = newComment; +} diff --git a/model/recipe/recipeingredient.h b/model/recipe/recipeingredient.h new file mode 100644 index 0000000..388a1a3 --- /dev/null +++ b/model/recipe/recipeingredient.h @@ -0,0 +1,29 @@ +#ifndef RECIPEINGREDIENT_H +#define RECIPEINGREDIENT_H + +#include + +#include "headers/ingredient.h" + +using namespace std; + +class RecipeIngredient : public Ingredient +{ +public: + RecipeIngredient(int id, string name, string foodGroup, int quantity, string unit); + RecipeIngredient(Ingredient i, int quantity, string unit); + + int getQuantity(); + string getUnit(); + string getComment(); + + void setQuantity(int newQuantity); + void setUnit(string newUnit); + void setComment(string newComment); +private: + int quantity; + string unit; + string comment; +}; + +#endif // RECIPEINGREDIENT_H diff --git a/sources/mainwindow.cpp b/userInterface/mainwindow.cpp similarity index 83% rename from sources/mainwindow.cpp rename to userInterface/mainwindow.cpp index 73a6e0b..3e2f80b 100644 --- a/sources/mainwindow.cpp +++ b/userInterface/mainwindow.cpp @@ -1,4 +1,4 @@ -#include "headers/mainwindow.h" +#include "userInterface/mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : diff --git a/headers/mainwindow.h b/userInterface/mainwindow.h similarity index 100% rename from headers/mainwindow.h rename to userInterface/mainwindow.h