Kstars

catalogobjectlistmodel.h
1 /*
2  SPDX-FileCopyrightText: 2021 Valentin Boettcher Jason Harris <hiro at protagon.space; @hiro:tchncs.de>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 #include <QAbstractTableModel>
9 #include "catalogobject.h"
10 
11 class CatalogObjectListModel : public QAbstractTableModel
12 {
13  Q_OBJECT
14  public:
15  CatalogObjectListModel(QObject *parent = nullptr,
16  std::vector<CatalogObject> objects = {});
17 
18  inline int rowCount(const QModelIndex & = QModelIndex()) const override
19  {
20  return m_objects.size();
21  };
22 
23  inline int columnCount(const QModelIndex & = QModelIndex()) const override
24  {
25  return 11;
26  };
27 
28  QVariant headerData(int section, Qt::Orientation orientation,
29  int role = Qt::DisplayRole) const override;
30 
31  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
32 
33  void setObjects(std::vector<CatalogObject> objects);
34 
35  inline const CatalogObject &getObject(const QModelIndex &index) const
36  {
37  return m_objects.at(index.row());
38  };
39 
40  private:
41  std::vector<CatalogObject> m_objects;
42 };
Q_OBJECTQ_OBJECT
DisplayRole
virtual int rowCount(const QModelIndex &parent) const const=0
virtual QVariant data(const QModelIndex &index, int role) const const=0
Orientation
virtual int columnCount(const QModelIndex &parent) const const=0
int row() const const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const const
A simple container object to hold the minimum information for a Deeb Sky Object to be drawn on the sk...
Definition: catalogobject.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 03:57:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.