mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 12:48:04 -06:00
Drop Qt 4 support
This commit is contained in:
@@ -121,15 +121,10 @@ tristatebool.cpp
|
||||
add_library(qbt_base STATIC ${QBT_BASE_HEADERS} ${QBT_BASE_SOURCES})
|
||||
target_link_libraries(qbt_base PRIVATE ZLIB::ZLIB PUBLIC LibtorrentRasterbar::LibTorrent)
|
||||
target_link_qt_components(qbt_base PUBLIC Core Network Xml)
|
||||
if (QT4_FOUND)
|
||||
if (GUI)
|
||||
target_link_libraries(qbt_base PUBLIC Qt4::QtGui)
|
||||
endif (GUI)
|
||||
else (QT4_FOUND)
|
||||
if (GUI)
|
||||
target_link_libraries(qbt_base PUBLIC Qt5::Gui Qt5::Widgets)
|
||||
endif (GUI)
|
||||
endif (QT4_FOUND)
|
||||
|
||||
if (GUI)
|
||||
target_link_libraries(qbt_base PUBLIC Qt5::Gui Qt5::Widgets)
|
||||
endif (GUI)
|
||||
|
||||
if (DBUS)
|
||||
target_link_qt_components(qbt_base PRIVATE DBus)
|
||||
|
||||
@@ -27,11 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#ifdef QBT_USES_QT5
|
||||
#include <QSaveFile>
|
||||
#else
|
||||
#include <QFile>
|
||||
#endif
|
||||
|
||||
#include "base/logger.h"
|
||||
#include "base/utils/fs.h"
|
||||
@@ -48,18 +44,12 @@ void ResumeDataSavingManager::saveResumeData(QString infoHash, QByteArray data)
|
||||
QString filepath = m_resumeDataDir.absoluteFilePath(filename);
|
||||
|
||||
qDebug() << "Saving resume data in" << filepath;
|
||||
#ifdef QBT_USES_QT5
|
||||
QSaveFile resumeFile(filepath);
|
||||
#else
|
||||
QFile resumeFile(filepath);
|
||||
#endif
|
||||
if (resumeFile.open(QIODevice::WriteOnly)) {
|
||||
resumeFile.write(data);
|
||||
#ifdef QBT_USES_QT5
|
||||
if (!resumeFile.commit()) {
|
||||
Logger::instance()->addMessage(QString("Couldn't save resume data in %1. Error: %2")
|
||||
.arg(filepath).arg(resumeFile.errorString()), Log::WARNING);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
#ifdef QBT_USES_QT5
|
||||
#include <QUrlQuery>
|
||||
#endif
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include "requestparser.h"
|
||||
@@ -121,11 +119,7 @@ bool RequestParser::parseStartingLine(const QString &line)
|
||||
m_request.path = url.path(); // Path
|
||||
|
||||
// Parse GET parameters
|
||||
#ifndef QBT_USES_QT5
|
||||
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
||||
#else
|
||||
QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems());
|
||||
#endif
|
||||
while (i.hasNext()) {
|
||||
QPair<QString, QString> pair = i.next();
|
||||
m_request.gets[pair.first] = pair.second;
|
||||
@@ -220,13 +214,8 @@ bool RequestParser::parseContent(const QByteArray& data)
|
||||
// Parse url-encoded POST data
|
||||
if (m_request.headers["content-type"].startsWith("application/x-www-form-urlencoded")) {
|
||||
QUrl url;
|
||||
#ifndef QBT_USES_QT5
|
||||
url.setEncodedQuery(data);
|
||||
QListIterator<QPair<QString, QString> > i(url.queryItems());
|
||||
#else
|
||||
url.setQuery(data);
|
||||
QListIterator<QPair<QString, QString> > i(QUrlQuery(url).queryItems(QUrl::FullyDecoded));
|
||||
#endif
|
||||
while (i.hasNext()) {
|
||||
QPair<QString, QString> pair = i.next();
|
||||
m_request.posts[pair.first.toLower()] = pair.second;
|
||||
|
||||
@@ -76,11 +76,7 @@ void Server::disableHttps()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef QBT_USES_QT5
|
||||
void Server::incomingConnection(qintptr socketDescriptor)
|
||||
#else
|
||||
void Server::incomingConnection(int socketDescriptor)
|
||||
#endif
|
||||
{
|
||||
QTcpSocket *serverSocket;
|
||||
#ifndef QT_NO_OPENSSL
|
||||
@@ -95,11 +91,7 @@ void Server::incomingConnection(int socketDescriptor)
|
||||
if (m_https) {
|
||||
static_cast<QSslSocket *>(serverSocket)->setProtocol(QSsl::SecureProtocols);
|
||||
static_cast<QSslSocket *>(serverSocket)->setPrivateKey(m_key);
|
||||
#ifdef QBT_USES_QT5
|
||||
static_cast<QSslSocket *>(serverSocket)->setLocalCertificateChain(m_certificates);
|
||||
#else
|
||||
static_cast<QSslSocket *>(serverSocket)->setLocalCertificate(m_certificates.first());
|
||||
#endif
|
||||
static_cast<QSslSocket *>(serverSocket)->setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||
static_cast<QSslSocket *>(serverSocket)->startServerEncryption();
|
||||
}
|
||||
|
||||
@@ -62,15 +62,10 @@ namespace Http
|
||||
private:
|
||||
IRequestHandler *m_requestHandler;
|
||||
|
||||
#ifdef QBT_USES_QT5
|
||||
void incomingConnection(qintptr socketDescriptor);
|
||||
#else
|
||||
void incomingConnection(int socketDescriptor);
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_OPENSSL
|
||||
QList<QSslCipher> safeCipherList() const;
|
||||
|
||||
bool m_https;
|
||||
QList<QSslCertificate> m_certificates;
|
||||
QSslKey m_key;
|
||||
|
||||
@@ -31,9 +31,7 @@
|
||||
#include <QDebug>
|
||||
#include <QRegExp>
|
||||
#include <QStringList>
|
||||
#ifdef QBT_USES_QT5
|
||||
#include <QUrlQuery>
|
||||
#endif
|
||||
|
||||
#include "base/logger.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
@@ -158,15 +156,10 @@ QString DNSUpdater::getUpdateUrl() const
|
||||
}
|
||||
url.setPath("/nic/update");
|
||||
|
||||
#ifndef QBT_USES_QT5
|
||||
url.addQueryItem("hostname", m_domain);
|
||||
url.addQueryItem("myip", m_lastIP.toString());
|
||||
#else
|
||||
QUrlQuery urlQuery(url);
|
||||
urlQuery.addQueryItem("hostname", m_domain);
|
||||
urlQuery.addQueryItem("myip", m_lastIP.toString());
|
||||
url.setQuery(urlQuery);
|
||||
#endif
|
||||
Q_ASSERT(url.isValid());
|
||||
|
||||
qDebug() << Q_FUNC_INFO << url.toString();
|
||||
|
||||
@@ -79,26 +79,6 @@ namespace
|
||||
using QNetworkCookieJar::allCookies;
|
||||
using QNetworkCookieJar::setAllCookies;
|
||||
|
||||
#ifndef QBT_USES_QT5
|
||||
virtual bool deleteCookie(const QNetworkCookie &cookie)
|
||||
{
|
||||
auto myCookies = allCookies();
|
||||
|
||||
QList<QNetworkCookie>::Iterator it;
|
||||
for (it = myCookies.begin(); it != myCookies.end(); ++it) {
|
||||
if ((it->name() == cookie.name())
|
||||
&& (it->domain() == cookie.domain())
|
||||
&& (it->path() == cookie.path())) {
|
||||
myCookies.erase(it);
|
||||
setAllCookies(myCookies);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const override
|
||||
{
|
||||
QDateTime now = QDateTime::currentDateTime();
|
||||
|
||||
@@ -65,10 +65,6 @@ namespace
|
||||
Boolean = 14,
|
||||
Float = 15
|
||||
};
|
||||
|
||||
#ifndef QBT_USES_QT5
|
||||
Q_IPV6ADDR createMappedAddress(quint32 ip4);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct DataFieldDescriptor
|
||||
@@ -166,13 +162,7 @@ QDateTime GeoIPDatabase::buildEpoch() const
|
||||
|
||||
QString GeoIPDatabase::lookup(const QHostAddress &hostAddr) const
|
||||
{
|
||||
#ifndef QBT_USES_QT5
|
||||
Q_IPV6ADDR addr = hostAddr.protocol() == QAbstractSocket::IPv4Protocol
|
||||
? createMappedAddress(hostAddr.toIPv4Address())
|
||||
: hostAddr.toIPv6Address();
|
||||
#else
|
||||
Q_IPV6ADDR addr = hostAddr.toIPv6Address();
|
||||
#endif
|
||||
|
||||
const uchar *ptr = m_data;
|
||||
|
||||
@@ -496,25 +486,3 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, quint32 count) const
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
#ifndef QBT_USES_QT5
|
||||
Q_IPV6ADDR createMappedAddress(quint32 ip4)
|
||||
{
|
||||
Q_IPV6ADDR ip6;
|
||||
memset(&ip6, 0, sizeof(ip6));
|
||||
|
||||
int i;
|
||||
for (i = 15; ip4 != 0; i--) {
|
||||
ip6[i] = ip4 & 0xFF;
|
||||
ip4 >>= 8;
|
||||
}
|
||||
|
||||
ip6[11] = 0xFF;
|
||||
ip6[10] = 0xFF;
|
||||
|
||||
return ip6;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -126,8 +126,4 @@ namespace Net
|
||||
};
|
||||
}
|
||||
|
||||
#ifndef QBT_USES_QT5
|
||||
Q_DECLARE_METATYPE(QAbstractSocket::SocketError)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1109,20 +1109,12 @@ void Preferences::setMainGeometry(const QByteArray &geometry)
|
||||
|
||||
QByteArray Preferences::getMainVSplitterState() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("MainWindow/qt5/vsplitterState").toByteArray();
|
||||
#else
|
||||
return value("MainWindow/vsplitterState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setMainVSplitterState(const QByteArray &state)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("MainWindow/qt5/vsplitterState", state);
|
||||
#else
|
||||
setValue("MainWindow/vsplitterState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Preferences::getMainLastDir() const
|
||||
@@ -1169,20 +1161,12 @@ void Preferences::setPrefHSplitterSizes(const QStringList &sizes)
|
||||
|
||||
QByteArray Preferences::getPeerListState() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("TorrentProperties/Peers/qt5/PeerListState").toByteArray();
|
||||
#else
|
||||
return value("TorrentProperties/Peers/PeerListState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setPeerListState(const QByteArray &state)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("TorrentProperties/Peers/qt5/PeerListState", state);
|
||||
#else
|
||||
setValue("TorrentProperties/Peers/PeerListState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Preferences::getPropSplitterSizes() const
|
||||
@@ -1197,20 +1181,12 @@ void Preferences::setPropSplitterSizes(const QString &sizes)
|
||||
|
||||
QByteArray Preferences::getPropFileListState() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("TorrentProperties/qt5/FilesListState").toByteArray();
|
||||
#else
|
||||
return value("TorrentProperties/FilesListState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setPropFileListState(const QByteArray &state)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("TorrentProperties/qt5/FilesListState", state);
|
||||
#else
|
||||
setValue("TorrentProperties/FilesListState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
int Preferences::getPropCurTab() const
|
||||
@@ -1235,20 +1211,12 @@ void Preferences::setPropVisible(const bool visible)
|
||||
|
||||
QByteArray Preferences::getPropTrackerListState() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("TorrentProperties/Trackers/qt5/TrackerListState").toByteArray();
|
||||
#else
|
||||
return value("TorrentProperties/Trackers/TrackerListState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setPropTrackerListState(const QByteArray &state)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
|
||||
#else
|
||||
setValue("TorrentProperties/Trackers/TrackerListState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Preferences::getRssGeometry() const
|
||||
@@ -1263,20 +1231,12 @@ void Preferences::setRssGeometry(const QByteArray &geometry)
|
||||
|
||||
QByteArray Preferences::getRssHSplitterSizes() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("RssFeedDownloader/qt5/hsplitterSizes").toByteArray();
|
||||
#else
|
||||
return value("RssFeedDownloader/hsplitterSizes").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setRssHSplitterSizes(const QByteArray &sizes)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("RssFeedDownloader/qt5/hsplitterSizes", sizes);
|
||||
#else
|
||||
setValue("RssFeedDownloader/hsplitterSizes", sizes);
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList Preferences::getRssOpenFolders() const
|
||||
@@ -1291,38 +1251,22 @@ void Preferences::setRssOpenFolders(const QStringList &folders)
|
||||
|
||||
QByteArray Preferences::getRssSideSplitterState() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("Rss/qt5/splitter_h").toByteArray();
|
||||
#else
|
||||
return value("Rss/splitter_h").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setRssSideSplitterState(const QByteArray &state)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("Rss/qt5/splitter_h", state);
|
||||
#else
|
||||
setValue("Rss/splitter_h", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Preferences::getRssMainSplitterState() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("Rss/qt5/splitterMain").toByteArray();
|
||||
#else
|
||||
return value("Rss/splitterMain").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setRssMainSplitterState(const QByteArray &state)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("Rss/qt5/splitterMain", state);
|
||||
#else
|
||||
setValue("Rss/splitterMain", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
QByteArray Preferences::getSearchTabHeaderState() const
|
||||
@@ -1465,20 +1409,12 @@ void Preferences::setTransSelFilter(const int &index)
|
||||
|
||||
QByteArray Preferences::getTransHeaderState() const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
return value("TransferList/qt5/HeaderState").toByteArray();
|
||||
#else
|
||||
return value("TransferList/HeaderState").toByteArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Preferences::setTransHeaderState(const QByteArray &state)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
setValue("TransferList/qt5/HeaderState", state);
|
||||
#else
|
||||
setValue("TransferList/HeaderState", state);
|
||||
#endif
|
||||
}
|
||||
|
||||
//From old RssSettings class
|
||||
|
||||
@@ -75,20 +75,7 @@ namespace
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
#ifdef QBT_USES_QT5
|
||||
typedef QHash<QString, QString> MappingTable;
|
||||
#else
|
||||
class MappingTable: public QHash<QString, QString>
|
||||
{
|
||||
public:
|
||||
MappingTable(std::initializer_list<std::pair<QString, QString>> list)
|
||||
{
|
||||
reserve(static_cast<int>(list.size()));
|
||||
for (const auto &i : list)
|
||||
insert(i.first, i.second);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
QString mapKey(const QString &key)
|
||||
{
|
||||
@@ -161,11 +148,7 @@ namespace
|
||||
{"Network/Proxy/IP", "Preferences/Connection/Proxy/IP"},
|
||||
{"Network/Proxy/Port", "Preferences/Connection/Proxy/Port"},
|
||||
{"Network/PortForwardingEnabled", "Preferences/Connection/UPnP"},
|
||||
#ifdef QBT_USES_QT5
|
||||
{"AddNewTorrentDialog/TreeHeaderState", "AddNewTorrentDialog/qt5/treeHeaderState"},
|
||||
#else
|
||||
{"AddNewTorrentDialog/TreeHeaderState", "AddNewTorrentDialog/treeHeaderState"},
|
||||
#endif
|
||||
{"AddNewTorrentDialog/Width", "AddNewTorrentDialog/width"},
|
||||
{"AddNewTorrentDialog/Position", "AddNewTorrentDialog/y"},
|
||||
{"AddNewTorrentDialog/Expanded", "AddNewTorrentDialog/expanded"},
|
||||
|
||||
@@ -55,15 +55,7 @@
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#ifndef QBT_USES_QT5
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <QStandardPaths>
|
||||
#endif
|
||||
|
||||
|
||||
#include "misc.h"
|
||||
@@ -182,24 +174,7 @@ bool Utils::Fs::forceRemove(const QString& file_path)
|
||||
*/
|
||||
void Utils::Fs::removeDirRecursive(const QString& dirName)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
QDir(dirName).removeRecursively();
|
||||
#else
|
||||
QDir dir(dirName);
|
||||
|
||||
if (!dir.exists()) return;
|
||||
|
||||
Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot |
|
||||
QDir::System |
|
||||
QDir::Hidden |
|
||||
QDir::AllDirs |
|
||||
QDir::Files, QDir::DirsFirst)) {
|
||||
if (info.isDir()) removeDirRecursive(info.absoluteFilePath());
|
||||
else forceRemove(info.absoluteFilePath());
|
||||
}
|
||||
|
||||
dir.rmdir(dirName);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,74 +388,12 @@ QString Utils::Fs::QDesktopServicesCacheLocation()
|
||||
|
||||
QString Utils::Fs::QDesktopServicesDownloadLocation()
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
#if defined(Q_OS_WIN)
|
||||
if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP
|
||||
return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath(
|
||||
QCoreApplication::translate("fsutils", "Downloads"));
|
||||
#endif
|
||||
return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
#else
|
||||
|
||||
#if defined(Q_OS_OS2)
|
||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
||||
QCoreApplication::translate("fsutils", "Downloads"));
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
// as long as it stays WinXP like we do the same on OS/2
|
||||
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
|
||||
// instead of hardcoding "Downloads"
|
||||
// Unfortunately, this would break compatibility with WinXP
|
||||
if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP
|
||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
||||
QCoreApplication::translate("fsutils", "Downloads"));
|
||||
else
|
||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)).absoluteFilePath("Downloads");
|
||||
#endif
|
||||
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||
QString save_path;
|
||||
// Default save path on Linux
|
||||
QString config_path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData());
|
||||
if (config_path.isEmpty())
|
||||
config_path = QDir::home().absoluteFilePath(".config");
|
||||
|
||||
QString user_dirs_file = config_path + "/user-dirs.dirs";
|
||||
if (QFile::exists(user_dirs_file)) {
|
||||
QSettings settings(user_dirs_file, QSettings::IniFormat);
|
||||
// We need to force UTF-8 encoding here since this is not
|
||||
// the default for Ini files.
|
||||
settings.setIniCodec("UTF-8");
|
||||
QString xdg_download_dir = settings.value("XDG_DOWNLOAD_DIR").toString();
|
||||
if (!xdg_download_dir.isEmpty()) {
|
||||
// Resolve $HOME environment variables
|
||||
xdg_download_dir.replace("$HOME", QDir::homePath());
|
||||
save_path = xdg_download_dir;
|
||||
qDebug() << Q_FUNC_INFO << "SUCCESS: Using XDG path for downloads: " << save_path;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback
|
||||
if (!save_path.isEmpty() && !QFile::exists(save_path)) {
|
||||
QDir().mkpath(save_path);
|
||||
}
|
||||
|
||||
if (save_path.isEmpty() || !QFile::exists(save_path)) {
|
||||
save_path = QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
|
||||
qDebug() << Q_FUNC_INFO << "using" << save_path << "as fallback since the XDG detection did not work";
|
||||
}
|
||||
|
||||
return save_path;
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
// TODO: How to support this on Mac OS?
|
||||
#endif
|
||||
|
||||
// Fallback
|
||||
return QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Utils::Fs::cacheLocation()
|
||||
|
||||
@@ -32,12 +32,9 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QCollator>
|
||||
#include <QtGlobal>
|
||||
#include <QLocale>
|
||||
|
||||
#ifdef QBT_USES_QT5
|
||||
#include <QCollator>
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
#include <QThreadStorage>
|
||||
#endif
|
||||
@@ -50,7 +47,6 @@ namespace
|
||||
explicit NaturalCompare(const bool caseSensitive = true)
|
||||
: m_caseSensitive(caseSensitive)
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
#if defined(Q_OS_WIN)
|
||||
// Without ICU library, QCollator uses the native API on Windows 7+. But that API
|
||||
// sorts older versions of μTorrent differently than the newer ones because the
|
||||
@@ -63,12 +59,10 @@ namespace
|
||||
#endif
|
||||
m_collator.setNumericMode(true);
|
||||
m_collator.setCaseSensitivity(caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool operator()(const QString &left, const QString &right) const
|
||||
{
|
||||
#ifdef QBT_USES_QT5
|
||||
#if defined(Q_OS_WIN)
|
||||
// Without ICU library, QCollator uses the native API on Windows 7+. But that API
|
||||
// sorts older versions of μTorrent differently than the newer ones because the
|
||||
@@ -80,9 +74,6 @@ namespace
|
||||
return lessThan(left, right);
|
||||
#endif
|
||||
return (m_collator.compare(left, right) < 0);
|
||||
#else
|
||||
return lessThan(left, right);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool lessThan(const QString &left, const QString &right) const
|
||||
@@ -111,20 +102,12 @@ namespace
|
||||
int startL = posL;
|
||||
while ((posL < left.size()) && left[posL].isDigit())
|
||||
++posL;
|
||||
#ifdef QBT_USES_QT5
|
||||
int numL = left.midRef(startL, posL - startL).toInt();
|
||||
#else
|
||||
int numL = left.mid(startL, posL - startL).toInt();
|
||||
#endif
|
||||
|
||||
int startR = posR;
|
||||
while ((posR < right.size()) && right[posR].isDigit())
|
||||
++posR;
|
||||
#ifdef QBT_USES_QT5
|
||||
int numR = right.midRef(startR, posR - startR).toInt();
|
||||
#else
|
||||
int numR = right.mid(startR, posR - startR).toInt();
|
||||
#endif
|
||||
|
||||
if (numL != numR)
|
||||
return (numL < numR);
|
||||
@@ -136,9 +119,7 @@ namespace
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef QBT_USES_QT5
|
||||
QCollator m_collator;
|
||||
#endif
|
||||
const bool m_caseSensitive;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user