File indexing completed on 2024-05-12 15:31:21
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de> 0004 // SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com> 0005 // 0006 0007 #ifndef WEATHERITEM_H 0008 #define WEATHERITEM_H 0009 0010 // Marble 0011 #include "AbstractDataPluginItem.h" 0012 0013 // Qt 0014 #include <QMap> 0015 0016 class QString; 0017 class QAction; 0018 class QDate; 0019 0020 namespace Marble 0021 { 0022 0023 class MarbleWidget; 0024 class WeatherData; 0025 0026 class WeatherItemPrivate; 0027 0028 /** 0029 * This is the class painting a weather item on the screen. So it is a subclass of 0030 * AbstractDataItem. 0031 */ 0032 class WeatherItem : public AbstractDataPluginItem 0033 { 0034 Q_OBJECT 0035 0036 Q_PROPERTY( QString station READ stationName WRITE setStationName NOTIFY stationNameChanged ) 0037 Q_PROPERTY( QString description READ description NOTIFY descriptionChanged ) 0038 Q_PROPERTY( QString image READ image NOTIFY imageChanged ) 0039 Q_PROPERTY( double temperature READ temperature NOTIFY temperatureChanged ) 0040 0041 public: 0042 explicit WeatherItem( QObject *parent = nullptr ); 0043 explicit WeatherItem( MarbleWidget* widget, QObject *parent = nullptr ); 0044 ~WeatherItem() override; 0045 0046 QAction *action() override; 0047 0048 /** 0049 * Test if the item wants to request @p type again. 0050 */ 0051 virtual bool request( const QString& type ); 0052 0053 /** 0054 * Returns the provider of the weather information. 0055 */ 0056 virtual QString service() const = 0; 0057 0058 bool initialized() const override; 0059 0060 void addDownloadedFile( const QString& url, const QString& type ) override = 0; 0061 0062 bool operator<( const AbstractDataPluginItem *other ) const override; 0063 0064 QString stationName() const; 0065 void setStationName( const QString& name ); 0066 0067 WeatherData currentWeather() const; 0068 void setCurrentWeather( const WeatherData& weather ); 0069 0070 QMap<QDate, WeatherData> forecastWeather() const; 0071 void setForecastWeather( const QMap<QDate, WeatherData>& forecasts ); 0072 0073 /** 0074 * Adds additional forecasts to the list. If there are multiple forecasts for one day, 0075 * it will choose the most recent (as of pubDate). 0076 */ 0077 void addForecastWeather( const QList<WeatherData>& forecasts ); 0078 0079 quint8 priority() const; 0080 void setPriority( quint8 priority ); 0081 0082 void setSettings( const QHash<QString, QVariant>& settings ) override; 0083 0084 void setMarbleWidget( MarbleWidget *widget ); 0085 0086 QList<QAction*> actions() override; 0087 0088 QString description() const; 0089 0090 QString image() const; 0091 0092 double temperature() const; 0093 0094 public Q_SLOTS: 0095 void openBrowser(); 0096 0097 Q_SIGNALS: 0098 void stationNameChanged(); 0099 0100 void descriptionChanged(); 0101 0102 void imageChanged(); 0103 0104 void temperatureChanged(); 0105 0106 private: 0107 Q_DISABLE_COPY(WeatherItem) 0108 WeatherItemPrivate * const d; 0109 friend class WeatherItemPrivate; 0110 QString createFromTemplate(const QString &templateHtml); 0111 }; 0112 0113 } // namespace Marble 0114 0115 #endif // WEATHERITEM_H