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 // 0005 0006 #ifndef WEATHERDATA_H 0007 #define WEATHERDATA_H 0008 0009 #include <QtGlobal> 0010 #include <QCoreApplication> 0011 0012 class QDate; 0013 class QDateTime; 0014 class QImage; 0015 0016 namespace Marble 0017 { 0018 0019 class WeatherDataPrivate; 0020 0021 class WeatherData 0022 { 0023 Q_DECLARE_TR_FUNCTIONS ( WeatherData ) 0024 public: 0025 enum WeatherCondition { 0026 // Clouds 0027 ConditionNotAvailable, 0028 ClearDay, 0029 ClearNight, 0030 FewCloudsDay, 0031 FewCloudsNight, 0032 PartlyCloudyDay, 0033 PartlyCloudyNight, 0034 Overcast, 0035 // Rain 0036 LightShowersDay, 0037 LightShowersNight, 0038 ShowersDay, 0039 ShowersNight, 0040 LightRain, 0041 Rain, 0042 // Special 0043 ChanceThunderstormDay, 0044 ChanceThunderstormNight, 0045 Thunderstorm, 0046 Hail, 0047 ChanceSnowDay, 0048 ChanceSnowNight, 0049 LightSnow, 0050 Snow, 0051 RainSnow, 0052 Mist, 0053 SandStorm // no icon available 0054 // FreezingDrizzle, would be nice, but no icon for the moment 0055 // Flurries, would be nice, but no icon available 0056 // REMEMBER to change the implementation of conditionString() if you add items to this enum 0057 }; 0058 0059 enum WindDirection { 0060 N, 0061 NNE, 0062 NE, 0063 ENE, 0064 E, 0065 SSE, 0066 SE, 0067 ESE, 0068 S, 0069 NNW, 0070 NW, 0071 WNW, 0072 W, 0073 SSW, 0074 SW, 0075 WSW, 0076 DirectionNotAvailable 0077 }; 0078 0079 enum PressureDevelopment { 0080 Rising, 0081 NoChange, 0082 Falling, 0083 PressureDevelopmentNotAvailable 0084 }; 0085 0086 enum Visibility { 0087 VeryGood, 0088 Good, 0089 Normal, 0090 Poor, 0091 VeryPoor, 0092 Fog, 0093 VisibilityNotAvailable 0094 }; 0095 0096 enum SpeedUnit { 0097 kph, 0098 mph, 0099 mps, 0100 knots, 0101 beaufort 0102 }; 0103 0104 enum TemperatureUnit { 0105 Celsius, 0106 Fahrenheit, 0107 Kelvin 0108 }; 0109 0110 enum PressureUnit { 0111 HectoPascal, 0112 KiloPascal, 0113 Bar, 0114 mmHg, 0115 inchHg 0116 }; 0117 0118 WeatherData(); 0119 WeatherData( const WeatherData &other ); 0120 ~WeatherData(); 0121 0122 bool isValid() const; 0123 0124 /** 0125 * Get the time when the data was published. 0126 */ 0127 QDateTime publishingTime() const; 0128 0129 /** 0130 * Set the time when the data was published. 0131 */ 0132 void setPublishingTime( const QDateTime& dateTime ); 0133 0134 /** 0135 * Checks, if the data item has a valid publishing time. 0136 */ 0137 bool hasValidPublishingTime() const; 0138 0139 /** 0140 * Get the date the data is meant for. 0141 */ 0142 QDate dataDate() const; 0143 0144 /** 0145 * Set the date the data is meant for. 0146 */ 0147 void setDataDate( const QDate& date ); 0148 0149 /** 0150 * Checks, if the data item has a valid data date. 0151 */ 0152 bool hasValidDataDate() const; 0153 0154 WeatherData::WeatherCondition condition() const; 0155 void setCondition( WeatherData::WeatherCondition condition ); 0156 bool hasValidCondition() const; 0157 QString conditionString() const; 0158 0159 /** 0160 * Get the icon showing the current condition. 0161 */ 0162 QImage icon() const; 0163 0164 QString iconSource() const; 0165 0166 WeatherData::WindDirection windDirection() const; 0167 void setWindDirection( WeatherData::WindDirection direction ); 0168 bool hasValidWindDirection() const; 0169 QString windDirectionString() const; 0170 0171 qreal windSpeed( WeatherData::SpeedUnit format = WeatherData::mps ) const; 0172 void setWindSpeed( qreal speed, WeatherData::SpeedUnit format = WeatherData::mps ); 0173 bool hasValidWindSpeed() const; 0174 QString windSpeedString( WeatherData::SpeedUnit unit = WeatherData::kph ) const; 0175 0176 qreal temperature( WeatherData::TemperatureUnit format = WeatherData::Kelvin ) const; 0177 void setTemperature( qreal temp, 0178 WeatherData::TemperatureUnit format = WeatherData::Kelvin ); 0179 bool hasValidTemperature() const; 0180 QString temperatureString( WeatherData::TemperatureUnit format = WeatherData::Kelvin ) const; 0181 0182 qreal maxTemperature( WeatherData::TemperatureUnit format = WeatherData::Kelvin ) const; 0183 void setMaxTemperature( qreal temp, 0184 WeatherData::TemperatureUnit format = WeatherData::Kelvin ); 0185 bool hasValidMaxTemperature() const; 0186 QString maxTemperatureString( WeatherData::TemperatureUnit format = WeatherData::Kelvin ) const; 0187 0188 qreal minTemperature( WeatherData::TemperatureUnit format = WeatherData::Kelvin ) const; 0189 void setMinTemperature( qreal temp, 0190 WeatherData::TemperatureUnit format = WeatherData::Kelvin ); 0191 bool hasValidMinTemperature() const; 0192 QString minTemperatureString( WeatherData::TemperatureUnit format = WeatherData::Kelvin ) const; 0193 0194 WeatherData::Visibility visibility() const; 0195 void setVisibilty( WeatherData::Visibility visibility ); 0196 bool hasValidVisibility() const; 0197 0198 qreal pressure( WeatherData::PressureUnit format = WeatherData::HectoPascal ) const; 0199 void setPressure( qreal pressure, 0200 WeatherData::PressureUnit format = WeatherData::HectoPascal ); 0201 bool hasValidPressure() const; 0202 QString pressureString( WeatherData::PressureUnit format = WeatherData::HectoPascal ) const; 0203 0204 WeatherData::PressureDevelopment pressureDevelopment() const; 0205 void setPressureDevelopment( WeatherData::PressureDevelopment ); 0206 bool hasValidPressureDevelopment() const; 0207 QString pressureDevelopmentString() const; 0208 0209 qreal humidity() const; 0210 void setHumidity( qreal humidity ); 0211 bool hasValidHumidity() const; 0212 QString humidityString() const; 0213 0214 QString toHtml( WeatherData::TemperatureUnit temperatureUnit, 0215 WeatherData::SpeedUnit speedUnit, 0216 WeatherData::PressureUnit pressureUnit ) const; 0217 0218 WeatherData& operator=( const WeatherData &other ); 0219 0220 void detach(); 0221 private: 0222 WeatherDataPrivate *d; 0223 }; 0224 0225 } // namespace Marble 0226 0227 #endif // WEATHERDATA_H