Replace boost::optional with std::optional (#4877)
This commit is contained in:
@@ -291,13 +291,12 @@ bool ChannelView::paused() const
|
||||
return this->pausable() && !this->pauses_.empty();
|
||||
}
|
||||
|
||||
void ChannelView::pause(PauseReason reason, boost::optional<uint> msecs)
|
||||
void ChannelView::pause(PauseReason reason, std::optional<uint> msecs)
|
||||
{
|
||||
if (msecs)
|
||||
{
|
||||
/// Msecs has a value
|
||||
auto timePoint =
|
||||
SteadyClock::now() + std::chrono::milliseconds(msecs.get());
|
||||
auto timePoint = SteadyClock::now() + std::chrono::milliseconds(*msecs);
|
||||
auto it = this->pauses_.find(reason);
|
||||
|
||||
if (it == this->pauses_.end())
|
||||
@@ -308,15 +307,19 @@ void ChannelView::pause(PauseReason reason, boost::optional<uint> msecs)
|
||||
else
|
||||
{
|
||||
/// If the new time point is newer then we override.
|
||||
if (it->second && it->second.get() < timePoint)
|
||||
it->second = timePoint;
|
||||
auto &previousTimePoint = it->second;
|
||||
if (previousTimePoint.has_value() &&
|
||||
previousTimePoint.value() < timePoint)
|
||||
{
|
||||
previousTimePoint = timePoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Msecs is none -> pause is infinite.
|
||||
/// We just override the value.
|
||||
this->pauses_[reason] = boost::none;
|
||||
this->pauses_[reason] = std::nullopt;
|
||||
}
|
||||
|
||||
this->updatePauses();
|
||||
@@ -339,7 +342,7 @@ void ChannelView::updatePauses()
|
||||
this->unpaused();
|
||||
|
||||
/// No pauses so we can stop the timer
|
||||
this->pauseEnd_ = boost::none;
|
||||
this->pauseEnd_ = std::nullopt;
|
||||
this->pauseTimer_.stop();
|
||||
|
||||
this->scrollBar_->offsetMaximum(this->pauseScrollMaximumOffset_);
|
||||
@@ -355,7 +358,7 @@ void ChannelView::updatePauses()
|
||||
}))
|
||||
{
|
||||
/// Some of the pauses are infinite
|
||||
this->pauseEnd_ = boost::none;
|
||||
this->pauseEnd_ = std::nullopt;
|
||||
this->pauseTimer_.stop();
|
||||
}
|
||||
else
|
||||
@@ -366,7 +369,7 @@ void ChannelView::updatePauses()
|
||||
[](auto &&a, auto &&b) {
|
||||
return a.second > b.second;
|
||||
})
|
||||
->second.get();
|
||||
->second.value();
|
||||
|
||||
if (pauseEnd != this->pauseEnd_)
|
||||
{
|
||||
@@ -645,13 +648,12 @@ bool ChannelView::getEnableScrollingToBottom() const
|
||||
return this->enableScrollingToBottom_;
|
||||
}
|
||||
|
||||
void ChannelView::setOverrideFlags(boost::optional<MessageElementFlags> value)
|
||||
void ChannelView::setOverrideFlags(std::optional<MessageElementFlags> value)
|
||||
{
|
||||
this->overrideFlags_ = std::move(value);
|
||||
}
|
||||
|
||||
const boost::optional<MessageElementFlags> &ChannelView::getOverrideFlags()
|
||||
const
|
||||
const std::optional<MessageElementFlags> &ChannelView::getOverrideFlags() const
|
||||
{
|
||||
return this->overrideFlags_;
|
||||
}
|
||||
@@ -697,7 +699,7 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
|
||||
this->channelConnections_.managedConnect(
|
||||
underlyingChannel->messageAppended,
|
||||
[this](MessagePtr &message,
|
||||
boost::optional<MessageFlags> overridingFlags) {
|
||||
std::optional<MessageFlags> overridingFlags) {
|
||||
if (this->shouldIncludeMessage(message))
|
||||
{
|
||||
if (this->channel_->lastDate_ != QDate::currentDate())
|
||||
@@ -713,12 +715,12 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
|
||||
// logging will be handled. Prevent duplications.
|
||||
if (overridingFlags)
|
||||
{
|
||||
overridingFlags.get().set(MessageFlag::DoNotLog);
|
||||
overridingFlags->set(MessageFlag::DoNotLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
overridingFlags = MessageFlags(message->flags);
|
||||
overridingFlags.get().set(MessageFlag::DoNotLog);
|
||||
overridingFlags->set(MessageFlag::DoNotLog);
|
||||
}
|
||||
|
||||
this->channel_->addMessage(message, overridingFlags);
|
||||
@@ -764,7 +766,7 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
|
||||
this->channelConnections_.managedConnect(
|
||||
this->channel_->messageAppended,
|
||||
[this](MessagePtr &message,
|
||||
boost::optional<MessageFlags> overridingFlags) {
|
||||
std::optional<MessageFlags> overridingFlags) {
|
||||
this->messageAppended(message, std::move(overridingFlags));
|
||||
});
|
||||
|
||||
@@ -880,12 +882,12 @@ bool ChannelView::hasSourceChannel() const
|
||||
}
|
||||
|
||||
void ChannelView::messageAppended(MessagePtr &message,
|
||||
boost::optional<MessageFlags> overridingFlags)
|
||||
std::optional<MessageFlags> overridingFlags)
|
||||
{
|
||||
auto *messageFlags = &message->flags;
|
||||
if (overridingFlags)
|
||||
{
|
||||
messageFlags = overridingFlags.get_ptr();
|
||||
messageFlags = &*overridingFlags;
|
||||
}
|
||||
|
||||
auto messageRef = std::make_shared<MessageLayout>(message);
|
||||
@@ -1109,7 +1111,7 @@ MessageElementFlags ChannelView::getFlags() const
|
||||
|
||||
if (this->overrideFlags_)
|
||||
{
|
||||
return this->overrideFlags_.get();
|
||||
return *this->overrideFlags_;
|
||||
}
|
||||
|
||||
MessageElementFlags flags = app->windows->getWordFlags();
|
||||
|
||||
Reference in New Issue
Block a user