407 } |
409 } |
408 |
410 |
409 void HWChatWidget::printChatString( |
411 void HWChatWidget::printChatString( |
410 const QString & nick, const QString & str, const QString & cssClassPart, bool highlight) |
412 const QString & nick, const QString & str, const QString & cssClassPart, bool highlight) |
411 { |
413 { |
412 QSortFilterProxyModel * playersSortFilterModel = qobject_cast<QSortFilterProxyModel *>(chatNicks->model()); |
414 if(!m_usersModel) |
413 if(!playersSortFilterModel) |
|
414 return; |
|
415 |
|
416 PlayersListModel * players = qobject_cast<PlayersListModel *>(playersSortFilterModel->sourceModel()); |
|
417 |
|
418 if(!players) |
|
419 return; |
415 return; |
420 |
416 |
421 // don't show chat lines that are from ignored nicks |
417 // don't show chat lines that are from ignored nicks |
422 if (players->isFlagSet(nick, PlayersListModel::Ignore)) |
418 if (m_usersModel->isFlagSet(nick, PlayersListModel::Ignore)) |
423 return; |
419 return; |
424 |
420 |
425 bool isFriend = (!nick.isEmpty()) && players->isFlagSet(nick, PlayersListModel::Friend); |
421 bool isFriend = (!nick.isEmpty()) && m_usersModel->isFlagSet(nick, PlayersListModel::Friend); |
426 |
422 |
427 QString cssClass = (isFriend ? "msg_Friend" : "msg_User") + cssClassPart; |
423 QString cssClass = (isFriend ? "msg_Friend" : "msg_User") + cssClassPart; |
428 |
424 |
429 addLine(cssClass, str, highlight); |
425 addLine(cssClass, str, highlight); |
|
426 } |
|
427 |
|
428 bool HWChatWidget::isInGame() { |
|
429 if (!m_usersModel) |
|
430 return false; |
|
431 |
|
432 return m_usersModel->isFlagSet(m_userNick, PlayersListModel::InGame); |
430 } |
433 } |
431 |
434 |
432 void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight) |
435 void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight) |
433 { |
436 { |
434 if (s_displayNone->contains(cssClass)) |
437 if (s_displayNone->contains(cssClass)) |
450 |
453 |
451 if (isHighlight) |
454 if (isHighlight) |
452 { |
455 { |
453 line = QString("<span class=\"highlight\">%1</span>").arg(line); |
456 line = QString("<span class=\"highlight\">%1</span>").arg(line); |
454 SDLInteraction::instance().playSoundFile(m_hilightSound); |
457 SDLInteraction::instance().playSoundFile(m_hilightSound); |
455 HWApplication::alert(this, 800); |
458 if (!isInGame()) |
|
459 HWApplication::alert(this, 800); |
456 } |
460 } |
457 |
461 |
458 chatStrings.append(line); |
462 chatStrings.append(line); |
459 |
463 |
460 chatText->setHtml("<html><body>"+chatStrings.join("<br>")+"</body></html>"); |
464 chatText->setHtml("<html><body>"+chatStrings.join("<br>")+"</body></html>"); |
851 { |
855 { |
852 chatNicks->selectionModel()->deleteLater(); |
856 chatNicks->selectionModel()->deleteLater(); |
853 |
857 |
854 chatNicks->setModel(model); |
858 chatNicks->setModel(model); |
855 chatNicks->setModelColumn(0); |
859 chatNicks->setModelColumn(0); |
|
860 |
|
861 QSortFilterProxyModel * sfpModel = qobject_cast<QSortFilterProxyModel *>(model); |
|
862 if (sfpModel) |
|
863 m_usersModel = qobject_cast<PlayersListModel*>(sfpModel->sourceModel()); |
|
864 else |
|
865 m_usersModel = qobject_cast<PlayersListModel*>(model); |
856 } |
866 } |
857 |
867 |
858 void HWChatWidget::nicksContextMenuRequested(const QPoint &pos) |
868 void HWChatWidget::nicksContextMenuRequested(const QPoint &pos) |
859 { |
869 { |
860 QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); |
870 QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); |