1 /*
2     SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "binarylistcomponent.h"
10 #include "ksparser.h"
11 #include "typedef.h"
12 #include "skyobjects/ksasteroid.h"
13 #include "solarsystemlistcomponent.h"
14 #include "filedownloader.h"
15 
16 #include <QList>
17 #include <QPointer>
18 
19 /**
20  * @class AsteroidsComponent
21  * Represents the asteroids on the sky map.
22  *
23  * @author Thomas Kabelmann
24  * @version 0.1
25  */
26 class AsteroidsComponent : public QObject, public SolarSystemListComponent,
27     virtual public BinaryListComponent<KSAsteroid, AsteroidsComponent>
28 {
29         Q_OBJECT
30 
31         friend class BinaryListComponent<KSAsteroid, AsteroidsComponent>;
32     public:
33         /**
34          * @short Default constructor.
35          *
36          * @p parent pointer to the parent SolarSystemComposite
37          */
38         explicit AsteroidsComponent(SolarSystemComposite *parent);
39         virtual ~AsteroidsComponent() override = default;
40 
41         void draw(SkyPainter *skyp) override;
42         bool selected() override;
43         SkyObject *objectNearest(SkyPoint *p, double &maxrad) override;
44 
45         void updateDataFile(bool isAutoUpdate = false);
46 
47         QString ans();
48 
49     protected slots:
50         void downloadReady();
51         void downloadError(const QString &errorString);
52 
53     private:
54         void loadDataFromText() override;
55 
56         QPointer<FileDownloader> downloadJob;
57 };
58