diff --git a/src/DiaryWindow.cpp b/src/DiaryWindow.cpp index ced913e85..849b68c9b 100644 --- a/src/DiaryWindow.cpp +++ b/src/DiaryWindow.cpp @@ -65,8 +65,13 @@ DiaryWindow::DiaryWindow(Context *context) : monthlyView = new QTableView(this); monthlyView->setItemDelegate(new GcCalendarDelegate); monthlyView->setModel(calendarModel); +#if QT_VERSION > 0x050000 monthlyView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); monthlyView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); +#else + monthlyView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + monthlyView->verticalHeader()->setResizeMode(QHeaderView::Stretch); +#endif monthlyView->verticalHeader()->hide(); monthlyView->viewport()->installEventFilter(this); monthlyView->setGridStyle(Qt::DotLine); diff --git a/src/LTMSettings.cpp b/src/LTMSettings.cpp index fe47c6fbc..986819613 100644 --- a/src/LTMSettings.cpp +++ b/src/LTMSettings.cpp @@ -129,7 +129,7 @@ LTMSettings::readChartXML(QDir home, QList &charts) QDataStream &operator<<(QDataStream &out, const LTMSettings &settings) { // 4.6 - 4.9 all the same - out.setVersion(QDataStream::Qt_4_9); + out.setVersion(QDataStream::Qt_4_6); // all the baisc fields first out<>(QDataStream &in, LTMSettings &settings) { // 4.6 - 4.9 all the same - in.setVersion(QDataStream::Qt_4_9); + in.setVersion(QDataStream::Qt_4_6); RideMetricFactory &factory = RideMetricFactory::instance(); int counter=0; diff --git a/src/OAuthDialog.cpp b/src/OAuthDialog.cpp index 4b831624b..63e0b3869 100644 --- a/src/OAuthDialog.cpp +++ b/src/OAuthDialog.cpp @@ -79,7 +79,11 @@ OAuthDialog::urlChanged(const QUrl &url) QString code = url.toString().right(url.toString().length()-url.toString().indexOf("code=")-5); QByteArray data; +#if QT_VERSION > 0x050000 QUrlQuery params; +#else + QUrl params; +#endif QString urlstr = ""; if (site == STRAVA) { @@ -104,7 +108,11 @@ OAuthDialog::urlChanged(const QUrl &url) } params.addQueryItem("code", code); +#if QT_VERSION > 0x050000 data.append(params.query(QUrl::FullyEncoded)); +#else + data=params.encodedQuery(); +#endif QUrl url = QUrl(urlstr); QNetworkRequest request = QNetworkRequest(url); diff --git a/src/OAuthDialog.h b/src/OAuthDialog.h index a4153ba1c..e1b6d7438 100644 --- a/src/OAuthDialog.h +++ b/src/OAuthDialog.h @@ -24,11 +24,16 @@ #include #include #include +#include #include #include #include -#include + +// QUrl split into QUrlQuerty in QT5 +#if QT_VERSION > 0x050000 #include +#endif + class OAuthDialog : public QDialog { diff --git a/src/TtbDialog.cpp b/src/TtbDialog.cpp index 0df1baf44..9f8033b7e 100644 --- a/src/TtbDialog.cpp +++ b/src/TtbDialog.cpp @@ -141,15 +141,22 @@ TtbDialog::requestSettings() QString username = appsettings->cvalue(context->athlete->cyclist, GC_TTBUSER).toString(); QString password = appsettings->cvalue(context->athlete->cyclist, GC_TTBPASS).toString(); +#if QT_VERSION > 0x050000 QUrlQuery urlquery( TTB_URL + "/settings/list" ); +#else + QUrl urlquery( TTB_URL + "/settings/list" ); +#endif urlquery.addQueryItem( "view", "xml" ); urlquery.addQueryItem( "user", username ); urlquery.addQueryItem( "pass", password ); +#if QT_VERSION > 0x050000 QUrl url; url.setQuery(urlquery); - QNetworkRequest request = QNetworkRequest(url); +#else + QNetworkRequest request = QNetworkRequest(urlquery); +#endif request.setRawHeader( "Accept-Encoding", "identity" ); request.setRawHeader( "Accept", "application/xml" ); request.setRawHeader( "Accept-Charset", "utf-8" ); @@ -168,15 +175,23 @@ TtbDialog::requestSession() QString username = appsettings->cvalue(context->athlete->cyclist, GC_TTBUSER).toString(); QString password = appsettings->cvalue(context->athlete->cyclist, GC_TTBPASS).toString(); +#if QT_VERSION > 0x050000 QUrlQuery urlquery( TTB_URL + "/login/sso" ); +#else + QUrl urlquery( TTB_URL + "/login/sso" ); +#endif urlquery.addQueryItem( "view", "xml" ); urlquery.addQueryItem( "user", username ); urlquery.addQueryItem( "pass", password ); +#if QT_VERSION > 0x050000 QUrl url; url.setQuery(urlquery); - QNetworkRequest request = QNetworkRequest(url); +#else + QNetworkRequest request = QNetworkRequest(urlquery); +#endif + request.setRawHeader( "Accept-Encoding", "identity" ); request.setRawHeader( "Accept", "application/xml" ); request.setRawHeader( "Accept-Charset", "utf-8" ); @@ -234,14 +249,22 @@ TtbDialog::requestUpload() currentRequest = reqUpload; +#if QT_VERSION > 0x050000 QUrlQuery urlquery( TTB_URL + "/file/upload" ); +#else + QUrl urlquery( TTB_URL + "/file/upload" ); +#endif urlquery.addQueryItem( "view", "xml" ); urlquery.addQueryItem( "sso", sessionId ); +#if QT_VERSION > 0x050000 QUrl url; url.setQuery(urlquery); - QNetworkRequest request = QNetworkRequest(url); +#else + QNetworkRequest request = QNetworkRequest(urlquery); +#endif + request.setRawHeader( "Accept-Encoding", "identity" ); request.setRawHeader( "Accept", "application/xml" ); request.setRawHeader( "Accept-Charset", "utf-8" ); diff --git a/src/TtbDialog.h b/src/TtbDialog.h index a58a92229..c0a3eb671 100644 --- a/src/TtbDialog.h +++ b/src/TtbDialog.h @@ -26,13 +26,17 @@ #include #include #include -#include #include #include #include #include #include +// QUrl split into QUrlQuerty in QT5 +#if QT_VERSION > 0x050000 +#include +#endif + #include "Context.h" #include "RideItem.h" diff --git a/src/VideoWindow.cpp b/src/VideoWindow.cpp index 984aeb992..3aa927897 100644 --- a/src/VideoWindow.cpp +++ b/src/VideoWindow.cpp @@ -63,10 +63,15 @@ VideoWindow::VideoWindow(Context *context, const QDir &home) : /* This is a non working code that show how to hooks into a window, * if we have a window around */ #ifdef Q_OS_LINUX +#if QT_VERSION > 0x050000 x11Container = new QWidget(this); //XXX PORT TO 5.1 BROKEN CODE XXX +#else + x11Container = new QX11EmbedContainer(this); +#endif layout->addWidget(x11Container); libvlc_media_player_set_xwindow (mp, x11Container->winId()); #endif + #ifdef WIN32 container = new QWidget(this); layout->addWidget(container); @@ -84,9 +89,9 @@ VideoWindow::VideoWindow(Context *context, const QDir &home) : VideoWindow::~VideoWindow() { -#ifdef Q_OS_LINUX +#ifdef Q_OS_LINUX && QT_VERSION < 0x050000 //XXX IN PORT TO QT 5.1 THIS IS BROKEN CODE XXX // unembed vlc backend first - //x11Container->discardClient(); //XXX PORT TO QT 5.1 BROKEN CODE XXX + x11Container->discardClient(); #endif stopPlayback(); diff --git a/src/VideoWindow.h b/src/VideoWindow.h index a281223e4..8a9189bc6 100644 --- a/src/VideoWindow.h +++ b/src/VideoWindow.h @@ -39,6 +39,10 @@ extern "C" { #include "RealtimeData.h" #include "TrainSidebar.h" +#ifdef Q_OS_LINUX && QT_VERSION < 0x050000 +#include +#endif + class MediaHelper { public: @@ -92,8 +96,13 @@ class VideoWindow : public GcWindow libvlc_media_t *m; #ifdef Q_OS_LINUX +#if QT_VERSION > 0x050000 QWidget *x11Container; +#else + QX11EmbedContainer *x11Container; #endif +#endif + #ifdef WIN32 QWidget *container; #endif diff --git a/src/WorkoutWizard.cpp b/src/WorkoutWizard.cpp index 53bf1f9f3..717aea143 100644 --- a/src/WorkoutWizard.cpp +++ b/src/WorkoutWizard.cpp @@ -70,7 +70,11 @@ WorkoutEditorBase::WorkoutEditorBase(QStringList &colms, QWidget *parent) :QFram table->setColumnCount(colms.count()); table->setHorizontalHeaderLabels(colms); +#if QT_VERSION > 0x050000 table->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); +#else + table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); +#endif table->setShowGrid(true); table->setAlternatingRowColors(true); table->resizeColumnsToContents(); diff --git a/src/main.cpp b/src/main.cpp index a66dc04d3..2a272bf59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "ChooseCyclistDialog.h" #include "MainWindow.h" #include "Settings.h" @@ -50,6 +49,10 @@ void nostderr(QString dir) #include #endif +#if QT_VERSION > 0x050000 +#include +#endif + QApplication *application; bool restarting = false; @@ -161,13 +164,16 @@ main(int argc, char *argv[]) #if defined(Q_OS_MACX) QString libraryPath="Library/GoldenCheetah"; #elif defined(Q_OS_WIN) - //4.8 etc QString libraryPath=QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/GoldenCheetah"; +#if QT_VERSION > 0x050000 // windows and qt5 QStringList paths=QStandardPaths::standardLocations(QStandardPaths::DataLocation); - QString libraryPath = paths.at(0) + "/GoldenCheetah"; -#else + QString libraryPath = paths.at(0) + "/GoldenCheetah"; +#else // windows not qt5 + QString libraryPath=QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/GoldenCheetah"; +#endif // qt5 +#else // not windows or osx (must be Linux or OpenBSD) // Q_OS_LINUX et al QString libraryPath=".goldencheetah"; -#endif +#endif // // or did we override in settings? QString sh; diff --git a/src/src.pro b/src/src.pro index 7b26555a4..1ffb9127e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -2,21 +2,40 @@ include( gcconfig.pri ) +# +# What we are making and core dependencies +# TEMPLATE = app TARGET = GoldenCheetah - !isEmpty( APP_NAME ) { TARGET = $${APP_NAME} } DEPENDPATH += . +## qwt and libz INCLUDEPATH += ../qwt/src ../qxt/src $${LIBZ_INCLUDE} -QT += core xml sql network webkitwidgets script svg widgets -macx { - QT += macextras -} - LIBS += ../qwt/lib/libqwt.a LIBS += -lm $${LIBZ_LIBS} +# +# We support 4.8.4 or higher +# 5.2.0 or higher +# +## common modules +QT += xml sql network script svg + +lessThan(QT_MAJOR_VERSION, 5) { + + ## QT4 specific modules + QT += webkit + +} else { + + ## QT5 specific modules + QT += webkitwidgets widgets + macx { + QT += macextras + } +} + # if we are building in debug mode # then set MACRO -DGC_DEBUG so we can # add / turnoff code for debugging purposes @@ -24,10 +43,6 @@ CONFIG(debug, debug|release) { QMAKE_CXXFLAGS += -DGC_DEBUG } -!isEmpty( ZLIB_INCLUDE ) { - INCLUDEPATH += $${ZLIB_INCLUDE} -} - !isEmpty( LIBOAUTH_INSTALL ) { isEmpty( LIBOAUTH_INCLUDE ) { LIBOAUTH_INCLUDE += $${LIBOAUTH_INSTALL}/include } isEmpty( LIBOAUTH_LIBS ) {