+ }
+
+ // Now, figure out the message type
+ if (!msgType.isEmpty()) {
+ if (msgType == "plain")
+ fmtType |= UiStyle::PlainMsg;
+ else if (msgType == "notice")
+ fmtType |= UiStyle::NoticeMsg;
+ else if (msgType == "action")
+ fmtType |= UiStyle::ActionMsg;
+ else if (msgType == "nick")
+ fmtType |= UiStyle::NickMsg;
+ else if (msgType == "mode")
+ fmtType |= UiStyle::ModeMsg;
+ else if (msgType == "join")
+ fmtType |= UiStyle::JoinMsg;
+ else if (msgType == "part")
+ fmtType |= UiStyle::PartMsg;
+ else if (msgType == "quit")
+ fmtType |= UiStyle::QuitMsg;
+ else if (msgType == "kick")
+ fmtType |= UiStyle::KickMsg;
+ else if (msgType == "kill")
+ fmtType |= UiStyle::KillMsg;
+ else if (msgType == "server")
+ fmtType |= UiStyle::ServerMsg;
+ else if (msgType == "info")
+ fmtType |= UiStyle::InfoMsg;
+ else if (msgType == "error")
+ fmtType |= UiStyle::ErrorMsg;
+ else if (msgType == "daychange")
+ fmtType |= UiStyle::DayChangeMsg;
+ else if (msgType == "topic")
+ fmtType |= UiStyle::TopicMsg;
+ else if (msgType == "netsplit-join")
+ fmtType |= UiStyle::NetsplitJoinMsg;
+ else if (msgType == "netsplit-quit")
+ fmtType |= UiStyle::NetsplitQuitMsg;
+ else if (msgType == "invite")
+ fmtType |= UiStyle::InviteMsg;
+ else {
+ qWarning() << Q_FUNC_INFO << tr("Invalid message type in %1").arg(decl);
+ }
+ }
+
+ // Next up: conditional (formats, labels, nickhash)
+ QRegExp condRx("\\s*([\\w\\-]+)\\s*=\\s*\"(\\w+)\"\\s*");
+ if (!conditions.isEmpty()) {
+ foreach(const QString &cond, conditions.split(',', QString::SkipEmptyParts)) {
+ if (!condRx.exactMatch(cond)) {
+ qWarning() << Q_FUNC_INFO << tr("Invalid condition %1").arg(cond);
+ return UiStyle::Invalid;
+ }
+ QString condName = condRx.cap(1);
+ QString condValue = condRx.cap(2);
+ if (condName == "label") {
+ quint64 labeltype = 0;
+ if (condValue == "highlight")
+ labeltype = UiStyle::Highlight;
+ else if (condValue == "selected")
+ labeltype = UiStyle::Selected;
+ else {
+ qWarning() << Q_FUNC_INFO << tr("Invalid message label: %1").arg(condValue);
+ return UiStyle::Invalid;
+ }
+ fmtType |= (labeltype << 32);
+ }
+ else if (condName == "sender") {
+ if (condValue == "self")
+ fmtType |= (quint64) UiStyle::OwnMsg << 32; // sender="self" is actually treated as a label
+ else {
+ bool ok = true;
+ quint64 val = condValue.toUInt(&ok, 16);
+ if (!ok) {
+ qWarning() << Q_FUNC_INFO << tr("Invalid senderhash specification: %1").arg(condValue);
+ return UiStyle::Invalid;
+ }
+ if (val >= 16) {
+ qWarning() << Q_FUNC_INFO << tr("Senderhash can be at most \"0x0f\"!");
+ return UiStyle::Invalid;
+ }
+ fmtType |= ++val << 48;
+ }
+ }
+ else if (condName == "format") {
+ if (condValue == "bold")
+ fmtType |= UiStyle::Bold;
+ else if (condValue == "italic")
+ fmtType |= UiStyle::Italic;
+ else if (condValue == "underline")
+ fmtType |= UiStyle::Underline;
+ else if (condValue == "reverse")
+ fmtType |= UiStyle::Reverse;
+ else {
+ qWarning() << Q_FUNC_INFO << tr("Invalid format name: %1").arg(condValue);
+ return UiStyle::Invalid;
+ }