-void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) {
- //checkForHighlight(msg);
- //QTime start = QTime::currentTime();
- foreach(QVariant v, msgs) {
- _messageModel->insertMessage(v.value<Message>());
- }
- //qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
-}
-
-void Client::layoutMsg() {
- if(layoutQueue.isEmpty()) {
- layoutTimer->stop();
- return;
- }
-
- Buffer *buffer = layoutQueue.takeFirst();
- if(buffer->layoutMsg()) {
- layoutQueue.append(buffer); // Buffer has more messages in its queue --> Round Robin
- return;
- }
-
- if(layoutQueue.isEmpty())
- layoutTimer->stop();
-}
-
-AbstractUiMsg *Client::layoutMsg(const Message &msg) {
- return instance()->mainUi->layoutMsg(msg);
-}
-
-void Client::checkForHighlight(Message &msg) {
- 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((msg.type() & (Message::Plain | Message::Notice | Message::Action))
- && !(msg.flags() & Message::Self)
- && 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((msg.type() & (Message::Plain | Message::Notice | Message::Action))
- && !(msg.flags() & Message::Self)
- && 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) {
- qWarning() << "Client::updateLastSeen(): Unknown buffer" << id;
- return;
- }
- b->setLastSeenMsg(msgId);