Kstars

detaildialoglite.h
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QObject>
10 #include <QString>
11 
12 /**
13  * @class DetalDialogLite
14  * @short Backend for Object details dialog in QML
15  * A backend of details dialog declared in QML. Members of this class are the properties that are used
16  * in QML. Whenever user clicks on some object the properties are updated with the info about this object
17  * and Details dialog in QML is updated automatically as we use property binding there.
18  *
19  * @author Artem Fedoskin, Jason Harris, Jasem Mutlaq
20  * @version 1.0
21  */
22 class DetailDialogLite : public QObject
23 {
24  Q_OBJECT
25 
26  //General
27  Q_PROPERTY(QString name MEMBER m_name NOTIFY nameChanged)
28  Q_PROPERTY(QString magnitude MEMBER m_magnitude NOTIFY magnitudeChanged)
29  Q_PROPERTY(QString distance MEMBER m_distance NOTIFY distanceChanged)
30  Q_PROPERTY(QString BVindex MEMBER m_BVindex NOTIFY BVindexChanged)
31  Q_PROPERTY(QString angSize MEMBER m_angSize NOTIFY angSizeChanged)
32  Q_PROPERTY(QString illumination MEMBER m_illumination NOTIFY illuminationChanged)
33  Q_PROPERTY(QString typeInConstellation MEMBER m_typeInConstellation NOTIFY typeInConstellationChanged)
34  Q_PROPERTY(QString thumbnail MEMBER m_thumbnail NOTIFY thumbnailChanged)
35 
36  //General advanced
37  Q_PROPERTY(QString perihelion MEMBER m_perihelion NOTIFY perihelionChanged)
38  Q_PROPERTY(QString orbitID MEMBER m_orbitID NOTIFY orbitIDChanged)
39  Q_PROPERTY(QString NEO MEMBER m_NEO NOTIFY NEOChanged)
40  Q_PROPERTY(QString diameter MEMBER m_diameter NOTIFY diameterChanged)
41  Q_PROPERTY(QString rotation MEMBER m_rotation NOTIFY rotationChanged)
42  Q_PROPERTY(QString earthMOID MEMBER m_earthMOID NOTIFY earthMOIDChanged)
43  Q_PROPERTY(QString orbitClass MEMBER m_orbitClass NOTIFY orbitClassChanged)
44  Q_PROPERTY(QString albedo MEMBER m_albedo NOTIFY albedoChanged)
45  Q_PROPERTY(QString dimensions MEMBER m_dimensions NOTIFY dimensionsChanged)
46  Q_PROPERTY(QString period MEMBER m_period NOTIFY periodChanged)
47 
48  //Position
49  Q_PROPERTY(QString decLabel MEMBER m_decLabel NOTIFY decLabelChanged)
50  Q_PROPERTY(QString dec MEMBER m_dec NOTIFY decChanged)
51 
52  Q_PROPERTY(QString RALabel MEMBER m_RALabel NOTIFY RALabelChanged)
53  Q_PROPERTY(QString RA MEMBER m_RA NOTIFY RAChanged)
54 
55  Q_PROPERTY(QString az MEMBER m_az NOTIFY azChanged)
56  Q_PROPERTY(QString airmass MEMBER m_airmass NOTIFY airmassChanged)
57  Q_PROPERTY(QString HA MEMBER m_HA NOTIFY HAChanged)
58  Q_PROPERTY(QString alt MEMBER m_alt NOTIFY altChanged)
59  Q_PROPERTY(QString RA0 MEMBER m_RA0 NOTIFY RA0Changed)
60  Q_PROPERTY(QString dec0 MEMBER m_dec0 NOTIFY dec0Changed)
61 
62  Q_PROPERTY(QString timeRise MEMBER m_timeRise NOTIFY timeRiseChanged)
63  Q_PROPERTY(QString timeTransit MEMBER m_timeTransit NOTIFY timeTransitChanged)
64  Q_PROPERTY(QString timeSet MEMBER m_timeSet NOTIFY timeSetChanged)
65 
66  Q_PROPERTY(QString azRise MEMBER m_azRise NOTIFY azRiseChanged)
67  Q_PROPERTY(QString altTransit MEMBER m_altTransit NOTIFY altTransitChanged)
68  Q_PROPERTY(QString azSet MEMBER m_azSet NOTIFY azSetChanged)
69 
70  //Links
71  Q_PROPERTY(QStringList infoTitleList MEMBER m_infoTitleList NOTIFY infoTitleListChanged)
72  Q_PROPERTY(QStringList imageTitleList MEMBER m_imageTitleList NOTIFY imageTitleListChanged)
73  Q_PROPERTY(bool isLinksOn MEMBER m_isLinksOn NOTIFY isLinksOnChanged)
74 
75  //Log
76  Q_PROPERTY(bool isLogOn MEMBER m_isLogOn NOTIFY isLogOnChanged)
77  Q_PROPERTY(QString userLog MEMBER m_userLog NOTIFY userLogChanged)
78 
79  public:
80  DetailDialogLite();
81 
82  /** Connect SkyMapLite's signals to proper slots */
83  void initialize();
84 
85  /** Set thumbnail to SkyMapLite::clickedObjectLite's thumbnail (if any) */
86  void setupThumbnail();
87 
88  /**
89  * @brief addLink adds new link to SkyObject
90  * @param url URL of the link
91  * @param desc description of the link
92  * @param isImageLink true if it is a link to image. False if it is information link
93  */
94  Q_INVOKABLE void addLink(const QString &url, const QString &desc, bool isImageLink);
95 
96  /**
97  * @short Remove link from user's database
98  * @param itemIndex - index of a link
99  * @param isImage - true if it is a link on image, false if it is an info link
100  */
101  Q_INVOKABLE void removeLink(int itemIndex, bool isImage);
102 
103  /**
104  * @short Edit link's description and URL
105  * @param itemIndex - index of a link
106  * @param isImage - true if it is a link on image, false if it is an info link
107  * @param desc - new description
108  * @param url - new URL
109  */
110  void editLink(int itemIndex, bool isImage, const QString &desc, const QString &url);
111 
112  /**
113  * Update the local info_url and image_url files
114  * @param type The URL type. 0 for Info Links, 1 for Images.
115  * @param search_line The line to be search for in the local URL files
116  * @param replace_line The replacement line once search_line is found.
117  * @note If replace_line is empty, the function will remove search_line from the file
118  */
119  void updateLocalDatabase(int type, const QString &search_line, const QString &replace_line = QString());
120 
121  //We don't need bindings to URLs so let's just have getters
122  /**
123  * @param index - URL's index in SkyObject::ImageList()
124  * @return URL to user added information about object
125  */
126  Q_INVOKABLE QString getInfoURL(int index);
127 
128  /**
129  * @param index - URL's index in SkyObject::ImageList()
130  * @return URL to user added object image
131  */
132  Q_INVOKABLE QString getImageURL(int index);
133 
134  public slots:
135  /** Update properties that are shown on "General" tab */
136  void createGeneralTab();
137 
138  /** Update properties that are shown on "Position" tab */
139  void createPositionTab();
140 
141  /** Update properties that are shown on "Log" tab */
142  void createLogTab();
143 
144  /** Update properties that are shown on "Links" tab */
145  void createLinksTab();
146 
147  /** Save the User's text in the Log Tab to the userlog.dat file. */
148  void saveLogData(const QString &userLog);
149 
150  signals:
151  //General
152  void nameChanged(QString);
153  void magnitudeChanged(QString);
154  void distanceChanged(QString);
155  void BVindexChanged(QString);
156  void angSizeChanged(QString);
157  void illuminationChanged(QString);
158  void typeInConstellationChanged(QString);
159  void thumbnailChanged(QString);
160 
161  //General advanced
162  void perihelionChanged(QString);
163  void orbitIDChanged(QString);
164  void NEOChanged(QString);
165  void diameterChanged(QString);
166  void rotationChanged(QString);
167  void earthMOIDChanged(QString);
168  void orbitClassChanged(QString);
169  void albedoChanged(QString);
170  void dimensionsChanged(QString);
171  void periodChanged(QString);
172 
173  //Position
174  void decLabelChanged();
175  void decChanged();
176 
177  void RALabelChanged();
178  void RAChanged();
179 
180  void azChanged();
181  void airmassChanged();
182  void HAChanged();
183  void altChanged();
184  void RA0Changed();
185  void dec0Changed();
186 
187  void timeRiseChanged();
188  void timeTransitChanged();
189  void timeSetChanged();
190 
191  void azRiseChanged();
192  void altTransitChanged();
193  void azSetChanged();
194 
195  //Links
196  void infoTitleListChanged();
197  void imageTitleListChanged();
198  void isLinksOnChanged();
199 
200  //Log
201  void isLogOnChanged();
202  void userLogChanged();
203 
204  private:
205  //General
206  QString m_name;
207  QString m_magnitude;
208  QString m_distance;
209  QString m_BVindex;
210  QString m_angSize;
211  QString m_illumination;
212  QString m_typeInConstellation;
213  QString m_thumbnail;
214 
215  //General advanced
216  QString m_perihelion;
217  QString m_orbitID;
218  QString m_NEO;
219  QString m_diameter;
220  QString m_rotation;
221  QString m_earthMOID;
222  QString m_orbitClass;
223  QString m_albedo;
224  QString m_dimensions;
225  QString m_period;
226 
227  //Position
228  QString m_decLabel;
229  QString m_dec;
230 
231  QString m_RALabel;
232  QString m_RA;
233 
234  QString m_az;
235  QString m_airmass;
236  QString m_HA;
237  QString m_alt;
238  QString m_RA0;
239  QString m_dec0;
240 
241  QString m_timeRise;
242  QString m_timeTransit;
243  QString m_timeSet;
244 
245  QString m_azRise;
246  QString m_altTransit;
247  QString m_azSet;
248 
249  //Links
250  bool m_isLinksOn { false };
251  QStringList m_infoTitleList;
252  QStringList m_imageTitleList;
253 
254  //Log
255  bool m_isLogOn { false };
256  QString m_userLog;
257 };
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
void initialize(StandardShortcut id)
Q_INVOKABLEQ_INVOKABLE
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Aug 8 2022 04:13:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.