File indexing completed on 2024-10-06 09:27:46

0001 /*
0002     SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 #include <QString>
0011 
0012 /**
0013  * @class DetalDialogLite
0014  * @short Backend for Object details dialog in QML
0015  * A backend of details dialog declared in QML. Members of this class are the properties that are used
0016  * in QML. Whenever user clicks on some object the properties are updated with the info about this object
0017  * and Details dialog in QML is updated automatically as we use property binding there.
0018  *
0019  * @author Artem Fedoskin, Jason Harris, Jasem Mutlaq
0020  * @version 1.0
0021  */
0022 class DetailDialogLite : public QObject
0023 {
0024     Q_OBJECT
0025 
0026     //General
0027     Q_PROPERTY(QString name MEMBER m_name NOTIFY nameChanged)
0028     Q_PROPERTY(QString magnitude MEMBER m_magnitude NOTIFY magnitudeChanged)
0029     Q_PROPERTY(QString distance MEMBER m_distance NOTIFY distanceChanged)
0030     Q_PROPERTY(QString BVindex MEMBER m_BVindex NOTIFY BVindexChanged)
0031     Q_PROPERTY(QString angSize MEMBER m_angSize NOTIFY angSizeChanged)
0032     Q_PROPERTY(QString illumination MEMBER m_illumination NOTIFY illuminationChanged)
0033     Q_PROPERTY(QString typeInConstellation MEMBER m_typeInConstellation NOTIFY typeInConstellationChanged)
0034     Q_PROPERTY(QString thumbnail MEMBER m_thumbnail NOTIFY thumbnailChanged)
0035 
0036     //General advanced
0037     Q_PROPERTY(QString perihelion MEMBER m_perihelion NOTIFY perihelionChanged)
0038     Q_PROPERTY(QString orbitID MEMBER m_orbitID NOTIFY orbitIDChanged)
0039     Q_PROPERTY(QString NEO MEMBER m_NEO NOTIFY NEOChanged)
0040     Q_PROPERTY(QString diameter MEMBER m_diameter NOTIFY diameterChanged)
0041     Q_PROPERTY(QString rotation MEMBER m_rotation NOTIFY rotationChanged)
0042     Q_PROPERTY(QString earthMOID MEMBER m_earthMOID NOTIFY earthMOIDChanged)
0043     Q_PROPERTY(QString orbitClass MEMBER m_orbitClass NOTIFY orbitClassChanged)
0044     Q_PROPERTY(QString albedo MEMBER m_albedo NOTIFY albedoChanged)
0045     Q_PROPERTY(QString dimensions MEMBER m_dimensions NOTIFY dimensionsChanged)
0046     Q_PROPERTY(QString period MEMBER m_period NOTIFY periodChanged)
0047 
0048     //Position
0049     Q_PROPERTY(QString decLabel MEMBER m_decLabel NOTIFY decLabelChanged)
0050     Q_PROPERTY(QString dec MEMBER m_dec NOTIFY decChanged)
0051 
0052     Q_PROPERTY(QString RALabel MEMBER m_RALabel NOTIFY RALabelChanged)
0053     Q_PROPERTY(QString RA MEMBER m_RA NOTIFY RAChanged)
0054 
0055     Q_PROPERTY(QString az MEMBER m_az NOTIFY azChanged)
0056     Q_PROPERTY(QString airmass MEMBER m_airmass NOTIFY airmassChanged)
0057     Q_PROPERTY(QString HA MEMBER m_HA NOTIFY HAChanged)
0058     Q_PROPERTY(QString alt MEMBER m_alt NOTIFY altChanged)
0059     Q_PROPERTY(QString RA0 MEMBER m_RA0 NOTIFY RA0Changed)
0060     Q_PROPERTY(QString dec0 MEMBER m_dec0 NOTIFY dec0Changed)
0061 
0062     Q_PROPERTY(QString timeRise MEMBER m_timeRise NOTIFY timeRiseChanged)
0063     Q_PROPERTY(QString timeTransit MEMBER m_timeTransit NOTIFY timeTransitChanged)
0064     Q_PROPERTY(QString timeSet MEMBER m_timeSet NOTIFY timeSetChanged)
0065 
0066     Q_PROPERTY(QString azRise MEMBER m_azRise NOTIFY azRiseChanged)
0067     Q_PROPERTY(QString altTransit MEMBER m_altTransit NOTIFY altTransitChanged)
0068     Q_PROPERTY(QString azSet MEMBER m_azSet NOTIFY azSetChanged)
0069 
0070     //Links
0071     Q_PROPERTY(QStringList infoTitleList MEMBER m_infoTitleList NOTIFY infoTitleListChanged)
0072     Q_PROPERTY(QStringList imageTitleList MEMBER m_imageTitleList NOTIFY imageTitleListChanged)
0073     Q_PROPERTY(bool isLinksOn MEMBER m_isLinksOn NOTIFY isLinksOnChanged)
0074 
0075     //Log
0076     Q_PROPERTY(bool isLogOn MEMBER m_isLogOn NOTIFY isLogOnChanged)
0077     Q_PROPERTY(QString userLog MEMBER m_userLog NOTIFY userLogChanged)
0078 
0079   public:
0080     DetailDialogLite();
0081 
0082     /** Connect SkyMapLite's signals to proper slots */
0083     void initialize();
0084 
0085     /** Set thumbnail to SkyMapLite::clickedObjectLite's thumbnail (if any) */
0086     void setupThumbnail();
0087 
0088     /**
0089      * @brief addLink adds new link to SkyObject
0090      * @param url URL of the link
0091      * @param desc description of the link
0092      * @param isImageLink true if it is a link to image. False if it is information link
0093      */
0094     Q_INVOKABLE void addLink(const QString &url, const QString &desc, bool isImageLink);
0095 
0096     /**
0097      * @short Remove link from user's database
0098      * @param itemIndex - index of a link
0099      * @param isImage - true if it is a link on image, false if it is an info link
0100      */
0101     Q_INVOKABLE void removeLink(int itemIndex, bool isImage);
0102 
0103     /**
0104      * @short Edit link's description and URL
0105      * @param itemIndex - index of a link
0106      * @param isImage - true if it is a link on image, false if it is an info link
0107      * @param desc - new description
0108      * @param url - new URL
0109      */
0110     void editLink(int itemIndex, bool isImage, const QString &desc, const QString &url);
0111 
0112     /**
0113      * Update the local info_url and image_url files
0114      * @param type The URL type. 0 for Info Links, 1 for Images.
0115      * @param search_line The line to be search for in the local URL files
0116      * @param replace_line The replacement line once search_line is found.
0117      * @note If replace_line is empty, the function will remove search_line from the file
0118      */
0119     void updateLocalDatabase(int type, const QString &search_line, const QString &replace_line = QString());
0120 
0121     //We don't need bindings to URLs so let's just have getters
0122     /**
0123      * @param index - URL's index in SkyObject::ImageList()
0124      * @return URL to user added information about object
0125      */
0126     Q_INVOKABLE QString getInfoURL(int index);
0127 
0128     /**
0129      * @param index - URL's index in SkyObject::ImageList()
0130      * @return URL to user added object image
0131      */
0132     Q_INVOKABLE QString getImageURL(int index);
0133 
0134   public slots:
0135     /** Update properties that are shown on "General" tab */
0136     void createGeneralTab();
0137 
0138     /** Update properties that are shown on "Position" tab */
0139     void createPositionTab();
0140 
0141     /** Update properties that are shown on "Log" tab */
0142     void createLogTab();
0143 
0144     /** Update properties that are shown on "Links" tab */
0145     void createLinksTab();
0146 
0147     /** Save the User's text in the Log Tab to the userlog.dat file. */
0148     void saveLogData(const QString &userLog);
0149 
0150   signals:
0151     //General
0152     void nameChanged(QString);
0153     void magnitudeChanged(QString);
0154     void distanceChanged(QString);
0155     void BVindexChanged(QString);
0156     void angSizeChanged(QString);
0157     void illuminationChanged(QString);
0158     void typeInConstellationChanged(QString);
0159     void thumbnailChanged(QString);
0160 
0161     //General advanced
0162     void perihelionChanged(QString);
0163     void orbitIDChanged(QString);
0164     void NEOChanged(QString);
0165     void diameterChanged(QString);
0166     void rotationChanged(QString);
0167     void earthMOIDChanged(QString);
0168     void orbitClassChanged(QString);
0169     void albedoChanged(QString);
0170     void dimensionsChanged(QString);
0171     void periodChanged(QString);
0172 
0173     //Position
0174     void decLabelChanged();
0175     void decChanged();
0176 
0177     void RALabelChanged();
0178     void RAChanged();
0179 
0180     void azChanged();
0181     void airmassChanged();
0182     void HAChanged();
0183     void altChanged();
0184     void RA0Changed();
0185     void dec0Changed();
0186 
0187     void timeRiseChanged();
0188     void timeTransitChanged();
0189     void timeSetChanged();
0190 
0191     void azRiseChanged();
0192     void altTransitChanged();
0193     void azSetChanged();
0194 
0195     //Links
0196     void infoTitleListChanged();
0197     void imageTitleListChanged();
0198     void isLinksOnChanged();
0199 
0200     //Log
0201     void isLogOnChanged();
0202     void userLogChanged();
0203 
0204   private:
0205     //General
0206     QString m_name;
0207     QString m_magnitude;
0208     QString m_distance;
0209     QString m_BVindex;
0210     QString m_angSize;
0211     QString m_illumination;
0212     QString m_typeInConstellation;
0213     QString m_thumbnail;
0214 
0215     //General advanced
0216     QString m_perihelion;
0217     QString m_orbitID;
0218     QString m_NEO;
0219     QString m_diameter;
0220     QString m_rotation;
0221     QString m_earthMOID;
0222     QString m_orbitClass;
0223     QString m_albedo;
0224     QString m_dimensions;
0225     QString m_period;
0226 
0227     //Position
0228     QString m_decLabel;
0229     QString m_dec;
0230 
0231     QString m_RALabel;
0232     QString m_RA;
0233 
0234     QString m_az;
0235     QString m_airmass;
0236     QString m_HA;
0237     QString m_alt;
0238     QString m_RA0;
0239     QString m_dec0;
0240 
0241     QString m_timeRise;
0242     QString m_timeTransit;
0243     QString m_timeSet;
0244 
0245     QString m_azRise;
0246     QString m_altTransit;
0247     QString m_azSet;
0248 
0249     //Links
0250     bool m_isLinksOn { false };
0251     QStringList m_infoTitleList;
0252     QStringList m_imageTitleList;
0253 
0254     //Log
0255     bool m_isLogOn { false };
0256     QString m_userLog;
0257 };