Merge pull request #18936 from Chocobo1/tidy

Code clean up
This commit is contained in:
Chocobo1
2023-05-08 13:11:11 +08:00
committed by GitHub
39 changed files with 106 additions and 117 deletions

View File

@@ -41,7 +41,6 @@ using namespace std::chrono_literals;
BandwidthScheduler::BandwidthScheduler(QObject *parent)
: QObject(parent)
, m_lastAlternative(false)
{
connect(&m_timer, &QTimer::timeout, this, &BandwidthScheduler::onTimeout);
}

View File

@@ -49,5 +49,5 @@ private:
void onTimeout();
QTimer m_timer;
bool m_lastAlternative;
bool m_lastAlternative = false;
};

View File

@@ -89,7 +89,7 @@ namespace
}
private:
lt::address_v4::bytes_type m_buf;
lt::address_v4::bytes_type m_buf {};
};
bool parseIPAddress(const char *data, lt::address &address)
@@ -111,7 +111,6 @@ namespace
FilterParserThread::FilterParserThread(QObject *parent)
: QThread(parent)
, m_abort(false)
{
}

View File

@@ -62,7 +62,7 @@ private:
int getlineInStream(QDataStream &stream, std::string &name, char delim);
int parseP2BFilterFile();
bool m_abort;
bool m_abort = false;
Path m_filePath;
lt::ip_filter m_filter;
};

View File

@@ -54,7 +54,7 @@ namespace BitTorrent
bool firstLastPiecePriority = false;
bool hasFinishedStatus = false;
bool stopped = false;
Torrent::StopCondition stopCondition;
Torrent::StopCondition stopCondition = Torrent::StopCondition::None;
bool addToQueueTop = false; // only for new torrents

View File

@@ -75,8 +75,7 @@ using namespace BitTorrent;
const int magnetUriId = qRegisterMetaType<MagnetUri>();
MagnetUri::MagnetUri(const QString &source)
: m_valid(false)
, m_url(source)
: m_url(source)
{
if (source.isEmpty()) return;

View File

@@ -54,7 +54,7 @@ namespace BitTorrent
lt::add_torrent_params addTorrentParams() const;
private:
bool m_valid;
bool m_valid = false;
QString m_url;
InfoHash m_infoHash;
QString m_name;

View File

@@ -485,15 +485,15 @@ namespace BitTorrent
{
lt::torrent_handle torrentHandle;
Path path;
MoveStorageMode mode;
MoveStorageContext context;
MoveStorageMode mode {};
MoveStorageContext context {};
};
struct RemovingTorrentData
{
QString name;
Path pathToRemove;
DeleteOption deleteOption;
DeleteOption deleteOption {};
};
explicit SessionImpl(QObject *parent = nullptr);

View File

@@ -46,14 +46,14 @@ namespace BitTorrent
struct TorrentCreatorParams
{
bool isPrivate;
bool isPrivate = false;
#ifdef QBT_USES_LIBTORRENT2
TorrentFormat torrentFormat;
TorrentFormat torrentFormat = TorrentFormat::Hybrid;
#else
bool isAlignmentOptimized;
int paddedFileSizeLimit;
#endif
int pieceSize;
int pieceSize = 0;
Path inputPath;
Path savePath;
QString comment;

View File

@@ -84,7 +84,7 @@ namespace BitTorrent
struct FileErrorInfo
{
lt::error_code error;
lt::operation_t operation;
lt::operation_t operation = lt::operation_t::unknown;
};
class TorrentImpl final : public Torrent

View File

@@ -47,9 +47,9 @@ namespace Http
struct ParseResult
{
// when `status != ParseStatus::OK`, `request` & `frameSize` are undefined
ParseStatus status;
ParseStatus status = ParseStatus::BadRequest;
Request request;
long frameSize; // http request frame size (bytes)
long frameSize = 0; // http request frame size (bytes)
};
static ParseResult parse(const QByteArray &data);

View File

@@ -79,10 +79,10 @@ namespace Http
struct Environment
{
QHostAddress localAddress;
quint16 localPort;
quint16 localPort = 0;
QHostAddress clientAddress;
quint16 clientPort;
quint16 clientPort = 0;
};
struct UploadedFile

View File

@@ -51,17 +51,17 @@ namespace Log
struct Msg
{
int id;
MsgType type;
qint64 timestamp;
int id = -1;
MsgType type = ALL;
qint64 timestamp = -1;
QString message;
};
struct Peer
{
int id;
bool blocked;
qint64 timestamp;
int id = -1;
bool blocked = false;
qint64 timestamp = -1;
QString ip;
QString reason;
};

View File

@@ -44,8 +44,6 @@ const std::chrono::seconds IP_CHECK_INTERVAL = 30min;
DNSUpdater::DNSUpdater(QObject *parent)
: QObject(parent)
, m_state(OK)
, m_service(DNS::Service::None)
{
updateCredentials();

View File

@@ -74,9 +74,9 @@ namespace Net
QHostAddress m_lastIP;
QDateTime m_lastIPCheckTime;
QTimer m_ipCheckTimer;
int m_state;
int m_state = OK;
// Service creds
DNS::Service m_service;
DNS::Service m_service = DNS::Service::None;
QString m_domain;
QString m_username;
QString m_password;

View File

@@ -103,7 +103,7 @@ namespace Net
struct DownloadResult
{
QString url;
DownloadStatus status;
DownloadStatus status = DownloadStatus::Failed;
QString errorString;
QByteArray data;
Path filePath;

View File

@@ -177,7 +177,7 @@ std::unique_ptr<QSettings> Private::CustomProfile::applicationSettings(const QSt
const auto CONF_FILE_EXTENSION = u".conf"_qs;
#endif
const Path settingsFilePath = configLocation() / Path(name + CONF_FILE_EXTENSION);
return std::unique_ptr<QSettings>(new QSettings(settingsFilePath.data(), QSettings::IniFormat));
return std::make_unique<QSettings>(settingsFilePath.data(), QSettings::IniFormat);
}
Path Private::NoConvertConverter::fromPortablePath(const Path &portablePath) const

View File

@@ -723,13 +723,16 @@ void RSS::Private::Parser::parseAtomArticle(QXmlStreamReader &xml)
: xml.attributes().value(u"href"_qs).toString());
if (link.startsWith(u"magnet:", Qt::CaseInsensitive))
{
article[Article::KeyTorrentURL] = link; // magnet link instead of a news URL
}
else
{
// Atom feeds can have relative links, work around this and
// take the stress of figuring article full URI from UI
// Assemble full URI
article[Article::KeyLink] = (m_baseUrl.isEmpty() ? link : m_baseUrl + link);
}
}
else if ((name == u"summary") || (name == u"content"))
{

View File

@@ -42,9 +42,9 @@ struct SearchResult
{
QString fileName;
QString fileUrl;
qlonglong fileSize;
qlonglong nbSeeders;
qlonglong nbLeechers;
qlonglong fileSize = 0;
qlonglong nbSeeders = 0;
qlonglong nbLeechers = 0;
QString siteUrl;
QString descrLink;
};

View File

@@ -366,7 +366,7 @@ QString SearchPluginManager::categoryFullName(const QString &categoryName)
return categoryTable.value(categoryName);
}
QString SearchPluginManager::pluginFullName(const QString &pluginName)
QString SearchPluginManager::pluginFullName(const QString &pluginName) const
{
return pluginInfo(pluginName) ? pluginInfo(pluginName)->fullName : QString();
}

View File

@@ -52,7 +52,7 @@ struct PluginInfo
QString url;
QStringList supportedCategories;
Path iconPath;
bool enabled;
bool enabled = false;
};
class SearchDownloadHandler;
@@ -88,7 +88,7 @@ public:
static PluginVersion getPluginVersion(const Path &filePath);
static QString categoryFullName(const QString &categoryName);
QString pluginFullName(const QString &pluginName);
QString pluginFullName(const QString &pluginName) const;
static Path pluginsLocation();
static Path engineLocation();