Move message timestamp-code to its own function

This commit is contained in:
Rasmus Karlsson 2017-12-16 19:03:22 +01:00
parent 87203c1120
commit b39034ab74

View file

@ -70,11 +70,10 @@ const QString &Message::getId() const
return this->id;
}
/// Static
Message *Message::createSystemMessage(const QString &text)
{
Message *message = new Message;
namespace {
void AddCurrentTimestamp(Message *message)
{
std::time_t t;
time(&t);
char timeStampBuffer[69];
@ -90,6 +89,23 @@ Message *Message::createSystemMessage(const QString &text)
QString timestampWithSeconds(timeStampBuffer);
message->getWords().push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds,
MessageColor(MessageColor::System), QString(), QString()));
}
} // namespace
/// Static
Message *Message::createSystemMessage(const QString &text)
{
Message *message = new Message;
AddCurrentTimestamp(message);
Word word(text, Word::Type::Default, MessageColor(MessageColor::Type::System), text, text);
message->getWords().push_back(word);
return message;
}
Word word(text, Word::Type::Default, MessageColor(MessageColor::Type::System), text, text);