Commit 78836532b3ea7f4cb2ec775c2ada7a9396241d6a

Authored by Imanol-Mikel Barba Sabariego
1 parent d6432402

git-svn-id: svn://imanolbarba.net/PAD@50 c2ee353e-ed0d-4329-bf56-03aec153487f

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