QTfrontend/ui/widget/chatwidget.cpp
changeset 6194 32b7e0ece99a
parent 6193 4f234aa06182
child 6197 4ce7c29799b9
equal deleted inserted replaced
6193:4f234aa06182 6194:32b7e0ece99a
    28 #include <QMenu>
    28 #include <QMenu>
    29 #include <QCursor>
    29 #include <QCursor>
    30 #include <QScrollBar>
    30 #include <QScrollBar>
    31 #include <QItemSelectionModel>
    31 #include <QItemSelectionModel>
    32 #include <QStringList>
    32 #include <QStringList>
    33 #include <QRegExp>
       
    34 
    33 
    35 
    34 
    36 #include "HWDataManager.h"
    35 #include "HWDataManager.h"
    37 #include "hwconsts.h"
    36 #include "hwconsts.h"
    38 #include "gameuiconfig.h"
    37 #include "gameuiconfig.h"
   466                 cssClass = "msg_FriendChat";
   465                 cssClass = "msg_FriendChat";
   467     }
   466     }
   468 
   467 
   469     bool isHL = (!nick.isEmpty() &&
   468     bool isHL = (!nick.isEmpty() &&
   470                 (nick != m_userNick) &&
   469                 (nick != m_userNick) &&
   471                 str.toLower().contains(
   470                 str.toLower().contains(m_hlRegExp));
   472                         QRegExp(QString("^(.* )?%1(( |: ).*)?$").
       
   473                             arg(QRegExp::escape(m_userNick).toLower())))
       
   474                 );
       
   475 
   471 
   476     addLine(cssClass, formattedStr, isHL);
   472     addLine(cssClass, formattedStr, isHL);
   477 }
   473 }
   478 
   474 
   479 void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight)
   475 void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight)
   543     chatEditLine->reset();
   539     chatEditLine->reset();
   544     chatText->clear();
   540     chatText->clear();
   545     chatStrings.clear();
   541     chatStrings.clear();
   546     chatNicks->clear();
   542     chatNicks->clear();
   547     m_userNick = gameSettings->value("net/nick","").toString();
   543     m_userNick = gameSettings->value("net/nick","").toString();
       
   544     m_hlRegExp = QRegExp(QString("^(.* )?%1(( |[^-a-z0-9_]( |$)).*)?$").
       
   545                             arg(QRegExp::escape(m_userNick).toLower()));
   548 }
   546 }
   549 
   547 
   550 void HWChatWidget::onKick()
   548 void HWChatWidget::onKick()
   551 {
   549 {
   552     QListWidgetItem * curritem = chatNicks->currentItem();
   550     QListWidgetItem * curritem = chatNicks->currentItem();