From 648a6a388495a8ecaf427976b5fa5f1c57bcca3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:53:45 +0200 Subject: [PATCH 1/5] Qt5: QUrl addQueryItem moved to QUrlQuery --- cockatrice/src/deckstats_interface.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cockatrice/src/deckstats_interface.cpp b/cockatrice/src/deckstats_interface.cpp index eae4caae8..d5cb4ba08 100644 --- a/cockatrice/src/deckstats_interface.cpp +++ b/cockatrice/src/deckstats_interface.cpp @@ -7,6 +7,10 @@ #include #include +#if QT_VERSION >= 0x050000 +#include +#endif + DeckStatsInterface::DeckStatsInterface(QObject *parent) : QObject(parent) { @@ -42,7 +46,13 @@ void DeckStatsInterface::queryFinished(QNetworkReply *reply) void DeckStatsInterface::analyzeDeck(DeckList *deck) { QUrl params; +#if QT_VERSION < 0x050000 params.addQueryItem("deck", deck->writeToString_Plain()); +#else + QUrlQuery urlQuery; + urlQuery.addQueryItem("deck", deck->writeToString_Plain()); + params.setUrlQuery(urlQuery); +#endif QByteArray data; data.append(params.encodedQuery()); From a903c231f266a87fa6ef5b49600a9e6dc8df62b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:54:46 +0200 Subject: [PATCH 2/5] Qt5: QDesktopServices::storageLocation deprecated --- cockatrice/src/main.cpp | 4 ++++ oracle/src/window_main.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index ef57655a0..2de76f9e3 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -120,7 +120,11 @@ int main(int argc, char *argv[]) qsrand(QDateTime::currentDateTime().toTime_t()); bool startMainProgram = true; +#if QT_VERSION < 0x050000 const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#else + const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(); +#endif if (!db->getLoadSuccess()) if (db->loadCardDatabase(dataDir + "/cards.xml")) settingsCache->setCardDatabasePath(dataDir + "/cards.xml"); diff --git a/oracle/src/window_main.cpp b/oracle/src/window_main.cpp index 0283bdedb..6d4a1be9f 100644 --- a/oracle/src/window_main.cpp +++ b/oracle/src/window_main.cpp @@ -24,7 +24,11 @@ const QString WindowMain::defaultSetsUrl = QString("http://www.woogerworks.com/f WindowMain::WindowMain(QWidget *parent) : QMainWindow(parent) { +#if QT_VERSION < 0x050000 importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this); +#else + importer = new OracleImporter(QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(), this); +#endif nam = new QNetworkAccessManager(this); checkBoxLayout = new QVBoxLayout; @@ -176,7 +180,11 @@ void WindowMain::updateTotalProgress(int cardsImported, int setIndex, const QStr if (nextSetName.isEmpty()) { QMessageBox::information(this, tr("Oracle importer"), tr("Import finished: %1 cards.").arg(importer->getCardList().size())); bool ok = false; +#if QT_VERSION < 0x050000 const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#else + const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(); +#endif QDir dir(dataDir); if (!dir.exists()) dir.mkpath(dataDir); From 6fa94dd475a951b393052179ca096ba285e943e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:55:26 +0200 Subject: [PATCH 3/5] Qt5: toAscii() and fromAscii() Methods are deprecated --- cockatrice/src/qt-json/json.cpp | 2 +- servatrice/src/passwordhasher.cpp | 2 +- servatrice/src/servatrice.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/qt-json/json.cpp b/cockatrice/src/qt-json/json.cpp index 1cda44536..faf6601b3 100644 --- a/cockatrice/src/qt-json/json.cpp +++ b/cockatrice/src/qt-json/json.cpp @@ -553,7 +553,7 @@ int Json::nextToken(const QString &json, int &index) QChar c = json[index]; index++; - switch(c.toAscii()) + switch(c.toLatin1()) { case '{': return JsonTokenCurlyOpen; case '}': return JsonTokenCurlyClose; diff --git a/servatrice/src/passwordhasher.cpp b/servatrice/src/passwordhasher.cpp index 1cc8528c9..073cd9b91 100644 --- a/servatrice/src/passwordhasher.cpp +++ b/servatrice/src/passwordhasher.cpp @@ -16,7 +16,7 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt const int algo = GCRY_MD_SHA512; const int rounds = 1000; - QByteArray passwordBuffer = (salt + password).toAscii(); + QByteArray passwordBuffer = (salt + password).toLatin1(); int hashLen = gcry_md_get_algo_dlen(algo); char hash[hashLen], tmp[hashLen]; gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size()); diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index ee5133390..c4a312059 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -319,7 +319,7 @@ void Servatrice::updateServerList() query.prepare("select id, ssl_cert, hostname, address, game_port, control_port from " + dbPrefix + "_servers order by id asc"); servatriceDatabaseInterface->execSqlQuery(query); while (query.next()) { - ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toAscii()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); + ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toLatin1()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); serverList.append(prop); qDebug() << QString("#%1 CERT=%2 NAME=%3 IP=%4:%5 CPORT=%6").arg(prop.id).arg(QString(prop.cert.digest().toHex())).arg(prop.hostname).arg(prop.address.toString()).arg(prop.gamePort).arg(prop.controlPort); } From 0721f5b41656757e56a0a4a343412c942f63306f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 16:56:15 +0200 Subject: [PATCH 4/5] Qt5: QtWidgets as a Separate Module --- oracle/src/oracleimporter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index c244e56a0..f4463455f 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -1,5 +1,10 @@ #include "oracleimporter.h" +#if QT_VERSION < 0x050000 #include +#else +#include +#endif + #include #include #include From 05f46011eb35efff2c90ee4d7fa57c53f4ca2d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Morschh=C3=A4user?= Date: Fri, 20 Jun 2014 18:16:46 +0200 Subject: [PATCH 5/5] Fix toLatin1() changes from 6fa94dd to toUtf8(). --- servatrice/src/passwordhasher.cpp | 2 +- servatrice/src/servatrice.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/servatrice/src/passwordhasher.cpp b/servatrice/src/passwordhasher.cpp index 073cd9b91..785034b43 100644 --- a/servatrice/src/passwordhasher.cpp +++ b/servatrice/src/passwordhasher.cpp @@ -16,7 +16,7 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt const int algo = GCRY_MD_SHA512; const int rounds = 1000; - QByteArray passwordBuffer = (salt + password).toLatin1(); + QByteArray passwordBuffer = (salt + password).toUtf8(); int hashLen = gcry_md_get_algo_dlen(algo); char hash[hashLen], tmp[hashLen]; gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size()); diff --git a/servatrice/src/servatrice.cpp b/servatrice/src/servatrice.cpp index c4a312059..6e0dbeb1e 100644 --- a/servatrice/src/servatrice.cpp +++ b/servatrice/src/servatrice.cpp @@ -319,7 +319,7 @@ void Servatrice::updateServerList() query.prepare("select id, ssl_cert, hostname, address, game_port, control_port from " + dbPrefix + "_servers order by id asc"); servatriceDatabaseInterface->execSqlQuery(query); while (query.next()) { - ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toLatin1()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); + ServerProperties prop(query.value(0).toInt(), QSslCertificate(query.value(1).toString().toUtf8()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt()); serverList.append(prop); qDebug() << QString("#%1 CERT=%2 NAME=%3 IP=%4:%5 CPORT=%6").arg(prop.id).arg(QString(prop.cert.digest().toHex())).arg(prop.hostname).arg(prop.address.toString()).arg(prop.gamePort).arg(prop.controlPort); }