Merge pull request #14593 from glassez/qt6-compat

Make current codebase more compatible with Qt6
This commit is contained in:
Vladimir Golovnev
2021-03-29 14:00:23 +03:00
committed by GitHub
12 changed files with 48 additions and 17 deletions

View File

@@ -58,7 +58,9 @@
#include <QFile>
#include <QHostAddress>
#include <QNetworkAddressEntry>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QNetworkConfigurationManager>
#endif
#include <QNetworkInterface>
#include <QRegularExpression>
#include <QString>
@@ -95,7 +97,6 @@
#include "statistics.h"
#include "torrentimpl.h"
#include "tracker.h"
#include "trackerentry.h"
using namespace BitTorrent;
@@ -444,7 +445,9 @@ Session::Session(QObject *parent)
, m_statistics {new Statistics {this}}
, m_ioThread {new QThread {this}}
, m_recentErroredTorrentsTimer {new QTimer {this}}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
, m_networkManager {new QNetworkConfigurationManager {this}}
#endif
{
if (port() < 0)
m_port = Utils::Random::rand(1024, 65535);
@@ -485,11 +488,13 @@ Session::Session(QObject *parent)
, &Net::ProxyConfigurationManager::proxyConfigurationChanged
, this, &Session::configureDeferred);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Network configuration monitor
connect(m_networkManager, &QNetworkConfigurationManager::onlineStateChanged, this, &Session::networkOnlineStateChanged);
connect(m_networkManager, &QNetworkConfigurationManager::configurationAdded, this, &Session::networkConfigurationChange);
connect(m_networkManager, &QNetworkConfigurationManager::configurationRemoved, this, &Session::networkConfigurationChange);
connect(m_networkManager, &QNetworkConfigurationManager::configurationChanged, this, &Session::networkConfigurationChange);
#endif
m_fileSearcher = new FileSearcher;
m_fileSearcher->moveToThread(m_ioThread);
@@ -2413,6 +2418,7 @@ void Session::setTempPath(QString path)
torrent->handleTempPathChanged();
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void Session::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);
@@ -2433,6 +2439,7 @@ void Session::networkConfigurationChange(const QNetworkConfiguration &cfg)
configureListeningInterface();
}
}
#endif
QStringList Session::getListeningIPs() const
{

View File

@@ -50,10 +50,13 @@
#include "cachestatus.h"
#include "sessionstatus.h"
#include "torrentinfo.h"
#include "trackerentry.h"
class QFile;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
class QNetworkConfiguration;
class QNetworkConfigurationManager;
#endif
class QString;
class QThread;
class QTimer;
@@ -100,7 +103,6 @@ namespace BitTorrent
class TorrentImpl;
class Tracker;
struct LoadTorrentParams;
struct TrackerEntry;
enum class MoveStorageMode;
@@ -542,9 +544,11 @@ namespace BitTorrent
void handleDownloadFinished(const Net::DownloadResult &result);
void fileSearchFinished(const TorrentID &id, const QString &savePath, const QStringList &fileNames);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Session reconfiguration triggers
void networkOnlineStateChanged(bool online);
void networkConfigurationChange(const QNetworkConfiguration &);
#endif
private:
struct MoveStorageJob
@@ -783,8 +787,9 @@ 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

@@ -28,7 +28,6 @@
#include "reverseresolution.h"
#include <QHostAddress>
#include <QHostInfo>
#include <QString>

View File

@@ -29,9 +29,9 @@
#pragma once
#include <QCache>
#include <QHostAddress>
#include <QObject>
class QHostAddress;
class QHostInfo;
class QString;

View File

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