X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fmessage.h;h=7fcd797cdcd5a1b54d59423bb91bc1d9842509a8;hp=65d28280fafe0751231c9054c61742ec20ccab41;hb=de1613db2dd9623aa650f7217eb718381bb642e3;hpb=de9a7ec6b70c796182e0a7992aa380a58b954b94 diff --git a/src/common/message.h b/src/common/message.h index 65d28280..7fcd797c 100644 --- a/src/common/message.h +++ b/src/common/message.h @@ -21,33 +21,54 @@ #ifndef _MESSAGE_H_ #define _MESSAGE_H_ +#include #include #include #include "global.h" -struct Message { +class Message { + Q_DECLARE_TR_FUNCTIONS(Message); - /** The different types a message can have for display */ - enum Type { Plain, Notice, Action, Nick, Mode, Join, Part, Quit, Kick, Kill, Server, Info, Error }; - enum Flags { None = 0, Self = 1, PrivMsg = 2, Highlight = 4 }; + public: + /** The different types a message can have for display */ + enum Type { Plain, Notice, Action, Nick, Mode, Join, Part, Quit, Kick, Kill, Server, Info, Error }; + enum Flags { None = 0, Self = 1, PrivMsg = 2, Highlight = 4 }; - uint msgId; - BufferId buffer; - QString text; - QString sender; - Type type; - quint8 flags; - QDateTime timeStamp; + Message(BufferId buffer = BufferId(), Type type = Plain, QString text = "", QString sender = "", quint8 flags = None); - //Message(QString _target, Type _type = Plain, QString _text = "", QString _sender = "", quint8 _flags = None) - //: target(_target), text(_text), sender(_sender), type(_type), flags(_flags) { timeStamp = QDateTime::currentDateTime().toUTC(); } + Message(QDateTime ts, BufferId buffer = BufferId(), Type type = Plain, QString text = "", QString sender = "", quint8 flags = None); - Message(BufferId _buffer = BufferId(), Type _type = Plain, QString _text = "", QString _sender = "", quint8 _flags = None) - : buffer(_buffer), text(_text), sender(_sender), type(_type), flags(_flags) { timeStamp = QDateTime::currentDateTime().toUTC(); } + MsgId msgId() const; + void setMsgId(MsgId id); - Message(QDateTime _ts, BufferId _buffer = BufferId(), Type _type = Plain, QString _text = "", QString _sender = "", quint8 _flags = None) - : buffer(_buffer), text(_text), sender(_sender), type(_type), flags(_flags), timeStamp(_ts) {} + BufferId buffer() const; + QString text() const; + QString sender() const; + Type type() const; + quint8 flags() const; + QDateTime timeStamp() const; + + QString formattedTimeStamp(); + QString formattedSender(); + QString formattedText(); + + void format(); + + private: + QDateTime _timeStamp; + MsgId _msgId; + BufferId _buffer; + QString _text; + QString _sender; + Type _type; + quint8 _flags; + + QString _formattedTimeStamp, _formattedSender, _formattedText; // cache + + QString mircToInternal(QString); + + friend QDataStream &operator>>(QDataStream &in, Message &msg); };