Ticket #10286: mythweather-worldweathermap.patch

File mythweather-worldweathermap.patch, 24.5 KB (added by joachim@…, 8 years ago)

Patch without binary files

  • new file mythplugins/mythweather/mythweather/location.cpp

    From da63cf6851791b7bf374255572bb236103a0d498 Mon Sep 17 00:00:00 2001
    From: Joachim Langenbach <joachim.langenbach@engsas.de>
    Date: Wed, 25 Jan 2012 20:46:57 +0100
    Subject: [PATCH 1/2] Added new screen world weather map. Since it is really different from other screen behaviour, it has it's own class WorldWeatherScreen. This screen displays one of the maps within the
     bluemarble folder and displays weather icons for the associated locations.
    
    The class Location is used to store this data during fetching process of geo coordinates.
    
    The world map uses QtMobility Location API to map weather locations into geo coordinates.
    ---
     .../bluemarble/land_ocean_ice_lights_8192.png      |  Bin 0 -> 9615852 bytes
     .../bluemarble/land_shallow_topo_8192.png          |  Bin 0 -> 22458804 bytes
     mythplugins/mythweather/mythweather/location.cpp   |  140 +++++++++++++
     mythplugins/mythweather/mythweather/location.h     |   63 ++++++
     .../mythweather/mythweather/worldweatherscreen.cpp |  213 ++++++++++++++++++++
     .../mythweather/mythweather/worldweatherscreen.h   |  101 +++++++++
     6 files changed, 517 insertions(+), 0 deletions(-)
     create mode 100644 mythplugins/mythweather/mythweather/bluemarble/land_ocean_ice_lights_8192.png
     create mode 100644 mythplugins/mythweather/mythweather/bluemarble/land_shallow_topo_8192.png
     create mode 100644 mythplugins/mythweather/mythweather/location.cpp
     create mode 100644 mythplugins/mythweather/mythweather/location.h
     create mode 100644 mythplugins/mythweather/mythweather/worldweatherscreen.cpp
     create mode 100644 mythplugins/mythweather/mythweather/worldweatherscreen.h
    
    diff --git a/mythplugins/mythweather/mythweather/bluemarble/land_ocean_ice_lights_8192.png b/mythplugins/mythweather/mythweather/bluemarble/land_ocean_ice_lights_8192.png
    new file mode 100644
    index 0000000..4f51b60
    Binary files /dev/null and b/mythplugins/mythweather/mythweather/bluemarble/land_ocean_ice_lights_8192.png differ
    diff --git a/mythplugins/mythweather/mythweather/bluemarble/land_shallow_topo_8192.png b/mythplugins/mythweather/mythweather/bluemarble/land_shallow_topo_8192.png
    new file mode 100644
    index 0000000..75bda59
    Binary files /dev/null and b/mythplugins/mythweather/mythweather/bluemarble/land_shallow_topo_8192.png differ
    diff --git a/mythplugins/mythweather/mythweather/location.cpp b/mythplugins/mythweather/mythweather/location.cpp
    new file mode 100644
    index 0000000..25a374f
    - +  
     1/*
     2    Copyright (C) 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3
     4    This program is free software: you can redistribute it and/or modify
     5    it under the terms of the GNU General Public License as published by
     6    the Free Software Foundation, either version 3 of the License, or
     7    (at your option) any later version.
     8
     9    This program is distributed in the hope that it will be useful,
     10    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12    GNU General Public License for more details.
     13
     14    You should have received a copy of the GNU General Public License
     15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16
     17*/
     18
     19
     20#include "location.h"
     21
     22#include <mythimage.h>
     23#include <mythmainwindow.h>
     24
     25#include <QStringList>
     26#include <QPainter>
     27#include <QPixmap>
     28#include <QFont>
     29#include <QFontMetrics>
     30
     31// Location::Location(qreal latitude, qreal longitude, QString station, QString name)
     32// {
     33//      init();
     34// //   myCoordinates = QtMobility::QGeoCoordinate(latitude, longitude);
     35//      myStation = station;
     36//      myName = name;
     37// }
     38
     39void Location::setName(QString name)
     40{
     41        myName = name;
     42}
     43
     44QString Location::name() const
     45{
     46        return myName;
     47}
     48
     49// void Location::setCoordinate(QtMobility::QGeoCoordinate coordinates)
     50// {
     51//      myCoordinates = coordinates;
     52// }
     53
     54// QString Location::latitude() const
     55// {
     56//      // Format: 27° 28' 3.2" S, 153° 1' 40.4" E, 28.1m
     57//      QString myValues = myCoordinates.toString(QtMobility::QGeoCoordinate::DegreesMinutesSecondsWithHemisphere);
     58//      return myValues.split(", ")[0];
     59// }
     60//
     61// QString Location::longitude() const
     62// {
     63// // Format: 27° 28' 3.2" S, 153° 1' 40.4" E, 28.1m
     64//      QString myValues = myCoordinates.toString(QtMobility::QGeoCoordinate::DegreesMinutesSecondsWithHemisphere);
     65//      return myValues.split(", ")[1];
     66// }
     67
     68void Location::setCurrentTemperatur(QString temperature)
     69{
     70        myCurrentTemperature = temperature;
     71}
     72
     73QString Location::currentTemperature() const
     74{
     75        return myCurrentTemperature;
     76}
     77
     78void Location::setCurrentWeatherIcon(QString icon)
     79{
     80        if(!icon.startsWith(":/weathermap/") && !icon.startsWith(":"))
     81                icon = ":/weathermap/"+ icon;
     82        myCurrentWeatherIcon = icon;
     83}
     84
     85QString Location::currentWeatherIcon() const
     86{
     87        return myCurrentWeatherIcon;
     88}
     89
     90// QtMobility::QGeoCoordinate Location::toCoordinate() const
     91// {
     92//      return myCoordinates;
     93// }
     94
     95bool Location::addToMap(MythImage* map, QPoint position)
     96{
     97        if(!map)
     98                return false;
     99       
     100        // load weather icon
     101        MythImage *weatherIcon = GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
     102        weatherIcon->Load(currentWeatherIcon());
     103        if(weatherIcon->isNull())
     104                weatherIcon->Load("unknown.png");
     105       
     106        // add the temperature value
     107        QFont iconFont;
     108        iconFont.setPixelSize(40);
     109        QFontMetrics metrics(iconFont);
     110        QString text = QObject::tr("%1: %2 C").arg(name()).arg(currentTemperature());
     111        int iconWidth = weatherIcon->size().width();
     112        if(iconWidth < metrics.width(text))
     113                iconWidth = metrics.width(text);
     114       
     115        QPixmap icon(iconWidth, weatherIcon->size().height() + 1.2 * float(metrics.height()));
     116        icon.fill(Qt::transparent);
     117        QPainter painter;
     118        painter.begin(&icon);
     119        painter.setFont(iconFont);
     120        painter.setPen(Qt::white);
     121        // remember: iconWidth = weatherIcon.width()
     122        painter.drawImage((icon.width() - iconWidth)/2, 0, *weatherIcon);
     123        painter.drawText(float(icon.width() - metrics.width(text)) / 2.0, weatherIcon->height() + painter.fontMetrics().height(), text);
     124        painter.end();
     125       
     126        icon = icon.scaled(iconWidth, 80, Qt::KeepAspectRatio);
     127        // set offset
     128        position.setX(position.x() - icon.width()/2);
     129        position.setY(position.y() - 40);
     130        painter.begin(map);
     131        painter.drawPixmap(position.x(), position.y(), icon);
     132        painter.end();
     133       
     134        return true;
     135}
     136
     137void Location::init()
     138{
     139        myCurrentWeatherIcon = "unknown.png";
     140}
  • new file mythplugins/mythweather/mythweather/location.h

    diff --git a/mythplugins/mythweather/mythweather/location.h b/mythplugins/mythweather/mythweather/location.h
    new file mode 100644
    index 0000000..52b1fd8
    - +  
     1/*
     2    Copyright (C) 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3
     4    This program is free software: you can redistribute it and/or modify
     5    it under the terms of the GNU General Public License as published by
     6    the Free Software Foundation, either version 3 of the License, or
     7    (at your option) any later version.
     8
     9    This program is distributed in the hope that it will be useful,
     10    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12    GNU General Public License for more details.
     13
     14    You should have received a copy of the GNU General Public License
     15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16
     17*/
     18
     19
     20#ifndef LOCATION_H
     21#define LOCATION_H
     22
     23// #include <QGeoCoordinate>
     24
     25class MythImage;
     26
     27#include <QMetaType>
     28
     29/**
     30        * @brief Represents a location with its coordinates and weather.
     31        */
     32class Location
     33{
     34        public:
     35                inline Location(){ init(); }
     36//              Location(qreal latitude, qreal longitude, QString station, QString name);
     37               
     38                void setName(QString name);
     39                QString name() const;
     40//              void setCoordinate(QtMobility::QGeoCoordinate coordinates);
     41//              QString latitude() const;
     42//              QString longitude() const;
     43                void setCurrentTemperatur(QString temperature);
     44                QString currentTemperature() const;
     45                void setCurrentWeatherIcon(QString icon);
     46                QString currentWeatherIcon() const;
     47//              QtMobility::QGeoCoordinate toCoordinate() const;
     48                bool addToMap(MythImage *map, QPoint position);
     49               
     50
     51        private:
     52                void init();
     53               
     54//              QtMobility::QGeoCoordinate myCoordinates;
     55                QString myName, myStation, myCurrentWeatherIcon;
     56                QString myCurrentTemperature;
     57};
     58
     59typedef QList<Location*> Locations;
     60
     61Q_DECLARE_METATYPE(Location)
     62
     63#endif // LOCATION_H
  • new file mythplugins/mythweather/mythweather/worldweatherscreen.cpp

    diff --git a/mythplugins/mythweather/mythweather/worldweatherscreen.cpp b/mythplugins/mythweather/mythweather/worldweatherscreen.cpp
    new file mode 100644
    index 0000000..10e1fc5
    - +  
     1/*
     2    Copyright (C) 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3
     4    This program is free software: you can redistribute it and/or modify
     5    it under the terms of the GNU General Public License as published by
     6    the Free Software Foundation, either version 3 of the License, or
     7    (at your option) any later version.
     8
     9    This program is distributed in the hope that it will be useful,
     10    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12    GNU General Public License for more details.
     13
     14    You should have received a copy of the GNU General Public License
     15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16
     17*/
     18
     19
     20#include "worldweatherscreen.h"
     21
     22#include "location.h"
     23
     24#include <QGeoSearchManager>
     25#include <QGeoServiceProvider>
     26#include <QGeoCoordinate>
     27#include <QGeoAddress>
     28
     29#include <mythimage.h>
     30#include <mythuiimage.h>
     31#include <mythmainwindow.h>
     32#include <mythdirs.h>
     33
     34#include <cmath>
     35
     36using namespace QtMobility;
     37
     38#include <QDebug>
     39
     40WorldWeatherScreen::WorldWeatherScreen(MythScreenStack* parent, ScreenListInfo* screenDefn, int id)
     41        : WeatherScreen(parent, screenDefn, id)
     42{
     43        map = NULL;
     44        geoProvider = NULL;
     45        geoSearch = NULL;
     46//      manager = NULL;
     47}
     48
     49WorldWeatherScreen::~WorldWeatherScreen()
     50{
     51        if(geoProvider)
     52                delete geoProvider;
     53}
     54
     55ScreenListInfo WorldWeatherScreen::info()
     56{
     57    ScreenListInfo info;
     58    info.name = "World Weather";
     59    info.title = tr("World Weather");
     60    info.hasUnits = false;
     61    // seems to be ignored right now
     62    info.multiLoc = true;
     63                info.dataTypes << "cclocation" << "c1location" << "temp" << "weather" << "weather_icon" << "copyright";
     64    return info;
     65}
     66
     67bool WorldWeatherScreen::Create(void )
     68{
     69    bool foundtheme = false;
     70
     71    // Load the theme for this screen
     72    foundtheme = LoadWindowFromXML("weather-ui.xml", "World Weather", this);
     73
     74    if (!foundtheme)
     75        return false;
     76               
     77                bool err = false;
     78
     79    UIUtilE::Assign(this, m_mapImage, "map_image", &err);
     80
     81                if (err)
     82    {
     83        VERBOSE(VB_IMPORTANT, "Window World Weather is missing required elements.");
     84        return false;
     85    }
     86
     87    if (!prepareScreen(true))
     88        return false;
     89
     90    return true;
     91}
     92
     93void WorldWeatherScreen::newData(QString loc, units_t units, DataMap data)
     94{
     95        Location *location = new Location();
     96        QGeoAddress address;
     97        foreach(QString key, data.uniqueKeys()){
     98                qDebug() << "WorldWeather::newData: "+ key +": "+ data.value(key);
     99                if(key.endsWith("location")){
     100                        QStringList names = data.value(key).split(", ");
     101                        if(names.size() < 2)
     102                                return;
     103                        location->setName(names[0]);
     104                        address.setCity(names[0]);
     105                        address.setCountry(names[1]);
     106                }
     107                if(key == "temp")
     108                        location->setCurrentTemperatur(data.value(key));
     109                if(key == "weather_icon")
     110                        location->setCurrentWeatherIcon(data.value(key));
     111        }
     112        if(address.isEmpty())
     113                return;
     114        locations << location;
     115        QGeoSearchReply *reply = geoSearch->geocode(address);
     116        connect(reply, SIGNAL(finished()), this, SLOT(geocodingFinished()));
     117}
     118
     119bool WorldWeatherScreen::prepareScreen(bool checkOnly)
     120{
     121        // setup provider and scene
     122        if(!geoProvider)
     123                geoProvider = new QGeoServiceProvider("nokia");
     124        if(!geoProvider)
     125                return false;
     126        if(!geoSearch)
     127                geoSearch = geoProvider->searchManager();
     128        if(!geoSearch)
     129                return false;
     130       
     131        if(!map || map->isNull())
     132                if(!loadMap(SatelliteMapDay))
     133                        return false;
     134
     135        // draw empty map
     136  m_mapImage->SetImage(map);
     137       
     138        return true;
     139}
     140
     141void WorldWeatherScreen::geocodingFinished()
     142{
     143        qDebug() << "geocoding finished";
     144        QGeoSearchReply *reply = qobject_cast<QGeoSearchReply*>(sender());
     145        if(!reply)
     146                return;
     147        if(!reply->error() != QGeoSearchReply::NoError){
     148                qDebug() << "Network error";
     149//              return;
     150        }
     151        if(locations.size() < 1)
     152                return;
     153       
     154        Location *location = locations.first();
     155        foreach(QGeoPlace place, reply->places()){
     156                qDebug() << "trying "+ place.address().city() +" --> "+ location->name();
     157                if(place.address().city() == location->name()){
     158                        qDebug() << "add "+ place.address().city() +" to the map";
     159                        if(!location->addToMap(map, coordinateToWorldReferencePosition(place.coordinate())))
     160                                qDebug() << "drawing weathericon has failed";
     161                        locations.removeFirst();
     162                        delete location;
     163                        if(locations.size() < 1)
     164                                break;
     165                        location = locations.first();
     166                }
     167        }
     168       
     169        emit screenReady(this);
     170}
     171
     172bool WorldWeatherScreen::loadMap(MapType type)
     173{
     174        if(!map)
     175                map = GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
     176       
     177        if(type == SatelliteMapNight)
     178                map->Load(QString("%1/mythweather/bluemarble/land_ocean_ice_lights_8192.png").arg(GetShareDir()));
     179        else
     180                map->Load(QString("%1/mythweather/bluemarble/land_shallow_topo_8192.png").arg(GetShareDir()));
     181        return !map->isNull();
     182}
     183
     184QPoint WorldWeatherScreen::coordinateToWorldReferencePosition(const QGeoCoordinate& coordinate) const
     185{
     186        double longitude = coordinate.longitude();
     187        double latitude = coordinate.latitude();
     188       
     189        int x = floor(longitude * mLongitude() + nLongitude());
     190        int y = floor(latitude * mLatitude() + nLatitude());
     191       
     192        return QPoint(x, y);
     193}
     194
     195qreal WorldWeatherScreen::mLongitude() const
     196{
     197        return qreal(map->size().width())/360.0;
     198}
     199
     200qreal WorldWeatherScreen::mLatitude() const
     201{
     202        return qreal(map->size().height())/-180.0;
     203}
     204
     205qreal WorldWeatherScreen::nLongitude() const
     206{
     207        return qreal(map->size().width())/2.0;
     208}
     209
     210qreal WorldWeatherScreen::nLatitude() const
     211{
     212        return qreal(map->size().height()) + mLatitude() * 90.0;
     213}
  • new file mythplugins/mythweather/mythweather/worldweatherscreen.h

    diff --git a/mythplugins/mythweather/mythweather/worldweatherscreen.h b/mythplugins/mythweather/mythweather/worldweatherscreen.h
    new file mode 100644
    index 0000000..99e4929
    - +  
     1/*
     2    Copyright (C) 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3
     4    This program is free software: you can redistribute it and/or modify
     5    it under the terms of the GNU General Public License as published by
     6    the Free Software Foundation, either version 3 of the License, or
     7    (at your option) any later version.
     8
     9    This program is distributed in the hope that it will be useful,
     10    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12    GNU General Public License for more details.
     13
     14    You should have received a copy of the GNU General Public License
     15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16
     17*/
     18
     19
     20#ifndef WORLDWEATHERSCREEN_H
     21#define WORLDWEATHERSCREEN_H
     22
     23#include "weatherScreen.h"
     24#include "weatherUtils.h"
     25
     26class Location;
     27
     28#include <QGeoCoordinate>
     29
     30namespace QtMobility{
     31        class QGeoServiceProvider;
     32        class QGeoSearchManager;
     33};
     34
     35class MythImage;
     36
     37class WorldWeatherScreen : public WeatherScreen
     38{
     39    Q_OBJECT
     40    public:
     41                                /**
     42                                        * @brief List of supported maps.
     43                                        */
     44                                enum MapType{
     45                                        SatelliteMapDay,                /**< Day map */
     46                                        SatelliteMapNight       /**< Night map */
     47                                };
     48                       
     49        WorldWeatherScreen(MythScreenStack *parent, ScreenListInfo *screenDefn, int id);
     50        ~WorldWeatherScreen();
     51               
     52        static ScreenListInfo info();
     53               
     54        bool Create(void);
     55                               
     56    public slots:
     57        void newData(QString loc, units_t units, DataMap data);
     58                               
     59    protected:
     60        bool prepareScreen(bool checkOnly = false);
     61                               
     62                private slots:
     63                        void geocodingFinished();
     64                               
     65    private:
     66                                /**
     67                                        * @brief Loads the map of @p type type.
     68                                        */
     69                                bool loadMap(MapType type);
     70                                /**
     71                                        * @brief Converts the coordinate \a coordinate to a pixel position on the entire map at the maximum zoom level.
     72                                        *
     73                                        * @note Do not check for longitude between -180 and 180 and latitude between
     74                                        *       -90 and 90, because the map starts over after 180 and -180 and so on.
     75                                        */
     76                                QPoint coordinateToWorldReferencePosition(const QtMobility::QGeoCoordinate &coordinate) const;
     77                                /**
     78                                        * @brief pixel/Deg for longitude.
     79                                        */
     80                                qreal mLongitude() const;
     81                                /**
     82                                        * @brief pixel/deg for latitude.
     83                                        */
     84                                qreal mLatitude() const;
     85                                /**
     86                                        * @brief pixel of greenwich meridian.
     87                                        */
     88                                qreal nLongitude() const;
     89                                /**
     90                                        * @brief pixel of equator.
     91                                        */
     92                                qreal nLatitude() const;
     93                       
     94                                MythImage *map;
     95        MythUIImage *m_mapImage;
     96                                QtMobility::QGeoServiceProvider *geoProvider;
     97                                QtMobility::QGeoSearchManager *geoSearch;
     98                                QList<Location*> locations;
     99};
     100
     101#endif // WORLDWEATHERSCREEN_H
  • mythplugins/mythweather/mythweather/weatherScreen.cpp

    -- 
    1.7.3.4
    
    
    From ae2f2d8773630c576f0398d639e6a19067e9717d Mon Sep 17 00:00:00 2001
    From: Joachim Langenbach <joachim.langenbach@engsas.de>
    Date: Thu, 26 Jan 2012 22:17:49 +0100
    Subject: [PATCH 2/2] Forgotten some changes for WorldWeatherMap
    
    ---
     .../mythweather/mythweather/weatherScreen.cpp      |   15 ++++----
     .../mythweather/mythweather/weatherUtils.cpp       |   32 +++++++++++-------
     mythplugins/mythweather/mythweather/weatherUtils.h |   35 ++++++++------------
     3 files changed, 41 insertions(+), 41 deletions(-)
    
    diff --git a/mythplugins/mythweather/mythweather/weatherScreen.cpp b/mythplugins/mythweather/mythweather/weatherScreen.cpp
    index f34cc09..0f25c20 100644
    a b using namespace std; 
    88// MythWeather headers
    99#include "weather.h"
    1010#include "weatherScreen.h"
     11#include "worldweatherscreen.h"
    1112
    1213WeatherScreen *WeatherScreen::loadScreen(MythScreenStack *parent,
    1314                                         ScreenListInfo *screenDefn, int id)
    1415{
     16    if(screenDefn->name == "World Weather")
     17        return new WorldWeatherScreen(parent, screenDefn, id);
    1518    return new WeatherScreen(parent, screenDefn, id);
    1619}
    1720
    1821WeatherScreen::WeatherScreen(MythScreenStack *parent,
    1922                             ScreenListInfo *screenDefn, int id) :
    2023               MythScreenType (parent, screenDefn->title),
    21     m_units(SI_UNITS),
    2224    m_screenDefn(screenDefn),
    2325    m_name(m_screenDefn->name),
    2426    m_inuse(false),
    2527    m_prepared(false),
    2628    m_id(id)
    2729{
    28 
    2930    QStringList types = m_screenDefn->dataTypes;
    3031
    3132    for (int i = 0; i < types.size(); ++i)
    bool WeatherScreen::canShowScreen() 
    6667        i.next();
    6768        if (i.key().isEmpty())
    6869        {
    69             LOG(VB_GENERAL, LOG_DEBUG, i.key());
     70            VERBOSE(VB_GENERAL, i.key());
    7071            ok = false;
    7172        }
    7273    }
    void WeatherScreen::newData(QString loc, units_t units, DataMap data) 
    9697    // This may seem like overkill, but it is necessary to actually update the
    9798    // static and animated maps when they are redownloaded on an update
    9899    if (!prepareScreen())
    99         LOG(VB_GENERAL, LOG_ERR, "Theme is missing a required widget!");
     100        VERBOSE(VB_IMPORTANT, "Theme is missing a required widget!");
    100101
    101102    emit screenReady(this);
    102103}
    bool WeatherScreen::prepareScreen(bool checkOnly) 
    119120
    120121        if (!widget)
    121122        {
    122             LOG(VB_GENERAL, LOG_ERR, "Widget not found " + itr.key());
     123            VERBOSE(VB_GENERAL, "Widget not found " + itr.key());
    123124
    124125            if (name == "copyright")
    125126            {
    126                 LOG(VB_GENERAL, LOG_WARNING,
     127                VERBOSE(VB_IMPORTANT,
    127128                    QString("No copyright widget found, skipping screen %1.")
    128                         .arg(m_name));
     129                    .arg(m_name));
    129130                return false;
    130131            }
    131132        }
  • mythplugins/mythweather/mythweather/weatherUtils.cpp

    diff --git a/mythplugins/mythweather/mythweather/weatherUtils.cpp b/mythplugins/mythweather/mythweather/weatherUtils.cpp
    index 4284d64..f3e4b64 100644
    a b  
    88
    99// MythWeather headers
    1010#include "weatherUtils.h"
     11#include "worldweatherscreen.h"
    1112
    1213static QString getScreenTitle(const QString &screenName)
    1314{
    static QString getScreenTitle(const QString &screenName) 
    3233ScreenListMap loadScreens()
    3334{
    3435    ScreenListMap screens;
    35     QStringList searchpath = GetMythUI()->GetThemeSearchPath();
    36 
     36    QList<QString> searchpath = GetMythUI()->GetThemeSearchPath();
     37               
     38                ScreenListInfo info = WorldWeatherScreen::info();
     39                screens[info.name].multiLoc = false;
     40                screens[info.name].name = info.name;
     41                screens[info.name].title = info.title;
     42                screens[info.name].hasUnits = true;
     43                screens[info.name].dataTypes = info.dataTypes;
     44   
    3745    // Check the theme first if it has its own weather-screens.xml
    38 
    39     QStringList::iterator it;
    40     for (it = searchpath.begin(); it != searchpath.end(); ++it)
     46   
     47    QList<QString>::iterator i;
     48    for (i = searchpath.begin(); i != searchpath.end(); i++)
    4149    {
    42         QString filename = (*it) + "weather-screens.xml";
     50        QString filename = *i + "weather-screens.xml";
    4351        if (doLoadScreens(filename, screens))
    4452        {
    45             LOG(VB_GENERAL, LOG_INFO,
    46                 QString("Loading from: %1").arg(filename));
     53            VERBOSE(VB_GENERAL, QString("Loading from: %1").arg(filename));
    4754            break;
    4855        }
    4956    }
    5057
    5158    //  Also load from the default file in case the theme file doesn't
    5259    //  exist or the theme file doesn't define all the screens
    53 
     60   
    5461    QString filename = GetShareDir() + "mythweather/weather-screens.xml";
    55 
     62   
    5663    if (!doLoadScreens(filename, screens))
    5764    {
    58         LOG(VB_GENERAL, LOG_ERR,
    59             QString("Unable to parse weather-screens.xml"));
     65        VERBOSE(VB_IMPORTANT, QString("Unable to parse weather-screens.xml"));
    6066    }
    6167
    6268    return screens;
    bool doLoadScreens(const QString &filename, ScreenListMap &screens) 
    6672{
    6773    QFile f(filename);
    6874    QDomDocument doc;
    69 
     75       
    7076    if (!f.open(QIODevice::ReadOnly))
    7177    {
    7278        return false;
  • mythplugins/mythweather/mythweather/weatherUtils.h

    diff --git a/mythplugins/mythweather/mythweather/weatherUtils.h b/mythplugins/mythweather/mythweather/weatherUtils.h
    index d39d5da..2b392b5 100644
    a b  
    1515#define SI_UNITS 0
    1616#define ENG_UNITS 1
    1717#define DEFAULT_UPDATE_TIMEOUT (5*60*1000)
    18 #define DEFAULT_SCRIPT_TIMEOUT (60)
     18#define DEFAULT_SCRIPT_TIMEOUT (60*1000)
    1919
    2020typedef unsigned char units_t;
    2121typedef QMap<QString, QString> DataMap;
    typedef QMap<QString, QString> DataMap; 
    2323class TypeListInfo
    2424{
    2525  public:
    26 
     26 
    2727    TypeListInfo(const TypeListInfo& info)
    2828        : name(info.name), location(info.location), src(info.src)
    2929    {
    3030        name.detach();
    3131        location.detach();
    3232    }
    33 
     33 
    3434    TypeListInfo(const QString &_name)
    3535        : name(_name), location(QString::null), src(NULL)
    3636    {
    typedef QMultiHash<QString, TypeListInfo> TypeListMap; 
    6060class ScreenListInfo
    6161{
    6262  public:
    63     ScreenListInfo() :
    64         units(SI_UNITS),
    65         hasUnits(false),
    66         multiLoc(false)
    67     {
    68         updating = false;
    69     }
     63    ScreenListInfo() {updating = false;}
    7064
    7165    ScreenListInfo(const ScreenListInfo& info) :
    72         name(info.name),
    73         title(info.title),
    74         types(info.types),
    75         dataTypes(info.dataTypes),
    76         helptxt(info.helptxt),
    77         sources(info.sources),
    78         units(info.units),
    79         hasUnits(info.hasUnits),
    80         multiLoc(info.multiLoc),
    81         updating(info.updating)
     66    name(info.name),
     67    title(info.title),
     68    types(info.types),
     69    helptxt(info.helptxt),
     70    sources(info.sources),
     71    units(info.units),
     72    hasUnits(info.hasUnits),
     73    multiLoc(info.multiLoc),
     74    updating(info.updating)
    8275    {
    8376      types.detach();
    8477    }
    class ScreenListInfo 
    9891    bool updating;
    9992};
    10093
    101 Q_DECLARE_METATYPE(ScreenListInfo *);
     94Q_DECLARE_METATYPE(ScreenListInfo *); 
    10295
    10396typedef QMap<QString, ScreenListInfo> ScreenListMap;
    10497