This commit is contained in:
VanNostrand 2014-06-20 16:19:34 +00:00
commit 34b3ab0be7
7 changed files with 30 additions and 3 deletions

View file

@ -7,6 +7,10 @@
#include <QMessageBox> #include <QMessageBox>
#include <QDesktopServices> #include <QDesktopServices>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
#endif
DeckStatsInterface::DeckStatsInterface(QObject *parent) DeckStatsInterface::DeckStatsInterface(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
@ -42,7 +46,13 @@ void DeckStatsInterface::queryFinished(QNetworkReply *reply)
void DeckStatsInterface::analyzeDeck(DeckList *deck) void DeckStatsInterface::analyzeDeck(DeckList *deck)
{ {
QUrl params; QUrl params;
#if QT_VERSION < 0x050000
params.addQueryItem("deck", deck->writeToString_Plain()); params.addQueryItem("deck", deck->writeToString_Plain());
#else
QUrlQuery urlQuery;
urlQuery.addQueryItem("deck", deck->writeToString_Plain());
params.setUrlQuery(urlQuery);
#endif
QByteArray data; QByteArray data;
data.append(params.encodedQuery()); data.append(params.encodedQuery());

View file

@ -120,7 +120,11 @@ int main(int argc, char *argv[])
qsrand(QDateTime::currentDateTime().toTime_t()); qsrand(QDateTime::currentDateTime().toTime_t());
bool startMainProgram = true; bool startMainProgram = true;
#if QT_VERSION < 0x050000
const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#else
const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString();
#endif
if (!db->getLoadSuccess()) if (!db->getLoadSuccess())
if (db->loadCardDatabase(dataDir + "/cards.xml")) if (db->loadCardDatabase(dataDir + "/cards.xml"))
settingsCache->setCardDatabasePath(dataDir + "/cards.xml"); settingsCache->setCardDatabasePath(dataDir + "/cards.xml");

View file

@ -553,7 +553,7 @@ int Json::nextToken(const QString &json, int &index)
QChar c = json[index]; QChar c = json[index];
index++; index++;
switch(c.toAscii()) switch(c.toLatin1())
{ {
case '{': return JsonTokenCurlyOpen; case '{': return JsonTokenCurlyOpen;
case '}': return JsonTokenCurlyClose; case '}': return JsonTokenCurlyClose;

View file

@ -1,5 +1,10 @@
#include "oracleimporter.h" #include "oracleimporter.h"
#if QT_VERSION < 0x050000
#include <QtGui> #include <QtGui>
#else
#include <QtWidgets>
#endif
#include <QtNetwork> #include <QtNetwork>
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QDomDocument> #include <QDomDocument>

View file

@ -24,7 +24,11 @@ const QString WindowMain::defaultSetsUrl = QString("http://www.woogerworks.com/f
WindowMain::WindowMain(QWidget *parent) WindowMain::WindowMain(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
#if QT_VERSION < 0x050000
importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this); importer = new OracleImporter(QDesktopServices::storageLocation(QDesktopServices::DataLocation), this);
#else
importer = new OracleImporter(QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString(), this);
#endif
nam = new QNetworkAccessManager(this); nam = new QNetworkAccessManager(this);
checkBoxLayout = new QVBoxLayout; checkBoxLayout = new QVBoxLayout;
@ -176,7 +180,11 @@ void WindowMain::updateTotalProgress(int cardsImported, int setIndex, const QStr
if (nextSetName.isEmpty()) { if (nextSetName.isEmpty()) {
QMessageBox::information(this, tr("Oracle importer"), tr("Import finished: %1 cards.").arg(importer->getCardList().size())); QMessageBox::information(this, tr("Oracle importer"), tr("Import finished: %1 cards.").arg(importer->getCardList().size()));
bool ok = false; bool ok = false;
#if QT_VERSION < 0x050000
const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); const QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
#else
const QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString();
#endif
QDir dir(dataDir); QDir dir(dataDir);
if (!dir.exists()) if (!dir.exists())
dir.mkpath(dataDir); dir.mkpath(dataDir);

View file

@ -16,7 +16,7 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt
const int algo = GCRY_MD_SHA512; const int algo = GCRY_MD_SHA512;
const int rounds = 1000; const int rounds = 1000;
QByteArray passwordBuffer = (salt + password).toAscii(); QByteArray passwordBuffer = (salt + password).toUtf8();
int hashLen = gcry_md_get_algo_dlen(algo); int hashLen = gcry_md_get_algo_dlen(algo);
char hash[hashLen], tmp[hashLen]; char hash[hashLen], tmp[hashLen];
gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size()); gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size());

View file

@ -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"); query.prepare("select id, ssl_cert, hostname, address, game_port, control_port from " + dbPrefix + "_servers order by id asc");
servatriceDatabaseInterface->execSqlQuery(query); servatriceDatabaseInterface->execSqlQuery(query);
while (query.next()) { 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().toUtf8()), query.value(2).toString(), QHostAddress(query.value(3).toString()), query.value(4).toInt(), query.value(5).toInt());
serverList.append(prop); 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); 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);
} }