summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c2fbb7e)
raw | patch | inline | side by side (parent: c2fbb7e)
author | dgerlach <d-gerlach@ti.com> | |
Wed, 5 Sep 2012 16:18:30 +0000 (11:18 -0500) | ||
committer | dgerlach <d-gerlach@ti.com> | |
Wed, 5 Sep 2012 16:18:30 +0000 (11:18 -0500) |
ThermostatDemo | patch | blob | history | |
ThermostatDemoSource/webdata.cpp | patch | blob | history | |
ThermostatDemoSource/webdata.h | patch | blob | history |
diff --git a/ThermostatDemo b/ThermostatDemo
index 792732a42256f0b1827f27214042e74e1579c252..cc9a744f7c0ac47f2e57f91e16f360c120afc023 100755 (executable)
Binary files a/ThermostatDemo and b/ThermostatDemo differ
Binary files a/ThermostatDemo and b/ThermostatDemo differ
index 5c96842837cb72a8cb548fab282a7eb25fde3340..952d3292028b11c27ce06580911bfb32bcf70526 100644 (file)
void WebData::responseReceived()
{
+ m_networkTimer.stop();
+
if(reply->error() == QNetworkReply::NoError)
{
QByteArray xmlData = reply->readAll();
}
else
{
+ qDebug() << reply->errorString();
loadLocalData();
emit networkTimeout();
}
// receive document and parse it
request.setUrl(QUrl(cityUrl));
+ //set up timer to check for network timeout
+ connect(&m_networkTimer, SIGNAL(timeout()), this, SLOT(handleNetworkTimeout()));
+ m_networkTimer.start(30000);
+
+ //make actual network request
reply = manager->get(request);
connect(reply,SIGNAL(finished()),this,SLOT(responseReceived()));
}
-QString WebData::unitConversion(QString currentValue)
+void WebData::handleNetworkTimeout()
{
- // check to see if setting is Farhenheit or Celsius and make proper conversion
- // values are read in as Fahrenheit, so only need to convert to Celsius if necessary
- int FInt, CInt;
-
- if(!(m_globalSettings->temperatureFormat() == GlobalSettings::TempFormatF)) {
- // false means C
- // we want Celsius, but currently in Fahrenheit
- FInt = currentValue.toInt();
- CInt = ((FInt - 32) * 5)/9;
- return QString::number(CInt);
- } else {
- return currentValue;
- }
+ m_networkTimer.stop();
+ reply->abort();
+ emit(networkTimeout());
}
index 1d67087153c3be7275053b715e05ab778d8c85ec..f32d3d35df0ef73939bfb8977e7eb138afd60d66 100644 (file)
private slots:
void parseXML(QByteArray *xmlData);
void responseReceived();
+ void handleNetworkTimeout();
private:
QStringList forecastIconList;
QStringList weekdayList;
QStringList forecastTempList;
- QString unitConversion(QString);
+
+ QTimer m_networkTimer;
GlobalSettings *m_globalSettings;