Commit 78836532b3ea7f4cb2ec775c2ada7a9396241d6a
1 parent
d6432402
git-svn-id: svn://imanolbarba.net/PAD@50 c2ee353e-ed0d-4329-bf56-03aec153487f
Showing
2 changed files
with
5 additions
and
2 deletions
QChatClient/chatroom.cpp
... | ... | @@ -101,7 +101,7 @@ void recvThread(Socket* s, Chatroom* chat) |
101 | 101 | else if(recv.substr(0,8) == "USERLIST") |
102 | 102 | { |
103 | 103 | QString userlist = QString::fromStdString(recv.substr(8)); |
104 | - chat->updateUserList(userlist); | |
104 | + emit chat->newUsers(userlist); | |
105 | 105 | } |
106 | 106 | else |
107 | 107 | { |
... | ... | @@ -142,6 +142,7 @@ Chatroom::Chatroom(QWidget *parent) : |
142 | 142 | connect(ui->userList,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(launchChatWindow(QModelIndex))); |
143 | 143 | connect(this,SIGNAL(createChat(QString)),this,SLOT(newChat(QString))); |
144 | 144 | connect(this,SIGNAL(toggleConnected(bool)),this,SLOT(setConnected(bool))); |
145 | + connect(this,SIGNAL(newUsers(QString)),this,SLOT(updateUserList(QString))); | |
145 | 146 | } |
146 | 147 | |
147 | 148 | void Chatroom::closeEvent(QCloseEvent *event) |
... | ... | @@ -203,6 +204,7 @@ QString Chatroom::getNickname() |
203 | 204 | |
204 | 205 | void Chatroom::updateUserList(QString userlist) |
205 | 206 | { |
207 | + ui->userList->clearSelection(); | |
206 | 208 | ui->userList->clear(); |
207 | 209 | QStringList users = userlist.split('\n',QString::SkipEmptyParts); |
208 | 210 | for(int i = 0; i < users.size(); i++) | ... | ... |
QChatClient/chatroom.h
... | ... | @@ -28,7 +28,6 @@ public: |
28 | 28 | bool getConnected(); |
29 | 29 | QString getNickname(); |
30 | 30 | void setNickname(QString nick); |
31 | - void updateUserList(QString userlist); | |
32 | 31 | void relayMsg(string msg); |
33 | 32 | void removeChat(QString &nickname); |
34 | 33 | void putMsgToPrintQueue(string& msg, int type); |
... | ... | @@ -68,6 +67,7 @@ private slots: |
68 | 67 | void printServerMsg(); |
69 | 68 | void printStatusMsg(); |
70 | 69 | void newChat(QString peerNick); |
70 | + void updateUserList(QString userlist); | |
71 | 71 | |
72 | 72 | signals: |
73 | 73 | void messagesToPrint(); |
... | ... | @@ -75,6 +75,7 @@ signals: |
75 | 75 | void statusMessagesToPrint(); |
76 | 76 | void createChat(QString sender); |
77 | 77 | void toggleConnected(bool status); |
78 | + void newUsers(QString); | |
78 | 79 | |
79 | 80 | }; |
80 | 81 | ... | ... |