Actually Usable Version #7

Merged
andrewlalis merged 7 commits from development into master 2018-03-29 14:11:27 +00:00
8 changed files with 18 additions and 7 deletions
Showing only changes of commit fefa913e94 - Show all commits

View File

@ -38,7 +38,6 @@ SOURCES += model/recipe/instruction.cpp \
HEADERS += model/recipe/instruction.h \
model/recipe/recipe.h \
userInterface/mainwindow.h \
model/database/database.h \
model/recipe/ingredients/unitofmeasure.h \
model/recipe/ingredients/ingredient.h \

View File

@ -1,4 +1,4 @@
#include "userInterface/mainwindow.h"
#include "gui/mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :

View File

@ -28,6 +28,7 @@ public:
//Loads all data from a recipe into the GUI components.
void loadFromRecipe(Recipe recipe);
private slots:
void on_newButton_clicked();

View File

@ -22,6 +22,11 @@ OpenRecipeDialog::~OpenRecipeDialog()
void OpenRecipeDialog::populateRecipesTable(){
vector<Recipe> recipes = this->recipeDB->retrieveAllRecipes();
printf("Found %d recipes:\n", recipes.size());
for (Recipe r : recipes){
r.print();
printf("\n------------------\n");
}
this->recipeTableModel.setRecipes(recipes);
ui->recipeTableView->update(QModelIndex());
ui->recipeTableView->show();
}

View File

@ -1,4 +1,4 @@
#include "userInterface/mainwindow.h"
#include "gui/mainwindow.h"
#include "gui/newrecipedialog.h"
#include <QApplication>

View File

@ -232,8 +232,8 @@ vector<RecipeTag> RecipeDatabase::retrieveAllTags(){
return tags;
}
void RecipeDatabase::deleteTag(RecipeTag tag){
ResultTable t = this->executeSQL("DELETE FROM recipeTag WHERE tagName="+surroundString(tag.getValue(), "'"));
bool RecipeDatabase::deleteRecipe(string name){
}
void RecipeDatabase::ensureTablesExist(){

View File

@ -40,6 +40,7 @@ class RecipeDatabase : public Database
vector<RecipeTag> retrieveAllTags();
//Deletion.
bool deleteRecipe(string name);
void deleteTag(RecipeTag tag);
private:

View File

@ -45,6 +45,10 @@ QVariant RecipeTableModel::headerData(int section, Qt::Orientation orientation,
return "Name";
case 1:
return "Created On";
case 2:
default:
return QVariant();
}
} else if (orientation == Qt::Vertical){
return QString::fromStdString(std::to_string(section));
@ -53,6 +57,7 @@ QVariant RecipeTableModel::headerData(int section, Qt::Orientation orientation,
}
void RecipeTableModel::setRecipes(vector<Recipe> recipes){
beginInsertRows({}, 0, recipes.size()-1);
this->recipes = recipes;
emit dataChanged(createIndex(0, 0), createIndex(this->recipes.size()-1, 2));
endInsertRows();
}