mirror-chatterino2/messages/message.h

139 lines
2.6 KiB
C
Raw Normal View History

2017-01-05 16:07:20 +01:00
#ifndef MESSAGE_H
#define MESSAGE_H
2017-01-11 18:52:09 +01:00
#include "channel.h"
2017-01-18 21:30:23 +01:00
#include "messages/word.h"
#include "messages/wordpart.h"
2017-01-05 16:07:20 +01:00
2017-01-11 01:08:20 +01:00
#include <IrcMessage>
#include <QVector>
#include <chrono>
2017-01-18 21:30:23 +01:00
namespace chatterino {
namespace messages {
2017-01-05 16:07:20 +01:00
class Message
{
public:
2017-01-11 18:52:09 +01:00
Message(const QString &text);
2017-01-26 17:48:14 +01:00
Message(const IrcPrivateMessage &ircMessage, Channel &Channel,
2017-01-11 18:52:09 +01:00
bool enablePingSound = true, bool isReceivedWhisper = false,
bool isSentWhisper = false, bool includeChannel = false);
2017-01-05 16:07:20 +01:00
2017-01-11 18:52:09 +01:00
~Message()
{
2017-01-11 01:08:20 +01:00
}
2017-01-11 18:52:09 +01:00
bool
2017-01-18 04:33:30 +01:00
getCanHighlightTab() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return highlightTab;
2017-01-05 16:07:20 +01:00
}
2017-01-11 18:52:09 +01:00
const QString &
2017-01-18 04:33:30 +01:00
getTimeoutUser() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return timeoutUser;
2017-01-05 16:07:20 +01:00
}
2017-01-11 18:52:09 +01:00
int
2017-01-18 04:33:30 +01:00
getTimeoutCount() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return timeoutCount;
2017-01-05 16:07:20 +01:00
}
2017-01-11 18:52:09 +01:00
const QString &
2017-01-18 04:33:30 +01:00
getUserName() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return userName;
2017-01-05 16:07:20 +01:00
}
2017-01-11 18:52:09 +01:00
const QString &
2017-01-18 04:33:30 +01:00
getDisplayName() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return displayName;
2017-01-05 16:07:20 +01:00
}
2017-01-11 18:52:09 +01:00
const std::vector<Word>
2017-01-18 04:33:30 +01:00
getWords() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return words;
2017-01-05 16:07:20 +01:00
}
2017-01-15 16:38:30 +01:00
const std::vector<WordPart>
2017-01-18 04:33:30 +01:00
getWordParts() const
2017-01-11 18:52:09 +01:00
{
2017-01-28 20:29:02 +01:00
return wordParts;
2017-01-11 01:08:20 +01:00
}
2017-01-11 18:52:09 +01:00
bool
2017-01-18 04:33:30 +01:00
getDisabled() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return disabled;
2017-01-05 16:07:20 +01:00
}
2017-01-11 18:52:09 +01:00
const QString &
2017-01-18 04:33:30 +01:00
getId() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return id;
2017-01-05 20:49:33 +01:00
}
2017-01-11 18:52:09 +01:00
int
2017-01-18 04:33:30 +01:00
getHeight() const
2017-01-11 18:52:09 +01:00
{
2017-01-18 04:33:30 +01:00
return height;
2017-01-11 01:08:20 +01:00
}
bool layout(int width, bool enableEmoteMargins = true);
2017-01-11 18:52:09 +01:00
void
requestRelayout()
{
2017-01-18 04:33:30 +01:00
relayoutRequested = true;
2017-01-11 18:52:09 +01:00
}
2017-01-11 01:08:20 +01:00
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
2017-01-18 04:33:30 +01:00
bool highlightTab = false;
QString timeoutUser = "";
int timeoutCount = 0;
bool disabled = false;
std::chrono::time_point<std::chrono::system_clock> parseTime;
2017-01-05 16:07:20 +01:00
2017-01-18 04:33:30 +01:00
QString userName = "";
QString displayName = "";
QString id = "";
2017-01-05 16:07:20 +01:00
2017-01-18 04:33:30 +01:00
int height = 0;
2017-01-11 01:08:20 +01:00
2017-01-18 04:33:30 +01:00
std::vector<Word> words;
2017-01-28 20:29:02 +01:00
std::vector<WordPart> wordParts;
2017-01-11 01:08:20 +01:00
2017-01-18 04:33:30 +01:00
long currentLayoutWidth = -1;
bool relayoutRequested = true;
int fontGeneration = -1;
int emoteGeneration = -1;
2017-01-06 23:28:48 +01:00
2017-01-28 20:29:02 +01:00
void alignWordParts(int lineStart, int lineHeight);
2017-01-11 18:52:09 +01:00
static QString matchLink(const QString &string);
2017-01-07 20:43:55 +01:00
2017-01-11 18:52:09 +01:00
static bool sortTwitchEmotes(
const std::pair<long int, LazyLoadedImage *> &a,
const std::pair<long int, LazyLoadedImage *> &b);
2017-01-05 16:07:20 +01:00
};
2017-01-28 20:29:02 +01:00
} // namespace messages
} // namespace chatterino
2017-01-05 16:07:20 +01:00
2017-01-11 18:52:09 +01:00
#endif // MESSAGE_H