Kstars

detaildialog.h
1 /*
2  SPDX-FileCopyrightText: 2002 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "ui_details_data.h"
10 #include "ui_details_data_comet.h"
11 #include "ui_details_database.h"
12 #include "ui_details_links.h"
13 #include "ui_details_log.h"
14 #include "ui_details_position.h"
15 
16 #include "skyobjectuserdata.h"
17 #include <kpagedialog.h>
18 
19 #include <QPalette>
20 #include <QString>
21 
22 #include <memory>
23 
24 class QListWidgetItem;
25 class QPixmap;
26 
27 class DataCometWidget;
28 class DataWidget;
29 class GeoLocation;
30 class KStars;
31 class KStarsDateTime;
32 class SkyObject;
33 
34 class PositionWidget;
35 class LinksWidget;
36 class DatabaseWidget;
37 class LogWidget;
38 
39 struct ADVTreeData
40 {
41  QString Name;
42  QString Link;
43  int Type;
44 };
45 
46 /**
47  * @class DetailDialog
48  * DetailDialog is a window showing detailed information for a selected object.
49  * The window is split into four Tabs: General, Links, Advanced and Log.
50  * The General Tab displays some type-specific data about the object, as well as its
51  * present coordinates and Rise/Set/Transit times for the current date. The Type-specific
52  * data are:
53  * @li Stars: common name, genetive name, Spectral type, magnitude, distance
54  * @li Solar System: name, object type (planet/comet/asteroid), Distance, magnitude (TBD),
55  * angular size (TBD)
56  * @li Deep Sky: Common name, other names, object type, magnitude, angular size
57  *
58  * The Links Tab allows the user to manage the list of Image and Information links
59  * listed in the object's popup menu. The Advanced Tab allows the user to query
60  * a number of professional-grade online astronomical databases for data on the object.
61  * The Log tab allows the user to attach their own text notes about the object.
62  *
63  * The General Tab includes a clickable image of the object. Clicking the image opens
64  * a Thumbnail picker tool, which downloads a list of mages of the object from the
65  * network, which the user may select as the new image for this objects Details window.
66  *
67  * @author Jason Harris, Jasem Mutlaq
68  * @version 1.0
69  */
70 class DetailDialog : public KPageDialog
71 {
72  Q_OBJECT
73  public:
74  /** Constructor */
75  DetailDialog(SkyObject *o, const KStarsDateTime &ut, GeoLocation *geo, QWidget *parent = nullptr);
76 
77  /** Destructor */
78  ~DetailDialog() override = default;
79 
80  /** @return pointer to the QPixmap of the object's thumbnail image */
81  inline QPixmap *thumbnail() { return Thumbnail.get(); }
82 
83  public slots:
84  /** @short Slot to add this object to the observing list. */
85  void addToObservingList();
86 
87  /** @short Slot to center this object in the display. */
88  void centerMap();
89 
90  /** @short Slot to center this object in the telescope. */
91  void centerTelescope();
92 
93  //TODO: showThumbnail() is only called in the ctor; make it private and not a slot.
94  /** @short Slot to display the thumbnail image for the object */
95  void showThumbnail();
96 
97  /**
98  * @short Slot to update thumbnail image for the object, using the Thumbnail
99  * Picker tool.
100  * @sa ThumbnailPicker
101  */
102  void updateThumbnail();
103 
104  /** @short Slot for viewing the selected image or info URL in the web browser. */
105  void viewLink();
106 
107  /**
108  * Popup menu function: Add a custom Image or Information URL.
109  * Opens the AddLinkDialog window.
110  */
111  void addLink();
112 
113  /**
114  * @short Set the currently-selected URL resource.
115  *
116  * This function is needed because there are two QListWidgets,
117  * each with its own selection. We need to know which the user selected most recently.
118  */
120 
121  /**
122  * @short Rebuild the Image and Info URL lists for this object.
123  * @note used when an item is added to either list.
124  */
125  void updateLists();
126 
127  /**
128  * @short Open a dialog to edit a URL in either the Images or Info lists,
129  * and update the user's *url.dat file.
130  */
131  void editLinkDialog();
132 
133  /**
134  * @short remove a URL entry from either the Images or Info lists, and
135  * update the user's *url.dat file.
136  */
137  void removeLinkDialog();
138 
139  /**
140  * Open the web browser to the selected online astronomy database,
141  * with a query to the object of this Detail Dialog.
142  */
143  void viewADVData();
144 
145  /** Save the User's text in the Log Tab to the userlog.dat file. */
146  void saveLogData();
147 
148  /** Update View/Edit/Remove buttons */
149  void updateButtons();
150 
151  private:
152  /** Build the General Data Tab for the current object. */
153  void createGeneralTab();
154 
155  /** Build the Position Tab for the current object. */
156  void createPositionTab(const KStarsDateTime &ut, GeoLocation *geo);
157 
158  /**
159  * Build the Links Tab, populating the image and info lists with the
160  * known URLs for the current Object.
161  */
162  void createLinksTab();
163 
164  /** Build the Advanced Tab */
165  void createAdvancedTab();
166 
167  /** Build the Log Tab */
168  void createLogTab();
169 
170  /** Populate the TreeView of known astronomical databases in the Advanced Tab */
171  void populateADVTree();
172 
173  /**
174  * Data for the Advanced Tab TreeView is stored in the file advinterface.dat.
175  * This function parses advinterface.dat.
176  */
177  QString parseADVData(const QString &link);
178 
179  /**
180  * Update the local info_url and image_url files
181  * @param type The URL type. 0 for Info Links, 1 for Images.
182  * @param search_line The line to be search for in the local URL files
183  * @param replace_line The replacement line once search_line is found.
184  * @note If replace_line is empty, the function will remove search_line from the file
185  */
186  void updateLocalDatabase(int type, const QString &search_line, const QString &replace_line = QString());
187 
188  SkyObject *selectedObject { nullptr };
189  QPalette titlePalette;
190  QListWidgetItem *m_CurrentLink { nullptr };
191  std::unique_ptr<QPixmap> Thumbnail;
192  DataWidget *Data { nullptr };
193  DataCometWidget *DataComet { nullptr };
194  PositionWidget *Pos { nullptr };
195  LinksWidget *Links { nullptr };
196  DatabaseWidget *Adv { nullptr };
197  LogWidget *Log { nullptr };
198  const SkyObjectUserdata::Data &m_user_data;
199 };
200 
201 class DataWidget : public QFrame, public Ui::DetailsData
202 {
203  Q_OBJECT
204 
205  public:
206  explicit DataWidget(QWidget *parent = nullptr);
207 };
208 
209 class DataCometWidget : public QFrame, public Ui::DetailsDataComet
210 {
211  Q_OBJECT
212 
213  public:
214  explicit DataCometWidget(QWidget *parent = nullptr);
215 };
216 
217 class PositionWidget : public QFrame, public Ui::DetailsPosition
218 {
219  Q_OBJECT
220 
221  public:
222  explicit PositionWidget(QWidget *parent = nullptr);
223 };
224 
225 class LinksWidget : public QFrame, public Ui::DetailsLinks
226 {
227  Q_OBJECT
228 
229  public:
230  explicit LinksWidget(QWidget *parent = nullptr);
231 };
232 
233 class DatabaseWidget : public QFrame, public Ui::DetailsDatabase
234 {
235  Q_OBJECT
236 
237  public:
238  explicit DatabaseWidget(QWidget *parent = nullptr);
239 };
240 
241 class LogWidget : public QFrame, public Ui::DetailsLog
242 {
243  Q_OBJECT
244 
245  public:
246  explicit LogWidget(QWidget *parent = nullptr);
247 };
Q_OBJECTQ_OBJECT
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
void centerTelescope()
Slot to center this object in the telescope.
void addLink()
Popup menu function: Add a custom Image or Information URL.
void centerMap()
Slot to center this object in the display.
Stores Users' Logs, Pictures and Websites regarding an object in the sky.
void updateLists()
Rebuild the Image and Info URL lists for this object.
void viewADVData()
Open the web browser to the selected online astronomy database, with a query to the object of this De...
~DetailDialog() override=default
Destructor.
void saveLogData()
Save the User's text in the Log Tab to the userlog.dat file.
void viewLink()
Slot for viewing the selected image or info URL in the web browser.
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:90
DetailDialog(SkyObject *o, const KStarsDateTime &ut, GeoLocation *geo, QWidget *parent=nullptr)
Constructor.
void updateThumbnail()
Slot to update thumbnail image for the object, using the Thumbnail Picker tool.
void editLinkDialog()
Open a dialog to edit a URL in either the Images or Info lists, and update the user's *url....
void showThumbnail()
Slot to display the thumbnail image for the object.
void setCurrentLink(QListWidgetItem *it)
Set the currently-selected URL resource.
void addToObservingList()
Slot to add this object to the observing list.
QPixmap * thumbnail()
Definition: detaildialog.h:81
void updateButtons()
Update View/Edit/Remove buttons.
void removeLinkDialog()
remove a URL entry from either the Images or Info lists, and update the user's *url....
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
Relevant data about an observing location on Earth.
Definition: geolocation.h:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:06:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.