//qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
}
-// TODO optimize checkForHighlight
-void Client::checkForHighlight(Message &msg) {
- if(!((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self)))
- return;
-
- NotificationSettings notificationSettings;
- const Network *net = network(msg.bufferInfo().networkId());
- if(net && !net->myNick().isEmpty()) {
- QStringList nickList;
- if(notificationSettings.highlightNick() == NotificationSettings::CurrentNick) {
- nickList << net->myNick();
- } else if(notificationSettings.highlightNick() == NotificationSettings::AllNicks) {
- const Identity *myIdentity = 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;
- }
- }
-
- foreach(QVariant highlight, notificationSettings.highlightList()) {
- QVariantMap highlightRule = highlight.toMap();
- if(!highlightRule["enable"].toBool())
- continue;
- Qt::CaseSensitivity caseSensitivity = highlightRule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive;
- QString name = highlightRule["name"].toString();
- QRegExp userRegExp;
- if(highlightRule["regex"].toBool()) {
- userRegExp = QRegExp(name, caseSensitivity);
- } else {
- userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(name) + "(\\W.*)?$", caseSensitivity);
- }
- if(userRegExp.exactMatch(msg.contents())) {
- msg.setFlags(msg.flags() | Message::Highlight);
- return;
- }
- }
- }
-}
-
void Client::updateLastSeenMsg(BufferId id, const MsgId &msgId) {
Buffer *b = buffer(id);
if(!b) {
Q_OBJECT
public:
+ enum ClientMode {
+ LocalCore,
+ RemoteCore
+ };
+
static Client *instance();
static void destroy();
static void init(AbstractUi *);
static void userInput(BufferInfo bufferInfo, QString message);
- enum ClientMode { LocalCore, RemoteCore };
-
- static void checkForHighlight(Message &msg);
static void setBufferLastSeenMsg(BufferId id, const MsgId &msgId); // this is synced to core and other clients
static void removeBuffer(BufferId id);
#include "qtuimessageprocessor.h"
#include "client.h"
+#include "clientsettings.h"
+#include "identity.h"
#include "messagemodel.h"
+#include "network.h"
QtUiMessageProcessor::QtUiMessageProcessor(QObject *parent) : AbstractMessageProcessor(parent) {
}
void QtUiMessageProcessor::processMessage(Message &msg) {
- Client::checkForHighlight(msg);
+ checkForHighlight(msg);
Client::messageModel()->insertMessage(msg);
}
void QtUiMessageProcessor::processMessages(QList<Message> &msgs) {
foreach(Message msg, msgs) {
- Client::checkForHighlight(msg);
+ checkForHighlight(msg);
Client::messageModel()->insertMessage(msg);
}
}
+
+// TODO optimize checkForHighlight
+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(notificationSettings.highlightNick() == NotificationSettings::CurrentNick) {
+ nickList << net->myNick();
+ } else if(notificationSettings.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;
+ }
+ }
+
+ foreach(QVariant highlight, notificationSettings.highlightList()) {
+ QVariantMap highlightRule = highlight.toMap();
+ if(!highlightRule["enable"].toBool())
+ continue;
+ Qt::CaseSensitivity caseSensitivity = highlightRule["cs"].toBool() ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ QString name = highlightRule["name"].toString();
+ QRegExp userRegExp;
+ if(highlightRule["regex"].toBool()) {
+ userRegExp = QRegExp(name, caseSensitivity);
+ } else {
+ userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(name) + "(\\W.*)?$", caseSensitivity);
+ }
+ if(userRegExp.exactMatch(msg.contents())) {
+ msg.setFlags(msg.flags() | Message::Highlight);
+ return;
+ }
+ }
+ }
+}
QtUiMessageProcessor(QObject *parent);
- protected:
+ private:
void processMessage(Message &msg);
void processMessages(QList<Message> &msgs);
+ void checkForHighlight(Message &msg);
+
};
#endif