Drop support of Qt 5

Also remove usage of some deprecated stuff.

PR #19338.
This commit is contained in:
Vladimir Golovnev
2023-07-20 11:17:27 +03:00
committed by GitHub
parent 5e610cfdcf
commit dbe79484d2
55 changed files with 48 additions and 462 deletions

View File

@@ -20,7 +20,6 @@ add_library(qbt_base STATIC
bittorrent/infohash.h
bittorrent/loadtorrentparams.h
bittorrent/ltqbitarray.h
bittorrent/ltqhash.h
bittorrent/lttypecast.h
bittorrent/magneturi.h
bittorrent/nativesessionextension.h

View File

@@ -41,8 +41,6 @@
#include <libtorrent/io_context.hpp>
#include <QHash>
#include "ltqhash.h"
#else
#include <libtorrent/storage.hpp>
#endif

View File

@@ -848,7 +848,7 @@ namespace
query.bindValue(DB_COLUMN_NAME.placeholder, m_resumeData.name);
query.bindValue(DB_COLUMN_CATEGORY.placeholder, m_resumeData.category);
query.bindValue(DB_COLUMN_TAGS.placeholder, (m_resumeData.tags.isEmpty()
? QVariant(QVariant::String) : m_resumeData.tags.join(u","_s)));
? QString() : m_resumeData.tags.join(u","_s)));
query.bindValue(DB_COLUMN_CONTENT_LAYOUT.placeholder, Utils::String::fromEnum(m_resumeData.contentLayout));
query.bindValue(DB_COLUMN_RATIO_LIMIT.placeholder, static_cast<int>(m_resumeData.ratioLimit * 1000));
query.bindValue(DB_COLUMN_SEEDING_TIME_LIMIT.placeholder, m_resumeData.seedingTimeLimit);

View File

@@ -111,11 +111,7 @@ BitTorrent::TorrentID BitTorrent::TorrentID::fromSHA256Hash(const SHA256Hash &ha
return BaseType::UnderlyingType(static_cast<typename SHA256Hash::UnderlyingType>(hash).data());
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const BitTorrent::TorrentID &key, const std::size_t seed)
#else
uint BitTorrent::qHash(const BitTorrent::TorrentID &key, const uint seed)
#endif
{
return ::qHash(static_cast<TorrentID::BaseType>(key), seed);
}

View File

@@ -87,11 +87,7 @@ namespace BitTorrent
WrappedType m_nativeHash;
};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TorrentID &key, std::size_t seed = 0);
#else
uint qHash(const TorrentID &key, uint seed = 0);
#endif
bool operator==(const InfoHash &left, const InfoHash &right);
bool operator!=(const InfoHash &left, const InfoHash &right);

View File

@@ -1,51 +0,0 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2020 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#pragma once
#include <QtGlobal>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <functional>
#include <libtorrent/units.hpp>
#include <QHash>
namespace libtorrent
{
namespace aux
{
template <typename T, typename Tag>
uint qHash(const strong_typedef<T, Tag> &key, const uint seed = 0)
{
return ::qHash((std::hash<strong_typedef<T, Tag>> {})(key), seed);
}
}
}
#endif

View File

@@ -77,14 +77,7 @@ bool BitTorrent::operator==(const BitTorrent::PeerAddress &left, const BitTorren
return (left.ip == right.ip) && (left.port == right.port);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const std::size_t seed)
{
return qHashMulti(seed, addr.ip, addr.port);
}
#else
uint BitTorrent::qHash(const BitTorrent::PeerAddress &addr, const uint seed)
{
return (::qHash(addr.ip, seed) ^ ::qHash(addr.port));
}
#endif

View File

@@ -45,9 +45,5 @@ namespace BitTorrent
};
bool operator==(const PeerAddress &left, const PeerAddress &right);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const PeerAddress &addr, std::size_t seed = 0);
#else
uint qHash(const PeerAddress &addr, uint seed = 0);
#endif
}

View File

@@ -66,9 +66,6 @@
#include <QJsonObject>
#include <QJsonValue>
#include <QNetworkAddressEntry>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QNetworkConfigurationManager>
#endif
#include <QNetworkInterface>
#include <QRegularExpression>
#include <QString>
@@ -118,24 +115,6 @@ const Path CATEGORIES_FILE_NAME {u"categories.json"_s};
const int MAX_PROCESSING_RESUMEDATA_COUNT = 50;
const int STATISTICS_SAVE_INTERVAL = std::chrono::milliseconds(15min).count();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
namespace std
{
uint qHash(const std::string &key, uint seed = 0)
{
return ::qHash(std::hash<std::string> {}(key), seed);
}
}
namespace libtorrent
{
uint qHash(const libtorrent::torrent_handle &key)
{
return static_cast<uint>(libtorrent::hash_value(key));
}
}
#endif
namespace
{
const char PEER_ID[] = "qB";
@@ -537,9 +516,6 @@ SessionImpl::SessionImpl(QObject *parent)
, m_ioThread {new QThread}
, m_asyncWorker {new QThreadPool(this)}
, m_recentErroredTorrentsTimer {new QTimer(this)}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
, m_networkManager {new QNetworkConfigurationManager(this)}
#endif
{
// It is required to perform async access to libtorrent sequentially
m_asyncWorker->setMaxThreadCount(1);
@@ -580,14 +556,6 @@ SessionImpl::SessionImpl(QObject *parent)
, &Net::ProxyConfigurationManager::proxyConfigurationChanged
, this, &SessionImpl::configureDeferred);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Network configuration monitor
connect(m_networkManager, &QNetworkConfigurationManager::onlineStateChanged, this, &SessionImpl::networkOnlineStateChanged);
connect(m_networkManager, &QNetworkConfigurationManager::configurationAdded, this, &SessionImpl::networkConfigurationChange);
connect(m_networkManager, &QNetworkConfigurationManager::configurationRemoved, this, &SessionImpl::networkConfigurationChange);
connect(m_networkManager, &QNetworkConfigurationManager::configurationChanged, this, &SessionImpl::networkConfigurationChange);
#endif
m_fileSearcher = new FileSearcher;
m_fileSearcher->moveToThread(m_ioThread.get());
connect(m_ioThread.get(), &QThread::finished, m_fileSearcher, &QObject::deleteLater);
@@ -3148,13 +3116,7 @@ void SessionImpl::saveResumeData()
// clear queued storage move jobs except the current ongoing one
if (m_moveStorageQueue.size() > 1)
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_moveStorageQueue = m_moveStorageQueue.mid(0, 1);
#else
m_moveStorageQueue.resize(1);
#endif
}
QElapsedTimer timer;
timer.start();
@@ -3277,29 +3239,6 @@ void SessionImpl::setDownloadPath(const Path &path)
torrent->handleCategoryOptionsChanged();
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void SessionImpl::networkOnlineStateChanged(const bool online)
{
LogMsg(tr("System network status changed to %1", "e.g: System network status changed to ONLINE").arg(online ? tr("ONLINE") : tr("OFFLINE")), Log::INFO);
}
void SessionImpl::networkConfigurationChange(const QNetworkConfiguration &cfg)
{
const QString configuredInterfaceName = networkInterface();
// Empty means "Any Interface". In this case libtorrent has binded to 0.0.0.0 so any change to any interface will
// be automatically picked up. Otherwise we would rebinding here to 0.0.0.0 again.
if (configuredInterfaceName.isEmpty()) return;
const QString changedInterface = cfg.name();
if (configuredInterfaceName == changedInterface)
{
LogMsg(tr("Network configuration of %1 has changed, refreshing session binding", "e.g: Network configuration of tun0 has changed, refreshing session binding").arg(changedInterface), Log::INFO);
configureListeningInterface();
}
}
#endif
QStringList SessionImpl::getListeningIPs() const
{
QStringList IPs;
@@ -6201,12 +6140,8 @@ void SessionImpl::processTrackerStatuses()
const QMap<TrackerEntry::Endpoint, int> &updateInfo = updatedTrackersIter.value();
TrackerEntry trackerEntry = torrent->updateTrackerEntry(announceEntry, updateInfo);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
updatedTrackerEntries[trackerEntry.url] = std::move(trackerEntry);
#else
const QString url = trackerEntry.url;
updatedTrackerEntries.emplace(url, std::move(trackerEntry));
#endif
}
emit trackerEntriesUpdated(torrent, updatedTrackerEntries);

View File

@@ -57,10 +57,6 @@
#include "torrentinfo.h"
#include "trackerentry.h"
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
class QNetworkConfiguration;
class QNetworkConfigurationManager;
#endif
class QString;
class QThread;
class QThreadPool;
@@ -486,12 +482,6 @@ namespace BitTorrent
void handleDownloadFinished(const Net::DownloadResult &result);
void fileSearchFinished(const TorrentID &id, const Path &savePath, const PathList &fileNames);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Session reconfiguration triggers
void networkOnlineStateChanged(bool online);
void networkConfigurationChange(const QNetworkConfiguration &);
#endif
private:
struct ResumeSessionContext;
@@ -778,9 +768,6 @@ namespace BitTorrent
SessionStatus m_status;
CacheStatus m_cacheStatus;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QNetworkConfigurationManager *m_networkManager = nullptr;
#endif
QList<MoveStorageJob> m_moveStorageQueue;

View File

@@ -35,11 +35,7 @@
namespace BitTorrent
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TorrentState key, const std::size_t seed)
#else
uint qHash(const TorrentState key, const uint seed)
#endif
{
return ::qHash(static_cast<std::underlying_type_t<TorrentState>>(key), seed);
}

View File

@@ -100,11 +100,7 @@ namespace BitTorrent
Error
};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(TorrentState key, std::size_t seed = 0);
#else
uint qHash(TorrentState key, uint seed = 0);
#endif
class Torrent : public TorrentContentHandler
{

View File

@@ -62,7 +62,6 @@
#include "extensiondata.h"
#include "loadtorrentparams.h"
#include "ltqbitarray.h"
#include "ltqhash.h"
#include "lttypecast.h"
#include "peeraddress.h"
#include "peerinfo.h"

View File

@@ -140,11 +140,7 @@ namespace BitTorrent
return !(left == right);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Peer &key, const std::size_t seed)
#else
uint qHash(const Peer &key, const uint seed)
#endif
{
return qHash(key.uniqueID(), seed);
}

View File

@@ -65,11 +65,7 @@ namespace BitTorrent
bool operator==(const Peer &left, const Peer &right);
bool operator!=(const Peer &left, const Peer &right);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Peer &key, std::size_t seed = 0);
#else
uint qHash(const Peer &key, uint seed = 0);
#endif
// *Basic* Bittorrent tracker implementation
// [BEP-3] The BitTorrent Protocol Specification

View File

@@ -61,11 +61,7 @@ bool BitTorrent::operator==(const TrackerEntry &left, const TrackerEntry &right)
return (left.url == right.url);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t BitTorrent::qHash(const TrackerEntry &key, const std::size_t seed)
#else
uint BitTorrent::qHash(const TrackerEntry &key, const uint seed)
#endif
{
return ::qHash(key.url, seed);
}

View File

@@ -79,9 +79,5 @@ namespace BitTorrent
QVector<TrackerEntry> parseTrackerEntries(QStringView str);
bool operator==(const TrackerEntry &left, const TrackerEntry &right);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const TrackerEntry &key, std::size_t seed = 0);
#else
uint qHash(const TrackerEntry &key, uint seed = 0);
#endif
}

View File

@@ -157,16 +157,8 @@ bool operator<(const Digest32<N> &left, const Digest32<N> &right)
< static_cast<typename Digest32<N>::UnderlyingType>(right);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
template <int N>
std::size_t qHash(const Digest32<N> &key, const std::size_t seed = 0)
{
return ::qHash(static_cast<typename Digest32<N>::UnderlyingType>(key), seed);
}
#else
template <int N>
uint qHash(const Digest32<N> &key, const uint seed = 0)
{
return ::qHash(std::hash<typename Digest32<N>::UnderlyingType> {}(key), seed);
}
#endif

View File

@@ -50,11 +50,7 @@ void asConst(const T &&) = delete;
// https://doc.qt.io/qt-6/qstring.html#operator-22-22_s
inline QString operator"" _s(const char16_t *str, const std::size_t size)
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
return QString::fromRawData(reinterpret_cast<const QChar *>(str), static_cast<int>(size));
#else
return operator""_qs(str, size);
#endif
}
#else
using namespace Qt::Literals::StringLiterals;

View File

@@ -376,17 +376,10 @@ Net::ServiceID Net::ServiceID::fromURL(const QUrl &url)
return {url.host(), url.port(80)};
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t Net::qHash(const ServiceID &serviceID, const std::size_t seed)
{
return qHashMulti(seed, serviceID.hostName, serviceID.port);
}
#else
uint Net::qHash(const ServiceID &serviceID, const uint seed)
{
return ::qHash(serviceID.hostName, seed) ^ ::qHash(serviceID.port);
}
#endif
bool Net::operator==(const ServiceID &lhs, const ServiceID &rhs)
{

View File

@@ -54,11 +54,7 @@ namespace Net
static ServiceID fromURL(const QUrl &url);
};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const ServiceID &serviceID, std::size_t seed = 0);
#else
uint qHash(const ServiceID &serviceID, uint seed = 0);
#endif
bool operator==(const ServiceID &lhs, const ServiceID &rhs);
enum class DownloadStatus

View File

@@ -484,7 +484,7 @@ QVariant GeoIPDatabase::readMapValue(quint32 &offset, const quint32 count) const
const QString key = field.toString();
field = readDataField(offset);
if (field.userType() == QVariant::Invalid)
if (field.userType() == QMetaType::UnknownType)
return {};
map[key] = field;
@@ -500,7 +500,7 @@ QVariant GeoIPDatabase::readArrayValue(quint32 &offset, const quint32 count) con
for (quint32 i = 0; i < count; ++i)
{
const QVariant field = readDataField(offset);
if (field.userType() == QVariant::Invalid)
if (field.userType() == QMetaType::UnknownType)
return {};
array.append(field);

View File

@@ -377,11 +377,7 @@ QDataStream &operator>>(QDataStream &in, Path &path)
return in;
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Path &key, const std::size_t seed)
#else
uint qHash(const Path &key, const uint seed)
#endif
{
return ::qHash(key.data(), seed);
}

View File

@@ -101,8 +101,4 @@ Path operator+(const Path &lhs, QStringView rhs);
QDataStream &operator<<(QDataStream &out, const Path &path);
QDataStream &operator>>(QDataStream &in, Path &path);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
std::size_t qHash(const Path &key, std::size_t seed = 0);
#else
uint qHash(const Path &key, uint seed = 0);
#endif

View File

@@ -1671,11 +1671,7 @@ void Preferences::setMainLastDir(const Path &path)
QByteArray Preferences::getPeerListState() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TorrentProperties/PeerListState"_s);
#else
return value<QByteArray>(u"TorrentProperties/Peers/qt5/PeerListState"_s);
#endif
}
void Preferences::setPeerListState(const QByteArray &state)
@@ -1683,11 +1679,7 @@ void Preferences::setPeerListState(const QByteArray &state)
if (state == getPeerListState())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TorrentProperties/PeerListState"_s, state);
#else
setValue(u"TorrentProperties/Peers/qt5/PeerListState"_s, state);
#endif
}
QString Preferences::getPropSplitterSizes() const
@@ -1705,11 +1697,7 @@ void Preferences::setPropSplitterSizes(const QString &sizes)
QByteArray Preferences::getPropFileListState() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TorrentProperties/FilesListState"_s);
#else
return value<QByteArray>(u"TorrentProperties/qt5/FilesListState"_s);
#endif
}
void Preferences::setPropFileListState(const QByteArray &state)
@@ -1717,11 +1705,7 @@ void Preferences::setPropFileListState(const QByteArray &state)
if (state == getPropFileListState())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TorrentProperties/FilesListState"_s, state);
#else
setValue(u"TorrentProperties/qt5/FilesListState"_s, state);
#endif
}
int Preferences::getPropCurTab() const
@@ -1752,11 +1736,7 @@ void Preferences::setPropVisible(const bool visible)
QByteArray Preferences::getPropTrackerListState() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TorrentProperties/TrackerListState"_s);
#else
return value<QByteArray>(u"TorrentProperties/Trackers/qt5/TrackerListState"_s);
#endif
}
void Preferences::setPropTrackerListState(const QByteArray &state)
@@ -1764,11 +1744,7 @@ void Preferences::setPropTrackerListState(const QByteArray &state)
if (state == getPropTrackerListState())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TorrentProperties/TrackerListState"_s, state);
#else
setValue(u"TorrentProperties/Trackers/qt5/TrackerListState"_s, state);
#endif
}
QStringList Preferences::getRssOpenFolders() const
@@ -1786,11 +1762,7 @@ void Preferences::setRssOpenFolders(const QStringList &folders)
QByteArray Preferences::getRssSideSplitterState() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/RSSWidget/SideSplitterState"_s);
#else
return value<QByteArray>(u"GUI/RSSWidget/qt5/splitter_h"_s);
#endif
}
void Preferences::setRssSideSplitterState(const QByteArray &state)
@@ -1798,20 +1770,12 @@ void Preferences::setRssSideSplitterState(const QByteArray &state)
if (state == getRssSideSplitterState())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/RSSWidget/SideSplitterState"_s, state);
#else
setValue(u"GUI/RSSWidget/qt5/splitter_h"_s, state);
#endif
}
QByteArray Preferences::getRssMainSplitterState() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/RSSWidget/MainSplitterState"_s);
#else
return value<QByteArray>(u"GUI/RSSWidget/qt5/splitterMain"_s);
#endif
}
void Preferences::setRssMainSplitterState(const QByteArray &state)
@@ -1819,20 +1783,12 @@ void Preferences::setRssMainSplitterState(const QByteArray &state)
if (state == getRssMainSplitterState())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/RSSWidget/MainSplitterState"_s, state);
#else
setValue(u"GUI/RSSWidget/qt5/splitterMain"_s, state);
#endif
}
QByteArray Preferences::getSearchTabHeaderState() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/SearchTab/HeaderState"_s);
#else
return value<QByteArray>(u"SearchTab/qt5/HeaderState"_s);
#endif
}
void Preferences::setSearchTabHeaderState(const QByteArray &state)
@@ -1840,11 +1796,7 @@ void Preferences::setSearchTabHeaderState(const QByteArray &state)
if (state == getSearchTabHeaderState())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/SearchTab/HeaderState"_s, state);
#else
setValue(u"SearchTab/qt5/HeaderState"_s, state);
#endif
}
bool Preferences::getRegexAsFilteringPatternForSearchJob() const
@@ -1979,11 +1931,7 @@ void Preferences::setHideZeroStatusFilters(const bool hide)
QByteArray Preferences::getTransHeaderState() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
return value<QByteArray>(u"GUI/Qt6/TransferList/HeaderState"_s);
#else
return value<QByteArray>(u"TransferList/qt5/HeaderState"_s);
#endif
}
void Preferences::setTransHeaderState(const QByteArray &state)
@@ -1991,11 +1939,7 @@ void Preferences::setTransHeaderState(const QByteArray &state)
if (state == getTransHeaderState())
return;
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
setValue(u"GUI/Qt6/TransferList/HeaderState"_s, state);
#else
setValue(u"TransferList/qt5/HeaderState"_s, state);
#endif
}
bool Preferences::getRegexAsFilteringPatternForTransferList() const

View File

@@ -212,11 +212,7 @@ bool SettingsStorage::writeNativeSettings() const
void SettingsStorage::removeValue(const QString &key)
{
const QWriteLocker locker(&m_lock);
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
if (m_data.remove(key))
#else
if (m_data.remove(key) > 0)
#endif
{
m_dirty = true;
m_timer.start();

View File

@@ -233,7 +233,7 @@ void TorrentFilesWatcher::loadLegacy()
{
const Path watchedFolder {it.key()};
BitTorrent::AddTorrentParams params;
if (it.value().type() == QVariant::Int)
if (it.value().userType() == QMetaType::Int)
{
if (it.value().toInt() == 0)
{

View File

@@ -32,15 +32,10 @@
#include <cmath>
#include <QLocale>
#include <QRegularExpression>
#include <QStringList>
#include <QVector>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QRegularExpression>
#else
#include <QRegExp>
#endif
// to send numbers instead of strings with suffixes
QString Utils::String::fromDouble(const double n, const int precision)
{
@@ -54,21 +49,10 @@ QString Utils::String::fromDouble(const double n, const int precision)
return QLocale::system().toString(std::floor(n * prec) / prec, 'f', precision);
}
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QString Utils::String::wildcardToRegexPattern(const QString &pattern)
{
return QRegularExpression::wildcardToRegularExpression(pattern, QRegularExpression::UnanchoredWildcardConversion);
}
#else
// This is marked as internal in QRegExp.cpp, but is exported. The alternative would be to
// copy the code from QRegExp::wc2rx().
QString qt_regexp_toCanonical(const QString &pattern, QRegExp::PatternSyntax patternSyntax);
QString Utils::String::wildcardToRegexPattern(const QString &pattern)
{
return qt_regexp_toCanonical(pattern, QRegExp::Wildcard);
}
#endif
QStringList Utils::String::splitCommand(const QString &command)
{