mirror-chatterino2/src/messages/message.cpp

103 lines
2.2 KiB
C++
Raw Normal View History

2017-06-11 09:31:45 +02:00
#include "messages/message.hpp"
#include "channel.hpp"
#include "colorscheme.hpp"
#include "emojis.hpp"
#include "emotemanager.hpp"
#include "fontmanager.hpp"
#include "ircmanager.hpp"
#include "messages/link.hpp"
#include "resources.hpp"
2017-01-05 16:43:01 +01:00
#include <ctime>
2017-01-11 01:08:20 +01:00
#include <list>
2017-01-11 18:52:09 +01:00
#include <tuple>
2017-01-05 16:43:01 +01:00
2017-04-14 17:52:22 +02:00
namespace chatterino {
namespace messages {
2017-01-18 21:30:23 +01:00
2017-09-24 18:43:24 +02:00
bool Message::getCanHighlightTab() const
2017-01-05 16:07:20 +01:00
{
2017-09-24 18:43:24 +02:00
return this->highlightTab;
2017-01-05 16:07:20 +01:00
}
2017-09-24 18:43:24 +02:00
void Message::setHighlight(bool value)
2017-04-12 17:46:44 +02:00
{
2017-09-24 18:43:24 +02:00
this->highlightTab = value;
2017-04-12 17:46:44 +02:00
}
2017-01-07 20:43:55 +01:00
2017-04-12 17:46:44 +02:00
const QString &Message::getTimeoutUser() const
{
return this->timeoutUser;
2017-04-12 17:46:44 +02:00
}
2017-01-07 20:43:55 +01:00
2017-04-12 17:46:44 +02:00
int Message::getTimeoutCount() const
{
return this->timeoutCount;
2017-04-12 17:46:44 +02:00
}
2017-01-07 20:43:55 +01:00
2017-04-12 17:46:44 +02:00
const QString &Message::getUserName() const
{
return this->userName;
2017-04-12 17:46:44 +02:00
}
2017-01-15 16:38:30 +01:00
2017-04-12 17:46:44 +02:00
const QString &Message::getDisplayName() const
{
return this->displayName;
2017-04-12 17:46:44 +02:00
}
2017-01-07 20:43:55 +01:00
2017-04-12 17:46:44 +02:00
const QString &Message::getContent() const
{
return this->content;
2017-04-12 17:46:44 +02:00
}
2017-01-07 20:43:55 +01:00
2017-04-12 17:46:44 +02:00
const std::chrono::time_point<std::chrono::system_clock> &Message::getParseTime() const
{
return this->parseTime;
2017-04-12 17:46:44 +02:00
}
2017-01-07 20:43:55 +01:00
2017-04-12 17:46:44 +02:00
std::vector<Word> &Message::getWords()
{
return this->words;
2017-01-06 23:28:48 +01:00
}
2017-04-12 17:46:44 +02:00
bool Message::isDisabled() const
2017-01-07 20:43:55 +01:00
{
return this->disabled;
2017-01-07 20:43:55 +01:00
}
2017-01-28 20:29:02 +01:00
2017-04-12 17:46:44 +02:00
const QString &Message::getId() const
2017-01-28 20:29:02 +01:00
{
return this->id;
2017-01-18 21:30:23 +01:00
}
2017-01-28 20:29:02 +01:00
/// Static
Message *Message::createSystemMessage(const QString &text)
{
Message *message = new Message;
std::time_t t;
time(&t);
char timeStampBuffer[69];
// Add word for timestamp with no seconds
strftime(timeStampBuffer, 69, "%H:%M", localtime(&t));
QString timestampNoSeconds(timeStampBuffer);
message->getWords().push_back(Word(timestampNoSeconds, Word::TimestampNoSeconds,
MessageColor(MessageColor::System), QString(), QString()));
// Add word for timestamp with seconds
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&t));
QString timestampWithSeconds(timeStampBuffer);
message->getWords().push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds,
MessageColor(MessageColor::System), QString(), QString()));
Word word(text, Word::Type::Default, MessageColor(MessageColor::Type::System), text, text);
message->getWords().push_back(word);
return message;
}
2017-04-14 17:52:22 +02:00
} // namespace messages
} // namespace chatterino