Implemented abstract methods for IngredientListModel.
This commit is contained in:
parent
e37179e4ae
commit
30c1328f3b
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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")));
|
||||||
|
|
Loading…
Reference in New Issue