From 78836532b3ea7f4cb2ec775c2ada7a9396241d6a Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Tue, 7 Jan 2014 03:48:21 +0000 Subject: [PATCH] git-svn-id: svn://imanolbarba.net/PAD@50 c2ee353e-ed0d-4329-bf56-03aec153487f --- QChatClient/chatroom.cpp | 4 +++- QChatClient/chatroom.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/QChatClient/chatroom.cpp b/QChatClient/chatroom.cpp index d2e730e..4ac923c 100644 --- a/QChatClient/chatroom.cpp +++ b/QChatClient/chatroom.cpp @@ -101,7 +101,7 @@ void recvThread(Socket* s, Chatroom* chat) else if(recv.substr(0,8) == "USERLIST") { QString userlist = QString::fromStdString(recv.substr(8)); - chat->updateUserList(userlist); + emit chat->newUsers(userlist); } else { @@ -142,6 +142,7 @@ Chatroom::Chatroom(QWidget *parent) : connect(ui->userList,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(launchChatWindow(QModelIndex))); connect(this,SIGNAL(createChat(QString)),this,SLOT(newChat(QString))); connect(this,SIGNAL(toggleConnected(bool)),this,SLOT(setConnected(bool))); + connect(this,SIGNAL(newUsers(QString)),this,SLOT(updateUserList(QString))); } void Chatroom::closeEvent(QCloseEvent *event) @@ -203,6 +204,7 @@ QString Chatroom::getNickname() void Chatroom::updateUserList(QString userlist) { + ui->userList->clearSelection(); ui->userList->clear(); QStringList users = userlist.split('\n',QString::SkipEmptyParts); for(int i = 0; i < users.size(); i++) diff --git a/QChatClient/chatroom.h b/QChatClient/chatroom.h index 3701cdd..48ef798 100644 --- a/QChatClient/chatroom.h +++ b/QChatClient/chatroom.h @@ -28,7 +28,6 @@ public: bool getConnected(); QString getNickname(); void setNickname(QString nick); - void updateUserList(QString userlist); void relayMsg(string msg); void removeChat(QString &nickname); void putMsgToPrintQueue(string& msg, int type); @@ -68,6 +67,7 @@ private slots: void printServerMsg(); void printStatusMsg(); void newChat(QString peerNick); + void updateUserList(QString userlist); signals: void messagesToPrint(); @@ -75,6 +75,7 @@ signals: void statusMessagesToPrint(); void createChat(QString sender); void toggleConnected(bool status); + void newUsers(QString); }; -- libgit2 0.22.2