Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merge qt5

  • Loading branch information...
commit 03a5425f4f371c84c624449aee4251bb4cf88170 2 parents 3d157e5 + d2a0804
@eartle eartle authored
View
26 CMakeLists.txt
@@ -25,8 +25,30 @@ include(GNUInstallDirs)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake/Modules")
# setup qt stuff
-find_package(Qt4 COMPONENTS QtCore QtNetwork QtXml REQUIRED)
-set(CMAKE_AUTOMOC TRUE)
+set(CMAKE_AUTOMOC ON)
+find_package(Qt5Core QUIET)
+if(Qt5Core_DIR)
+ message(STATUS "Found Qt5! Please keep in mind, this is highly experimental and not our main development target..")
+
+# macro(qt_wrap_ui)
+# qt5_wrap_ui(${ARGN})
+# endmacro()
+#
+# macro(qt_add_resources)
+# qt5_add_resources(${ARGN})
+# endmacro()
+#
+# find_package(Qt5LinguistTools REQUIRED)
+# macro(qt_add_translation)
+# qt5_add_translation(${ARGN})
+# endmacro()
+else()
+ find_package(Qt4 COMPONENTS QtCore QtNetwork QtXml REQUIRED)
+
+ macro(qt5_use_modules)
+ endmacro()
+endif()
+
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions("-fno-operator-names -fvisibility-inlines-hidden -fvisibility=hidden")
View
10 src/CMakeLists.txt
@@ -9,6 +9,11 @@ set(liblastfm_LIBRARIES
${QT_QTXML_LIBRARY}
)
+list(APPEND liblastfm_QT5_MODULES
+ Xml
+ Network
+)
+
set(liblastfm_SOURCES
ws.cpp
NetworkConnectionMonitor.cpp
@@ -78,12 +83,13 @@ if(UNIX AND NOT APPLE)
list(APPEND liblastfm_SOURCES
linux/LNetworkConnectionMonitor_linux.cpp
)
-
- find_package(Qt4 COMPONENTS QtDbus REQUIRED)
list(APPEND liblastfm_LIBRARIES ${QT_QTDBUS_LIBRARY})
+ list(APPEND liblastfm_QT5_MODULES DBus)
endif()
add_library(lastfm SHARED ${liblastfm_SOURCES})
+qt5_use_modules(lastfm ${liblastfm_QT5_MODULES})
+
target_link_libraries(lastfm ${liblastfm_LIBRARIES})
set_target_properties(lastfm PROPERTIES
VERSION ${LASTFM_VERSION_STRING}
View
10 src/UrlBuilder.cpp
@@ -1,5 +1,5 @@
/*
- Copyright 2009 Last.fm Ltd.
+ Copyright 2009 Last.fm Ltd.
- Primarily authored by Max Howell, Jono Cole and Doug Mansell
This file is part of liblastfm.
@@ -32,7 +32,7 @@ class lastfm::UrlBuilderPrivate
lastfm::UrlBuilder::UrlBuilder( const QString& base )
: d( new UrlBuilderPrivate )
{
- d->path = '/' + base.toAscii();
+ d->path = '/' + base.toLatin1();
}
@@ -62,7 +62,11 @@ lastfm::UrlBuilder::url() const
QUrl url;
url.setScheme( "http" );
url.setHost( host() );
+#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
+ url.setPath( d->path );
+#else
url.setEncodedPath( d->path );
+#endif
return url;
}
@@ -86,7 +90,7 @@ lastfm::UrlBuilder::host( const QLocale& locale )
switch (locale.language())
{
case QLocale::Portuguese: return "www.lastfm.com.br";
- case QLocale::Turkish: return "www.lastfm.com.tr";
+ case QLocale::Turkish: return "www.lastfm.com.tr";
case QLocale::French: return "www.lastfm.fr";
case QLocale::Italian: return "www.lastfm.it";
case QLocale::German: return "www.lastfm.de";
View
23 src/ws.cpp
@@ -1,5 +1,5 @@
/*
- Copyright 2009 Last.fm Ltd.
+ Copyright 2009 Last.fm Ltd.
- Primarily authored by Max Howell, Jono Cole and Doug Mansell
This file is part of liblastfm.
@@ -30,6 +30,10 @@
#include <QThread>
#include <QMutex>
+#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
+ #include <QUrlQuery>
+#endif
+
static QMap< QThread*, QNetworkAccessManager* > threadNamHash;
static QSet< QThread* > ourNamSet;
@@ -79,7 +83,7 @@ lastfm::ws::ParseError::operator=( const ParseError& that )
return *this;
}
-QString
+QString
lastfm::ws::host()
{
QStringList const args = QCoreApplication::arguments();
@@ -98,13 +102,14 @@ static QUrl baseUrl()
QUrl url;
url.setScheme( "http" );
url.setHost( lastfm::ws::host() );
- url.setEncodedPath( "/2.0/" );
+ url.setPath( "/2.0/" );
+
return url;
}
static QString iso639()
-{
- return QLocale().name().left( 2 ).toLower();
+{
+ return QLocale().name().left( 2 ).toLower();
}
void autograph( QMap<QString, QString>& params )
@@ -144,7 +149,11 @@ lastfm::ws::url( QMap<QString, QString> params, bool sk )
i.next();
QByteArray const key = QUrl::toPercentEncoding( i.key() );
QByteArray const value = QUrl::toPercentEncoding( i.value() );
+#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
+ QUrlQuery(url).addQueryItem( key, value );
+#else
url.addEncodedQueryItem( key, value );
+#endif
}
return url;
@@ -160,7 +169,7 @@ lastfm::ws::get( QMap<QString, QString> params )
QNetworkReply*
lastfm::ws::post( QMap<QString, QString> params, bool sk )
-{
+{
sign( params, sk );
QByteArray query;
QMapIterator<QString, QString> i( params );
@@ -275,7 +284,7 @@ namespace lastfm
const char* ApiKey;
/** if this is found set to "" we conjure ourselves a suitable one */
- const char* UserAgent = 0;
+ const char* UserAgent = 0;
}
}
View
16 tests/TestUrlBuilder.h
@@ -1,6 +1,6 @@
/*
- This software is in the public domain, furnished "as is", without technical
- support, and with no warranty, express or implied, as to its usefulness for
+ This software is in the public domain, furnished "as is", without technical
+ support, and with no warranty, express or implied, as to its usefulness for
any purpose.
*/
@@ -19,7 +19,7 @@ static inline int getResponseCode( const QUrl& url )
{
QNetworkAccessManager nam;
QNetworkReply* reply = nam.head( QNetworkRequest(url) );
-
+
QEventLoop loop;
loop.connect( reply, SIGNAL(finished()), SLOT(quit()) );
loop.exec();
@@ -41,10 +41,10 @@ private slots:
void encode() /** @author <jono@last.fm> */
{
QFETCH( QString, input );
- QFETCH( QString, output );
- QCOMPARE( lastfm::UrlBuilder::encode( input ), output.toAscii() );
+ QFETCH( QString, output );
+ QCOMPARE( lastfm::UrlBuilder::encode( input ), output.toLatin1() );
}
-
+
void encode_data() /** @author <jono@last.fm> */
{
QTest::addColumn<QString>("input");
@@ -55,7 +55,7 @@ private slots:
QTest::newRow( "ascii with symbols" ) << "some track [original version]" << "some+track+%5Boriginal+version%5D";
QTest::newRow( "ascii with last.fm-special symbols" ) << "Survivalism [Revision #1]" << "Survivalism%2B%255BRevision%2B%25231%255D";
}
-
+
void no404() /** @author <max@last.fm> */
{
QFETCH( QString, artist );
@@ -65,7 +65,7 @@ private slots:
QCOMPARE( getResponseCode( url ), 200 );
}
-
+
void no404_data() /** @author <max@last.fm> */
{
QTest::addColumn<QString>("artist");
View
2  tests/lastfm_add_test.cmake
@@ -6,6 +6,8 @@ macro(lastfm_add_test test_class)
configure_file(Test${LASTFM_TEST_CLASS}.h Test${LASTFM_TEST_CLASS}.h)
add_executable(${LASTFM_TEST_CLASS}Test Test${LASTFM_TEST_CLASS}.cpp)
+ qt5_use_modules(${LASTFM_TEST_CLASS}Test Core Test Xml Network)
+
target_link_libraries(${LASTFM_TEST_CLASS}Test
lastfm
${QT_QTTEST_LIBRARY}
Please sign in to comment.
Something went wrong with that request. Please try again.