File indexing completed on 2024-04-28 15:11:24
0001 /* 0002 SPDX-FileCopyrightText: 2012 Samikshan Bairagya <samikshan@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QString> 0010 #include <QVariant> 0011 0012 class SkyObject; 0013 0014 /** 0015 * @class SkyObjItem 0016 * Represents an item in the list of interesting sky-objects. 0017 * 0018 * @author Samikshan Bairagya 0019 */ 0020 class SkyObjItem 0021 { 0022 public: 0023 /** 0024 * @enum SkyObjectRoles 0025 * User-defined role for the SkyObjItem 0026 */ 0027 enum SkyObjectRoles 0028 { 0029 DispNameRole = Qt::UserRole + 1, 0030 DispImageRole, 0031 DispSummaryRole, 0032 CategoryRole, 0033 CategoryNameRole 0034 }; 0035 0036 /** 0037 * @enum Type 0038 * The type classification for the SkyObjItem 0039 */ 0040 enum Type 0041 { 0042 Planet, 0043 Star, 0044 Constellation, 0045 Galaxy, 0046 Cluster, 0047 Nebula, 0048 Supernova 0049 }; 0050 0051 /** 0052 * @brief Constructor 0053 * @param so Pointer to the SkyObject which the SkyObjItem represents. 0054 */ 0055 explicit SkyObjItem(SkyObject *so = nullptr); 0056 ~SkyObjItem() = default; 0057 0058 /** 0059 * @brief Get data associated with a particular role for the SkyObjItem 0060 * @param role User-defined role for which data is required 0061 * @return QVariant data associated with role 0062 */ 0063 QVariant data(int role); 0064 0065 /** 0066 * @brief Get name of sky-object associated with the SkyObjItem. 0067 * @return Name of sky-object associated with the SkyObjItem as a QString 0068 */ 0069 inline QString getName() const { return m_Name; } 0070 0071 /** 0072 * @brief Get longname of sky-object associated with the SkyObjItem. 0073 * @return Longname of sky-object associated with the SkyObjItem as a QString 0074 */ 0075 inline QString getDescName() const 0076 { 0077 if (m_LongName == m_Name) 0078 return m_LongName; 0079 else 0080 return m_LongName + "\n (" + m_Name + ")"; 0081 } 0082 0083 /** 0084 * @brief Get longname of sky-object associated with the SkyObjItem. 0085 * @return Longname of sky-object associated with the SkyObjItem as a QString 0086 */ 0087 inline QString getLongName() const { return m_LongName; } 0088 0089 /** 0090 * @brief Get category of sky-object associated with the SkyObjItem as a QString. 0091 * @return Category of sky-object associated with the SkyObjItem as a QString. 0092 */ 0093 inline QString getTypeName() const { return m_TypeName; } 0094 0095 /** 0096 * @brief Get category of sky-object associated with the SkyObjItem as an integer. 0097 * @return Category of sky-object associated with the SkyObjItem as a QString as an integer. 0098 */ 0099 inline int getType() const { return m_Type; } 0100 0101 /** 0102 * @brief Get current position of sky-object associated with the SkyObjItem. 0103 * @return Current position of sky-object associated with the SkyObjItem. 0104 */ 0105 inline QString getPosition() const { return m_Position; } 0106 0107 /** 0108 * @brief Get current RA/DE of sky-object associated with the SkyObjItem. 0109 * @return Current RA/DE of sky-object associated with the SkyObjItem. 0110 */ 0111 QString getRADE() const; 0112 0113 /** 0114 * @brief Get current Altitude and Azimuth of sky-object associated with the SkyObjItem. 0115 * @return Current Altitude and Azimuth of sky-object associated with the SkyObjItem. 0116 */ 0117 QString getAltAz() const; 0118 0119 /** 0120 * @brief Get sky-object associated with the SkyObjItem. 0121 * @return Pointer to SkyObject associated with the SkyObjItem. 0122 */ 0123 inline SkyObject *getSkyObject() { return m_So; } 0124 0125 QString getImageURL(bool preferThumb) const; 0126 0127 inline QString loadObjectDescription() const; 0128 0129 /** 0130 * @brief Get Summary Description for the SkyObjItem. 0131 * @return Summary Description for the SkyObjItem as a QString. 0132 */ 0133 QString getSummary(bool includeDescription) const; 0134 0135 /** 0136 * @brief Get magnitude of sky-object associated with the SkyObjItem. 0137 * @return Magnitude of sky-object associated with the SkyObjItem. 0138 */ 0139 float getMagnitude() const; 0140 0141 /** 0142 * @brief Get surface-brightness of sky-object associated with the SkyObjItem as a QString 0143 * to be displayed on the details-view. 0144 * @return Surface-brightness of sky-object associated with the SkyObjItem as a QString. 0145 */ 0146 QString getSurfaceBrightness() const; 0147 0148 /** 0149 * @brief Get size of sky-object associated with the SkyObjItem as a QString 0150 * to be displayed on the details-view. 0151 * @return Size of sky-object associated with the SkyObjItem as a QString. 0152 */ 0153 QString getSize() const; 0154 0155 /** 0156 * @brief Set current position of the sky-object in the sky. 0157 * @param so Pointer to SkyObject for which position information is required. 0158 */ 0159 void setPosition(SkyObject *so); 0160 0161 private: 0162 /// Name of sky-object 0163 QString m_Name; 0164 /// Long name of sky-object(if available) 0165 QString m_LongName; 0166 /// Category of sky-object 0167 QString m_TypeName; 0168 /// Position of sky-object in the sky. 0169 QString m_Position; 0170 /// Category of sky-object of type SkyObjItem::Type 0171 Type m_Type { SkyObjItem::Planet }; 0172 /// Pointer to SkyObject represented by SkyObjItem 0173 SkyObject *m_So { nullptr }; 0174 };