Replace boost::optional with std::optional (#4877)

This commit is contained in:
pajlada
2023-10-08 18:50:48 +02:00
committed by GitHub
parent fe4d6121a2
commit fec45889a8
88 changed files with 428 additions and 383 deletions
+4 -3
View File
@@ -2,9 +2,10 @@
#include "common/WindowDescriptors.hpp"
#include <boost/optional.hpp>
#include <QApplication>
#include <optional>
namespace chatterino {
/// Command line arguments passed to Chatterino.
@@ -18,12 +19,12 @@ public:
bool shouldRunBrowserExtensionHost{};
// Shows a single chat. Used on windows to embed in another application.
bool isFramelessEmbed{};
boost::optional<unsigned long long> parentWindowId{};
std::optional<unsigned long long> parentWindowId{};
// Not settings directly
bool dontSaveSettings{};
bool dontLoadMainWindow{};
boost::optional<WindowLayout> customChannelLayout;
std::optional<WindowLayout> customChannelLayout;
bool verbose{};
private:
+1 -1
View File
@@ -80,7 +80,7 @@ LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot()
}
void Channel::addMessage(MessagePtr message,
boost::optional<MessageFlags> overridingFlags)
std::optional<MessageFlags> overridingFlags)
{
auto app = getApp();
MessagePtr deleted;
+4 -5
View File
@@ -4,13 +4,13 @@
#include "controllers/completion/TabCompletionModel.hpp"
#include "messages/LimitedQueue.hpp"
#include <boost/optional.hpp>
#include <pajlada/signals/signal.hpp>
#include <QDate>
#include <QString>
#include <QTimer>
#include <memory>
#include <optional>
namespace chatterino {
@@ -52,7 +52,7 @@ public:
pajlada::Signals::Signal<const QString &, const QString &, const QString &,
bool &>
sendReplySignal;
pajlada::Signals::Signal<MessagePtr &, boost::optional<MessageFlags>>
pajlada::Signals::Signal<MessagePtr &, std::optional<MessageFlags>>
messageAppended;
pajlada::Signals::Signal<std::vector<MessagePtr> &> messagesAddedAtStart;
pajlada::Signals::Signal<size_t, MessagePtr &> messageReplaced;
@@ -75,9 +75,8 @@ public:
// overridingFlags can be filled in with flags that should be used instead
// of the message's flags. This is useful in case a flag is specific to a
// type of split
void addMessage(
MessagePtr message,
boost::optional<MessageFlags> overridingFlags = boost::none);
void addMessage(MessagePtr message,
std::optional<MessageFlags> overridingFlags = std::nullopt);
void addMessagesAtStart(const std::vector<MessagePtr> &messages_);
/// Inserts the given messages in order by Message::serverReceivedTime.
+1 -1
View File
@@ -1,11 +1,11 @@
#pragma once
#include <boost/optional.hpp>
#include <boost/preprocessor.hpp>
#include <QString>
#include <QWidget>
#include <memory>
#include <optional>
#include <string>
namespace chatterino {
+2 -2
View File
@@ -44,7 +44,7 @@ namespace {
return defaultValue;
}
boost::optional<QString> readOptionalStringEnv(const char *envName)
std::optional<QString> readOptionalStringEnv(const char *envName)
{
auto envString = std::getenv(envName);
if (envString != nullptr)
@@ -52,7 +52,7 @@ namespace {
return QString(envString);
}
return boost::none;
return std::nullopt;
}
uint16_t readPortEnv(const char *envName, uint16_t defaultValue)
+3 -2
View File
@@ -1,8 +1,9 @@
#pragma once
#include <boost/optional.hpp>
#include <QString>
#include <optional>
namespace chatterino {
class Env
@@ -17,7 +18,7 @@ public:
const QString twitchServerHost;
const uint16_t twitchServerPort;
const bool twitchServerSecure;
const boost::optional<QString> proxyUrl;
const std::optional<QString> proxyUrl;
};
} // namespace chatterino
+9 -6
View File
@@ -2,12 +2,13 @@
#include "common/SignalVector.hpp"
#include <boost/optional.hpp>
#include <pajlada/signals/signalholder.hpp>
#include <QAbstractTableModel>
#include <QMimeData>
#include <QStandardItem>
#include <optional>
namespace chatterino {
template <typename T>
@@ -127,7 +128,8 @@ public:
QVariant data(const QModelIndex &index, int role) const override
{
int row = index.row(), column = index.column();
int row = index.row();
int column = index.column();
if (row < 0 || column < 0 || row >= this->rows_.size() ||
column >= this->columnCount_)
{
@@ -140,7 +142,8 @@ public:
bool setData(const QModelIndex &index, const QVariant &value,
int role) override
{
int row = index.row(), column = index.column();
int row = index.row();
int column = index.column();
if (row < 0 || column < 0 || row >= this->rows_.size() ||
column >= this->columnCount_)
{
@@ -166,7 +169,7 @@ public:
assert(this->rows_[row].original);
TVectorItem item = this->getItemFromRow(
this->rows_[row].items, this->rows_[row].original.get());
this->rows_[row].items, this->rows_[row].original.value());
this->vector_->insert(item, vecRow, this);
}
@@ -262,7 +265,7 @@ public:
TVectorItem item =
this->getItemFromRow(this->rows_[sourceRow].items,
this->rows_[sourceRow].original.get());
this->rows_[sourceRow].original.value());
this->vector_->removeAt(signalVectorRow);
this->vector_->insert(
item, this->getVectorIndexFromModelIndex(destinationChild));
@@ -417,7 +420,7 @@ protected:
struct Row {
std::vector<QStandardItem *> items;
boost::optional<TVectorItem> original;
std::optional<TVectorItem> original;
bool isCustomRow;
Row(std::vector<QStandardItem *> _items, bool _isCustomRow = false)