Warning, file /education/kstars/kstars/dialogs/detaildialog.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2002 Jason Harris <kstars@30doradus.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ui_details_data.h"
0010 #include "ui_details_data_comet.h"
0011 #include "ui_details_database.h"
0012 #include "ui_details_links.h"
0013 #include "ui_details_log.h"
0014 #include "ui_details_position.h"
0015 
0016 #include "skyobjectuserdata.h"
0017 #include <kpagedialog.h>
0018 
0019 #include <QPalette>
0020 #include <QString>
0021 
0022 #include <memory>
0023 
0024 class QListWidgetItem;
0025 class QPixmap;
0026 
0027 class DataCometWidget;
0028 class DataWidget;
0029 class GeoLocation;
0030 class KStars;
0031 class KStarsDateTime;
0032 class SkyObject;
0033 
0034 class PositionWidget;
0035 class LinksWidget;
0036 class DatabaseWidget;
0037 class LogWidget;
0038 
0039 struct ADVTreeData
0040 {
0041     QString Name;
0042     QString Link;
0043     int Type;
0044 };
0045 
0046 /**
0047   * @class DetailDialog
0048   * DetailDialog is a window showing detailed information for a selected object.
0049     * The window is split into four Tabs: General, Links, Advanced and Log.
0050     * The General Tab displays some type-specific data about the object, as well as its
0051     * present coordinates and Rise/Set/Transit times for the current date.  The Type-specific
0052     * data are:
0053     * @li Stars: common name, genetive name, Spectral type, magnitude, distance
0054     * @li Solar System: name, object type (planet/comet/asteroid), Distance, magnitude (TBD),
0055     * angular size (TBD)
0056     * @li Deep Sky: Common name, other names, object type, magnitude, angular size
0057     *
0058     * The Links Tab allows the user to manage the list of Image and Information links
0059     * listed in the object's popup menu.  The Advanced Tab allows the user to query
0060     * a number of professional-grade online astronomical databases for data on the object.
0061     * The Log tab allows the user to attach their own text notes about the object.
0062     *
0063     * The General Tab includes a clickable image of the object.  Clicking the image opens
0064     * a Thumbnail picker tool, which downloads a list of mages of the object from the
0065     * network, which the user may select as the new image for this objects Details window.
0066     *
0067     * @author Jason Harris, Jasem Mutlaq
0068     * @version 1.0
0069     */
0070 class DetailDialog : public KPageDialog
0071 {
0072     Q_OBJECT
0073   public:
0074     /** Constructor */
0075     DetailDialog(SkyObject *o, const KStarsDateTime &ut, GeoLocation *geo, QWidget *parent = nullptr);
0076 
0077     /** Destructor */
0078     ~DetailDialog() override = default;
0079 
0080     /** @return pointer to the QPixmap of the object's thumbnail image */
0081     inline QPixmap *thumbnail() { return Thumbnail.get(); }
0082 
0083   public slots:
0084     /** @short Slot to add this object to the observing list. */
0085     void addToObservingList();
0086 
0087     /** @short Slot to center this object in the display. */
0088     void centerMap();
0089 
0090     /** @short Slot to center this object in the telescope. */
0091     void centerTelescope();
0092 
0093     //TODO: showThumbnail() is only called in the ctor; make it private and not a slot.
0094     /** @short Slot to display the thumbnail image for the object */
0095     void showThumbnail();
0096 
0097     /**
0098      * @short Slot to update thumbnail image for the object, using the Thumbnail
0099      * Picker tool.
0100      * @sa ThumbnailPicker
0101      */
0102     void updateThumbnail();
0103 
0104     /** @short Slot for viewing the selected image or info URL in the web browser. */
0105     void viewLink();
0106 
0107     /**
0108      * Popup menu function: Add a custom Image or Information URL.
0109      * Opens the AddLinkDialog window.
0110      */
0111     void addLink();
0112 
0113     /**
0114      * @short Set the currently-selected URL resource.
0115      *
0116      * This function is needed because there are two QListWidgets,
0117      * each with its own selection.  We need to know which the user selected most recently.
0118      */
0119     void setCurrentLink(QListWidgetItem *it);
0120 
0121     /**
0122      * @short Rebuild the Image and Info URL lists for this object.
0123      * @note used when an item is added to either list.
0124      */
0125     void updateLists();
0126 
0127     /**
0128      * @short Open a dialog to edit a URL in either the Images or Info lists,
0129      * and update the user's *url.dat file.
0130      */
0131     void editLinkDialog();
0132 
0133     /**
0134      * @short remove a URL entry from either the Images or Info lists, and
0135      * update the user's *url.dat file.
0136      */
0137     void removeLinkDialog();
0138 
0139     /**
0140      * Open the web browser to the selected online astronomy database,
0141      * with a query to the object of this Detail Dialog.
0142      */
0143     void viewADVData();
0144 
0145     /** Save the User's text in the Log Tab to the userlog.dat file. */
0146     void saveLogData();
0147 
0148     /** Update View/Edit/Remove buttons */
0149     void updateButtons();
0150 
0151   private:
0152     /** Build the General Data Tab for the current object. */
0153     void createGeneralTab();
0154 
0155     /** Build the Position Tab for the current object. */
0156     void createPositionTab(const KStarsDateTime &ut, GeoLocation *geo);
0157 
0158     /**
0159      * Build the Links Tab, populating the image and info lists with the
0160      * known URLs for the current Object.
0161      */
0162     void createLinksTab();
0163 
0164     /** Build the Advanced Tab */
0165     void createAdvancedTab();
0166 
0167     /** Build the Log Tab */
0168     void createLogTab();
0169 
0170     /** Populate the TreeView of known astronomical databases in the Advanced Tab */
0171     void populateADVTree();
0172 
0173     /**
0174      * Data for the Advanced Tab TreeView is stored in the file advinterface.dat.
0175      * This function parses advinterface.dat.
0176      */
0177     QString parseADVData(const QString &link);
0178 
0179     /**
0180      * Update the local info_url and image_url files
0181      * @param type The URL type. 0 for Info Links, 1 for Images.
0182      * @param search_line The line to be search for in the local URL files
0183      * @param replace_line The replacement line once search_line is found.
0184      * @note If replace_line is empty, the function will remove search_line from the file
0185      */
0186     void updateLocalDatabase(int type, const QString &search_line, const QString &replace_line = QString());
0187 
0188     SkyObject *selectedObject { nullptr };
0189     QPalette titlePalette;
0190     QListWidgetItem *m_CurrentLink { nullptr };
0191     std::unique_ptr<QPixmap> Thumbnail;
0192     DataWidget *Data { nullptr };
0193     DataCometWidget *DataComet { nullptr };
0194     PositionWidget *Pos { nullptr };
0195     LinksWidget *Links { nullptr };
0196     DatabaseWidget *Adv { nullptr };
0197     LogWidget *Log { nullptr };
0198     const SkyObjectUserdata::Data &m_user_data;
0199 };
0200 
0201 class DataWidget : public QFrame, public Ui::DetailsData
0202 {
0203   Q_OBJECT
0204 
0205   public:
0206     explicit DataWidget(QWidget *parent = nullptr);
0207 };
0208 
0209 class DataCometWidget : public QFrame, public Ui::DetailsDataComet
0210 {
0211   Q_OBJECT
0212 
0213   public:
0214     explicit DataCometWidget(QWidget *parent = nullptr);
0215 };
0216 
0217 class PositionWidget : public QFrame, public Ui::DetailsPosition
0218 {
0219   Q_OBJECT
0220 
0221   public:
0222     explicit PositionWidget(QWidget *parent = nullptr);
0223 };
0224 
0225 class LinksWidget : public QFrame, public Ui::DetailsLinks
0226 {
0227   Q_OBJECT
0228 
0229   public:
0230     explicit LinksWidget(QWidget *parent = nullptr);
0231 };
0232 
0233 class DatabaseWidget : public QFrame, public Ui::DetailsDatabase
0234 {
0235   Q_OBJECT
0236 
0237   public:
0238     explicit DatabaseWidget(QWidget *parent = nullptr);
0239 };
0240 
0241 class LogWidget : public QFrame, public Ui::DetailsLog
0242 {
0243   Q_OBJECT
0244 
0245   public:
0246     explicit LogWidget(QWidget *parent = nullptr);
0247 };