Improvements in Code Quality, all basic aspects of a recipe can be displayed. #2
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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")));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue