mirror-chatterino2/src/messages/Message.hpp

65 lines
1.7 KiB
C++
Raw Normal View History

#pragma once
2017-01-05 16:07:20 +01:00
2018-06-26 17:20:03 +02:00
#include "common/FlagsEnum.hpp"
2018-06-26 14:09:39 +02:00
#include "widgets/helper/ScrollbarHighlight.hpp"
#include <QTime>
#include <boost/noncopyable.hpp>
#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
namespace chatterino {
class MessageElement;
2019-03-20 20:46:20 +01:00
enum class MessageFlag : uint32_t {
2018-08-07 07:55:31 +02:00
None = 0,
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),
ConnectedMessage = (1 << 8),
DisconnectedMessage = (1 << 9),
Untimeout = (1 << 10),
PubSub = (1 << 11),
Subscription = (1 << 12),
DoNotLog = (1 << 13),
AutoMod = (1 << 14),
RecentMessage = (1 << 15),
2019-03-20 20:46:20 +01:00
Whisper = (1 << 16)
2018-08-07 07:55:31 +02:00
};
using MessageFlags = FlagsEnum<MessageFlag>;
2018-01-05 23:14:55 +01:00
2018-08-07 07:55:31 +02:00
struct Message : boost::noncopyable {
2018-08-07 01:35:24 +02:00
Message();
~Message();
// Making this a mutable means that we can update a messages flags,
// while still keeping Message constant. This means that a message's flag
// can be updated without the renderer being made aware, which might be bad.
// This is a temporary effort until we can figure out what the right
// const-correct way to deal with this is.
// This might bring race conditions with it
mutable MessageFlags flags;
2018-01-28 03:29:42 +01:00
QTime parseTime;
QString id;
QString searchText;
QString messageText;
2018-01-28 03:29:42 +01:00
QString loginName;
QString displayName;
QString localizedName;
QString timeoutUser;
uint32_t count = 1;
2018-08-07 01:35:24 +02:00
std::vector<std::unique_ptr<MessageElement>> elements;
2018-06-26 17:06:17 +02:00
ScrollbarHighlight getScrollBarHighlight() const;
2017-01-05 16:07:20 +01:00
};
2017-01-28 20:29:02 +01:00
2018-08-07 01:35:24 +02:00
using MessagePtr = std::shared_ptr<const Message>;
2017-04-14 17:52:22 +02:00
} // namespace chatterino