X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fmessage.h;h=878acfadc6b1806429915b423d6c38ca7aa969b0;hb=902c95728306e5ba115de84800fc8d5d239c9d62;hp=8cfa23add586ae54c9b95baec21342422f2767c4;hpb=6869909402a4dc807ee5261cc2a0999ac33053ee;p=quassel.git diff --git a/src/common/message.h b/src/common/message.h index 8cfa23ad..878acfad 100644 --- a/src/common/message.h +++ b/src/common/message.h @@ -21,33 +21,56 @@ #ifndef _MESSAGE_H_ #define _MESSAGE_H_ -#include +#include +#include +#include + +#include "bufferinfo.h" #include "global.h" -struct Message { +class Message { + Q_DECLARE_TR_FUNCTIONS(Message); + + 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 }; + + Message(BufferInfo buffer = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", quint8 flags = None); + + Message(QDateTime ts, BufferInfo buffer = BufferInfo(), Type type = Plain, QString text = "", QString sender = "", quint8 flags = None); + + MsgId msgId() const; + void setMsgId(MsgId id); + + BufferInfo buffer() const; + QString text() const; + QString sender() const; + Type type() const; + quint8 flags() const; + QDateTime timeStamp() const; - /** 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 }; + QString formattedTimeStamp(); + QString formattedSender(); + QString formattedText(); - uint msgId; - BufferId buffer; - QString target; - QString text; - QString sender; - Type type; - quint8 flags; - QDateTime timeStamp; + void format(); - 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(); } + private: + QDateTime _timeStamp; + MsgId _msgId; + BufferInfo _buffer; + QString _text; + QString _sender; + Type _type; + quint8 _flags; - 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(); } + QString _formattedTimeStamp, _formattedSender, _formattedText; // cache - 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) {} + /** Convert mIRC control codes to our own */ + QString mircToInternal(QString); + friend QDataStream &operator>>(QDataStream &in, Message &msg); }; QDataStream &operator<<(QDataStream &out, const Message &msg);