diff --git a/src/app/signalhandler.cpp b/src/app/signalhandler.cpp index f5ef5263c..1116b5a34 100644 --- a/src/app/signalhandler.cpp +++ b/src/app/signalhandler.cpp @@ -34,7 +34,6 @@ #include #include -#include #ifdef Q_OS_UNIX #include diff --git a/src/base/bittorrent/addtorrentparams.cpp b/src/base/bittorrent/addtorrentparams.cpp index ec21cfe5e..d2e17ab74 100644 --- a/src/base/bittorrent/addtorrentparams.cpp +++ b/src/base/bittorrent/addtorrentparams.cpp @@ -28,8 +28,6 @@ #include "addtorrentparams.h" -#include - #include #include #include @@ -101,51 +99,38 @@ namespace } } -bool BitTorrent::operator==(const AddTorrentParams &lhs, const AddTorrentParams &rhs) -{ - return std::tie(lhs.name, lhs.category, lhs.tags, - lhs.savePath, lhs.useDownloadPath, lhs.downloadPath, - lhs.sequential, lhs.firstLastPiecePriority, lhs.addForced, - lhs.addToQueueTop, lhs.addPaused, lhs.stopCondition, - lhs.filePaths, lhs.filePriorities, lhs.skipChecking, - lhs.contentLayout, lhs.useAutoTMM, lhs.uploadLimit, - lhs.downloadLimit, lhs.seedingTimeLimit, lhs.inactiveSeedingTimeLimit, lhs.ratioLimit) - == std::tie(rhs.name, rhs.category, rhs.tags, - rhs.savePath, rhs.useDownloadPath, rhs.downloadPath, - rhs.sequential, rhs.firstLastPiecePriority, rhs.addForced, - rhs.addToQueueTop, rhs.addPaused, rhs.stopCondition, - rhs.filePaths, rhs.filePriorities, rhs.skipChecking, - rhs.contentLayout, rhs.useAutoTMM, rhs.uploadLimit, - rhs.downloadLimit, rhs.seedingTimeLimit, rhs.inactiveSeedingTimeLimit, rhs.ratioLimit); -} - BitTorrent::AddTorrentParams BitTorrent::parseAddTorrentParams(const QJsonObject &jsonObj) { - AddTorrentParams params; - params.category = jsonObj.value(PARAM_CATEGORY).toString(); - params.tags = parseTagSet(jsonObj.value(PARAM_TAGS).toArray()); - params.savePath = Path(jsonObj.value(PARAM_SAVEPATH).toString()); - params.useDownloadPath = getOptionalBool(jsonObj, PARAM_USEDOWNLOADPATH); - params.downloadPath = Path(jsonObj.value(PARAM_DOWNLOADPATH).toString()); - params.addForced = (getEnum(jsonObj, PARAM_OPERATINGMODE) == TorrentOperatingMode::Forced); - params.addToQueueTop = getOptionalBool(jsonObj, PARAM_QUEUETOP); - params.addPaused = getOptionalBool(jsonObj, PARAM_STOPPED); - params.stopCondition = getOptionalEnum(jsonObj, PARAM_STOPCONDITION); - params.skipChecking = jsonObj.value(PARAM_SKIPCHECKING).toBool(); - params.contentLayout = getOptionalEnum(jsonObj, PARAM_CONTENTLAYOUT); - params.useAutoTMM = getOptionalBool(jsonObj, PARAM_AUTOTMM); - params.uploadLimit = jsonObj.value(PARAM_UPLOADLIMIT).toInt(-1); - params.downloadLimit = jsonObj.value(PARAM_DOWNLOADLIMIT).toInt(-1); - params.seedingTimeLimit = jsonObj.value(PARAM_SEEDINGTIMELIMIT).toInt(Torrent::USE_GLOBAL_SEEDING_TIME); - params.inactiveSeedingTimeLimit = jsonObj.value(PARAM_INACTIVESEEDINGTIMELIMIT).toInt(Torrent::USE_GLOBAL_INACTIVE_SEEDING_TIME); - params.ratioLimit = jsonObj.value(PARAM_RATIOLIMIT).toDouble(Torrent::USE_GLOBAL_RATIO); - + const AddTorrentParams params + { + .name = {}, + .category = jsonObj.value(PARAM_CATEGORY).toString(), + .tags = parseTagSet(jsonObj.value(PARAM_TAGS).toArray()), + .savePath = Path(jsonObj.value(PARAM_SAVEPATH).toString()), + .useDownloadPath = getOptionalBool(jsonObj, PARAM_USEDOWNLOADPATH), + .downloadPath = Path(jsonObj.value(PARAM_DOWNLOADPATH).toString()), + .addForced = (getEnum(jsonObj, PARAM_OPERATINGMODE) == TorrentOperatingMode::Forced), + .addToQueueTop = getOptionalBool(jsonObj, PARAM_QUEUETOP), + .addPaused = getOptionalBool(jsonObj, PARAM_STOPPED), + .stopCondition = getOptionalEnum(jsonObj, PARAM_STOPCONDITION), + .filePaths = {}, + .filePriorities = {}, + .skipChecking = jsonObj.value(PARAM_SKIPCHECKING).toBool(), + .contentLayout = getOptionalEnum(jsonObj, PARAM_CONTENTLAYOUT), + .useAutoTMM = getOptionalBool(jsonObj, PARAM_AUTOTMM), + .uploadLimit = jsonObj.value(PARAM_UPLOADLIMIT).toInt(-1), + .downloadLimit = jsonObj.value(PARAM_DOWNLOADLIMIT).toInt(-1), + .seedingTimeLimit = jsonObj.value(PARAM_SEEDINGTIMELIMIT).toInt(Torrent::USE_GLOBAL_SEEDING_TIME), + .inactiveSeedingTimeLimit = jsonObj.value(PARAM_INACTIVESEEDINGTIMELIMIT).toInt(Torrent::USE_GLOBAL_INACTIVE_SEEDING_TIME), + .ratioLimit = jsonObj.value(PARAM_RATIOLIMIT).toDouble(Torrent::USE_GLOBAL_RATIO) + }; return params; } QJsonObject BitTorrent::serializeAddTorrentParams(const AddTorrentParams ¶ms) { - QJsonObject jsonObj { + QJsonObject jsonObj + { {PARAM_CATEGORY, params.category}, {PARAM_TAGS, serializeTagSet(params.tags)}, {PARAM_SAVEPATH, params.savePath.data()}, diff --git a/src/base/bittorrent/addtorrentparams.h b/src/base/bittorrent/addtorrentparams.h index 63ec0e4e7..809310744 100644 --- a/src/base/bittorrent/addtorrentparams.h +++ b/src/base/bittorrent/addtorrentparams.h @@ -69,9 +69,9 @@ namespace BitTorrent int seedingTimeLimit = Torrent::USE_GLOBAL_SEEDING_TIME; int inactiveSeedingTimeLimit = Torrent::USE_GLOBAL_INACTIVE_SEEDING_TIME; qreal ratioLimit = Torrent::USE_GLOBAL_RATIO; - }; - bool operator==(const AddTorrentParams &lhs, const AddTorrentParams &rhs); + friend bool operator==(const AddTorrentParams &lhs, const AddTorrentParams &rhs) = default; + }; AddTorrentParams parseAddTorrentParams(const QJsonObject &jsonObj); QJsonObject serializeAddTorrentParams(const AddTorrentParams ¶ms); diff --git a/src/base/bittorrent/bencoderesumedatastorage.cpp b/src/base/bittorrent/bencoderesumedatastorage.cpp index f6602bebc..2ca225e87 100644 --- a/src/base/bittorrent/bencoderesumedatastorage.cpp +++ b/src/base/bittorrent/bencoderesumedatastorage.cpp @@ -76,7 +76,7 @@ namespace template QString fromLTString(const LTStr &str) { - return QString::fromUtf8(str.data(), static_cast(str.size())); + return QString::fromUtf8(str.data(), static_cast(str.size())); } using ListType = lt::entry::list_type; diff --git a/src/base/bittorrent/dbresumedatastorage.cpp b/src/base/bittorrent/dbresumedatastorage.cpp index 66c6307d0..3d8e5ece3 100644 --- a/src/base/bittorrent/dbresumedatastorage.cpp +++ b/src/base/bittorrent/dbresumedatastorage.cpp @@ -148,7 +148,7 @@ namespace template QString fromLTString(const LTStr &str) { - return QString::fromUtf8(str.data(), static_cast(str.size())); + return QString::fromUtf8(str.data(), static_cast(str.size())); } QString quoted(const QString &name) diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index 27dda0be0..280a0ffbc 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -227,20 +227,20 @@ void TorrentCreatorDialog::onCreateButtonClicked() .replace(QRegularExpression(u"\n\n[\n]+"_s), u"\n\n"_s).split(u'\n'); const BitTorrent::TorrentCreatorParams params { - m_ui->checkPrivate->isChecked() + .isPrivate = m_ui->checkPrivate->isChecked(), #ifdef QBT_USES_LIBTORRENT2 - , getTorrentFormat() + .torrentFormat = getTorrentFormat(), #else - , m_ui->checkOptimizeAlignment->isChecked() - , getPaddedFileSizeLimit() + .isAlignmentOptimized = m_ui->checkOptimizeAlignment->isChecked(), + .paddedFileSizeLimit = getPaddedFileSizeLimit(), #endif - , getPieceSize() - , inputPath - , destPath - , m_ui->txtComment->toPlainText() - , m_ui->lineEditSource->text() - , trackers - , m_ui->URLSeedsList->toPlainText().split(u'\n', Qt::SkipEmptyParts) + .pieceSize = getPieceSize(), + .inputPath = inputPath, + .savePath = destPath, + .comment = m_ui->txtComment->toPlainText(), + .source = m_ui->lineEditSource->text(), + .trackers = trackers, + .urlSeeds = m_ui->URLSeedsList->toPlainText().split(u'\n', Qt::SkipEmptyParts) }; auto *torrentCreator = new BitTorrent::TorrentCreator(params); @@ -257,7 +257,7 @@ void TorrentCreatorDialog::handleCreationFailure(const QString &msg) { // Remove busy cursor setCursor(QCursor(Qt::ArrowCursor)); - QMessageBox::information(this, tr("Torrent creation failed"), tr("Reason: %1").arg(msg)); + QMessageBox::information(this, tr("Torrent creation failed"), msg); setInteractionEnabled(true); } diff --git a/src/webui/api/torrentscontroller.cpp b/src/webui/api/torrentscontroller.cpp index 25618da55..242a4a34a 100644 --- a/src/webui/api/torrentscontroller.cpp +++ b/src/webui/api/torrentscontroller.cpp @@ -754,7 +754,7 @@ void TorrentsController::addAction() } } - const DataMap torrents = data(); + const DataMap &torrents = data(); for (auto it = torrents.constBegin(); it != torrents.constEnd(); ++it) { if (const auto loadResult = BitTorrent::TorrentDescriptor::load(it.value()))