Kstars

skyobjlistmodel.h
1/*
2 SPDX-FileCopyrightText: 2012 Samikshan Bairagya <samikshan@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "qabstractitemmodel.h"
10
11class 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{
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};
Represents an item in the list of interesting sky-objects.
Definition skyobjitem.h:21
Represents a model for the list of interesting sky-objects to be displayed in the QML interface.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Overridden method from QAbstractItemModel.
SkyObjItem * getSkyObjItem(int index)
Get sky-object item referred to by index.
QHash< int, QByteArray > roleNames() const override
Create and return a QHash<int, QByteArray> of rolenames for the SkyObjItem.
void resetModel()
Erase all data in model.
SkyObjListModel(SkyObjItem *soitem=nullptr, QObject *parent=nullptr)
Constructor.
QList< SkyObjItem * > getSkyObjItems()
Get the list of sky-object items in the model.
void addSkyObject(SkyObjItem *sobj)
Add a sky-object to the model.
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
Q_OBJECTQ_OBJECT
QObject * parent() const const
DisplayRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:53:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.