mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-07 21:51:25 -07:00
Drop Qt 4 support
This commit is contained in:
parent
60998a68eb
commit
e64bb1de8c
67 changed files with 48 additions and 8809 deletions
|
@ -33,10 +33,6 @@
|
|||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
|
||||
#ifndef QBT_USES_QT5
|
||||
#include <QMetaType>
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
||||
#include <QElapsedTimer>
|
||||
#endif
|
||||
|
@ -54,8 +50,6 @@
|
|||
#include "base/utils/misc.h"
|
||||
#include "jsonutils.h"
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
||||
|
||||
#define CACHED_VARIABLE(VARTYPE, VAR, DUR) \
|
||||
static VARTYPE VAR; \
|
||||
static QElapsedTimer cacheTimer; \
|
||||
|
@ -76,15 +70,6 @@
|
|||
cacheTimer.start(); \
|
||||
VAR = VARTYPE()
|
||||
|
||||
#else
|
||||
// We don't support caching for Qt < 4.7 at the moment
|
||||
#define CACHED_VARIABLE(VARTYPE, VAR, DUR) \
|
||||
VARTYPE VAR
|
||||
|
||||
#define CACHED_VARIABLE_FOR_HASH(VARTYPE, VAR, DUR, HASH) \
|
||||
VARTYPE VAR
|
||||
|
||||
#endif
|
||||
|
||||
// Numerical constants
|
||||
static const int CACHE_DURATION_MS = 1500; // 1500ms
|
||||
|
@ -238,50 +223,18 @@ public:
|
|||
QTorrentCompare(QString key, bool greaterThan = false)
|
||||
: key_(key)
|
||||
, greaterThan_(greaterThan)
|
||||
#ifndef QBT_USES_QT5
|
||||
, type_(QVariant::Invalid)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(QVariant torrent1, QVariant torrent2)
|
||||
{
|
||||
#ifndef QBT_USES_QT5
|
||||
if (type_ == QVariant::Invalid)
|
||||
type_ = torrent1.toMap().value(key_).type();
|
||||
|
||||
switch (static_cast<QMetaType::Type>(type_)) {
|
||||
case QMetaType::Int:
|
||||
return greaterThan_ ? torrent1.toMap().value(key_).toInt() > torrent2.toMap().value(key_).toInt()
|
||||
: torrent1.toMap().value(key_).toInt() < torrent2.toMap().value(key_).toInt();
|
||||
case QMetaType::LongLong:
|
||||
return greaterThan_ ? torrent1.toMap().value(key_).toLongLong() > torrent2.toMap().value(key_).toLongLong()
|
||||
: torrent1.toMap().value(key_).toLongLong() < torrent2.toMap().value(key_).toLongLong();
|
||||
case QMetaType::ULongLong:
|
||||
return greaterThan_ ? torrent1.toMap().value(key_).toULongLong() > torrent2.toMap().value(key_).toULongLong()
|
||||
: torrent1.toMap().value(key_).toULongLong() < torrent2.toMap().value(key_).toULongLong();
|
||||
case QMetaType::Float:
|
||||
return greaterThan_ ? torrent1.toMap().value(key_).toFloat() > torrent2.toMap().value(key_).toFloat()
|
||||
: torrent1.toMap().value(key_).toFloat() < torrent2.toMap().value(key_).toFloat();
|
||||
case QMetaType::Double:
|
||||
return greaterThan_ ? torrent1.toMap().value(key_).toDouble() > torrent2.toMap().value(key_).toDouble()
|
||||
: torrent1.toMap().value(key_).toDouble() < torrent2.toMap().value(key_).toDouble();
|
||||
default:
|
||||
return greaterThan_ ? torrent1.toMap().value(key_).toString() > torrent2.toMap().value(key_).toString()
|
||||
: torrent1.toMap().value(key_).toString() < torrent2.toMap().value(key_).toString();
|
||||
}
|
||||
#else
|
||||
return greaterThan_ ? torrent1.toMap().value(key_) > torrent2.toMap().value(key_)
|
||||
: torrent1.toMap().value(key_) < torrent2.toMap().value(key_);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
QString key_;
|
||||
bool greaterThan_;
|
||||
#ifndef QBT_USES_QT5
|
||||
QVariant::Type type_;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -947,7 +900,7 @@ QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantM
|
|||
lastAcceptedData.clear();
|
||||
syncData = data;
|
||||
|
||||
#if (QBT_USES_QT5 && QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||
// QJsonDocument::fromVariant() supports QVariantHash only
|
||||
// since Qt5.5, so manually convert data["torrents"]
|
||||
QVariantMap torrentsMap;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue