+QString UiStyle::StyledMessage::plainSender() const {
+ switch(type()) {
+ case Message::Plain:
+ case Message::Notice:
+ return nickFromMask(sender());
+ default:
+ return QString();
+ }
+}
+
+QString UiStyle::StyledMessage::decoratedSender() const {
+ switch(type()) {
+ case Message::Plain:
+ return tr("<%1>").arg(plainSender()); break;
+ case Message::Notice:
+ return tr("[%1]").arg(plainSender()); break;
+ case Message::Server:
+ return tr("*"); break;
+ case Message::Error:
+ return tr("*"); break;
+ case Message::Join:
+ return tr("-->"); break;
+ case Message::Part:
+ return tr("<--"); break;
+ case Message::Quit:
+ return tr("<--"); break;
+ case Message::Kick:
+ return tr("<-*"); break;
+ case Message::Nick:
+ return tr("<->"); break;
+ case Message::Mode:
+ return tr("***"); break;
+ case Message::Action:
+ return tr("-*-"); break;
+ default:
+ return tr("%1").arg(plainSender());
+ }
+}
+
+UiStyle::FormatType UiStyle::StyledMessage::senderFormat() const {
+ switch(type()) {
+ case Message::Plain:
+ return UiStyle::Sender; break;
+ case Message::Notice:
+ return UiStyle::NoticeMsg; break;
+ case Message::Server:
+ return UiStyle::ServerMsg; break;
+ case Message::Error:
+ return UiStyle::ErrorMsg; break;
+ case Message::Join:
+ return UiStyle::JoinMsg; break;
+ case Message::Part:
+ return UiStyle::PartMsg; break;
+ case Message::Quit:
+ return UiStyle::QuitMsg; break;
+ case Message::Kick:
+ return UiStyle::KickMsg; break;
+ case Message::Nick:
+ return UiStyle::RenameMsg; break;
+ case Message::Mode:
+ return UiStyle::ModeMsg; break;
+ case Message::Action:
+ return UiStyle::ActionMsg; break;
+ default:
+ return UiStyle::ErrorMsg;
+ }
+}
+
+
+/***********************************************************************************/
+
+QDataStream &operator<<(QDataStream &out, const UiStyle::FormatList &formatList) {
+ out << formatList.count();
+ UiStyle::FormatList::const_iterator it = formatList.begin();
+ while(it != formatList.end()) {
+ out << (*it).first << (*it).second;
+ ++it;
+ }
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, UiStyle::FormatList &formatList) {
+ quint16 cnt;
+ in >> cnt;
+ for(quint16 i = 0; i < cnt; i++) {
+ quint16 pos; quint32 ftype;
+ in >> pos >> ftype;
+ formatList.append(qMakePair((quint16)pos, ftype));
+ }
+ return in;
+}