2018-05-22 03:55:46 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-05-23 06:11:58 +00:00
|
|
|
#include "CheckableItem.h"
|
|
|
|
#include "CheckableItems.h"
|
2018-05-22 18:23:03 +00:00
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
|
2018-05-22 03:55:46 +00:00
|
|
|
class GenusModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2018-05-22 06:22:46 +00:00
|
|
|
private:
|
2018-05-23 15:47:04 +00:00
|
|
|
CheckableItems m_tiere = {
|
|
|
|
"Tiger", "Bär", "Katze", "Pferd", "Gans", "Elefant", "Katze", "Hund"};
|
|
|
|
CheckableItems m_futter = {"Salat", "Fleisch", "Knocken", "Banane", "Apfel",
|
|
|
|
"Möhre", "Honig", "Zucker"};
|
|
|
|
CheckableItems m_zirkus = {"Kiste", "Holz", "Vorhang", "Baum"};
|
2018-05-22 06:22:46 +00:00
|
|
|
|
2018-05-22 03:55:46 +00:00
|
|
|
public:
|
|
|
|
GenusModel(QObject *parent);
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant data(
|
|
|
|
const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value,
|
|
|
|
int role = Qt::EditRole) override;
|
|
|
|
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation,
|
|
|
|
int role = Qt::DisplayRole) const;
|
|
|
|
|
|
|
|
void write(QJsonObject &json) const;
|
|
|
|
void read(const QJsonObject &json);
|
2018-05-22 08:57:25 +00:00
|
|
|
|
|
|
|
private:
|
2018-05-22 07:07:51 +00:00
|
|
|
bool isValidIndex(const QModelIndex &index) const;
|
2018-05-22 08:57:25 +00:00
|
|
|
|
2018-05-22 07:07:51 +00:00
|
|
|
CheckableItems &getItems(const QModelIndex &index);
|
|
|
|
const CheckableItems &getItems(const QModelIndex &index) const;
|
2018-05-22 08:57:25 +00:00
|
|
|
|
2018-05-22 07:07:51 +00:00
|
|
|
CheckableItem &getItem(const QModelIndex &index);
|
|
|
|
const CheckableItem &getItem(const QModelIndex &index) const;
|
2018-05-22 03:55:46 +00:00
|
|
|
};
|