From 5839b9f522c4153e7866566b39b9f75202ed2b8e Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 17 Dec 2017 17:48:46 +0100 Subject: [PATCH] add username to message (simple) --- src/logging/loggingchannel.cpp | 2 +- src/messages/message.cpp | 5 ----- src/messages/message.hpp | 4 ++-- src/messages/messagebuilder.hpp | 4 +++- src/twitch/twitchmessagebuilder.cpp | 2 ++ 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/logging/loggingchannel.cpp b/src/logging/loggingchannel.cpp index b38deb6c3..d3fe1dd17 100644 --- a/src/logging/loggingchannel.cpp +++ b/src/logging/loggingchannel.cpp @@ -37,7 +37,7 @@ void Channel::append(std::shared_ptr message) str.append('['); str.append(now.toString("HH:mm:ss")); str.append("] "); - str.append(message->getUserName()); + str.append(message->username); str.append(": "); str.append(message->getContent()); str.append('\n'); diff --git a/src/messages/message.cpp b/src/messages/message.cpp index 0e675b1b4..d0b84f174 100644 --- a/src/messages/message.cpp +++ b/src/messages/message.cpp @@ -36,11 +36,6 @@ int Message::getTimeoutCount() const return this->timeoutCount; } -const QString &Message::getUserName() const -{ - return this->userName; -} - const QString &Message::getDisplayName() const { return this->displayName; diff --git a/src/messages/message.hpp b/src/messages/message.hpp index cb49366f3..670ea744a 100644 --- a/src/messages/message.hpp +++ b/src/messages/message.hpp @@ -22,7 +22,6 @@ public: void setHighlight(bool value); const QString &getTimeoutUser() const; int getTimeoutCount() const; - const QString &getUserName() const; const QString &getDisplayName() const; const QString &getContent() const; const std::chrono::time_point &getParseTime() const; @@ -30,6 +29,8 @@ public: bool isDisabled() const; const QString &getId() const; + QString username; + const QString text; bool centered = false; @@ -57,7 +58,6 @@ private: bool disabled = false; std::chrono::time_point parseTime; - QString userName = ""; QString displayName = ""; QString content; QString id = ""; diff --git a/src/messages/messagebuilder.hpp b/src/messages/messagebuilder.hpp index adda6e0f5..ec61994f2 100644 --- a/src/messages/messagebuilder.hpp +++ b/src/messages/messagebuilder.hpp @@ -26,8 +26,10 @@ public: QString originalMessage; -private: +protected: std::shared_ptr message; + +private: std::vector _words; bool highlight = false; std::chrono::time_point _parseTime; diff --git a/src/twitch/twitchmessagebuilder.cpp b/src/twitch/twitchmessagebuilder.cpp index a6e3b70d9..e028a8713 100644 --- a/src/twitch/twitchmessagebuilder.cpp +++ b/src/twitch/twitchmessagebuilder.cpp @@ -287,6 +287,8 @@ void TwitchMessageBuilder::parseUsername() if (this->userName.isEmpty()) { this->userName = this->tags.value(QLatin1String("login")).toString(); } + + this->message->username = this->userName; } void TwitchMessageBuilder::appendUsername()