incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [26/26] qt commit: Patches to get code to compile with Qt5. Still backwards compatible with Qt 4.
Date Fri, 24 Feb 2012 20:52:11 GMT
Patches to get code to compile with Qt5. Still backwards compatible with Qt 4.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/commit/433c3d29
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/tree/433c3d29
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/diff/433c3d29

Branch: refs/heads/master
Commit: 433c3d29e15fba2525e05502907d03b0bc40dcb6
Parents: 59da17f
Author: Jeff Tranter <jtranter@ics.com>
Authored: Tue Feb 14 13:54:21 2012 -0500
Committer: Jeff Tranter <jtranter@ics.com>
Committed: Tue Feb 14 13:54:21 2012 -0500

----------------------------------------------------------------------
 cordovaqt.pro                |   70 ++++--------------------------------
 main.cpp                     |    2 +-
 mainwindow.cpp               |   15 +++++++-
 mainwindow.h                 |    2 +-
 src/plugins/connection.cpp   |   53 ++++++++++++++++++++++++++++
 src/plugins/connection.h     |   16 ++++++++
 src/plugins/device.cpp       |   20 +++++++++-
 src/plugins/geolocation.h    |    2 +
 src/plugins/notification.cpp |    2 +
 9 files changed, 115 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/cordovaqt.pro
----------------------------------------------------------------------
diff --git a/cordovaqt.pro b/cordovaqt.pro
index c0c8aa3..11ab062 100644
--- a/cordovaqt.pro
+++ b/cordovaqt.pro
@@ -49,6 +49,14 @@ HEADERS += mainwindow.h \
     src/cwebpage.h
 FORMS += mainwindow.ui
 
+# Needed for Qt 5
+greaterThan(QT_MAJOR_VERSION, 4) {
+QT += widgets
+QT += location
+QT += feedback
+QT += systeminfo
+}
+
 QT += webkit
 
 # Please do not modify the following two lines. Required for deployment.
@@ -56,65 +64,3 @@ include(deployment.pri)
 qtcAddDeployment()
 
 OTHER_FILES +=
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/main.cpp
----------------------------------------------------------------------
diff --git a/main.cpp b/main.cpp
index 3e30575..a1277ad 100644
--- a/main.cpp
+++ b/main.cpp
@@ -16,7 +16,7 @@
 
 #include "mainwindow.h"
 
-#include <QtGui/QApplication>
+#include <QApplication>
 
 int main(int argc, char *argv[])
 {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/mainwindow.cpp
----------------------------------------------------------------------
diff --git a/mainwindow.cpp b/mainwindow.cpp
index deafbd9..4690216 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -45,7 +45,9 @@ void MainWindow::setOrientation(ScreenOrientation orientation)
     }
 #endif // Q_OS_SYMBIAN
 
+#if QT_VERSION < 0x050000
     Qt::WidgetAttribute attribute;
+#endif
     switch (orientation) {
 #if QT_VERSION < 0x040702
     // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
@@ -59,7 +61,7 @@ void MainWindow::setOrientation(ScreenOrientation orientation)
     case ScreenOrientationAuto:
         attribute = static_cast<Qt::WidgetAttribute>(130);
         break;
-#else // QT_VERSION < 0x040702
+#elif QT_VERSION < 0x050000
     case ScreenOrientationLockPortrait:
         attribute = Qt::WA_LockPortraitOrientation;
         break;
@@ -70,9 +72,20 @@ void MainWindow::setOrientation(ScreenOrientation orientation)
     case ScreenOrientationAuto:
         attribute = Qt::WA_AutoOrientation;
         break;
+#else // Qt 5
+    // TODO: Implement for Qt 5
+    case ScreenOrientationLockPortrait:
+        break;
+    case ScreenOrientationLockLandscape:
+        break;
+    default:
+    case ScreenOrientationAuto:
+        break;
 #endif // QT_VERSION < 0x040702
     };
+#if QT_VERSION < 0x050000
     setAttribute(attribute, true);
+#endif
 }
 
 void MainWindow::showExpanded()

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/mainwindow.h
----------------------------------------------------------------------
diff --git a/mainwindow.h b/mainwindow.h
index eae2175..542c509 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -19,7 +19,7 @@
 
 #include "src/cordova.h"
 
-#include <QtGui/QMainWindow>
+#include <QMainWindow>
 
 namespace Ui {
     class MainWindow;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/src/plugins/connection.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/connection.cpp b/src/plugins/connection.cpp
index 07b1a36..b305d21 100644
--- a/src/plugins/connection.cpp
+++ b/src/plugins/connection.cpp
@@ -35,13 +35,24 @@ Connection::Connection() : CPlugin() {
  */
 void Connection::init() {
     m_changeCallback = -1;
+
+#if QT_VERSION < 0x050000
     m_systemNetworkInfo = new QSystemNetworkInfo();
+#else
+    m_systemNetworkInfo = new QNetworkInfo();
+#endif
     m_bInitialized = false;
 
     // Listen to changes in the network state
+#if QT_VERSION < 0x050000
     QObject::connect(m_systemNetworkInfo,SIGNAL(cellDataTechnologyChanged(QSystemNetworkInfo::CellDataTechnology)),this,SLOT(cellDataTechnologyChanged(QSystemNetworkInfo::CellDataTechnology)));
     QObject::connect(m_systemNetworkInfo,SIGNAL(networkModeChanged(QSystemNetworkInfo::NetworkMode)),this,SLOT(networkModeChanged(QSystemNetworkInfo::NetworkMode)));
     QObject::connect(m_systemNetworkInfo,SIGNAL(networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus)),this,SLOT(networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus)));
+#else
+    QObject::connect(m_systemNetworkInfo,SIGNAL(currentCellDataTechnologyChanged(int, QNetworkInfo::CellDataTechnology)),this,SLOT(currentCellDataTechnologyChanged(int,
QNetworkInfo::CellDataTechnology)));
+    QObject::connect(m_systemNetworkInfo,SIGNAL(currentNetworkModeChanged(QNetworkInfo::NetworkMode)),this,SLOT(currentNetworkModeChanged(QNetworkInfo::NetworkMode)));
+    QObject::connect(m_systemNetworkInfo,SIGNAL(networkStatusChanged(QNetworkInfo::NetworkMode,
int, QNetworkInfo::NetworkStatus)),this,SLOT(networkStatusChanged(QNetworkInfo::NetworkMode,
int, QNetworkInfo::NetworkStatus)));
+#endif
 }
 
 void Connection::setChangeCallback( int scId, int ecId ) {
@@ -56,6 +67,7 @@ void Connection::setChangeCallback( int scId, int ecId ) {
 /**
  * Callbacks for handling changes in the network type
  */
+#if QT_VERSION < 0x050000
 void Connection::cellDataTechnologyChanged( QSystemNetworkInfo::CellDataTechnology cellTech
) {
     typeChanged();
 }
@@ -65,6 +77,17 @@ void Connection::networkModeChanged( QSystemNetworkInfo::NetworkMode mode
) {
 void Connection::networkStatusChanged( QSystemNetworkInfo::NetworkMode mode, QSystemNetworkInfo::NetworkStatus
status ) {
     typeChanged();
 }
+#else
+void Connection::currentCellDataTechnologyChanged( int interface, QNetworkInfo::CellDataTechnology
cellTech ) {
+    typeChanged();
+}
+void Connection::currentNetworkModeChanged( QNetworkInfo::NetworkMode mode ) {
+    typeChanged();
+}
+void Connection::networkStatusChanged( QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus
status ) {
+    typeChanged();
+}
+#endif // QT_VERSION < 0x050000
 
 /**
  * Function for determining the current network type and updating the javascript end
@@ -75,29 +98,59 @@ void Connection::typeChanged() {
     int changeCallback = m_changeCallback;
     m_changeCallback = -1;
 
+#if QT_VERSION < 0x050000
     QSystemNetworkInfo::NetworkMode networkMode = m_systemNetworkInfo->currentMode();
     QSystemNetworkInfo::NetworkStatus networkStatus = m_systemNetworkInfo->networkStatus(networkMode);
     QSystemNetworkInfo::CellDataTechnology cellDataTechnology = m_systemNetworkInfo->cellDataTechnology();
+#else
+    QNetworkInfo::NetworkMode networkMode = m_systemNetworkInfo->currentNetworkMode();
+    QNetworkInfo::NetworkStatus networkStatus = m_systemNetworkInfo->networkStatus(networkMode,
0);
+    QNetworkInfo::CellDataTechnology cellDataTechnology = m_systemNetworkInfo->currentCellDataTechnology(0);
+#endif
 
     // First of all check the status
+#if QT_VERSION < 0x050000
     if( networkStatus == QSystemNetworkInfo::UndefinedStatus ) {
+#else
+    if( networkStatus == QNetworkInfo::UnknownStatus ) {
+#endif
         this->callback( changeCallback, "Connection.UNKNOWN" );
     }
+#if QT_VERSION < 0x050000
     else if( networkStatus == QSystemNetworkInfo::NoNetworkAvailable ) {
+#else
+    else if( networkStatus == QNetworkInfo::NoNetworkAvailable ) {
+#endif
         this->callback( changeCallback, "Connection.NONE" );
     }
     // Now find the type of connection by networkMode & cellDataTechnology
     else {
+#if QT_VERSION < 0x050000
         if( networkMode == QSystemNetworkInfo::WlanMode ) {
+#else
+        if( networkMode == QNetworkInfo::WlanMode ) {
+#endif
             this->callback( changeCallback, "Connection.WIFI" );
         }
+#if QT_VERSION < 0x050000
         else if( networkMode == QSystemNetworkInfo::EthernetMode ) {
+#else
+        else if( networkMode == QNetworkInfo::EthernetMode ) {
             this->callback( changeCallback, "Connection.ETHERNET" );
+#endif
         }
+#if QT_VERSION < 0x050000
         else if( networkMode == QSystemNetworkInfo::LteMode ) {
+#else
+        else if( networkMode == QNetworkInfo::LteMode ) {
+#endif
             this->callback( changeCallback, "Connection.CELL_4G" );
         }
+#if QT_VERSION < 0x050000
         else if( cellDataTechnology == QSystemNetworkInfo::UmtsDataTechnology ) {
+#else
+        else if( cellDataTechnology == QNetworkInfo::UmtsDataTechnology ) {
+#endif
             this->callback( changeCallback, "Connection.CELL_3G" );
         }
         else {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/src/plugins/connection.h
----------------------------------------------------------------------
diff --git a/src/plugins/connection.h b/src/plugins/connection.h
index 6fc6740..06ef3fe 100644
--- a/src/plugins/connection.h
+++ b/src/plugins/connection.h
@@ -19,9 +19,15 @@
 
 #include "../cplugin.h"
 
+#if QT_VERSION < 0x050000
 #include <QSystemNetworkInfo>
+#else
+#include <QtSystemInfo>
+#endif
 
+#ifdef QTM_NAMESPACE
 QTM_USE_NAMESPACE
+#endif
 
 class Connection : public CPlugin
 {
@@ -36,15 +42,25 @@ signals:
 public slots:
     void setChangeCallback( int scId, int ecId );
 
+#if QT_VERSION < 0x050000
     void cellDataTechnologyChanged( QSystemNetworkInfo::CellDataTechnology cellTech );
     void networkModeChanged( QSystemNetworkInfo::NetworkMode mode );
     void networkStatusChanged( QSystemNetworkInfo::NetworkMode mode, QSystemNetworkInfo::NetworkStatus
status );
+#else
+    void currentCellDataTechnologyChanged( int interface, QNetworkInfo::CellDataTechnology
cellTech );
+    void currentNetworkModeChanged( QNetworkInfo::NetworkMode mode );
+    void networkStatusChanged( QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus
status );
+#endif
 
 private:
     void typeChanged();
 
     int m_changeCallback;
+#if QT_VERSION < 0x050000
     QSystemNetworkInfo *m_systemNetworkInfo;
+#else
+    QNetworkInfo *m_systemNetworkInfo;
+#endif
     bool m_bInitialized;
 
     static Connection *m_connection;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/src/plugins/device.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/device.cpp b/src/plugins/device.cpp
index 83b0afc..4e8f41a 100644
--- a/src/plugins/device.cpp
+++ b/src/plugins/device.cpp
@@ -14,18 +14,25 @@
  *  limitations under the License.
  */
 
-#include "device.h"
+#include"device.h"
 
 #include "../pluginregistry.h"
 
+#if QT_VERSION < 0x050000
 #include <QSystemDeviceInfo>
 #include <QSystemInfo>
+#else
+#include <QDeviceInfo>
+#include <QtSystemInfo>
+#endif
 
 #include <QDebug>
 
-#define PHONEGAP "1.0.0"
+#define PHONEGAP "1.3.0"
 
+#ifdef QTM_NAMESPACE
 QTM_USE_NAMESPACE
+#endif
 
 // Create static instance of ourself
 Device* Device::m_device = new Device();
@@ -43,8 +50,13 @@ Device::Device() : CPlugin() {
 void Device::getInfo( int scId, int ecId ) {
     Q_UNUSED(ecId)
 
+#if QT_VERSION < 0x050000
     QSystemDeviceInfo *systemDeviceInfo = new QSystemDeviceInfo(this);
     QSystemInfo *systemInfo = new QSystemInfo(this);
+#else
+    QDeviceInfo *systemDeviceInfo = new QDeviceInfo(this);
+    QDeviceInfo *systemInfo = new QDeviceInfo(this);
+#endif
 
 #ifdef Q_OS_SYMBIAN
     QString platform = "Symbian";
@@ -59,5 +71,9 @@ void Device::getInfo( int scId, int ecId ) {
     QString platform = "Linux";
 #endif
 
+#if QT_VERSION < 0x050000
     this->callback( scId, "'" + systemDeviceInfo->model() + "', '" + PHONEGAP + "',
'" + platform + "', '" + systemDeviceInfo->uniqueDeviceID() + "', '" + systemInfo->version(
QSystemInfo::Os ) + "'" );
+#else
+    this->callback( scId, "'" + systemDeviceInfo->model() + "', '" + PHONEGAP + "',
'" + platform + "', '" + systemDeviceInfo->uniqueDeviceID() + "', '" + systemInfo->version(
QDeviceInfo::Os ) + "'" );
+#endif
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/src/plugins/geolocation.h
----------------------------------------------------------------------
diff --git a/src/plugins/geolocation.h b/src/plugins/geolocation.h
index a8fe09b..d7772f9 100644
--- a/src/plugins/geolocation.h
+++ b/src/plugins/geolocation.h
@@ -23,7 +23,9 @@
 #include <QGeoPositionInfo>
 #include <QList>
 
+#ifdef QTM_NAMESPACE
 QTM_USE_NAMESPACE
+#endif
 
 class Geolocation : public CPlugin
 {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-qt/blob/433c3d29/src/plugins/notification.cpp
----------------------------------------------------------------------
diff --git a/src/plugins/notification.cpp b/src/plugins/notification.cpp
index 9bd4caa..12581fc 100644
--- a/src/plugins/notification.cpp
+++ b/src/plugins/notification.cpp
@@ -21,7 +21,9 @@
 #include <QApplication>
 #include <QFeedbackHapticsEffect>
 
+#ifdef QTM_NAMESPACE
 QTM_USE_NAMESPACE
+#endif
 
 // Create static instance of ourself
 Notification* Notification::m_notification = new Notification();


Mime
View raw message