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"
IngredientListModel::IngredientListModel(){
this->ingredients = vector<Ingredient>();
this->ingredients = vector<RecipeIngredient>();
}
int IngredientListModel::rowCount(const QModelIndex &parent){
return this->ingredients.size();
}
QVariant IngredientListModel::data(const QModelIndex &index, int role){
int IngredientListModel::rowCount(const QModelIndex &parent) const{
}
void IngredientListModel::setIngredients(vector<Ingredient> ingredients){
QVariant IngredientListModel::data(const QModelIndex &index, int role) const{
}
void IngredientListModel::setIngredients(vector<RecipeIngredient> ingredients){
this->ingredients = ingredients;
}

View File

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

View File

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