mirror-chatterino2/src/messages/message.hpp

96 lines
2.4 KiB
C++
Raw Normal View History

#pragma once
2017-01-05 16:07:20 +01:00
2017-06-11 09:31:45 +02:00
#include "messages/word.hpp"
2018-01-06 03:48:56 +01:00
#include "widgets/helper/scrollbarhighlight.hpp"
2017-01-11 01:08:20 +01:00
#include <chrono>
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
2017-04-14 17:52:22 +02:00
namespace chatterino {
class Channel;
2017-04-14 17:52:22 +02:00
namespace messages {
2017-04-12 17:46:44 +02:00
class Message;
typedef std::shared_ptr<Message> SharedMessage;
2018-01-06 00:02:04 +01:00
typedef char 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,
System = (1 << 1),
Timeout = (1 << 2),
2018-01-06 03:48:56 +01:00
Highlighted = (1 << 3),
2018-01-05 23:14:55 +01:00
};
bool containsHighlightedPhrase() const;
2017-09-24 18:43:24 +02:00
void setHighlight(bool value);
2017-04-12 17:46:44 +02:00
const QString &getTimeoutUser() const;
int getTimeoutCount() const;
const QString &getContent() const;
const std::chrono::time_point<std::chrono::system_clock> &getParseTime() const;
std::vector<Word> &getWords();
2018-01-05 23:14:55 +01:00
MessageFlags getFlags() const;
void setFlags(MessageFlags flags);
void addFlags(MessageFlags flags);
void removeFlags(MessageFlags flags);
2017-04-12 17:46:44 +02:00
bool isDisabled() const;
void setDisabled(bool value);
2017-04-12 17:46:44 +02:00
const QString &getId() const;
bool getCollapsedDefault() const;
void setCollapsedDefault(bool value);
2018-01-05 01:31:01 +01:00
bool getDisableCompactEmotes() const;
void setDisableCompactEmotes(bool value);
2018-01-05 13:42:23 +01:00
void updateContent() const;
2018-01-06 03:48:56 +01:00
widgets::ScrollbarHighlight getScrollBarHighlight() const;
2017-01-05 20:49:33 +01:00
QString loginName;
QString displayName;
QString localizedName;
QString timeoutUser;
2017-12-17 17:48:46 +01:00
const QString text;
bool centered = false;
2017-06-06 21:18:05 +02:00
static Message *createSystemMessage(const QString &text);
static Message *createTimeoutMessage(const QString &username, const QString &durationInSeconds,
2018-01-05 23:14:55 +01:00
const QString &reason, bool multipleTimes);
2017-01-05 16:07:20 +01:00
private:
2017-01-11 18:52:09 +01:00
static LazyLoadedImage *badgeStaff;
static LazyLoadedImage *badgeAdmin;
static LazyLoadedImage *badgeGlobalmod;
static LazyLoadedImage *badgeModerator;
static LazyLoadedImage *badgeTurbo;
static LazyLoadedImage *badgeBroadcaster;
static LazyLoadedImage *badgePremium;
2017-01-05 16:07:20 +01:00
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;
2017-09-24 18:43:24 +02:00
// what is highlightTab?
bool highlightTab = false;
2017-09-24 18:43:24 +02:00
int timeoutCount = 0;
bool disabled = false;
bool collapsedDefault = false;
2018-01-05 01:31:01 +01:00
bool disableCompactEmotes = false;
std::chrono::time_point<std::chrono::system_clock> parseTime;
2017-01-28 20:29:02 +01:00
2018-01-05 13:42:23 +01:00
mutable QString content;
QString id = "";
2017-01-07 20:43:55 +01:00
std::vector<Word> words;
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