1 /*
2     SPDX-FileCopyrightText: 2016 Jasem Mutlaq <mutlaqja@ikarustech.com>
3 
4     Based on Samikshan Bairagya GSoC work.
5 
6     SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 
9 #pragma once
10 
11 #include "ksnumbers.h"
12 #include "listcomponent.h"
13 #include "skyobjects/supernova.h"
14 #include "filedownloader.h"
15 
16 #include <QList>
17 #include <QPointer>
18 
19 /**
20  * @class SupernovaeComponent
21  * @brief This class encapsulates Supernovae.
22  *
23  * @author Jasem Mutlaq, Samikshan Bairagya
24  *
25  * @version 0.2
26  */
27 
28 class Supernova;
29 
30 class SupernovaeComponent : public QObject, public ListComponent
31 {
32         Q_OBJECT
33 
34     public:
35         explicit SupernovaeComponent(SkyComposite *parent);
36         virtual ~SupernovaeComponent() override = default;
37 
38         bool selected() override;
39         void update(KSNumbers *num = nullptr) override;
40         SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
41 
42         /**
43          * @note This should actually be implemented in a better manner.
44          * Possibly by checking if the host galaxy for the supernova is drawn.
45          */
46         void draw(SkyPainter *skyp) override;
47 
48         //virtual void notifyNewSupernovae();
49         /** @note Basically copy pasted from StarComponent::zoomMagnitudeLimit() */
50         static float zoomMagnitudeLimit();
51 
52     public slots:
53         /** @short This initiates updating of the data file */
54         void slotTriggerDataFileUpdate();
55 
56     protected slots:
57         void downloadReady();
58         void downloadError(const QString &errorString);
59 
60     private:
61         void loadData();
62         bool m_DataLoaded { false }, m_DataLoading { false };
63         QPointer<FileDownloader> downloadJob;
64 };
65