--- a/QTfrontend/ui/widget/chatwidget.cpp Sun Nov 23 03:58:56 2014 +0100
+++ b/QTfrontend/ui/widget/chatwidget.cpp Sun Nov 23 05:03:11 2014 +0100
@@ -179,6 +179,8 @@
this->gameSettings = NULL;
this->notify = notify;
+ m_usersModel = NULL;
+
m_isAdmin = false;
m_autoKickEnabled = false;
@@ -409,26 +411,27 @@
void HWChatWidget::printChatString(
const QString & nick, const QString & str, const QString & cssClassPart, bool highlight)
{
- QSortFilterProxyModel * playersSortFilterModel = qobject_cast<QSortFilterProxyModel *>(chatNicks->model());
- if(!playersSortFilterModel)
- return;
-
- PlayersListModel * players = qobject_cast<PlayersListModel *>(playersSortFilterModel->sourceModel());
-
- if(!players)
+ if(!m_usersModel)
return;
// don't show chat lines that are from ignored nicks
- if (players->isFlagSet(nick, PlayersListModel::Ignore))
+ if (m_usersModel->isFlagSet(nick, PlayersListModel::Ignore))
return;
- bool isFriend = (!nick.isEmpty()) && players->isFlagSet(nick, PlayersListModel::Friend);
+ bool isFriend = (!nick.isEmpty()) && m_usersModel->isFlagSet(nick, PlayersListModel::Friend);
QString cssClass = (isFriend ? "msg_Friend" : "msg_User") + cssClassPart;
addLine(cssClass, str, highlight);
}
+bool HWChatWidget::isInGame() {
+ if (!m_usersModel)
+ return false;
+
+ return m_usersModel->isFlagSet(m_userNick, PlayersListModel::InGame);
+}
+
void HWChatWidget::addLine(const QString & cssClass, QString line, bool isHighlight)
{
if (s_displayNone->contains(cssClass))
@@ -452,7 +455,8 @@
{
line = QString("<span class=\"highlight\">%1</span>").arg(line);
SDLInteraction::instance().playSoundFile(m_hilightSound);
- HWApplication::alert(this, 800);
+ if (!isInGame())
+ HWApplication::alert(this, 800);
}
chatStrings.append(line);
@@ -853,6 +857,12 @@
chatNicks->setModel(model);
chatNicks->setModelColumn(0);
+
+ QSortFilterProxyModel * sfpModel = qobject_cast<QSortFilterProxyModel *>(model);
+ if (sfpModel)
+ m_usersModel = qobject_cast<PlayersListModel*>(sfpModel->sourceModel());
+ else
+ m_usersModel = qobject_cast<PlayersListModel*>(model);
}
void HWChatWidget::nicksContextMenuRequested(const QPoint &pos)
--- a/QTfrontend/ui/widget/chatwidget.h Sun Nov 23 03:58:56 2014 +0100
+++ b/QTfrontend/ui/widget/chatwidget.h Sun Nov 23 05:03:11 2014 +0100
@@ -32,6 +32,7 @@
#include "SDLInteraction.h"
#include "SmartLineEdit.h"
+#include "playerslistmodel.h"
class QTextBrowser;
class QLineEdit;
@@ -87,6 +88,7 @@
QString linkedNick(const QString & nickname);
void beforeContentAdd();
void afterContentAdd();
+ bool isInGame();
/**
* @brief Checks whether the message contains a highlight.
@@ -132,6 +134,7 @@
void consoleCommand(const QString & command);
private:
+ PlayersListModel* m_usersModel;
bool m_isAdmin;
QHBoxLayout mainLayout;
QTextBrowser* chatText;