Update to support both Qt 4 and Qt 5 origin/HEAD origin/master
authorFranklin S. Cooper Jr <fcooper@ti.com>
Mon, 2 Mar 2015 15:05:01 +0000 (09:05 -0600)
committerFranklin S. Cooper Jr <fcooper@ti.com>
Mon, 2 Mar 2015 15:05:01 +0000 (09:05 -0600)
Signed-off-by: Franklin S. Cooper Jr <fcooper@ti.com>
13 files changed:
awayscreen.h
keyboard/keyboard.h
main.cpp
mainwindow.h
qkeyboardlineedit.h
remoteaccessmanager.cpp
remoteaccessmanager.h
schedulescreen.h
settingscreen.h
thermostatwidget.h
weatherdata.h
weatherwidget.h
webdataengine/openweathermapdataengine.cpp

index 2a2b040afa108593836a7c932d30d0d5ac4dcce7..728f67085b0f85bc3da5a718881589871c87cbeb 100644 (file)
@@ -1,8 +1,18 @@
 #ifndef AWAYSCREEN_H
 #define AWAYSCREEN_H
 
+#include <qglobal.h>
+
 #include <QtGui>
 
+#if QT_VERSION >= 0x050000
+
+#include <QSpinBox>
+#include <QLabel>
+#include <QLineEdit>
+
+#endif
+
 class GlobalSettings;
 
 class AwayScreen : public QWidget
index 2d5c5844de5570a63a8cd678767583ac409f2c92..880dabd396084251e744ee8920c5446e2b0b4cbe 100644 (file)
@@ -1,8 +1,16 @@
 #ifndef KEYBOARD_H
 #define KEYBOARD_H
 
+#include <qglobal.h>
 #include <QWidget>
 #include <QtGui>
+#if QT_VERSION >= 0x050000
+
+#include <QLineEdit>
+#include <QPushButton>
+
+#endif
+
 namespace Ui {
 class Keyboard;
 }
index 18234c9b736dc79029a21ac01fe1864fa5288af2..fbabcfe823a7eda3aa8223a662f5b3554faf9e69 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -6,6 +6,13 @@
 #include "optionswidget.h"\r
 #include "webdata.h"\r
 \r
+#include <qglobal.h>\r
+#if QT_VERSION >= 0x050000\r
+\r
+#include <QDesktopWidget>\r
+\r
+#endif\r
+\r
 #include <QtDebug>\r
 \r
 int main(int argc, char *argv[])\r
index f59d9923f47afebd19d96f679eaa89ad1888729c..37d20b8b28205668a105b349e3dbb33fea1ada44 100644 (file)
@@ -1,9 +1,16 @@
 #ifndef MAINWINDOW_H\r
 #define MAINWINDOW_H\r
 \r
+#include <qglobal.h>\r
 #include <QtGui>\r
 #include "webdata.h"\r
 \r
+#if QT_VERSION >= 0x050000\r
+\r
+#include <QPushButton>\r
+\r
+#endif\r
+\r
 \r
 class GlobalSettings;\r
 class OptionsWidget;\r
index 69687e9a26e7bd3d6661d44cb1cd25d329f927dc..16d0bc22187b68e12632bf6c1ea5793d9015f2f4 100644 (file)
@@ -1,8 +1,15 @@
 #ifndef QKEYBOARDLINEEDIT_H
 #define QKEYBOARDLINEEDIT_H
 
+#include <qglobal.h>
 #include <QLineEdit>
 
+#if QT_VERSION >= 0x050000
+
+#include <QApplication>
+
+#endif
+
 class Keyboard;
 
 class QKeyboardLineEdit : public QLineEdit
index 5eebdef637b53b289790c62b5112df69852418e6..161376d30d7206fdb93174382e922750c4369cba 100644 (file)
@@ -103,7 +103,12 @@ void RemoteAccessManager::processIncomingConnection()
         }
         else if(requestParser[1].contains(".jpg") || requestParser[1].contains(".png"))
         {
-            QFile imageFile(":"+QString::fromAscii(requestParser[1]));
+
+            #if QT_VERSION >= 0x050000
+                QFile imageFile(":"+QString::fromLatin1(requestParser[1]));
+            #else
+                QFile imageFile(":"+QString::fromAscii(requestParser[1]));
+            #endif
 
             if(!imageFile.open(QFile::ReadOnly))
                 ba = "HTTP/1.1 404 NOT FOUND";
@@ -119,7 +124,12 @@ void RemoteAccessManager::processIncomingConnection()
         }
         else if(requestParser[1].contains(".js"))
         {
-            QFile jsFile(":"+QString::fromAscii(requestParser[1]));
+
+            #if QT_VERSION >= 0x050000
+                QFile jsFile(":"+QString::fromLatin1(requestParser[1]));
+            #else
+                QFile jsFile(":"+QString::fromAscii(requestParser[1]));
+            #endif
 
             if(!jsFile.open(QFile::ReadOnly))
                 ba = "HTTP/1.1 404 NOT FOUND";
@@ -135,7 +145,12 @@ void RemoteAccessManager::processIncomingConnection()
         }
         else if(requestParser[1].contains(".css"))
         {
-            QFile cssFile(":"+QString::fromAscii(requestParser[1]));
+
+            #if QT_VERSION >= 0x050000
+                QFile cssFile(":"+QString::fromLatin1(requestParser[1]));
+            #else
+                QFile cssFile(":"+QString::fromAscii(requestParser[1]));
+            #endif
 
             if(!cssFile.open(QFile::ReadOnly))
                 ba = "HTTP/1.1 404 NOT FOUND";
@@ -211,11 +226,22 @@ QByteArray RemoteAccessManager::hashToJSONByteArray(QHash<QString, QVariant> has
 
     while(it.hasNext())
     {
+
         it.next();
-        if(it.value().type() == QVariant::Hash)
-            jsonByteArray+="\""+it.key().toAscii()+"\""+QByteArray::fromRawData(":",1)+""+hashToJSONByteArray(it.value().toHash())+",";
-        else
-            jsonByteArray += "\""+it.key().toAscii()+"\""+QByteArray::fromRawData(":",1)+"\""+it.value().toByteArray()+"\""+QByteArray::fromRawData(",",1);
+        if(it.value().type() == QVariant::Hash) {
+            #if QT_VERSION >= 0x050000
+                jsonByteArray+="\""+it.key().toLatin1()+"\""+QByteArray::fromRawData(":",1)+""+hashToJSONByteArray(it.value().toHash())+",";
+            #else
+                jsonByteArray+="\""+it.key().toAscii()+"\""+QByteArray::fromRawData(":",1)+""+hashToJSONByteArray(it.value().toHash())+",";
+            #endif
+        }
+        else {
+            #if QT_VERSION >= 0x050000
+                jsonByteArray += "\""+it.key().toLatin1()+"\""+QByteArray::fromRawData(":",1)+"\""+it.value().toByteArray()+"\""+QByteArray::fromRawData(",",1);
+            #else
+                jsonByteArray += "\""+it.key().toAscii()+"\""+QByteArray::fromRawData(":",1)+"\""+it.value().toByteArray()+"\""+QByteArray::fromRawData(",",1);
+            #endif
+        }
     }
 
     jsonByteArray = jsonByteArray.left(jsonByteArray.size()-1);
index d202df9a165f003a3a733a636c7aea4afa12923d..e2abc6b648642339c286f875628beddac38e019e 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef REMOTEACCESSMANAGER_H
 #define REMOTEACCESSMANAGER_H
 
+#include <qglobal.h>
 #include <QHash>
 #include <QObject>
 #include <QVariant>
index 9bc0897ac54784e4146a231f5c01050618ed5b19..98dee57637b90559a8f835ba9196bda334d06075 100644 (file)
@@ -1,7 +1,24 @@
 #ifndef SCHEDULESCREEN_H
 #define SCHEDULESCREEN_H
 
+#include <qglobal.h>
 #include <QtGui>
+
+#if QT_VERSION >= 0x050000
+
+#include <QTimer>
+#include <QGraphicsProxyWidget>
+#include <QGraphicsView>
+#include <QButtonGroup>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QDesktopWidget>
+#include <QGraphicsSceneMouseEvent>
+
+#endif
+
 #include "schedulepoint.h"
 
 class GlobalSettings;
index 4edf175725dc9258a933a3d6982d7dc62a16d811..52b450d2680912597b47b2800c5bf6e523ca7a8a 100644 (file)
@@ -1,8 +1,21 @@
 #ifndef SETTINGSCREEN_H
 #define SETTINGSCREEN_H
 
+#include <qglobal.h>
 #include <QtGui>
 
+#if QT_VERSION >= 0x050000
+
+#include <QComboBox>
+#include <QLabel>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QFormLayout>
+
+#endif
+
 class GlobalSettings;
 class QKeyboardLineEdit;
 
index ba8199bb318ac9520770f429457de51392ab415a..b517a2e2209a417a05afe10af38dc6d8956ebcfc 100644 (file)
@@ -1,8 +1,18 @@
 #ifndef THERMOSTATWIDGET_H\r
 #define THERMOSTATWIDGET_H\r
 \r
+#include <qglobal.h>\r
 #include <QtGui>\r
 \r
+#if QT_VERSION >= 0x050000\r
+\r
+#include <QPushButton>\r
+#include <QLabel>\r
+#include <QHBoxLayout>\r
+#include <QVBoxLayout>\r
+\r
+#endif\r
+\r
 class GlobalSettings;\r
 \r
 class ThermostatWidget : public QWidget\r
index 0f08abd614d32a5db3e4a5f68d345329939854e0..1b92cdbfbf491febd238418cb0b0961c5db31405 100644 (file)
@@ -1,8 +1,18 @@
 #ifndef WEATHERDATA_H
 #define WEATHERDATA_H
 
+#include <qglobal.h>
 #include <QDateTime>
 
+#if QT_VERSION >= 0x050000
+
+#include <QPushButton>
+#include <QLabel>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+
+#endif
+
 class ForecastData;
 
 class WeatherData
index bffb368ea9403dbe616ec6d7205df1be13a5a087..7129d57a784e015e4f1d0d493da6335466b52f54 100644 (file)
@@ -1,10 +1,19 @@
 #ifndef WEATHERWIDGET_H\r
 #define WEATHERWIDGET_H\r
 \r
+#include <qglobal.h>\r
 #include <QtGui>\r
-\r
 #include <QtSvg/QSvgWidget>\r
 \r
+#if QT_VERSION >= 0x050000\r
+\r
+#include <QStackedWidget>\r
+#include <QLabel>\r
+#include <QHBoxLayout>\r
+#include <QVBoxLayout>\r
+\r
+#endif\r
+\r
 class QLabel;\r
 class WeatherData;\r
 class WeatherDataWidget;\r
index 0286dd5bc337e6d18c458d7b3a39ed34d463a2f1..09581b358367a285eca73015c6ee376b90281a0d 100644 (file)
@@ -1,5 +1,6 @@
 #include "openweathermapdataengine.h"
 
+#include <qglobal.h>
 #include <QNetworkAccessManager>
 #include <QNetworkProxy>
 #include <QNetworkReply>
@@ -67,7 +68,12 @@ void OpenWeatherMapDataEngine::responseReceived()
         QByteArray data = m_reply->readAll();
         //qDebug() << data;
 
-        m_cityId = parseCityInformation(QString::fromAscii(data));
+        #if QT_VERSION >= 0x050000
+            m_cityId = parseCityInformation(QString::fromLatin1(data));
+        #else
+            m_cityId = parseCityInformation(QString::fromAscii(data));
+        #endif
+
         //docs say do not delete in the slot so well pass it off to the event loop
         m_reply->deleteLater();
         if(m_cityId == -1)