mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Simplify variant access with std::visit
This commit is contained in:
parent
0be787f1e4
commit
6d08e67abd
2 changed files with 2 additions and 74 deletions
|
@ -77,7 +77,7 @@ endif(Qt5Widgets_FOUND)
|
||||||
#
|
#
|
||||||
set(CMAKE_C_COMPILER gcc)
|
set(CMAKE_C_COMPILER gcc)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
|
|
@ -729,79 +729,7 @@ TimelineView::createDateSeparator(QDateTime datetime)
|
||||||
QString
|
QString
|
||||||
TimelineView::getEventSender(const mtx::events::collections::TimelineEvents &event) const
|
TimelineView::getEventSender(const mtx::events::collections::TimelineEvents &event) const
|
||||||
{
|
{
|
||||||
using Aliases = mtx::events::StateEvent<mtx::events::state::Aliases>;
|
return mpark::visit([](auto msg) { return QString::fromStdString(msg.sender); }, event);
|
||||||
using Avatar = mtx::events::StateEvent<mtx::events::state::Avatar>;
|
|
||||||
using CanonicalAlias = mtx::events::StateEvent<mtx::events::state::CanonicalAlias>;
|
|
||||||
using Create = mtx::events::StateEvent<mtx::events::state::Create>;
|
|
||||||
using HistoryVisibility = mtx::events::StateEvent<mtx::events::state::HistoryVisibility>;
|
|
||||||
using JoinRules = mtx::events::StateEvent<mtx::events::state::JoinRules>;
|
|
||||||
using Member = mtx::events::StateEvent<mtx::events::state::Member>;
|
|
||||||
using Name = mtx::events::StateEvent<mtx::events::state::Name>;
|
|
||||||
using PowerLevels = mtx::events::StateEvent<mtx::events::state::PowerLevels>;
|
|
||||||
using Topic = mtx::events::StateEvent<mtx::events::state::Topic>;
|
|
||||||
|
|
||||||
using Audio = mtx::events::RoomEvent<mtx::events::msg::Audio>;
|
|
||||||
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
|
||||||
using File = mtx::events::RoomEvent<mtx::events::msg::File>;
|
|
||||||
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
|
||||||
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
|
||||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
|
||||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
|
||||||
|
|
||||||
if (mpark::holds_alternative<Aliases>(event)) {
|
|
||||||
auto msg = mpark::get<Aliases>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Avatar>(event)) {
|
|
||||||
auto msg = mpark::get<Avatar>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<CanonicalAlias>(event)) {
|
|
||||||
auto msg = mpark::get<CanonicalAlias>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Create>(event)) {
|
|
||||||
auto msg = mpark::get<Create>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<HistoryVisibility>(event)) {
|
|
||||||
auto msg = mpark::get<HistoryVisibility>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<JoinRules>(event)) {
|
|
||||||
auto msg = mpark::get<JoinRules>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Name>(event)) {
|
|
||||||
auto msg = mpark::get<Name>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Member>(event)) {
|
|
||||||
auto msg = mpark::get<Member>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<PowerLevels>(event)) {
|
|
||||||
auto msg = mpark::get<PowerLevels>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Topic>(event)) {
|
|
||||||
auto msg = mpark::get<Topic>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Audio>(event)) {
|
|
||||||
auto msg = mpark::get<Audio>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Emote>(event)) {
|
|
||||||
auto msg = mpark::get<Emote>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<File>(event)) {
|
|
||||||
auto msg = mpark::get<File>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Image>(event)) {
|
|
||||||
auto msg = mpark::get<Image>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Notice>(event)) {
|
|
||||||
auto msg = mpark::get<Notice>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Text>(event)) {
|
|
||||||
auto msg = mpark::get<Text>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
} else if (mpark::holds_alternative<Video>(event)) {
|
|
||||||
auto msg = mpark::get<Video>(event);
|
|
||||||
return QString::fromStdString(msg.sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue