highlight lobbychat messages with own nick into

This commit is contained in:
doitux
2007-09-30 18:48:43 +00:00
parent 6fcc400443
commit 0e11228a95
4 changed files with 20 additions and 6 deletions
@@ -22,7 +22,7 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
{ {
setupUi(this); setupUi(this);
myChat = new LobbyChat(this); myChat = new LobbyChat(this, myConfig);
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
@@ -214,7 +214,7 @@ void gameLobbyDialogImpl::updateGameItem(QTreeWidgetItem *item, unsigned gameId)
if (info.mode == GAME_MODE_STARTED) if (info.mode == GAME_MODE_STARTED)
item->setData(2, Qt::DisplayRole, tr("running")); item->setData(2, Qt::DisplayRole, tr("running"));
else else
item->setData(2, Qt::DisplayRole, tr("registering")); item->setData(2, Qt::DisplayRole, tr("open"));
if (info.isPasswordProtected) if (info.isPasswordProtected)
item->setIcon(3, QIcon(myAppDataPath+"gfx/gui/misc/lock.png")); item->setIcon(3, QIcon(myAppDataPath+"gfx/gui/misc/lock.png"));
@@ -24,11 +24,12 @@
#include "gamelobbydialogimpl.h" #include "gamelobbydialogimpl.h"
#include "session.h" #include "session.h"
#include "configfile.h"
using namespace std; using namespace std;
LobbyChat::LobbyChat(gameLobbyDialogImpl* l) : myLobby(l) LobbyChat::LobbyChat(gameLobbyDialogImpl* l, ConfigFile *c) : myLobby(l), myConfig(c)
{ {
} }
@@ -114,7 +115,17 @@ void LobbyChat::playerLeft(QString playerName)
void LobbyChat::displayMessage(QString playerName, QString message) { void LobbyChat::displayMessage(QString playerName, QString message) {
myLobby->textBrowser_ChatDisplay->append(playerName + ": " + message); QString tempMsg;
cout << message.toStdString() << endl;
cout << QString::fromUtf8(myConfig->readConfigString("MyName").c_str()).toStdString() << endl;
if(message.contains(QString::fromUtf8(myConfig->readConfigString("MyName").c_str()), Qt::CaseInsensitive)) {
tempMsg = QString("<b>"+message+"</b>");
}
else {
tempMsg = message;
}
myLobby->textBrowser_ChatDisplay->append(playerName + ": " + tempMsg);
} }
void LobbyChat::checkInputLength(QString string) { void LobbyChat::checkInputLength(QString string) {
@@ -25,13 +25,14 @@
class gameLobbyDialogImpl; class gameLobbyDialogImpl;
class Session; class Session;
class ConfigFile;
class LobbyChat : public QObject class LobbyChat : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
LobbyChat(gameLobbyDialogImpl*); LobbyChat(gameLobbyDialogImpl*, ConfigFile*);
~LobbyChat(); ~LobbyChat();
@@ -53,8 +54,10 @@ public slots:
private: private:
gameLobbyDialogImpl *myLobby; gameLobbyDialogImpl *myLobby;
ConfigFile *myConfig;
QString myNick; QString myNick;
// friend class GuiWrapper; // friend class GuiWrapper;
}; };