Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Backport r25220 and some older code changes (UTF-8 support) to 0.23-f…

…ixes

git-svn-id: http://svn.mythtv.org/svn/branches/release-0-23-fixes@25221 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information...
commit 954b370f7318dd1c46c59ab91986c9dd016884f1 1 parent 7de3e50
@Beirdo Beirdo authored
View
10 mythplugins/mythweather/mythweather/weatherScreen.cpp
@@ -98,8 +98,9 @@ void WeatherScreen::newData(QString loc, units_t units, DataMap data)
++itr;
}
- if (!m_prepared)
- prepareScreen();
+ // This may seem like overkill, but it is necessary to actually update the
+ // static and animated maps when they are redownloaded on an update
+ prepareScreen();
emit screenReady(this);
}
@@ -167,7 +168,8 @@ QString WeatherScreen::formatDataItem(const QString &key, const QString &value)
return value + (m_units == ENG_UNITS ? " mi" : " km");
if (key == "temp" || key == "appt" || key.contains("low",Qt::CaseInsensitive) ||
- key.contains("high",Qt::CaseInsensitive))
+ key.contains("high",Qt::CaseInsensitive) ||
+ key.contains("temp",Qt::CaseInsensitive))
{
if ( (value == "NA") || (value == "N/A") )
return value;
@@ -176,7 +178,7 @@ QString WeatherScreen::formatDataItem(const QString &key, const QString &value)
}
if (key == "wind_gust" || key == "wind_spdgst" || key == "wind_speed")
- return value + (m_units == ENG_UNITS ? " mph" : " kph");
+ return value + (m_units == ENG_UNITS ? " mph" : " km/h");
/*The days of the week will be translated if the script sends elements from
the enum DaysOfWeek.*/
View
30 mythplugins/mythweather/mythweather/weatherSource.cpp
@@ -4,6 +4,7 @@
#include <QDir>
#include <QFile>
#include <QTextStream>
+#include <QTextCodec>
#include <QApplication>
// MythTV headers
@@ -475,6 +476,8 @@ QStringList WeatherSource::getLocationList(const QString &str)
QStringList locs;
m_proc->setReadChannel(QProcess::StandardOutput);
+
+ QTextCodec *codec = QTextCodec::codecForName("UTF-8");
while (m_proc->canReadLine())
{
QByteArray tmp = m_proc->readLine();
@@ -483,7 +486,10 @@ QStringList WeatherSource::getLocationList(const QString &str)
tmp.chop(1);
if (!tmp.isEmpty())
- locs.push_back(QString(tmp));
+ {
+ QString loc_string = codec->toUnicode(tmp);
+ locs.push_back(loc_string);
+ }
}
return locs;
@@ -500,7 +506,7 @@ void WeatherSource::startUpdate(bool forceUpdate)
{
db.prepare("SELECT updated FROM weathersourcesettings "
"WHERE sourceid = :ID AND "
- "TIMESTAMPADD(SECOND,update_timeout,updated) > NOW()");
+ "TIMESTAMPADD(SECOND,update_timeout-15,updated) > NOW()");
db.bindValue(":ID", getId());
if (db.exec() && db.size() > 0)
{
@@ -596,7 +602,8 @@ void WeatherSource::processExit()
if (!tempStr.isEmpty())
m_buffer += tempStr;
- QString cachefile = QString("%1/cache_%2").arg(m_dir).arg(m_locale);
+ QString locale_file = m_locale.replace("/", "-");
+ QString cachefile = QString("%1/cache_%2").arg(m_dir).arg(locale_file);
QFile cache(cachefile);
if (cache.open( QIODevice::WriteOnly ))
{
@@ -631,7 +638,11 @@ void WeatherSource::processExit()
void WeatherSource::processData()
{
- QStringList data = QString(m_buffer).split('\n', QString::SkipEmptyParts);
+ QTextCodec *codec = QTextCodec::codecForName("UTF-8");
+ QString unicode_buffer = codec->toUnicode(m_buffer);
+ QStringList data = unicode_buffer.split('\n', QString::SkipEmptyParts);
+
+ m_data.clear();
for (int i = 0; i < data.size(); ++i)
{
@@ -647,12 +658,15 @@ void WeatherSource::processData()
return; // we don't emit signal
}
- if (!m_data[temp[0]].isEmpty())
+ if (temp[1] != "---")
{
- m_data[temp[0]].append("\n" + temp[1]);
+ if (!m_data[temp[0]].isEmpty())
+ {
+ m_data[temp[0]].append("\n" + temp[1]);
+ }
+ else
+ m_data[temp[0]] = temp[1];
}
- else
- m_data[temp[0]] = temp[1];
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.