34 lines
935 B
C++
34 lines
935 B
C++
#ifndef TABLEMODEL_H
|
|
#define TABLEMODEL_H
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
class ModelItem;
|
|
|
|
using namespace std;
|
|
|
|
class TableModel : public QAbstractTableModel {
|
|
public:
|
|
explicit TableModel(QObject* parent = nullptr);
|
|
|
|
/// QAbstractItemModel interface
|
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
|
|
|
int rowCount(const QModelIndex& parent) const override;
|
|
int columnCount(const QModelIndex& parent) const override;
|
|
QVariant data(const QModelIndex& index, int role) const override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
|
// bool setItemData(const QModelIndex& index, const QMap<int, QVariant>& roles) override;
|
|
|
|
private:
|
|
/// members
|
|
QList<shared_ptr<ModelItem>> m_items;
|
|
|
|
/// functions
|
|
int getRoleForColumn(const int column) const;
|
|
};
|
|
|
|
#endif // TABLEMODEL_H
|