Kstars

skyobjlistmodel.h
1 /*
2  SPDX-FileCopyrightText: 2012 Samikshan Bairagya <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "qabstractitemmodel.h"
10 
11 class SkyObjItem;
12 
13 /**
14  * @class SkyObjListModel
15  * Represents a model for the list of interesting sky-objects to be displayed in the QML interface.
16  *
17  * @author Samikshan Bairagya
18  */
20 {
21  Q_OBJECT
22  public:
23  /** Constructor */
24  explicit SkyObjListModel(SkyObjItem *soitem = nullptr, QObject *parent = nullptr);
25 
26  /**
27  * @brief Add a sky-object to the model.
28  * @param sobj
29  * Pointer to sky-object to be added.
30  */
31  void addSkyObject(SkyObjItem *sobj);
32 
33  /**
34  * @brief Create and return a QHash<int, QByteArray> of rolenames for the SkyObjItem.
35  * @return QHash<int, QByteArray> of rolenames for the SkyObjItem.
36  */
37  QHash<int, QByteArray> roleNames() const override;
38 
39  /**
40  * @brief Overridden method from QAbstractItemModel.
41  * @return The number of items in the sky-object list model.
42  */
43  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
44 
45  /**
46  * @brief Overridden method from QAbstractItemModel.
47  * @return Data stored under the given role for the sky-object item referred to by the index.
48  */
49  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
50 
51  /**
52  * @brief Get the list of sky-object items in the model.
53  * @return A QList of pointers to SkyObjItems which are there in the model.
54  */
56 
57  /**
58  * @brief Get sky-object item referred to by index.
59  * @return Pointer to SkyObjItem referred to by index.
60  */
62 
63  /** Erase all data in model. */
64  void resetModel();
65 
66  int getSkyObjIndex(SkyObjItem *item);
67 
68  private:
69  QList<SkyObjItem *> m_SoItemList; ///List of sky-object items in model.
70 };
Q_OBJECTQ_OBJECT
DisplayRole
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Overridden method from QAbstractItemModel.
void resetModel()
Erase all data in model.
QHash< int, QByteArray > roleNames() const override
Create and return a QHash<int, QByteArray> of rolenames for the SkyObjItem.
SkyObjItem * getSkyObjItem(int index)
Get sky-object item referred to by index.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Overridden method from QAbstractItemModel.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QList< SkyObjItem * > getSkyObjItems()
Get the list of sky-object items in the model.
SkyObjListModel(SkyObjItem *soitem=nullptr, QObject *parent=nullptr)
Constructor.
QObject * parent() const const
void addSkyObject(SkyObjItem *sobj)
Add a sky-object to the model.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Aug 13 2022 04:02:00 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.