From bb9677835a5a12e6c5ae06574f6d1fd093e4bd6c Mon Sep 17 00:00:00 2001 From: doitux Date: Fri, 12 Oct 2007 18:45:28 +0000 Subject: [PATCH] integrating chattools in mainwindow chat --- src/gui/qt/chattools/chattools.cpp | 15 +++++++++++---- src/gui/qt/guiwrapper.cpp | 4 +--- src/gui/qt/mainwindow/chat/chat.cpp | 7 +++---- src/gui/qt/mainwindow/chat/chat.h | 3 --- src/gui/qt/mainwindow/mainwindowimpl.cpp | 10 ++++++++-- src/gui/qt/mainwindow/mainwindowimpl.h | 4 ++-- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/gui/qt/chattools/chattools.cpp b/src/gui/qt/chattools/chattools.cpp index 736df392..fbf60ac3 100644 --- a/src/gui/qt/chattools/chattools.cpp +++ b/src/gui/qt/chattools/chattools.cpp @@ -63,7 +63,7 @@ void ChatTools::nickAutoCompletition() { if(nickAutoCompletitionCounter == 0) { if(myNickTreeWidget) { - cout << "use Treewidget niclist" << endl; +// cout << "use Treewidget niclist" << endl; QTreeWidgetItemIterator it(myNickTreeWidget); while (*it) { if ((*it)->text(0).startsWith(myChatStringList.last(), Qt::CaseInsensitive) && myChatStringList.last() != "") @@ -73,11 +73,14 @@ void ChatTools::nickAutoCompletition() { } if(!myNickStringList.isEmpty()) { - cout << "use static nickList" << endl; +// cout << "use static nickList" << endl; QStringListIterator it(myNickStringList); - while (it.hasNext()) - cout << it.next().toLocal8Bit().constData() << endl; + while (it.hasNext()) { + QString next = it.next(); + if (next.startsWith(myChatStringList.last(), Qt::CaseInsensitive) && myChatStringList.last() != "") + matchStringList << next; + } //TODO code for static nickList } } @@ -91,6 +94,8 @@ void ChatTools::nickAutoCompletition() { myChatStringList.removeLast(); +// cout << nickAutoCompletitionCounter << endl; + if(nickAutoCompletitionCounter == 0) { //first one lastChatString = myChatStringList.join(" "); @@ -99,6 +104,8 @@ void ChatTools::nickAutoCompletition() { if(nickAutoCompletitionCounter == lastMatchStringList.size()) nickAutoCompletitionCounter = 0; + cout << nickAutoCompletitionCounter << endl; + // cout << nickAutoCompletitionCounter << "\n"; if(lastChatString == "") diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index 48e178b7..3a56f1ad 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -35,8 +35,6 @@ GuiWrapper::GuiWrapper(ConfigFile *c) : myLog(0), myW(0), myConfig(c) myW = new mainWindowImpl(myConfig); myW->show(); myLog = new Log(myW, myConfig); - myChat = new Chat(myW, myConfig); - } @@ -140,7 +138,7 @@ void GuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned p void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { myW->signalNetClientGameListPlayerLeft(gameId, playerId); } void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) { myW->signalNetClientGameStart(game); } -void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myChat->signalChatMessage(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } +void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myW->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } void GuiWrapper::SignalNetClientWaitDialog() { myW->signalShowClientDialog(); } void GuiWrapper::SignalNetServerSuccess(int /*actionID*/) { } diff --git a/src/gui/qt/mainwindow/chat/chat.cpp b/src/gui/qt/mainwindow/chat/chat.cpp index 9e48c21e..dd0bc255 100644 --- a/src/gui/qt/mainwindow/chat/chat.cpp +++ b/src/gui/qt/mainwindow/chat/chat.cpp @@ -28,10 +28,8 @@ using namespace std; Chat::Chat(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c) { - myW->setChat(this); - myChatTools = new ChatTools(myW->lineEdit_ChatInput); - connect(this, SIGNAL(signalChatMessage(QString, QString)), this, SLOT(receiveMessage(QString, QString))); + } Chat::~Chat() @@ -41,7 +39,8 @@ Chat::~Chat() } void Chat::sendMessage() { - + + fillChatLinesHistory(myW->lineEdit_ChatInput->text()); myW->getSession().sendChatMessage(myW->lineEdit_ChatInput->text().toUtf8().constData()); myW->lineEdit_ChatInput->setText(""); } diff --git a/src/gui/qt/mainwindow/chat/chat.h b/src/gui/qt/mainwindow/chat/chat.h index c4b9da7f..a34b5a05 100644 --- a/src/gui/qt/mainwindow/chat/chat.h +++ b/src/gui/qt/mainwindow/chat/chat.h @@ -37,9 +37,6 @@ public: ~Chat(); -signals: - void signalChatMessage(QString playerName, QString msg); - public slots: void sendMessage(); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp index 44619f7c..95230b26 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.cpp +++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp @@ -59,7 +59,7 @@ using namespace std; mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) - : QMainWindow(parent), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), breakAfterActualHand(FALSE) + : QMainWindow(parent), myChat(NULL), myConfig(c), gameSpeed(0), myActionIsBet(0), myActionIsRaise(0), breakAfterActualHand(FALSE) { int i; @@ -533,10 +533,12 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) myCreateNetworkGameDialog = new createNetworkGameDialogImpl(this, myConfig); myAboutPokerthDialog = new aboutPokerthImpl(this, myConfig); myGameLobbyDialog = new gameLobbyDialogImpl(this, myConfig); - + myStartNetworkGameDialog->setMyW(this); myGameLobbyDialog->setMyW(this); + myChat = new Chat(this, myConfig); + // //ShortCuts // QShortcut *quitPokerTHKeys = new QShortcut(QKeySequence(Qt::Key_Control + Qt::Key_Q), this); // connect( quitPokerTHKeys, SIGNAL(activated() ), actionQuit, SLOT( trigger() ) ); @@ -602,6 +604,7 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) connect( tabWidget_Left, SIGNAL( currentChanged(int) ), this, SLOT( tabSwitchAction() ) ); connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) ); connect( lineEdit_ChatInput, SIGNAL( textChanged (QString) ), this, SLOT( checkChatInputLength(QString) ) ); + connect( lineEdit_ChatInput, SIGNAL( textEdited (QString) ), myChat, SLOT( setChatTextEdited() ) ); //Nachrichten Thread-Save connect(this, SIGNAL(signalInitGui(int)), this, SLOT(initGui(int))); @@ -683,6 +686,9 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent) connect(this, SIGNAL(signalNetServerError(int, int)), this, SLOT(networkError(int, int))); connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr)), this, SLOT(networkStart(boost::shared_ptr))); + //Chat Messages + connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myChat, SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalIrcConnect(QString)), myGameLobbyDialog->getLobbyChat(), SLOT(connected(QString))); connect(this, SIGNAL(signalIrcSelfJoined(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(selfJoined(QString, QString))); connect(this, SIGNAL(signalIrcPlayerJoined(QString)), myGameLobbyDialog->getLobbyChat(), SLOT(playerJoined(QString))); diff --git a/src/gui/qt/mainwindow/mainwindowimpl.h b/src/gui/qt/mainwindow/mainwindowimpl.h index cbe529ec..7f2ba604 100755 --- a/src/gui/qt/mainwindow/mainwindowimpl.h +++ b/src/gui/qt/mainwindow/mainwindowimpl.h @@ -67,8 +67,7 @@ public: void setSession(boost::shared_ptr session); void setLog(Log* l) { myLog = l; } - void setChat(Chat* c) { myChat = c; } - + SDLPlayer* getMySDLPlayer() const { return mySDLPlayer; } void setSpeeds(); @@ -140,6 +139,7 @@ signals: void signalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); void signalNetClientGameStart(boost::shared_ptr game); + void signalNetClientChatMsg(QString nickName, QString msg); void signalIrcConnect(QString server); void signalIrcSelfJoined(QString nickName, QString channel);