2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
#include "messages/messageelement.hpp"
|
2018-01-06 03:48:56 +01:00
|
|
|
#include "widgets/helper/scrollbarhighlight.hpp"
|
2017-03-11 11:32:19 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
#include <cinttypes>
|
2017-04-12 17:46:44 +02:00
|
|
|
#include <memory>
|
2017-09-24 18:43:24 +02:00
|
|
|
#include <vector>
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
#include <QTime>
|
2017-03-11 11:32:19 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
namespace chatterino {
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace messages {
|
2017-04-12 17:46:44 +02:00
|
|
|
class Message;
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
typedef std::shared_ptr<Message> MessagePtr;
|
|
|
|
typedef uint8_t MessageFlagsType;
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-01-05 16:07:20 +01:00
|
|
|
class Message
|
|
|
|
{
|
|
|
|
public:
|
2018-01-06 00:02:04 +01:00
|
|
|
enum MessageFlags : MessageFlagsType {
|
2018-01-05 23:14:55 +01:00
|
|
|
None = 0,
|
2018-01-11 20:16:25 +01:00
|
|
|
System = (1 << 0),
|
|
|
|
Timeout = (1 << 1),
|
|
|
|
Highlighted = (1 << 2),
|
|
|
|
DoNotTriggerNotification = (1 << 3), // disable notification sound
|
|
|
|
Centered = (1 << 4),
|
|
|
|
Disabled = (1 << 5),
|
|
|
|
DisableCompactEmotes = (1 << 6),
|
|
|
|
Collapsed = (1 << 7),
|
2018-01-05 23:14:55 +01:00
|
|
|
};
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
// Elements
|
|
|
|
// Messages should not be added after the message is done initializing.
|
|
|
|
void addElement(MessageElement *element);
|
|
|
|
const std::vector<std::unique_ptr<MessageElement>> &getElements() const;
|
|
|
|
|
|
|
|
// Message flags
|
2018-01-05 23:14:55 +01:00
|
|
|
MessageFlags getFlags() const;
|
2018-01-11 20:16:25 +01:00
|
|
|
bool hasFlags(MessageFlags flags) const;
|
2018-01-17 02:22:57 +01:00
|
|
|
// void setFlags(MessageFlags flags);
|
2018-01-05 23:14:55 +01:00
|
|
|
void addFlags(MessageFlags flags);
|
|
|
|
void removeFlags(MessageFlags flags);
|
2018-01-11 20:16:25 +01:00
|
|
|
|
|
|
|
// Parse Time
|
|
|
|
const QTime &getParseTime() const;
|
|
|
|
|
|
|
|
// Id
|
2017-04-12 17:46:44 +02:00
|
|
|
const QString &getId() const;
|
2018-01-11 20:16:25 +01:00
|
|
|
void setId(const QString &id);
|
|
|
|
|
|
|
|
// Searching
|
|
|
|
const QString &getSearchText() const;
|
|
|
|
|
|
|
|
// Scrollbar
|
2018-01-06 03:48:56 +01:00
|
|
|
widgets::ScrollbarHighlight getScrollBarHighlight() const;
|
2017-01-05 20:49:33 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
// Usernames
|
2017-12-17 21:05:25 +01:00
|
|
|
QString loginName;
|
|
|
|
QString displayName;
|
|
|
|
QString localizedName;
|
2017-12-17 17:48:46 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
// Timeouts
|
|
|
|
const QString &getTimeoutUser(const QString &value) const;
|
|
|
|
void setTimeoutUser();
|
2017-06-06 21:18:05 +02:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
// Static
|
|
|
|
static MessagePtr createSystemMessage(const QString &text);
|
2017-12-16 18:11:36 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
static MessagePtr createTimeoutMessage(const QString &username,
|
|
|
|
const QString &durationInSeconds, const QString &reason,
|
|
|
|
bool multipleTimes);
|
2017-12-16 19:08:32 +01:00
|
|
|
|
2017-01-05 16:07:20 +01:00
|
|
|
private:
|
2017-01-11 18:52:09 +01:00
|
|
|
static QRegularExpression *cheerRegex;
|
2017-01-07 20:43:55 +01:00
|
|
|
|
2018-01-05 23:14:55 +01:00
|
|
|
MessageFlags flags = MessageFlags::None;
|
2018-01-11 20:16:25 +01:00
|
|
|
QString timeoutUser;
|
2017-12-19 00:09:38 +01:00
|
|
|
bool collapsedDefault = false;
|
2018-01-11 20:16:25 +01:00
|
|
|
QTime parseTime;
|
|
|
|
mutable QString searchText;
|
2017-06-13 22:03:29 +02:00
|
|
|
QString id = "";
|
2017-01-07 20:43:55 +01:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
std::vector<std::unique_ptr<MessageElement>> elements;
|
2017-01-05 16:07:20 +01:00
|
|
|
};
|
2017-01-28 20:29:02 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace messages
|
|
|
|
} // namespace chatterino
|