File indexing completed on 2024-04-21 14:46:41

0001 /*
0002     SPDX-FileCopyrightText: 2016 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     Based on Samikshan Bairagya GSoC work.
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include "ksnumbers.h"
0012 #include "listcomponent.h"
0013 #include "skyobjects/supernova.h"
0014 #include "filedownloader.h"
0015 
0016 #include <QList>
0017 #include <QPointer>
0018 
0019 /**
0020  * @class SupernovaeComponent
0021  * @brief This class encapsulates Supernovae.
0022  *
0023  * @author Jasem Mutlaq, Samikshan Bairagya
0024  *
0025  * @version 0.2
0026  */
0027 
0028 class Supernova;
0029 
0030 class SupernovaeComponent : public QObject, public ListComponent
0031 {
0032         Q_OBJECT
0033 
0034     public:
0035         explicit SupernovaeComponent(SkyComposite *parent);
0036         virtual ~SupernovaeComponent() override = default;
0037 
0038         bool selected() override;
0039         void update(KSNumbers *num = nullptr) override;
0040         SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
0041 
0042         /**
0043          * @note This should actually be implemented in a better manner.
0044          * Possibly by checking if the host galaxy for the supernova is drawn.
0045          */
0046         void draw(SkyPainter *skyp) override;
0047 
0048         //virtual void notifyNewSupernovae();
0049         /** @note Basically copy pasted from StarComponent::zoomMagnitudeLimit() */
0050         static float zoomMagnitudeLimit();
0051 
0052     public slots:
0053         /** @short This initiates updating of the data file */
0054         void slotTriggerDataFileUpdate();
0055 
0056     protected slots:
0057         void downloadReady();
0058         void downloadError(const QString &errorString);
0059 
0060     private:
0061         void loadData();
0062         void unzipData();
0063         static const QString tnsDataFilename;
0064         static const QString tnsDataFilenameZip;
0065         static const QString tnsDataUrl;
0066         bool m_DataLoaded { false }, m_DataLoading { false };
0067         QPointer<FileDownloader> downloadJob;
0068 };