+void UiStyle::StyledMessage::style() const {
+ QString user = userFromMask(sender());
+ QString host = hostFromMask(sender());
+ QString nick = nickFromMask(sender());
+ QString txt = UiStyle::mircToInternal(contents());
+ QString bufferName = bufferInfo().bufferName();
+ bufferName.replace('%', "%%"); // well, you _can_ have a % in a buffername apparently... -_-
+ host.replace('%', "%%"); // hostnames too...
+ user.replace('%', "%%"); // and the username.
+ const int maxNetsplitNicks = 15;
+
+ QString t;
+ switch(type()) {
+ case Message::Plain:
+ //: Plain Message
+ t = tr("%1").arg(txt); break;
+ case Message::Notice:
+ //: Notice Message
+ t = tr("%1").arg(txt); break;
+ case Message::Action:
+ //: Action Message
+ t = tr("%DN%1%DN %2").arg(nick).arg(txt);
+ break;
+ case Message::Nick:
+ //: Nick Message
+ if(nick == contents()) t = tr("You are now known as %DN%1%DN").arg(txt);
+ else t = tr("%DN%1%DN is now known as %DN%2%DN").arg(nick, txt);
+ break;
+ case Message::Mode:
+ //: Mode Message
+ if(nick.isEmpty()) t = tr("User mode: %DM%1%DM").arg(txt);
+ else t = tr("Mode %DM%1%DM by %DN%2%DN").arg(txt, nick);
+ break;
+ case Message::Join:
+ //: Join Message
+ t = tr("%DN%1%DN %DH(%2@%3)%DH has joined %DC%4%DC").arg(nick, user, host, bufferName); break;
+ case Message::Part:
+ //: Part Message
+ t = tr("%DN%1%DN %DH(%2@%3)%DH has left %DC%4%DC").arg(nick, user, host, bufferName);
+ if(!txt.isEmpty()) t = QString("%1 (%2)").arg(t).arg(txt);
+ break;
+ case Message::Quit:
+ //: Quit Message
+ t = tr("%DN%1%DN %DH(%2@%3)%DH has quit").arg(nick, user, host);
+ if(!txt.isEmpty()) t = QString("%1 (%2)").arg(t).arg(txt);
+ break;
+ case Message::Kick: {
+ QString victim = txt.section(" ", 0, 0);
+ QString kickmsg = txt.section(" ", 1);
+ //: Kick Message
+ t = tr("%DN%1%DN has kicked %DN%2%DN from %DC%3%DC").arg(nick).arg(victim).arg(bufferName);
+ if(!kickmsg.isEmpty()) t = QString("%1 (%2)").arg(t).arg(kickmsg);
+ }
+ break;
+ //case Message::Kill: FIXME
+
+ case Message::Server:
+ //: Server Message
+ t = tr("%1").arg(txt); break;
+ case Message::Info:
+ //: Info Message
+ t = tr("%1").arg(txt); break;
+ case Message::Error:
+ //: Error Message
+ t = tr("%1").arg(txt); break;
+ case Message::DayChange:
+ //: Day Change Message
+ t = tr("{Day changed to %1}").arg(timestamp().toString());
+ break;
+ case Message::Topic:
+ //: Topic Message
+ t = tr("%1").arg(txt); break;
+ case Message::NetsplitJoin: {
+ QStringList users = txt.split("#:#");
+ QStringList servers = users.takeLast().split(" ");
+
+ for(int i = 0; i < users.count() && i < maxNetsplitNicks; i++)
+ users[i] = nickFromMask(users.at(i));
+
+ t = tr("Netsplit between %DH%1%DH and %DH%2%DH ended. Users joined: ").arg(servers.at(0),servers.at(1));
+ if(users.count() <= maxNetsplitNicks)
+ t.append(QString("%DN%1%DN").arg(users.join(", ")));
+ else
+ t.append(tr("%DN%1%DN (%2 more)").arg(static_cast<QStringList>(users.mid(0, maxNetsplitNicks)).join(", ")).arg(users.count() - maxNetsplitNicks));
+ }
+ break;
+ case Message::NetsplitQuit: {
+ QStringList users = txt.split("#:#");
+ QStringList servers = users.takeLast().split(" ");
+
+ for(int i = 0; i < users.count() && i < maxNetsplitNicks; i++)
+ users[i] = nickFromMask(users.at(i));
+
+ t = tr("Netsplit between %DH%1%DH and %DH%2%DH. Users quit: ").arg(servers.at(0),servers.at(1));
+
+ if(users.count() <= maxNetsplitNicks)
+ t.append(QString("%DN%1%DN").arg(users.join(", ")));
+ else
+ t.append(tr("%DN%1%DN (%2 more)").arg(static_cast<QStringList>(users.mid(0, maxNetsplitNicks)).join(", ")).arg(users.count() - maxNetsplitNicks));
+ }
+ break;
+ default:
+ t = tr("[%1]").arg(txt);