Browse Source

Use std::optional instead of boost::optional

adaptive-webui-19844
Vladimir Golovnev (Glassez) 4 years ago
parent
commit
4429a16ca8
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 4
      src/base/bittorrent/addtorrentparams.h
  2. 4
      src/base/bittorrent/session.cpp
  3. 14
      src/base/rss/rss_autodownloadrule.cpp
  4. 6
      src/base/rss/rss_autodownloadrule.h
  5. 2
      src/gui/addnewtorrentdialog.cpp
  6. 2
      src/gui/rss/automatedrssdownloader.cpp
  7. 4
      src/webui/api/torrentscontroller.cpp

4
src/base/bittorrent/addtorrentparams.h

@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
#pragma once
#include <boost/optional.hpp>
#include <optional>
#include <QSet>
#include <QString>
@ -55,7 +55,7 @@ namespace BitTorrent @@ -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;

4
src/base/bittorrent/session.cpp

@ -2057,9 +2057,7 @@ LoadTorrentParams Session::initLoadTorrentParams(const AddTorrentParams &addTorr @@ -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()

14
src/base/rss/rss_autodownloadrule.cpp

@ -92,15 +92,15 @@ namespace @@ -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 @@ -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 @@ -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) @@ -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;
}

6
src/base/rss/rss_autodownloadrule.h

@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
#pragma once
#include <boost/optional.hpp>
#include <optional>
#include <QSharedDataPointer>
#include <QVariant>
@ -83,8 +83,8 @@ namespace RSS @@ -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);

2
src/gui/addnewtorrentdialog.cpp

@ -124,7 +124,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP @@ -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);

2
src/gui/rss/automatedrssdownloader.cpp

@ -354,7 +354,7 @@ void AutomatedRssDownloader::updateEditedRule() @@ -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);

4
src/webui/api/torrentscontroller.cpp

@ -616,9 +616,9 @@ void TorrentsController::addAction() @@ -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…
Cancel
Save