Improvements in Code Quality, all basic aspects of a recipe can be displayed. #2

Merged
andrewlalis merged 3 commits from development into master 2018-02-13 09:23:09 +00:00
3 changed files with 14 additions and 12 deletions
Showing only changes of commit 30c1328f3b - Show all commits

View File

@ -1,17 +1,17 @@
#include "model/recipe/ingredients/ingredientlistmodel.h" #include "model/recipe/ingredients/ingredientlistmodel.h"
IngredientListModel::IngredientListModel(){ IngredientListModel::IngredientListModel(){
this->ingredients = vector<Ingredient>(); this->ingredients = vector<RecipeIngredient>();
} }
int IngredientListModel::rowCount(const QModelIndex &parent){ int IngredientListModel::rowCount(const QModelIndex &parent) const{
return this->ingredients.size();
}
QVariant IngredientListModel::data(const QModelIndex &index, int role){
} }
void IngredientListModel::setIngredients(vector<Ingredient> ingredients){ QVariant IngredientListModel::data(const QModelIndex &index, int role) const{
}
void IngredientListModel::setIngredients(vector<RecipeIngredient> ingredients){
this->ingredients = ingredients; this->ingredients = ingredients;
} }

View File

@ -3,7 +3,7 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include "model/recipe/ingredients/ingredient.h" #include "model/recipe/ingredients/recipeingredient.h"
class IngredientListModel : public QAbstractListModel class IngredientListModel : public QAbstractListModel
{ {
@ -11,14 +11,14 @@ public:
IngredientListModel(); IngredientListModel();
//Overridden methods. //Overridden methods.
int rowCount(const QModelIndex &parent = QModelIndex()); int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
//Custom methods to handle ingredient data. //Custom methods to handle ingredient data.
void setIngredients(vector<Ingredient> ingredients); void setIngredients(vector<RecipeIngredient> ingredients);
private: private:
vector<Ingredient> ingredients; vector<RecipeIngredient> ingredients;
}; };
#endif // INGREDIENTLISTMODEL_H #endif // INGREDIENTLISTMODEL_H

View File

@ -6,6 +6,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow){ ui(new Ui::MainWindow){
ui->setupUi(this); ui->setupUi(this);
ui->ingredientsPanel->setModel();
//TESTING CODE //TESTING CODE
vector<RecipeIngredient> ri; vector<RecipeIngredient> ri;
ri.push_back(RecipeIngredient("flour", "grains", 3.0f, UnitOfMeasure("cup", "cups", "c"))); ri.push_back(RecipeIngredient("flour", "grains", 3.0f, UnitOfMeasure("cup", "cups", "c")));