2018-02-12 13:24:11 +00:00
|
|
|
#ifndef INGREDIENTLISTMODEL_H
|
|
|
|
#define INGREDIENTLISTMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
2018-02-13 09:22:05 +00:00
|
|
|
#include <QModelIndex>
|
2018-05-22 19:07:16 +00:00
|
|
|
#include <vector>
|
2018-02-12 13:24:11 +00:00
|
|
|
|
2018-05-22 19:07:16 +00:00
|
|
|
#include "model/recipe/ingredients/ingredient.h"
|
2018-02-12 13:24:11 +00:00
|
|
|
|
2018-05-22 19:24:36 +00:00
|
|
|
/**
|
|
|
|
* @brief The IngredientListModel class
|
|
|
|
*
|
|
|
|
* The ingredient list model extends the QAbstractListModel and is used for lists of ingredients,
|
|
|
|
* whether they appear in the NewRecipe dialog or in the main recipe view.
|
|
|
|
*/
|
2018-02-12 13:24:11 +00:00
|
|
|
class IngredientListModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IngredientListModel();
|
|
|
|
|
|
|
|
//Overridden methods.
|
2018-02-13 08:48:57 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
2018-02-12 13:24:11 +00:00
|
|
|
|
|
|
|
//Custom methods to handle ingredient data.
|
2018-03-30 12:33:48 +00:00
|
|
|
void setIngredients(vector<Ingredient> ingredients);
|
2018-05-22 19:07:16 +00:00
|
|
|
bool addIngredient(Ingredient i);
|
2018-03-10 12:22:04 +00:00
|
|
|
void deleteIngredient(int index);
|
2018-03-30 12:33:48 +00:00
|
|
|
vector<Ingredient> getIngredients();
|
2018-02-12 13:24:11 +00:00
|
|
|
|
|
|
|
private:
|
2018-03-30 12:33:48 +00:00
|
|
|
vector<Ingredient> ingredients;
|
2018-03-10 09:42:22 +00:00
|
|
|
|
2018-02-12 13:24:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INGREDIENTLISTMODEL_H
|