From 30c1328f3b82d80751e43a5c56e758abbd263c91 Mon Sep 17 00:00:00 2001 From: "A.G. Lalis" Date: Tue, 13 Feb 2018 09:48:57 +0100 Subject: [PATCH] Implemented abstract methods for IngredientListModel. --- model/recipe/ingredients/ingredientlistmodel.cpp | 14 +++++++------- model/recipe/ingredients/ingredientlistmodel.h | 10 +++++----- userInterface/mainwindow.cpp | 2 ++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/model/recipe/ingredients/ingredientlistmodel.cpp b/model/recipe/ingredients/ingredientlistmodel.cpp index edf629c..e9bae29 100644 --- a/model/recipe/ingredients/ingredientlistmodel.cpp +++ b/model/recipe/ingredients/ingredientlistmodel.cpp @@ -1,17 +1,17 @@ #include "model/recipe/ingredients/ingredientlistmodel.h" IngredientListModel::IngredientListModel(){ - this->ingredients = vector(); + this->ingredients = vector(); } -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 ingredients){ +QVariant IngredientListModel::data(const QModelIndex &index, int role) const{ + +} + +void IngredientListModel::setIngredients(vector ingredients){ this->ingredients = ingredients; } diff --git a/model/recipe/ingredients/ingredientlistmodel.h b/model/recipe/ingredients/ingredientlistmodel.h index b995210..ae4fb5d 100644 --- a/model/recipe/ingredients/ingredientlistmodel.h +++ b/model/recipe/ingredients/ingredientlistmodel.h @@ -3,7 +3,7 @@ #include -#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 ingredients); + void setIngredients(vector ingredients); private: - vector ingredients; + vector ingredients; }; #endif // INGREDIENTLISTMODEL_H diff --git a/userInterface/mainwindow.cpp b/userInterface/mainwindow.cpp index 55c857c..a96635e 100644 --- a/userInterface/mainwindow.cpp +++ b/userInterface/mainwindow.cpp @@ -6,6 +6,8 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow){ ui->setupUi(this); + ui->ingredientsPanel->setModel(); + //TESTING CODE vector ri; ri.push_back(RecipeIngredient("flour", "grains", 3.0f, UnitOfMeasure("cup", "cups", "c")));