dorian
c6e1e12cfe
- now using QAbstractItem model - added error handling so the app doesn't crash anymore when the data is invalid
45 lines
963 B
C++
45 lines
963 B
C++
#ifndef FOODPLANMODEL_H
|
|
#define FOODPLANMODEL_H
|
|
|
|
#include <QAbstractListModel>
|
|
#include <QtDebug>
|
|
#include "serverconn.h"
|
|
|
|
class FoodPlanModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit FoodPlanModel(QObject *parent = nullptr);
|
|
~FoodPlanModel();
|
|
enum DishRole {
|
|
CookteamRole = Qt::DisplayRole,
|
|
DateRole,
|
|
MainDishRole,
|
|
MainDishVegRole,
|
|
GarnishRole,
|
|
DessertRole
|
|
};
|
|
Q_ENUM(DishRole)
|
|
|
|
int rowCount(const QModelIndex & = QModelIndex()) const;
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
QHash<int, QByteArray> roleNames() const;
|
|
|
|
Q_INVOKABLE QVariantMap get(int row) const;
|
|
|
|
private:
|
|
struct Dish {
|
|
QString cookteam;
|
|
QString date;
|
|
QString mainDish;
|
|
QString mainDishVeg;
|
|
QString garnish;
|
|
QString dessert;
|
|
};
|
|
|
|
QList<Dish> m_foodPlan;
|
|
|
|
public slots:
|
|
};
|
|
|
|
#endif // FOODPLANMODEL_H
|