File indexing completed on 2025-04-20 06:32:41
0001 /* 0002 SPDX-FileCopyrightText: 2021 Valentin Boettcher Jason Harris <hiro at protagon.space; @hiro:tchncs.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 #include <QAbstractTableModel> 0009 #include "catalogobject.h" 0010 0011 class CatalogObjectListModel : public QAbstractTableModel 0012 { 0013 Q_OBJECT 0014 public: 0015 CatalogObjectListModel(QObject *parent = nullptr, 0016 std::vector<CatalogObject> objects = {}); 0017 0018 inline int rowCount(const QModelIndex & = QModelIndex()) const override 0019 { 0020 return m_objects.size(); 0021 }; 0022 0023 inline int columnCount(const QModelIndex & = QModelIndex()) const override 0024 { 0025 return 11; 0026 }; 0027 0028 QVariant headerData(int section, Qt::Orientation orientation, 0029 int role = Qt::DisplayRole) const override; 0030 0031 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0032 0033 void setObjects(std::vector<CatalogObject> objects); 0034 0035 inline const CatalogObject &getObject(const QModelIndex &index) const 0036 { 0037 return m_objects.at(index.row()); 0038 }; 0039 0040 private: 0041 std::vector<CatalogObject> m_objects; 0042 };