Added a ModelItem class to hold the data for each row.
This commit is contained in:
@ -3,16 +3,31 @@
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
class ModelItem;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class TableModel : public QAbstractTableModel {
|
||||
public:
|
||||
explicit TableModel(QObject* parent = nullptr);
|
||||
|
||||
/// QAbstractItemModel interface
|
||||
public:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user