+
+void QtUiMessageProcessor::checkForHighlight(Message &msg) {
+ if(!((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self)))
+ return;
+
+ //NotificationSettings notificationSettings;
+ 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();
+ }
+ foreach(QString nickname, nickList) {
+ QRegExp nickRegExp("^(.*\\W)?" + QRegExp::escape(nickname) + "(\\W.*)?$");
+ if(nickRegExp.exactMatch(msg.contents())) {
+ msg.setFlags(msg.flags() | Message::Highlight);
+ return;
+ }
+ }
+
+ for(int i = 0; i < _highlightRules.count(); i++) {
+ const HighlightRule &rule = _highlightRules[i];
+ if(!rule.isEnabled)
+ continue;
+
+ QRegExp userRegExp;
+ if(rule.isRegExp) {
+ userRegExp = QRegExp(rule.name, rule.caseSensitive);
+ } else {
+ userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(rule.name) + "(\\W.*)?$", rule.caseSensitive);
+ }
+ if(userRegExp.exactMatch(msg.contents())) {
+ msg.setFlags(msg.flags() | Message::Highlight);
+ return;
+ }
+ }
+ }
+}
+
+void QtUiMessageProcessor::highlightListChanged(const QVariant &variant) {
+ QVariantList varList = variant.toList();
+
+ _highlightRules.clear();
+ QVariantList::const_iterator iter = varList.constBegin();
+ QVariantList::const_iterator iterEnd = varList.constEnd();
+ while(iter != iterEnd) {
+ QVariantMap rule;
+ _highlightRules << HighlightRule(rule["name"].toString(),
+ rule["enable"].toBool(),
+ rule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive,
+ rule["regex"].toBool());
+ iter++;
+ }
+}
+
+void QtUiMessageProcessor::highlightNickChanged(const QVariant &variant) {
+ _highlightNick = (NotificationSettings::HighlightNickType)variant.toInt();
+}