• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • weather
BBCWeatherItem.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2009 Bastian Holst <bastianholst@gmx.de>
9 //
10 
11 // Self
12 #include "BBCWeatherItem.h"
13 
14 // Marble
15 #include "BBCParser.h"
16 #include "WeatherData.h"
17 #include "MarbleDebug.h"
18 
19 // Qt
20 #include <QFile>
21 #include <QTime>
22 #include <QUrl>
23 
24 using namespace Marble;
25 /* TRANSLATOR Marble::BBCWeatherItem */
26 
27 BBCWeatherItem::BBCWeatherItem( QObject *parent )
28  : WeatherItem( parent ),
29  m_observationRequested( false ),
30  m_forecastRequested( false )
31 {
32 }
33 
34 BBCWeatherItem::~BBCWeatherItem()
35 {
36 }
37 
38 bool BBCWeatherItem::request( const QString& type )
39 {
40  if ( type == "bbcobservation" ) {
41  if ( !m_observationRequested ) {
42  m_observationRequested = true;
43  return true;
44  }
45  }
46  else if ( type == "bbcforecast" ) {
47  if ( !m_forecastRequested ) {
48  m_forecastRequested = true;
49  return true;
50  }
51  }
52  return false;
53 }
54 
55 QString BBCWeatherItem::service() const
56 {
57  return QString( "BBC" );
58 }
59 
60 void BBCWeatherItem::addDownloadedFile( const QString& url, const QString& type )
61 {
62  if( type == "bbcobservation" || type == "bbcforecast" ) {
63  BBCParser::instance()->scheduleRead( url, this, type );
64  }
65 }
66 
67 quint32 BBCWeatherItem::bbcId() const
68 {
69  return m_bbcId;
70 }
71 
72 void BBCWeatherItem::setBbcId( quint32 id )
73 {
74  m_bbcId = id;
75  setId( QString( "bbc" ) + QString::number( id ) );
76 }
77 
78 QUrl BBCWeatherItem::observationUrl() const
79 {
80  return QUrl( QString( "http://newsrss.bbc.co.uk/weather/forecast/%1/ObservationsRSS.xml" )
81  .arg( QString::number( bbcId() ) ) );
82 }
83 
84 QUrl BBCWeatherItem::forecastUrl() const
85 {
86  return QUrl( QString( "http://newsrss.bbc.co.uk/weather/forecast/%1/Next3DaysRSS.xml" )
87  .arg( QString::number( bbcId() ) ) );
88 }
89 
90 QString BBCWeatherItem::creditHtml() const
91 {
92  return tr( "Supported by <a href=\"http://backstage.bbc.co.uk\" target=\"_BLANK\">backstage.bbc.co.uk</a>.<br>Weather data from UK MET Office" );
93 }
94 
95 #include "BBCWeatherItem.moc"
Marble::BBCWeatherItem::BBCWeatherItem
BBCWeatherItem(QObject *parent=0)
Definition: BBCWeatherItem.cpp:27
Marble::BBCWeatherItem::service
QString service() const
Returns the provider of the weather information.
Definition: BBCWeatherItem.cpp:55
BBCWeatherItem.h
Marble::AbstractDataPluginItem::setId
void setId(const QString &id)
Definition: AbstractDataPluginItem.cpp:86
Marble::BBCWeatherItem::forecastUrl
QUrl forecastUrl() const
Definition: BBCWeatherItem.cpp:84
Marble::BBCWeatherItem::~BBCWeatherItem
~BBCWeatherItem()
Definition: BBCWeatherItem.cpp:34
Marble::BBCParser::instance
static BBCParser * instance()
Definition: BBCParser.cpp:185
Marble::BBCWeatherItem::setBbcId
void setBbcId(quint32 id)
Definition: BBCWeatherItem.cpp:72
Marble::BBCWeatherItem::observationUrl
QUrl observationUrl() const
Definition: BBCWeatherItem.cpp:78
MarbleDebug.h
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
Marble::AbstractDataPluginItem::id
QString id() const
Definition: AbstractDataPluginItem.cpp:81
QString::number
QString number(int n, int base)
QObject
Marble::BBCParser::scheduleRead
void scheduleRead(const QString &path, BBCWeatherItem *item, const QString &type)
Definition: BBCParser.cpp:191
BBCParser.h
QString
QUrl
WeatherData.h
Marble::WeatherItem
This is the class painting a weather item on the screen.
Definition: WeatherItem.h:37
Marble::BBCWeatherItem::creditHtml
QString creditHtml() const
Definition: BBCWeatherItem.cpp:90
Marble::BBCWeatherItem::addDownloadedFile
void addDownloadedFile(const QString &url, const QString &type)
Definition: BBCWeatherItem.cpp:60
Marble::BBCWeatherItem::request
virtual bool request(const QString &type)
Test if the item wants to request type again.
Definition: BBCWeatherItem.cpp:38
Marble::BBCWeatherItem::bbcId
quint32 bbcId() const
Definition: BBCWeatherItem.cpp:67
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal