Use simpler DEFINE for detecting Qt5 so moc will work too.

This commit is contained in:
sledgehammer999
2015-12-05 21:49:46 +02:00
parent 18a520c9f9
commit 9b1090332b
28 changed files with 71 additions and 70 deletions

View File

@@ -260,7 +260,7 @@ void AbstractWebApplication::translateDocument(QString& data)
if (isTranslationNeeded) {
size_t context_index = 0;
while ((context_index < context_count) && (translation == word)) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
#ifndef QBT_USES_QT5
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1);
#else
translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1);

View File

@@ -41,7 +41,7 @@
#include <QDebug>
#include <QVariant>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifndef QBT_USES_QT5
#include <QMetaType>
#endif
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
@@ -188,7 +188,7 @@ public:
QTorrentCompare(QString key, bool greaterThan = false)
: key_(key)
, greaterThan_(greaterThan)
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifndef QBT_USES_QT5
, type_(QVariant::Invalid)
#endif
{
@@ -196,7 +196,7 @@ public:
bool operator()(QVariant torrent1, QVariant torrent2)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifndef QBT_USES_QT5
if (type_ == QVariant::Invalid)
type_ = torrent1.toMap().value(key_).type();
@@ -229,7 +229,7 @@ public:
private:
QString key_;
bool greaterThan_;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifndef QBT_USES_QT5
QVariant::Type type_;
#endif
};
@@ -793,7 +793,7 @@ QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantM
lastAcceptedData.clear();
syncData = data;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
#if (QBT_USES_QT5 && QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
// QJsonDocument::fromVariant() supports QVariantHash only
// since Qt5.5, so manually convert data["torrents"]
QVariantMap torrentsMap;

View File

@@ -30,7 +30,7 @@
#define JSONUTILS_H
#include <QVariant>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#ifdef QBT_USES_QT5
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
@@ -49,7 +49,7 @@ namespace json {
inline QByteArray toJson(const QVariant& var)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#ifdef QBT_USES_QT5
return QJsonDocument::fromVariant(var).toJson(QJsonDocument::Compact);
#else
QJson::Serializer serializer;
@@ -60,7 +60,7 @@ namespace json {
inline QVariant fromJson(const QString& json)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#ifdef QBT_USES_QT5
return QJsonDocument::fromJson(json.toUtf8()).toVariant();
#else
return QJson::Parser().parse(json.toUtf8());