X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=eeb25d5847e4faf35f261b2025391f199955fa4f;hp=e532df8a812a24e5ebdcb5fab336dd2ec13073d5;hb=bd37d2c94e49e791d2ba44baab4270e030442832;hpb=dfbd0465f2a58eee4771472afd261869e5e5c400 diff --git a/src/client/client.cpp b/src/client/client.cpp index e532df8a..eeb25d58 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -77,7 +77,7 @@ Client::Client(QObject *parent) { _monitorBuffer = new Buffer(BufferInfo(), this); _signalProxy->synchronize(_ircListHelper); - + connect(_backlogManager, SIGNAL(backlog(BufferId, const QVariantList &)), this, SLOT(receiveBacklog(BufferId, const QVariantList &))); } @@ -321,7 +321,7 @@ void Client::setSyncedToCore() { // create a new BufferViewManager _bufferViewManager = new BufferViewManager(signalProxy(), this); - + _syncedToCore = true; emit connected(); emit coreConnectionStateChanged(true); @@ -335,7 +335,7 @@ void Client::disconnectFromCore() { if(!isConnected()) return; _connectedToCore = false; - + if(socket) { socket->close(); socket->deleteLater(); @@ -357,6 +357,7 @@ void Client::disconnectFromCore() { _bufferViewManager = 0; } + _messageModel->clear(); _networkModel->clear(); QHash::iterator bufferIter = _buffers.begin(); @@ -437,9 +438,11 @@ void Client::networkDestroyed() { } } -void Client::recvMessage(const Message &msg) { - //checkForHighlight(msg); +void Client::recvMessage(const Message &msg_) { + Message msg = msg_; + checkForHighlight(msg); _messageModel->insertMessage(msg); + buffer(msg.bufferInfo())->updateActivityLevel(msg); } void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) { @@ -447,10 +450,14 @@ void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) { } void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) { - //checkForHighlight(msg); + //QTime start = QTime::currentTime(); foreach(QVariant v, msgs) { - _messageModel->insertMessage(v.value()); + Message msg = v.value(); + checkForHighlight(msg); + _messageModel->insertMessage(msg); + buffer(msg.bufferInfo())->updateActivityLevel(msg); } + //qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime()); } void Client::layoutMsg() { @@ -458,7 +465,7 @@ void Client::layoutMsg() { layoutTimer->stop(); return; } - + Buffer *buffer = layoutQueue.takeFirst(); if(buffer->layoutMsg()) { layoutQueue.append(buffer); // Buffer has more messages in its queue --> Round Robin @@ -473,7 +480,11 @@ AbstractUiMsg *Client::layoutMsg(const Message &msg) { return instance()->mainUi->layoutMsg(msg); } +// 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()) { @@ -487,9 +498,7 @@ void Client::checkForHighlight(Message &msg) { } foreach(QString nickname, nickList) { QRegExp nickRegExp("^(.*\\W)?" + QRegExp::escape(nickname) + "(\\W.*)?$"); - if((msg.type() & (Message::Plain | Message::Notice | Message::Action)) - && !(msg.flags() & Message::Self) - && nickRegExp.exactMatch(msg.contents())) { + if(nickRegExp.exactMatch(msg.contents())) { msg.setFlags(msg.flags() | Message::Highlight); return; } @@ -507,9 +516,7 @@ void Client::checkForHighlight(Message &msg) { } else { userRegExp = QRegExp("^(.*\\W)?" + QRegExp::escape(name) + "(\\W.*)?$", caseSensitivity); } - if((msg.type() & (Message::Plain | Message::Notice | Message::Action)) - && !(msg.flags() & Message::Self) - && userRegExp.exactMatch(msg.contents())) { + if(userRegExp.exactMatch(msg.contents())) { msg.setFlags(msg.flags() | Message::Highlight); return; }