Kstars

skyobjdescription.h
1 /*
2  SPDX-FileCopyrightText: 2013 Vijay Dhameliya <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QObject>
10 #include <QByteArray>
11 #include <QString>
12 #include <QNetworkAccessManager>
13 #include <QNetworkRequest>
14 #include <QNetworkReply>
15 
16 /**
17  * @class SkyObjDescription
18  *
19  * Fetches short description for various sky object from wikipedia.
20  *
21  * @author Vijay Dhameliya
22  */
23 class SkyObjDescription : public QObject
24 {
25  Q_OBJECT
26 
27  public:
28  /**
29  * @brief Constructor sends request to network for data from wikipedia API and starts
30  * downloading data from QUrl
31  * @param soName SkyObject name
32  * @param soType SkyObject type
33  */
34  explicit SkyObjDescription(const QString soName, const QString soType);
35 
36  virtual ~SkyObjDescription() override = default;
37 
38  /** @return returns description if it was available on wikipedia else returns empty string */
39  QString downloadedData() const { return m_description; }
40 
41  /** @return returns wikipedia link for skyobject */
42  QString url() const { return m_url; }
43 
44  signals:
45  void downloaded();
46 
47  private slots:
48  /**
49  * @brief parse downloaded data to extract description of SkyObject when downloading is finished
50  *
51  * @param reply
52  */
53  void fileDownloaded(QNetworkReply *reply);
54 
55  private:
56  QString soName, soType, m_description, m_url;
57  QNetworkAccessManager *manager { nullptr };
58  QByteArray m_DownloadedData;
59 };
Q_OBJECTQ_OBJECT
QString url() const
SkyObjDescription(const QString soName, const QString soType)
Constructor sends request to network for data from wikipedia API and starts downloading data from QUr...
QString downloadedData() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:00:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.