2007-05-24 22:50:18 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2006 by FThauer FHammer *
|
|
|
|
|
* f.thauer@web.de *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
#include "chat.h"
|
|
|
|
|
|
|
|
|
|
#include "mainwindowimpl.h"
|
2007-05-25 00:09:51 +00:00
|
|
|
#include "session.h"
|
2007-10-12 11:07:42 +00:00
|
|
|
#include "chattools.h"
|
|
|
|
|
#include "configfile.h"
|
2007-05-24 22:50:18 +00:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
Chat::Chat(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
|
|
|
|
|
{
|
2007-10-12 11:07:42 +00:00
|
|
|
myChatTools = new ChatTools(myW->lineEdit_ChatInput);
|
2007-10-12 18:45:28 +00:00
|
|
|
|
2007-05-24 22:50:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Chat::~Chat()
|
|
|
|
|
{
|
|
|
|
|
delete myConfig;
|
|
|
|
|
myConfig = 0;
|
|
|
|
|
}
|
2007-05-25 00:09:51 +00:00
|
|
|
|
|
|
|
|
void Chat::sendMessage() {
|
2007-10-12 18:45:28 +00:00
|
|
|
|
|
|
|
|
fillChatLinesHistory(myW->lineEdit_ChatInput->text());
|
2007-05-25 00:09:51 +00:00
|
|
|
myW->getSession().sendChatMessage(myW->lineEdit_ChatInput->text().toUtf8().constData());
|
|
|
|
|
myW->lineEdit_ChatInput->setText("");
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-25 16:03:12 +00:00
|
|
|
void Chat::receiveMessage(QString playerName, QString message) {
|
2007-05-25 10:49:26 +00:00
|
|
|
|
2007-05-25 16:03:12 +00:00
|
|
|
myW->textBrowser_Chat->append(playerName + ": " + message);
|
2007-05-25 10:49:26 +00:00
|
|
|
checkInvisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Chat::checkInvisible() {
|
|
|
|
|
|
2007-05-28 13:13:48 +00:00
|
|
|
switch (myW->tabWidget_Left->currentIndex()) {
|
2007-05-25 10:49:26 +00:00
|
|
|
|
2007-05-28 13:13:48 +00:00
|
|
|
case 1: { myW->tabWidget_Left->stopBlinkChatTab();
|
|
|
|
|
myW->tabWidget_Left->showDefaultChatTab();
|
2007-05-25 18:14:52 +00:00
|
|
|
}
|
2007-05-25 10:49:26 +00:00
|
|
|
break;
|
2007-05-28 13:13:48 +00:00
|
|
|
default: { myW->tabWidget_Left->startBlinkChatTab(); }
|
2007-05-25 10:49:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-05-25 17:57:03 +00:00
|
|
|
|
|
|
|
|
void Chat::checkInputLength(QString string) {
|
|
|
|
|
|
|
|
|
|
if(string.toUtf8().length() > 120) myW->lineEdit_ChatInput->setMaxLength(string.length());
|
|
|
|
|
}
|
2007-05-28 19:56:57 +00:00
|
|
|
|
|
|
|
|
void Chat::clearNewGame() {
|
|
|
|
|
|
|
|
|
|
myW->textBrowser_Chat->clear();
|
|
|
|
|
}
|
2007-10-12 11:07:42 +00:00
|
|
|
|
|
|
|
|
void Chat::setPlayerNicksList(QStringList nickList) {
|
|
|
|
|
//fill playerNicksList for nick-autocompletition
|
|
|
|
|
myChatTools->setPlayerNicksList(nickList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Chat::fillChatLinesHistory(QString fillString) { myChatTools->fillChatLinesHistory(fillString); }
|
|
|
|
|
int Chat::getChatLinesHistorySize() { return myChatTools->getChatLinesHistorySize(); }
|
|
|
|
|
void Chat::showChatHistoryIndex(int index) { myChatTools->showChatHistoryIndex(index); }
|
|
|
|
|
void Chat::nickAutoCompletition() { myChatTools->nickAutoCompletition(); }
|
|
|
|
|
void Chat::setChatTextEdited() { myChatTools->setChatTextEdited(); }
|