mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-09 04:08:16 +08:00
Use std::optional instead of boost::optional
This commit is contained in:
parent
08e0349ca3
commit
4429a16ca8
@ -28,7 +28,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
@ -55,7 +55,7 @@ namespace BitTorrent
|
||||
TriStateBool addPaused;
|
||||
QVector<DownloadPriority> filePriorities; // used if TorrentInfo is set
|
||||
bool skipChecking = false;
|
||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
TriStateBool useAutoTMM;
|
||||
int uploadLimit = -1;
|
||||
int downloadLimit = -1;
|
||||
|
@ -2057,9 +2057,7 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr
|
||||
loadTorrentParams.tags = addTorrentParams.tags;
|
||||
loadTorrentParams.firstLastPiecePriority = addTorrentParams.firstLastPiecePriority;
|
||||
loadTorrentParams.hasSeedStatus = addTorrentParams.skipChecking; // do not react on 'torrent_finished_alert' when skipping
|
||||
loadTorrentParams.contentLayout = (addTorrentParams.contentLayout
|
||||
? *addTorrentParams.contentLayout
|
||||
: torrentContentLayout());
|
||||
loadTorrentParams.contentLayout = addTorrentParams.contentLayout.value_or(torrentContentLayout());
|
||||
loadTorrentParams.forced = (addTorrentParams.addForced == TriStateBool::True);
|
||||
loadTorrentParams.paused = ((addTorrentParams.addPaused == TriStateBool::Undefined)
|
||||
? 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();
|
||||
if (str.isEmpty())
|
||||
return {};
|
||||
return std::nullopt;
|
||||
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)
|
||||
return {};
|
||||
@ -143,7 +143,7 @@ namespace RSS
|
||||
QString savePath;
|
||||
QString category;
|
||||
TriStateBool addPaused = TriStateBool::Undefined;
|
||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
|
||||
bool smartFilter = false;
|
||||
QStringList previouslyMatchedEpisodes;
|
||||
@ -505,7 +505,7 @@ AutoDownloadRule AutoDownloadRule::fromJsonObject(const QJsonObject &jsonObj, co
|
||||
else
|
||||
{
|
||||
const TriStateBool createSubfolder = jsonValueToTriStateBool(jsonObj.value(Str_CreateSubfolder));
|
||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
if (createSubfolder == TriStateBool::True)
|
||||
contentLayout = BitTorrent::TorrentContentLayout::Original;
|
||||
else if (createSubfolder == TriStateBool::False)
|
||||
@ -649,12 +649,12 @@ void AutoDownloadRule::setAddPaused(const TriStateBool addPaused)
|
||||
m_dataPtr->addPaused = addPaused;
|
||||
}
|
||||
|
||||
boost::optional<BitTorrent::TorrentContentLayout> AutoDownloadRule::torrentContentLayout() const
|
||||
std::optional<BitTorrent::TorrentContentLayout> AutoDownloadRule::torrentContentLayout() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <optional>
|
||||
|
||||
#include <QSharedDataPointer>
|
||||
#include <QVariant>
|
||||
@ -83,8 +83,8 @@ namespace RSS
|
||||
void setSavePath(const QString &savePath);
|
||||
TriStateBool addPaused() const;
|
||||
void setAddPaused(TriStateBool addPaused);
|
||||
boost::optional<BitTorrent::TorrentContentLayout> torrentContentLayout() const;
|
||||
void setTorrentContentLayout(boost::optional<BitTorrent::TorrentContentLayout> contentLayout);
|
||||
std::optional<BitTorrent::TorrentContentLayout> torrentContentLayout() const;
|
||||
void setTorrentContentLayout(std::optional<BitTorrent::TorrentContentLayout> contentLayout);
|
||||
QString assignedCategory() const;
|
||||
void setCategory(const QString &category);
|
||||
|
||||
|
@ -124,7 +124,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
||||
m_ui->checkBoxRememberLastSavePath->setChecked(rememberLastSavePath);
|
||||
|
||||
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->firstLastCheckBox->setChecked(m_torrentParams.firstLastPiecePriority);
|
||||
|
@ -354,7 +354,7 @@ void AutomatedRssDownloader::updateEditedRule()
|
||||
addPaused = TriStateBool::False;
|
||||
m_currentRule.setAddPaused(addPaused);
|
||||
|
||||
boost::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
std::optional<BitTorrent::TorrentContentLayout> contentLayout;
|
||||
if (m_ui->comboContentLayout->currentIndex() > 0)
|
||||
contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->comboContentLayout->currentIndex() - 1);
|
||||
m_currentRule.setTorrentContentLayout(contentLayout);
|
||||
|
@ -616,9 +616,9 @@ void TorrentsController::addAction()
|
||||
const auto autoTMM = TriStateBool::fromString(params()["autoTMM"]);
|
||||
|
||||
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)
|
||||
: boost::optional<BitTorrent::TorrentContentLayout> {});
|
||||
: std::optional<BitTorrent::TorrentContentLayout> {});
|
||||
|
||||
QList<QNetworkCookie> cookies;
|
||||
if (!cookie.isEmpty())
|
||||
|
Loading…
Reference in New Issue
Block a user