Kstars

skyobjitem.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 <QString>
10#include <QVariant>
11
12class SkyObject;
13
14/**
15 * @class SkyObjItem
16 * Represents an item in the list of interesting sky-objects.
17 *
18 * @author Samikshan Bairagya
19 */
21{
22 public:
23 /**
24 * @enum SkyObjectRoles
25 * User-defined role for the SkyObjItem
26 */
28 {
29 DispNameRole = Qt::UserRole + 1,
30 DispImageRole,
31 DispSummaryRole,
32 CategoryRole,
33 CategoryNameRole
34 };
35
36 /**
37 * @enum Type
38 * The type classification for the SkyObjItem
39 */
40 enum Type
41 {
42 Planet,
43 Star,
44 Constellation,
45 Galaxy,
46 Cluster,
47 Nebula,
49 };
50
51 /**
52 * @brief Constructor
53 * @param so Pointer to the SkyObject which the SkyObjItem represents.
54 */
55 explicit SkyObjItem(SkyObject *so = nullptr);
56 ~SkyObjItem() = default;
57
58 /**
59 * @brief Get data associated with a particular role for the SkyObjItem
60 * @param role User-defined role for which data is required
61 * @return QVariant data associated with role
62 */
63 QVariant data(int role);
64
65 /**
66 * @brief Get name of sky-object associated with the SkyObjItem.
67 * @return Name of sky-object associated with the SkyObjItem as a QString
68 */
69 inline QString getName() const { return m_Name; }
70
71 /**
72 * @brief Get longname of sky-object associated with the SkyObjItem.
73 * @return Longname of sky-object associated with the SkyObjItem as a QString
74 */
75 inline QString getDescName() const
76 {
77 if (m_LongName == m_Name)
78 return m_LongName;
79 else
80 return m_LongName + "\n (" + m_Name + ")";
81 }
82
83 /**
84 * @brief Get longname of sky-object associated with the SkyObjItem.
85 * @return Longname of sky-object associated with the SkyObjItem as a QString
86 */
87 inline QString getLongName() const { return m_LongName; }
88
89 /**
90 * @brief Get category of sky-object associated with the SkyObjItem as a QString.
91 * @return Category of sky-object associated with the SkyObjItem as a QString.
92 */
93 inline QString getTypeName() const { return m_TypeName; }
94
95 /**
96 * @brief Get category of sky-object associated with the SkyObjItem as an integer.
97 * @return Category of sky-object associated with the SkyObjItem as a QString as an integer.
98 */
99 inline int getType() const { return m_Type; }
100
101 /**
102 * @brief Get current position of sky-object associated with the SkyObjItem.
103 * @return Current position of sky-object associated with the SkyObjItem.
104 */
105 inline QString getPosition() const { return m_Position; }
106
107 /**
108 * @brief Get current RA/DE of sky-object associated with the SkyObjItem.
109 * @return Current RA/DE of sky-object associated with the SkyObjItem.
110 */
111 QString getRADE() const;
112
113 /**
114 * @brief Get current Altitude and Azimuth of sky-object associated with the SkyObjItem.
115 * @return Current Altitude and Azimuth of sky-object associated with the SkyObjItem.
116 */
117 QString getAltAz() const;
118
119 /**
120 * @brief Get sky-object associated with the SkyObjItem.
121 * @return Pointer to SkyObject associated with the SkyObjItem.
122 */
123 inline SkyObject *getSkyObject() { return m_So; }
124
125 QString getImageURL(bool preferThumb) const;
126
127 inline QString loadObjectDescription() const;
128
129 /**
130 * @brief Get Summary Description for the SkyObjItem.
131 * @return Summary Description for the SkyObjItem as a QString.
132 */
134
135 /**
136 * @brief Get magnitude of sky-object associated with the SkyObjItem.
137 * @return Magnitude of sky-object associated with the SkyObjItem.
138 */
139 float getMagnitude() const;
140
141 /**
142 * @brief Get surface-brightness of sky-object associated with the SkyObjItem as a QString
143 * to be displayed on the details-view.
144 * @return Surface-brightness of sky-object associated with the SkyObjItem as a QString.
145 */
147
148 /**
149 * @brief Get size of sky-object associated with the SkyObjItem as a QString
150 * to be displayed on the details-view.
151 * @return Size of sky-object associated with the SkyObjItem as a QString.
152 */
153 QString getSize() const;
154
155 /**
156 * @brief Set current position of the sky-object in the sky.
157 * @param so Pointer to SkyObject for which position information is required.
158 */
159 void setPosition(SkyObject *so);
160
161 private:
162 /// Name of sky-object
163 QString m_Name;
164 /// Long name of sky-object(if available)
165 QString m_LongName;
166 /// Category of sky-object
167 QString m_TypeName;
168 /// Position of sky-object in the sky.
169 QString m_Position;
170 /// Category of sky-object of type SkyObjItem::Type
171 Type m_Type { SkyObjItem::Planet };
172 /// Pointer to SkyObject represented by SkyObjItem
173 SkyObject *m_So { nullptr };
174};
Represents an item in the list of interesting sky-objects.
Definition skyobjitem.h:21
SkyObject * getSkyObject()
Get sky-object associated with the SkyObjItem.
Definition skyobjitem.h:123
SkyObjItem(SkyObject *so=nullptr)
Constructor.
QString getSurfaceBrightness() const
Get surface-brightness of sky-object associated with the SkyObjItem as a QString to be displayed on t...
QVariant data(int role)
Get data associated with a particular role for the SkyObjItem.
Type
The type classification for the SkyObjItem.
Definition skyobjitem.h:41
QString getAltAz() const
Get current Altitude and Azimuth of sky-object associated with the SkyObjItem.
int getType() const
Get category of sky-object associated with the SkyObjItem as an integer.
Definition skyobjitem.h:99
QString getSummary(bool includeDescription) const
Get Summary Description for the SkyObjItem.
QString getRADE() const
Get current RA/DE of sky-object associated with the SkyObjItem.
QString getTypeName() const
Get category of sky-object associated with the SkyObjItem as a QString.
Definition skyobjitem.h:93
QString getName() const
Get name of sky-object associated with the SkyObjItem.
Definition skyobjitem.h:69
QString getSize() const
Get size of sky-object associated with the SkyObjItem as a QString to be displayed on the details-vie...
SkyObjectRoles
User-defined role for the SkyObjItem.
Definition skyobjitem.h:28
float getMagnitude() const
Get magnitude of sky-object associated with the SkyObjItem.
QString getLongName() const
Get longname of sky-object associated with the SkyObjItem.
Definition skyobjitem.h:87
void setPosition(SkyObject *so)
Set current position of the sky-object in the sky.
QString getDescName() const
Get longname of sky-object associated with the SkyObjItem.
Definition skyobjitem.h:75
QString getPosition() const
Get current position of sky-object associated with the SkyObjItem.
Definition skyobjitem.h:105
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
Represents the supernova object.
Definition supernova.h:34
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:01:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.