mirror-chatterino2/message.h

108 lines
2.5 KiB
C
Raw Normal View History

2017-01-05 16:07:20 +01:00
#ifndef MESSAGE_H
#define MESSAGE_H
#include "word.h"
2017-01-11 01:08:20 +01:00
#include "wordpart.h"
2017-01-05 16:07:20 +01:00
#include "channel.h"
2017-01-11 01:08:20 +01:00
#include <IrcMessage>
#include <QVector>
#include <chrono>
2017-01-05 16:07:20 +01:00
class Message
{
public:
Message(const QString& text);
2017-01-05 20:49:33 +01:00
Message(const IrcPrivateMessage& ircMessage, const Channel& Channel, bool enablePingSound = true,
bool isReceivedWhisper = false, bool isSentWhisper = false, bool includeChannel = false);
2017-01-05 16:07:20 +01:00
2017-01-11 01:08:20 +01:00
~Message() {
if (m_wordParts != NULL) {
delete m_wordParts;
}
}
2017-01-07 20:43:55 +01:00
bool canHighlightTab() const {
2017-01-05 16:07:20 +01:00
return m_highlightTab;
}
2017-01-07 20:43:55 +01:00
const QString& timeoutUser() const {
2017-01-05 16:07:20 +01:00
return m_timeoutUser;
}
2017-01-07 20:43:55 +01:00
int timeoutCount() const {
2017-01-05 16:07:20 +01:00
return m_timeoutCount;
}
2017-01-07 20:43:55 +01:00
const QString& userName() const {
2017-01-05 16:07:20 +01:00
return m_userName;
}
2017-01-07 20:43:55 +01:00
const QString& displayName() const {
2017-01-05 16:07:20 +01:00
return m_displayName;
}
2017-01-11 01:08:20 +01:00
const std::vector<Word> words() const {
2017-01-05 16:07:20 +01:00
return m_words;
}
2017-01-11 01:08:20 +01:00
const std::list<WordPart> wordParts() const {
return *m_wordParts;
}
2017-01-07 20:43:55 +01:00
bool disabled() const {
2017-01-05 16:07:20 +01:00
return m_disabled;
}
2017-01-07 20:43:55 +01:00
const QString& id() const {
2017-01-05 20:49:33 +01:00
return m_id;
}
2017-01-11 01:08:20 +01:00
int height() const {
return m_height;
}
bool layout(int width, bool enableEmoteMargins = true);
void requestRelayout() { m_relayoutRequested = true; }
void requestTextRecalculation() { m_recalculateText = true; }
void requestImageRecalculation() { m_recalculateImages = true; }
2017-01-05 16:07:20 +01:00
private:
static LazyLoadedImage* badgeStaff;
static LazyLoadedImage* badgeAdmin;
static LazyLoadedImage* badgeGlobalmod;
static LazyLoadedImage* badgeModerator;
static LazyLoadedImage* badgeTurbo;
static LazyLoadedImage* badgeBroadcaster;
static LazyLoadedImage* badgePremium;
2017-01-07 20:43:55 +01:00
static QRegularExpression* cheerRegex;
2017-01-05 16:07:20 +01:00
bool m_highlightTab = false;
QString m_timeoutUser = "";
int m_timeoutCount = 0;
bool m_disabled = false;
std::chrono::time_point<std::chrono::system_clock> m_parseTime;
QString m_userName = "";
QString m_displayName = "";
2017-01-05 20:49:33 +01:00
QString m_id = "";
2017-01-05 16:07:20 +01:00
2017-01-11 01:08:20 +01:00
int m_height = 0;
std::vector<Word> m_words;
std::list<WordPart>* m_wordParts;
long m_currentLayoutWidth = -1;
bool m_relayoutRequested = true;
bool m_recalculateText = true;
bool m_recalculateImages = true;
2017-01-06 23:28:48 +01:00
2017-01-07 20:43:55 +01:00
static QString matchLink(const QString& string);
2017-01-06 23:28:48 +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
};
#endif // MESSAGE_H