File indexing completed on 2024-05-19 15:05:37
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Bastian Holst <bastianholst@gmx.de> 0004 // 0005 0006 // Self 0007 #include "BBCWeatherItem.h" 0008 0009 // Marble 0010 #include "BBCParser.h" 0011 #include "WeatherData.h" 0012 #include "MarbleDebug.h" 0013 0014 // Qt 0015 #include <QUrl> 0016 0017 using namespace Marble; 0018 /* TRANSLATOR Marble::BBCWeatherItem */ 0019 0020 BBCWeatherItem::BBCWeatherItem( QObject *parent ) 0021 : WeatherItem( parent ), 0022 m_observationRequested( false ), 0023 m_forecastRequested( false ) 0024 { 0025 } 0026 0027 BBCWeatherItem::~BBCWeatherItem() 0028 { 0029 } 0030 0031 bool BBCWeatherItem::request( const QString& type ) 0032 { 0033 if (type == QLatin1String("bbcobservation")) { 0034 if ( !m_observationRequested ) { 0035 m_observationRequested = true; 0036 return true; 0037 } 0038 } 0039 else if (type == QLatin1String("bbcforecast")) { 0040 if ( !m_forecastRequested ) { 0041 m_forecastRequested = true; 0042 return true; 0043 } 0044 } 0045 return false; 0046 } 0047 0048 QString BBCWeatherItem::service() const 0049 { 0050 return QString( "BBC" ); 0051 } 0052 0053 void BBCWeatherItem::addDownloadedFile( const QString& url, const QString& type ) 0054 { 0055 if (type == QLatin1String("bbcobservation") || type == QLatin1String("bbcforecast")) { 0056 BBCParser::instance()->scheduleRead( url, this, type ); 0057 } 0058 } 0059 0060 quint32 BBCWeatherItem::bbcId() const 0061 { 0062 return m_bbcId; 0063 } 0064 0065 void BBCWeatherItem::setBbcId( quint32 id ) 0066 { 0067 m_bbcId = id; 0068 setId(QLatin1String("bbc") + QString::number(id)); 0069 } 0070 0071 QUrl BBCWeatherItem::observationUrl() const 0072 { 0073 return QUrl( QString( "http://newsrss.bbc.co.uk/weather/forecast/%1/ObservationsRSS.xml" ) 0074 .arg( QString::number( bbcId() ) ) ); 0075 } 0076 0077 QUrl BBCWeatherItem::forecastUrl() const 0078 { 0079 return QUrl( QString( "http://newsrss.bbc.co.uk/weather/forecast/%1/Next3DaysRSS.xml" ) 0080 .arg( QString::number( bbcId() ) ) ); 0081 } 0082 0083 QString BBCWeatherItem::creditHtml() const 0084 { 0085 return tr( "Supported by <a href=\"https://www.bbc.co.uk/blogs/bbcbackstage\" target=\"_BLANK\">backstage.bbc.co.uk</a>.<br>Weather data from UK MET Office" ); 0086 } 0087 0088 #include "moc_BBCWeatherItem.cpp"