+
+ // TODO: Cache this (per network)
+ const Network *net = Client::network(msg.bufferInfo().networkId());
+ if (net && !net->myNick().isEmpty()) {
+ QStringList nickList;
+ if (_highlightNick == NotificationSettings::CurrentNick) {
+ nickList << net->myNick();
+ }
+ else if (_highlightNick == NotificationSettings::AllNicks) {
+ const Identity *myIdentity = Client::identity(net->identity());
+ if (myIdentity)
+ nickList = myIdentity->nicks();
+ if (!nickList.contains(net->myNick()))
+ nickList.prepend(net->myNick());
+ }
+ foreach(QString nickname, nickList) {
+ QRegExp nickRegExp("(^|\\W)" + QRegExp::escape(nickname) + "(\\W|$)", _nicksCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
+ if (nickRegExp.indexIn(stripFormatCodes(msg.contents())) >= 0) {
+ msg.setFlags(msg.flags() | Message::Highlight);
+ return;
+ }
+ }
+
+ for (int i = 0; i < _highlightRules.count(); i++) {
+ const HighlightRule &rule = _highlightRules.at(i);
+ if (!rule.isEnabled)
+ continue;
+
+ if (rule.chanName.size() > 0 && rule.chanName.compare(".*") != 0) {
+ if (rule.chanName.startsWith("!")) {
+ QRegExp rx(rule.chanName.mid(1), Qt::CaseInsensitive);
+ if (rx.exactMatch(msg.bufferInfo().bufferName()))
+ continue;
+ }
+ else {
+ QRegExp rx(rule.chanName, Qt::CaseInsensitive);
+ if (!rx.exactMatch(msg.bufferInfo().bufferName()))
+ continue;
+ }
+ }
+
+ QRegExp rx;
+ if (rule.isRegExp) {
+ rx = QRegExp(rule.name, rule.caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
+ }
+ else {
+ rx = QRegExp("(^|\\W)" + QRegExp::escape(rule.name) + "(\\W|$)", rule.caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive);
+ }
+ bool match = (rx.indexIn(stripFormatCodes(msg.contents())) >= 0);
+ if (match) {
+ msg.setFlags(msg.flags() | Message::Highlight);
+ return;
+ }
+ }