mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-06 21:21:24 -07:00
Use std::optional instead of boost::optional
This commit is contained in:
parent
08e0349ca3
commit
4429a16ca8
7 changed files with 17 additions and 19 deletions
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <optional>
|
||||||
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -55,7 +55,7 @@ namespace BitTorrent
|
||||||
TriStateBool addPaused;
|
TriStateBool addPaused;
|
||||||
QVector<DownloadPriority> filePriorities; // used if TorrentInfo is set
|
QVector<DownloadPriority> filePriorities; // used if TorrentInfo is set
|
||||||
bool skipChecking = false;
|
bool skipChecking = false;
|
||||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||||
TriStateBool useAutoTMM;
|
TriStateBool useAutoTMM;
|
||||||
int uploadLimit = -1;
|
int uploadLimit = -1;
|
||||||
int downloadLimit = -1;
|
int downloadLimit = -1;
|
||||||
|
|
|
@ -2057,9 +2057,7 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr
|
||||||
loadTorrentParams.tags = addTorrentParams.tags;
|
loadTorrentParams.tags = addTorrentParams.tags;
|
||||||
loadTorrentParams.firstLastPiecePriority = addTorrentParams.firstLastPiecePriority;
|
loadTorrentParams.firstLastPiecePriority = addTorrentParams.firstLastPiecePriority;
|
||||||
loadTorrentParams.hasSeedStatus = addTorrentParams.skipChecking; // do not react on 'torrent_finished_alert' when skipping
|
loadTorrentParams.hasSeedStatus = addTorrentParams.skipChecking; // do not react on 'torrent_finished_alert' when skipping
|
||||||
loadTorrentParams.contentLayout = (addTorrentParams.contentLayout
|
loadTorrentParams.contentLayout = addTorrentParams.contentLayout.value_or(torrentContentLayout());
|
||||||
? *addTorrentParams.contentLayout
|
|
||||||
: torrentContentLayout());
|
|
||||||
loadTorrentParams.forced = (addTorrentParams.addForced == TriStateBool::True);
|
loadTorrentParams.forced = (addTorrentParams.addForced == TriStateBool::True);
|
||||||
loadTorrentParams.paused = ((addTorrentParams.addPaused == TriStateBool::Undefined)
|
loadTorrentParams.paused = ((addTorrentParams.addPaused == TriStateBool::Undefined)
|
||||||
? isAddTorrentPaused()
|
? isAddTorrentPaused()
|
||||||
|
|
|
@ -92,15 +92,15 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<BitTorrent::TorrentContentLayout> jsonValueToContentLayout(const QJsonValue &jsonVal)
|
std::optional<BitTorrent::TorrentContentLayout> jsonValueToContentLayout(const QJsonValue &jsonVal)
|
||||||
{
|
{
|
||||||
const QString str = jsonVal.toString();
|
const QString str = jsonVal.toString();
|
||||||
if (str.isEmpty())
|
if (str.isEmpty())
|
||||||
return {};
|
return std::nullopt;
|
||||||
return Utils::String::toEnum(str, BitTorrent::TorrentContentLayout::Original);
|
return Utils::String::toEnum(str, BitTorrent::TorrentContentLayout::Original);
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonValue contentLayoutToJsonValue(const boost::optional<BitTorrent::TorrentContentLayout> contentLayout)
|
QJsonValue contentLayoutToJsonValue(const std::optional<BitTorrent::TorrentContentLayout> contentLayout)
|
||||||
{
|
{
|
||||||
if (!contentLayout)
|
if (!contentLayout)
|
||||||
return {};
|
return {};
|
||||||
|
@ -143,7 +143,7 @@ namespace RSS
|
||||||
QString savePath;
|
QString savePath;
|
||||||
QString category;
|
QString category;
|
||||||
TriStateBool addPaused = TriStateBool::Undefined;
|
TriStateBool addPaused = TriStateBool::Undefined;
|
||||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||||
|
|
||||||
bool smartFilter = false;
|
bool smartFilter = false;
|
||||||
QStringList previouslyMatchedEpisodes;
|
QStringList previouslyMatchedEpisodes;
|
||||||
|
@ -505,7 +505,7 @@ AutoDownloadRule AutoDownloadRule::fromJsonObject(const QJsonObject &jsonObj, co
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const TriStateBool createSubfolder = jsonValueToTriStateBool(jsonObj.value(Str_CreateSubfolder));
|
const TriStateBool createSubfolder = jsonValueToTriStateBool(jsonObj.value(Str_CreateSubfolder));
|
||||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||||
if (createSubfolder == TriStateBool::True)
|
if (createSubfolder == TriStateBool::True)
|
||||||
contentLayout = BitTorrent::TorrentContentLayout::Original;
|
contentLayout = BitTorrent::TorrentContentLayout::Original;
|
||||||
else if (createSubfolder == TriStateBool::False)
|
else if (createSubfolder == TriStateBool::False)
|
||||||
|
@ -649,12 +649,12 @@ void AutoDownloadRule::setAddPaused(const TriStateBool addPaused)
|
||||||
m_dataPtr->addPaused = addPaused;
|
m_dataPtr->addPaused = addPaused;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<BitTorrent::TorrentContentLayout> AutoDownloadRule::torrentContentLayout() const
|
std::optional<BitTorrent::TorrentContentLayout> AutoDownloadRule::torrentContentLayout() const
|
||||||
{
|
{
|
||||||
return m_dataPtr->contentLayout;
|
return m_dataPtr->contentLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoDownloadRule::setTorrentContentLayout(const boost::optional<BitTorrent::TorrentContentLayout> contentLayout)
|
void AutoDownloadRule::setTorrentContentLayout(const std::optional<BitTorrent::TorrentContentLayout> contentLayout)
|
||||||
{
|
{
|
||||||
m_dataPtr->contentLayout = contentLayout;
|
m_dataPtr->contentLayout = contentLayout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <optional>
|
||||||
|
|
||||||
#include <QSharedDataPointer>
|
#include <QSharedDataPointer>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
@ -83,8 +83,8 @@ namespace RSS
|
||||||
void setSavePath(const QString &savePath);
|
void setSavePath(const QString &savePath);
|
||||||
TriStateBool addPaused() const;
|
TriStateBool addPaused() const;
|
||||||
void setAddPaused(TriStateBool addPaused);
|
void setAddPaused(TriStateBool addPaused);
|
||||||
boost::optional<BitTorrent::TorrentContentLayout> torrentContentLayout() const;
|
std::optional<BitTorrent::TorrentContentLayout> torrentContentLayout() const;
|
||||||
void setTorrentContentLayout(boost::optional<BitTorrent::TorrentContentLayout> contentLayout);
|
void setTorrentContentLayout(std::optional<BitTorrent::TorrentContentLayout> contentLayout);
|
||||||
QString assignedCategory() const;
|
QString assignedCategory() const;
|
||||||
void setCategory(const QString &category);
|
void setCategory(const QString &category);
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
||||||
m_ui->checkBoxRememberLastSavePath->setChecked(rememberLastSavePath);
|
m_ui->checkBoxRememberLastSavePath->setChecked(rememberLastSavePath);
|
||||||
|
|
||||||
m_ui->contentLayoutComboBox->setCurrentIndex(
|
m_ui->contentLayoutComboBox->setCurrentIndex(
|
||||||
static_cast<int>(m_torrentParams.contentLayout ? *m_torrentParams.contentLayout : session->torrentContentLayout()));
|
static_cast<int>(m_torrentParams.contentLayout.value_or(session->torrentContentLayout())));
|
||||||
|
|
||||||
m_ui->sequentialCheckBox->setChecked(m_torrentParams.sequential);
|
m_ui->sequentialCheckBox->setChecked(m_torrentParams.sequential);
|
||||||
m_ui->firstLastCheckBox->setChecked(m_torrentParams.firstLastPiecePriority);
|
m_ui->firstLastCheckBox->setChecked(m_torrentParams.firstLastPiecePriority);
|
||||||
|
|
|
@ -354,7 +354,7 @@ void AutomatedRssDownloader::updateEditedRule()
|
||||||
addPaused = TriStateBool::False;
|
addPaused = TriStateBool::False;
|
||||||
m_currentRule.setAddPaused(addPaused);
|
m_currentRule.setAddPaused(addPaused);
|
||||||
|
|
||||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||||
if (m_ui->comboContentLayout->currentIndex() > 0)
|
if (m_ui->comboContentLayout->currentIndex() > 0)
|
||||||
contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->comboContentLayout->currentIndex() - 1);
|
contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->comboContentLayout->currentIndex() - 1);
|
||||||
m_currentRule.setTorrentContentLayout(contentLayout);
|
m_currentRule.setTorrentContentLayout(contentLayout);
|
||||||
|
|
|
@ -616,9 +616,9 @@ void TorrentsController::addAction()
|
||||||
const auto autoTMM = TriStateBool::fromString(params()["autoTMM"]);
|
const auto autoTMM = TriStateBool::fromString(params()["autoTMM"]);
|
||||||
|
|
||||||
const QString contentLayoutParam = params()["contentLayout"];
|
const QString contentLayoutParam = params()["contentLayout"];
|
||||||
const boost::optional<BitTorrent::TorrentContentLayout> contentLayout = (!contentLayoutParam.isEmpty()
|
const std::optional<BitTorrent::TorrentContentLayout> contentLayout = (!contentLayoutParam.isEmpty()
|
||||||
? Utils::String::toEnum(contentLayoutParam, BitTorrent::TorrentContentLayout::Original)
|
? Utils::String::toEnum(contentLayoutParam, BitTorrent::TorrentContentLayout::Original)
|
||||||
: boost::optional<BitTorrent::TorrentContentLayout> {});
|
: std::optional<BitTorrent::TorrentContentLayout> {});
|
||||||
|
|
||||||
QList<QNetworkCookie> cookies;
|
QList<QNetworkCookie> cookies;
|
||||||
if (!cookie.isEmpty())
|
if (!cookie.isEmpty())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue