Implemented abstract methods for IngredientListModel.

This commit is contained in:
A.G. Lalis 2018-02-13 09:48:57 +01:00
parent e37179e4ae
commit 30c1328f3b
3 changed files with 14 additions and 12 deletions

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")));