Commit 0a21b29ffa7eca8b3fc10b504a726296a2e67abf

Authored by Imanol-Mikel Barba Sabariego
1 parent 40eb5e8f

minor bugs left

git-svn-id: svn://imanolbarba.net/PAD@41 c2ee353e-ed0d-4329-bf56-03aec153487f
JChatServerV2/bin/pad/prac2/Connection.class
No preview for this file type
JChatServerV2/bin/pad/prac2/JChat$1.class
No preview for this file type
JChatServerV2/bin/pad/prac2/JChat.class
No preview for this file type
JChatServerV2/bin/pad/prac2/Server.class
No preview for this file type
JChatServerV2/src/pad/prac2/Connection.java
... ... @@ -126,11 +126,11 @@ public class Connection extends Thread
126 126 {
127 127 if(!str.contains(" "))
128 128 {
129   - serv.sendTo(this,str.substring(1),"1");
  129 + serv.sendTo(this,str.substring(1),"");
130 130 }
131 131 else
132 132 {
133   - serv.sendTo(this,"1"+str.substring(1,str.indexOf(' ')),str.substring(str.indexOf(' ')+1));
  133 + serv.sendTo(this,str.substring(1,str.indexOf(' ')),str.substring(str.indexOf(' ')+1));
134 134 }
135 135 }
136 136 catch(ChatException cE)
... ...
JChatServerV2/src/pad/prac2/JChat.java
... ... @@ -16,9 +16,11 @@ public class JChat
16 16 System.out.print("Size of chatroom: ");
17 17 roomSize = in.nextInt();
18 18 in.close();*/
  19 +
19 20 ip = "localhost";
20 21 port = 3001;
21 22 roomSize = 5;
  23 +
22 24 final Server serv = new Server(ip,port,roomSize);
23 25 Runtime.getRuntime().addShutdownHook(new Thread()
24 26 {
... ...
JChatServerV2/src/pad/prac2/Server.java
... ... @@ -113,7 +113,7 @@ public class Server
113 113 dest = it.next();
114 114 if(getNickname(dest).equals(nick))
115 115 {
116   - dest.sendMessage(msg);
  116 + dest.sendMessage("1"+msg);
117 117 lock.unlock();
118 118 return;
119 119 }
... ... @@ -156,7 +156,7 @@ public class Server
156 156 conn = it.next();
157 157 try
158 158 {
159   - conn.sendMessage("USERLIST:"+nickList());
  159 + conn.sendMessage("USERLIST"+nickList());
160 160 }
161 161 catch(IOException ioExc)
162 162 {
... ...
QChatClient/QChatClient.pro.user
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3   -<!-- Written by QtCreator 2.7.1, 2013-12-25T12:22:15. -->
  3 +<!-- Written by QtCreator 2.7.1, 2013-12-27T07:19:09. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
... ... @@ -51,9 +51,9 @@
51 51 <data>
52 52 <variable>ProjectExplorer.Project.Target.0</variable>
53 53 <valuemap type="QVariantMap">
54   - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
55   - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
56   - <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">{d6a12d1a-dee4-4341-8f4f-e2749eba145e}</value>
  54 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.0.1 (qt5)</value>
  55 + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.0.1 (qt5)</value>
  56 + <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">{c01623e0-8a32-406c-bbaa-3e691c0f6afc}</value>
57 57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
... ...
QChatClient/Socket.cpp
... ... @@ -186,4 +186,4 @@ const Socket&amp; Socket::operator &gt;&gt; ( std::string&amp; text )
186 186 message = NULL;
187 187 }
188 188 return *this;
189   -}
190 189 \ No newline at end of file
  190 +}
... ...
QChatClient/chatinputtext.cpp
1 1 #include "chatinputtext.h"
2 2  
  3 +#include <QTextCodec>
  4 +
3 5 chatInputText::chatInputText(QWidget *parent) :
4 6 QTextEdit(parent)
5 7 {
... ...
QChatClient/chatroom.cpp
... ... @@ -2,41 +2,12 @@
2 2 #include "ui_chatroom.h"
3 3  
4 4 list<QString> sendQueue;
5   -
6 5 std::mutex myMutex;
7   -
8 6 std::mutex msgMutex;
  7 +std::mutex printMutex;
9 8 unique_lock<std::mutex>* msgLock;
10   -
11 9 std::condition_variable msgListNotEmpty;
12 10  
13   -Chatroom::Chatroom(QWidget *parent) :
14   - QMainWindow(parent),
15   - ui(new Ui::Chatroom)
16   -{
17   - ui->setupUi(this);
18   - QList<int> chatSizes;
19   - QList<int> splitSizes;
20   - chatSizes.push_front(ui->chatText->height());
21   - chatSizes.push_front(100);
22   - splitSizes.push_front(ui->chatWindow->width());
23   - splitSizes.push_front(200);
24   - ui->chatSplitter->setSizes(chatSizes);
25   - ui->windowSplitter->setSizes(splitSizes);
26   - connected = false;
27   - msgLock = new unique_lock<std::mutex>(msgMutex,std::defer_lock);
28   - send = NULL;
29   - recv = NULL;
30   -
31   - connect(ui->actionConnect,SIGNAL(triggered()),this,SLOT(startSession()));
32   - connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(finish()));
33   - connect(this,SIGNAL(threadsFinished(bool)),this,SLOT(finishThreads(bool)));
34   - connect(ui->inputText,SIGNAL(msgReady()),this,SLOT(sendMsg()));
35   - connect(ui->actionDisconnect,SIGNAL(triggered()),this,SLOT(disconnectChatroom()));
36   - connect(ui->sendButton,SIGNAL(clicked()),this,SLOT(sendMsg()));
37   - connect(this,SIGNAL(messagesToPrint()),this,SLOT(printMsg()));
38   -}
39   -
40 11 void sendThread(Socket* s, Chatroom* chat)
41 12 {
42 13 string send;
... ... @@ -46,11 +17,11 @@ void sendThread(Socket* s, Chatroom* chat)
46 17 {
47 18 msgLock->lock();
48 19 msgListNotEmpty.wait(*msgLock);
  20 + msgLock->unlock();
49 21 if(!chat->getConnected())
50 22 {
51 23 return;
52 24 }
53   - msgLock->unlock();
54 25 }
55 26 msgLock->lock();
56 27 send = sendQueue.front().toStdString();
... ... @@ -59,27 +30,31 @@ void sendThread(Socket* s, Chatroom* chat)
59 30 {
60 31 if(send[0] == '@')
61 32 {
  33 + chat->relayMsg(send);
62 34 send = '1' + send;
63 35 }
64 36 else
65 37 {
66 38 send = '0' + send;
  39 + if(send.substr(1) != "/exit" && send.substr(1) != "/disconnect")
  40 + {
  41 + chat->putMsgToPrintQueue(chat->getNickname().toStdString().append(": ").append(send.substr(1)));
  42 + }
67 43 }
68   - *s << send;
69 44 msgLock->unlock();
  45 + *s << send;
70 46 send = send.substr(1);
71 47 if(send == "/disconnect" || send == "/exit")
72 48 {
73 49 break;
74 50 }
75   - chat->putMsgToPrintQueue(chat->getNickname().toStdString().append(": ").append(send));
  51 +
76 52 }
77 53 catch(SocketException& e)
78 54 {
79 55 cout << e.description() << endl;
80 56 }
81 57 }
82   - cout << "sendThread finished" << endl;
83 58 }
84 59  
85 60 void recvThread(Socket* s, Chatroom* chat)
... ... @@ -92,8 +67,7 @@ void recvThread(Socket* s, Chatroom* chat)
92 67 *s >> recv;
93 68 if(recv[0] == '1')
94 69 {
95   - recv = recv.substr(1);
96   - chat->relayMsg(recv);
  70 + chat->relayMsg(recv.substr(1));
97 71 continue;
98 72 }
99 73 else if(recv[0] == '0')
... ... @@ -106,7 +80,7 @@ void recvThread(Socket* s, Chatroom* chat)
106 80 chat->setConnected(false);
107 81 cout << e.description() << endl;
108 82 msgListNotEmpty.notify_all();
109   - emit chat->threadsFinished(false);
  83 + chat->close();
110 84 break;
111 85 }
112 86 if(recv == "DISC_OK")
... ... @@ -114,7 +88,6 @@ void recvThread(Socket* s, Chatroom* chat)
114 88 cout << "Disconnecting" << endl;
115 89 chat->setConnected(false);
116 90 msgListNotEmpty.notify_all();
117   - emit chat->threadsFinished(false);
118 91 break;
119 92 }
120 93 else if(recv == "EXIT_OK")
... ... @@ -122,15 +95,71 @@ void recvThread(Socket* s, Chatroom* chat)
122 95 cout << "Exiting" << endl;
123 96 chat->setConnected(false);
124 97 msgListNotEmpty.notify_all();
125   - emit chat->threadsFinished(true);
  98 + chat->close();
126 99 break;
127 100 }
  101 + else if(recv.substr(0,8) == "USERLIST")
  102 + {
  103 + QString userlist = QString::fromStdString(recv.substr(8));
  104 + chat->updateUserList(userlist);
  105 + }
128 106 else
129 107 {
130 108 chat->putMsgToPrintQueue(recv);
131 109 }
132 110 }
133   - cout << "recvThread finished" << endl;
  111 +}
  112 +
  113 +Chatroom::Chatroom(QWidget *parent) :
  114 + QMainWindow(parent),
  115 + ui(new Ui::Chatroom)
  116 +{
  117 + ui->setupUi(this);
  118 + QList<int> chatSizes;
  119 + QList<int> splitSizes;
  120 + chatSizes.push_front(ui->chatText->height());
  121 + chatSizes.push_front(100);
  122 + splitSizes.push_front(ui->chatWindow->width());
  123 + splitSizes.push_front(200);
  124 + ui->chatSplitter->setSizes(chatSizes);
  125 + ui->windowSplitter->setSizes(splitSizes);
  126 +
  127 + connected = false;
  128 + msgLock = new unique_lock<std::mutex>(msgMutex,std::defer_lock);
  129 + chatLock = new unique_lock<std::mutex>(chatMutex,std::defer_lock);
  130 + send = NULL;
  131 + recv = NULL;
  132 +
  133 + connect(ui->actionConnect,SIGNAL(triggered()),this,SLOT(startSession()));
  134 + connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close()));
  135 + connect(ui->actionDisconnect,SIGNAL(triggered()),this,SLOT(disconnectChatroom()));
  136 + connect(ui->actionSave_chat,SIGNAL(triggered()),ui->chatText,SLOT(saveChatToFile()));
  137 + connect(ui->inputText,SIGNAL(msgReady()),this,SLOT(sendMsg()));
  138 + connect(ui->sendButton,SIGNAL(clicked()),this,SLOT(sendMsg()));
  139 + connect(this,SIGNAL(messagesToPrint()),this,SLOT(printMsg()));
  140 + connect(ui->userList,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(launchChatWindow(QModelIndex)));
  141 + connect(this,SIGNAL(createChat(QString)),this,SLOT(newChat(QString)));
  142 +}
  143 +
  144 +void Chatroom::closeEvent(QCloseEvent *event)
  145 +{
  146 + if(recv == NULL && send == NULL)
  147 + {
  148 + ui->inputText->setReadOnly(true);
  149 + ui->chatText->printServerMsg("Disconnected");
  150 + event->accept();
  151 + return;
  152 + }
  153 + sendQueue.clear();
  154 + QString exitMsg("/exit");
  155 + putMsgToSendQueue(exitMsg);
  156 + ui->inputText->setReadOnly(true);
  157 + recv->join();
  158 + send->join();
  159 + ui->chatText->printServerMsg("Disconnected");
  160 + send = NULL;
  161 + recv = NULL;
  162 + event->accept();
134 163 }
135 164  
136 165 bool Chatroom::getConnected()
... ... @@ -148,27 +177,72 @@ void Chatroom::setConnected(bool status)
148 177 myMutex.unlock();
149 178 }
150 179  
151   -void Chatroom::putMsgToPrintQueue(string &msg)
  180 +void Chatroom::setNickname(QString nick)
152 181 {
153   - printQueue.push_back(msg);
154   - emit messagesToPrint();
  182 + nickname = nick;
155 183 }
156 184  
157   -string Chatroom::getSender(string& msg)
  185 +QString Chatroom::getNickname()
158 186 {
159   - return msg.substr(5,msg.find(':')-5);
  187 + return nickname;
160 188 }
161 189  
162   -void Chatroom::relayMsg(string& msg)
  190 +void Chatroom::updateUserList(QString userlist)
163 191 {
164   - string sender = getSender(msg);
165   - map<string,ChatWindow>::iterator it = activeChats.begin();
166   - if(activeChats.find(sender) == activeChats.end())
  192 + ui->userList->clear();
  193 + QStringList users = userlist.split('\n',QString::SkipEmptyParts);
  194 + for(int i = 0; i < users.size(); i++)
167 195 {
168   - //LAUNCH new windowchat
  196 + ui->userList->addItem(users[i]);
169 197 }
  198 +}
  199 +
  200 +void Chatroom::relayMsg(string msg)
  201 +{
  202 + string sender = getSender(msg);
  203 + //AT LEAST SOME FUCKING SANITY CHECK... PLEASE!!!
  204 + map<string,void*>::iterator it = activeChats.begin();
170 205 it = activeChats.find(sender);
171   - it->second.printMsg(msg);
  206 + if(it == activeChats.end())
  207 + {
  208 + chatLock->lock();
  209 + emit createChat(QString::fromStdString(sender));
  210 + chatCreated.wait(*chatLock);
  211 + chatLock->unlock();
  212 + it = activeChats.find(sender);
  213 + }
  214 + ((ChatWindow*)it->second)->notifyPrint(msg); //NOT GOOD!
  215 +}
  216 +
  217 +void Chatroom::newChat(QString peerNick)
  218 +{
  219 + ChatWindow* newchat = new ChatWindow(peerNick,this);
  220 + activeChats.insert(std::pair<string,ChatWindow*>(peerNick.toStdString(),newchat));
  221 + newchat->show();
  222 + chatCreated.notify_all();
  223 +}
  224 +
  225 +void Chatroom::removeChat(QString &nickname)
  226 +{
  227 + ChatWindow* chat = (ChatWindow*)activeChats.find(nickname.toStdString())->second;
  228 + delete chat;
  229 + activeChats.erase(nickname.toStdString());
  230 +}
  231 +
  232 +void Chatroom::launchChatWindow(QModelIndex index)
  233 +{
  234 + QString peerNick = ui->userList->model()->data(index).toString();
  235 + if(activeChats.find(peerNick.toStdString()) == activeChats.end())
  236 + {
  237 + emit newChat(peerNick);
  238 + }
  239 +}
  240 +
  241 +void Chatroom::putMsgToPrintQueue(string &msg)
  242 +{
  243 + printMutex.lock();
  244 + printQueue.push_back(msg);
  245 + emit messagesToPrint();
172 246 }
173 247  
174 248 void Chatroom::printMsg()
... ... @@ -179,6 +253,7 @@ void Chatroom::printMsg()
179 253 ui->chatText->printMsg(msg);
180 254 printQueue.pop_front();
181 255 }
  256 + printMutex.unlock();
182 257 }
183 258  
184 259 void Chatroom::putMsgToSendQueue(QString& msg)
... ... @@ -189,55 +264,35 @@ void Chatroom::putMsgToSendQueue(QString&amp; msg)
189 264 msgListNotEmpty.notify_all();
190 265 }
191 266  
192   -void Chatroom::setNickname(QString nick)
193   -{
194   - nickname = nick;
195   -}
196   -
197   -QString Chatroom::getNickname()
198   -{
199   - return nickname;
200   -}
201   -
202   -void Chatroom::startSession()
  267 +void Chatroom::sendMsg()
203 268 {
204   - LoginScreen login(&s,this);
205   - login.exec();
206   - int result = login.result();
207   - if(result == QDialog::Accepted)
  269 + QString msg = ui->inputText->toPlainText();
  270 + ui->inputText->clear();
  271 + if(msg == "/disconnect")
208 272 {
209   - ui->inputText->setReadOnly(false);
  273 + this->disconnectChatroom();
210 274 }
211   - else if(result == QDialog::Rejected)
  275 + else if(msg == "/exit")
212 276 {
213   - return;
  277 + this->close();
  278 + }
  279 + else
  280 + {
  281 + putMsgToSendQueue(msg);
214 282 }
215   - connected = true;
216   - ui->chatText->printServerMsg("Connected to chatroom");
217   - recv = new std::thread(recvThread,&s,this);
218   - send = new std::thread(sendThread,&s,this);
219   -}
220   -
221   -void Chatroom::sendMsg()
222   -{
223   - QString msg = ui->inputText->toPlainText();
224   - ui->inputText->clear();
225   - putMsgToSendQueue(msg);
226 283 }
227 284  
228   -void Chatroom::finish()
  285 +string Chatroom::getSender(string msg)
229 286 {
230   - if(recv == NULL && send == NULL)
  287 + cout << msg << endl;
  288 + if(msg[0] == '@')
231 289 {
232   - ui->inputText->setReadOnly(true);
233   - ui->chatText->printServerMsg("Disconnected");
234   - this->close();
  290 + return msg.substr(1,msg.find(" ")-1);
  291 + }
  292 + else
  293 + {
  294 + return msg.substr(0,msg.find(":"));
235 295 }
236   - msgMutex.lock();
237   - sendQueue.clear();
238   - sendQueue.push_back("/exit");
239   - msgMutex.unlock();
240   - msgListNotEmpty.notify_all();
241 296 }
242 297  
243 298 void Chatroom::disconnectChatroom()
... ... @@ -245,24 +300,34 @@ void Chatroom::disconnectChatroom()
245 300 msgMutex.lock();
246 301 sendQueue.clear();
247 302 sendQueue.push_back("/disconnect");
  303 + ui->chatText->printServerMsg("Disconnected");
  304 + this->ui->inputText->setReadOnly(true);
  305 + this->ui->sendButton->setDisabled(true);
  306 + this->ui->actionDisconnect->setDisabled(true);
248 307 msgMutex.unlock();
249 308 msgListNotEmpty.notify_all();
250 309 }
251 310  
252   -void Chatroom::finishThreads(bool exit)
  311 +void Chatroom::startSession()
253 312 {
254   - myMutex.lock();
255   - ui->inputText->setReadOnly(true);
256   - recv->join();
257   - send->join();
258   - myMutex.unlock();
259   - ui->chatText->printServerMsg("Disconnected");
260   - send = NULL;
261   - recv = NULL;
262   - if(exit)
  313 + LoginScreen login(&s,this);
  314 + login.exec();
  315 + int result = login.result();
  316 + if(result == QDialog::Accepted)
263 317 {
264   - this->close();
  318 + ui->inputText->setReadOnly(false);
  319 + }
  320 + else if(result == QDialog::Rejected)
  321 + {
  322 + return;
265 323 }
  324 + connected = true;
  325 + this->ui->inputText->setReadOnly(false);
  326 + this->ui->sendButton->setDisabled(false);
  327 + this->ui->actionDisconnect->setDisabled(false);
  328 + ui->chatText->printServerMsg("Connected to chatroom");
  329 + recv = new std::thread(recvThread,&s,this);
  330 + send = new std::thread(sendThread,&s,this);
266 331 }
267 332  
268 333 Chatroom::~Chatroom()
... ... @@ -270,6 +335,12 @@ Chatroom::~Chatroom()
270 335 delete msgLock;
271 336 delete recv;
272 337 delete send;
  338 + map<string,void*>::iterator it;
  339 + for(it = activeChats.begin(); it != activeChats.end(); it++)
  340 + {
  341 + ChatWindow* chat = (ChatWindow*) it->second;
  342 + delete chat;
  343 + }
273 344 delete ui;
274 345 }
275 346  
... ...
QChatClient/chatroom.h
... ... @@ -2,13 +2,14 @@
2 2 #define CHATROOM_H
3 3  
4 4 #include <QMainWindow>
5   -#include "Socket.h"
6   -#include "loginscreen.h"
  5 +#include <QModelIndex>
7 6 #include <thread>
8 7 #include <mutex>
9 8 #include <condition_variable>
10   -#include "chatwindow.h"
11 9 #include <map>
  10 +#include "loginscreen.h"
  11 +#include "chatwindow.h"
  12 +#include "Socket.h"
12 13  
13 14 namespace Ui {
14 15 class Chatroom;
... ... @@ -22,37 +23,49 @@ public:
22 23 explicit Chatroom(QWidget *parent = 0);
23 24 bool getConnected();
24 25 void setConnected(bool status);
25   - void relayMsg(string& msg);
26   - void setNickname(QString nick);
27 26 QString getNickname();
  27 + void setNickname(QString nick);
  28 + void updateUserList(QString userlist);
  29 + void relayMsg(string msg);
  30 + void removeChat(QString &nickname);
28 31 void putMsgToPrintQueue(string& msg);
  32 + void putMsgToSendQueue(QString& msg);
29 33 ~Chatroom();
30 34  
  35 +private:
  36 + Ui::Chatroom *ui;
  37 + Socket s;
  38 + bool connected;
  39 + std::thread *send;
  40 + std::thread *recv;
  41 + QString nickname;
  42 + list<string> printQueue;
  43 + map<string,void*> activeChats;
  44 + std::mutex chatMutex;
  45 + unique_lock<std::mutex>* chatLock;
  46 + std::condition_variable chatCreated;
  47 + string getSender(string msg);
  48 +
  49 +private slots:
  50 + void newChat(QString peerNick);
  51 +
  52 +
  53 +protected:
  54 + void closeEvent(QCloseEvent *event);
  55 +
31 56 public slots:
32 57 void startSession();
33 58 void sendMsg();
34   - void printMsg();
  59 + void disconnectChatroom();
  60 + void launchChatWindow(QModelIndex index);
35 61  
36 62 private slots:
37   - void finishThreads(bool exit);
38   - void finish();
39   - void disconnectChatroom();
  63 + void printMsg();
40 64  
41 65 signals:
42   - void threadsFinished(bool exit);
43 66 void messagesToPrint();
44   -
45   -private:
46   - Ui::Chatroom *ui;
47   - map<string,ChatWindow> activeChats;
48   - bool connected;
49   - string getSender(string& msg);
50   - void putMsgToSendQueue(QString& msg);
51   - std::thread *send;
52   - std::thread *recv;
53   - Socket s;
54   - QString nickname;
55   - list<string> printQueue;
  67 + void createChat(QString sender);
  68 +
56 69 };
57 70  
58 71 void sendThread(Socket* s, Chatroom *chat);
... ...
QChatClient/chatroom.ui
... ... @@ -44,7 +44,7 @@
44 44 </property>
45 45 <widget class="ChatWidget" name="chatText">
46 46 <property name="readOnly">
47   - <bool>false</bool>
  47 + <bool>true</bool>
48 48 </property>
49 49 </widget>
50 50 <widget class="chatInputText" name="inputText">
... ... @@ -92,6 +92,9 @@
92 92 </item>
93 93 <item row="1" column="0">
94 94 <widget class="QPushButton" name="sendButton">
  95 + <property name="enabled">
  96 + <bool>false</bool>
  97 + </property>
95 98 <property name="sizePolicy">
96 99 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
97 100 <horstretch>0</horstretch>
... ... @@ -120,6 +123,7 @@
120 123 </property>
121 124 <addaction name="actionConnect"/>
122 125 <addaction name="actionDisconnect"/>
  126 + <addaction name="actionSave_chat"/>
123 127 <addaction name="actionExit"/>
124 128 </widget>
125 129 <addaction name="menuChat"/>
... ... @@ -135,10 +139,18 @@
135 139 </property>
136 140 </action>
137 141 <action name="actionDisconnect">
  142 + <property name="enabled">
  143 + <bool>false</bool>
  144 + </property>
138 145 <property name="text">
139 146 <string>Disconnect</string>
140 147 </property>
141 148 </action>
  149 + <action name="actionSave_chat">
  150 + <property name="text">
  151 + <string>Save chat...</string>
  152 + </property>
  153 + </action>
142 154 </widget>
143 155 <customwidgets>
144 156 <customwidget>
... ... @@ -152,6 +164,12 @@
152 164 <header>chatinputtext.h</header>
153 165 </customwidget>
154 166 </customwidgets>
  167 + <tabstops>
  168 + <tabstop>chatText</tabstop>
  169 + <tabstop>inputText</tabstop>
  170 + <tabstop>userList</tabstop>
  171 + <tabstop>sendButton</tabstop>
  172 + </tabstops>
155 173 <resources/>
156 174 <connections/>
157 175 </ui>
... ...
QChatClient/chatwidget.cpp
... ... @@ -6,17 +6,40 @@ ChatWidget::ChatWidget(QWidget *parent) :
6 6  
7 7 }
8 8  
9   -void ChatWidget::printServerMsg(const string &str)
  9 +void ChatWidget::printMsg(const string &str)
10 10 {
11   - this->append("<p style=\"font-style:italic;color:gray;line-height:25%;\">" + QString::fromStdString(str) + "</p>");
  11 + this->setFontWeight(QFont::Normal);
  12 + this->setFontItalic(false);
  13 + this->setTextColor(Qt::black);
  14 + this->append(QString::fromStdString(str));
12 15 }
13 16  
14   -void ChatWidget::printMsg(const string &str)
  17 +void ChatWidget::printServerMsg(const string &str)
15 18 {
  19 + this->setFontWeight(QFont::Normal);
  20 + this->setFontItalic(true);
  21 + this->setTextColor(Qt::gray);
16 22 this->append(QString::fromStdString(str));
17 23 }
18 24  
19 25 void ChatWidget::printStatusMsg(const string &str)
20 26 {
21   - this->append("<p style=\"font-weight:bold;line-height:25%;\">" + QString::fromStdString(str) + "</p>");
  27 + this->setFontWeight(QFont::Bold);
  28 + this->setFontItalic(false);
  29 + this->setTextColor(Qt::black);
  30 + this->append(QString::fromStdString(str));
  31 +}
  32 +
  33 +void ChatWidget::saveChatToFile()
  34 +{
  35 + QFileDialog fileDialog;
  36 + fileDialog.setFileMode(QFileDialog::AnyFile);
  37 + fileDialog.setAcceptMode(QFileDialog::AcceptSave);
  38 + fileDialog.exec();
  39 + QString filename = fileDialog.selectedFiles().front();
  40 + QFile file(filename);
  41 + file.open(QIODevice::WriteOnly | QIODevice::Text);
  42 + QTextStream fileOut(&file);
  43 + fileOut << this->toPlainText() << endl;
  44 + file.close();
22 45 }
... ...
QChatClient/chatwidget.h
... ... @@ -2,6 +2,9 @@
2 2 #define CHATWIDGET_H
3 3  
4 4 #include <QTextEdit>
  5 +#include <QFileDialog>
  6 +#include <QFile>
  7 +#include <QTextStream>
5 8  
6 9 using namespace std;
7 10  
... ... @@ -10,13 +13,14 @@ class ChatWidget : public QTextEdit
10 13 Q_OBJECT
11 14 public:
12 15 explicit ChatWidget(QWidget *parent = 0);
13   - void printServerMsg(const string &str);
14 16 void printMsg(const string& str);
  17 + void printServerMsg(const string &str);
15 18 void printStatusMsg(const string& str);
16 19  
17 20 signals:
18 21  
19 22 public slots:
  23 + void saveChatToFile();
20 24  
21 25 };
22 26  
... ...
QChatClient/chatwindow.cpp
... ... @@ -3,7 +3,7 @@
3 3  
4 4 using namespace std;
5 5  
6   -ChatWindow::ChatWindow(QString& nickname, QWidget *parent) :
  6 +ChatWindow::ChatWindow(QString nick, QWidget *parent) :
7 7 QMainWindow(parent),
8 8 ui(new Ui::ChatWindow)
9 9 {
... ... @@ -12,13 +12,48 @@ ChatWindow::ChatWindow(QString&amp; nickname, QWidget *parent) :
12 12 sizes.push_front(ui->chatText->height());
13 13 sizes.push_front(100);
14 14 ui->splitter->setSizes(sizes);
15   - this->setWindowTitle("Chat with " + nickname);
  15 +
  16 + nickName = nick;
  17 + myNickname = ((Chatroom*)this->parent())->getNickname();
  18 + this->setWindowTitle("Chat with " + nick);
  19 +
16 20 connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close()));
  21 + connect(ui->actionSave_chat,SIGNAL(triggered()),ui->chatText,SLOT(saveChatToFile()));
  22 + connect(ui->inputText,SIGNAL(msgReady()),this,SLOT(sendMsg()));
  23 + connect(ui->sendButton,SIGNAL(clicked()),this,SLOT(sendMsg()));
  24 + connect(this,SIGNAL(msgToPrint(QString)),this,SLOT(printMsg(QString)));
  25 +}
  26 +
  27 +void ChatWindow::notifyPrint(string &msg)
  28 +{
  29 + emit msgToPrint(QString::fromStdString(msg));
  30 +}
  31 +
  32 +void ChatWindow::printMsg(QString str)
  33 +{
  34 + string msg = str.toStdString();
  35 + if(str[0] == '@')
  36 + {
  37 + ui->chatText->printMsg(myNickname.toStdString() + ":" + msg.substr(msg.find(" ")));
  38 + }
  39 + else
  40 + {
  41 + ui->chatText->printMsg(msg);
  42 + }
  43 +}
  44 +
  45 +void ChatWindow::sendMsg()
  46 +{
  47 + QString msg = ui->inputText->toPlainText();
  48 + ui->inputText->clear();
  49 + msg = "@" + nickName + " " +msg;
  50 + ((Chatroom*)this->parent())->putMsgToSendQueue(msg);
17 51 }
18 52  
19   -void ChatWindow::printMsg(string& str)
  53 +void ChatWindow::closeEvent(QCloseEvent *event)
20 54 {
21   - ui->chatText->printMsg(str);
  55 + ((Chatroom*)this->parent())->removeChat(this->nickName);
  56 + event->accept();
22 57 }
23 58  
24 59 ChatWindow::~ChatWindow()
... ...
QChatClient/chatwindow.h
... ... @@ -3,6 +3,7 @@
3 3  
4 4 #include <QMainWindow>
5 5 #include <string>
  6 +#include "chatroom.h"
6 7  
7 8 using namespace std;
8 9  
... ... @@ -15,12 +16,27 @@ class ChatWindow : public QMainWindow
15 16 Q_OBJECT
16 17  
17 18 public:
18   - explicit ChatWindow(QString& nickname,QWidget *parent = 0);
19   - void printMsg(string& str);
  19 + explicit ChatWindow(QString nick, QWidget *parent = 0);
  20 + void notifyPrint(string& msg);
20 21 ~ChatWindow();
  22 +
  23 +public slots:
  24 + void sendMsg();
21 25  
22 26 private:
23 27 Ui::ChatWindow *ui;
  28 + QString nickName;
  29 + QString myNickname;
  30 +
  31 +private slots:
  32 + void printMsg(QString str);
  33 +
  34 +protected:
  35 + void closeEvent(QCloseEvent *event);
  36 +
  37 +signals:
  38 + void msgToPrint(QString msg);
  39 +
24 40 };
25 41  
26 42 #endif // CHATWINDOW_H
... ...
QChatClient/chatwindow.ui
... ... @@ -92,7 +92,7 @@
92 92 </size>
93 93 </property>
94 94 <property name="readOnly">
95   - <bool>true</bool>
  95 + <bool>false</bool>
96 96 </property>
97 97 </widget>
98 98 </widget>
... ... @@ -115,6 +115,7 @@
115 115 <property name="title">
116 116 <string>Chat</string>
117 117 </property>
  118 + <addaction name="actionSave_chat"/>
118 119 <addaction name="actionExit"/>
119 120 </widget>
120 121 <addaction name="menuChat"/>
... ... @@ -124,6 +125,11 @@
124 125 <string>Exit</string>
125 126 </property>
126 127 </action>
  128 + <action name="actionSave_chat">
  129 + <property name="text">
  130 + <string>Save chat...</string>
  131 + </property>
  132 + </action>
127 133 </widget>
128 134 <layoutdefault spacing="6" margin="11"/>
129 135 <customwidgets>
... ... @@ -138,6 +144,11 @@
138 144 <header>chatinputtext.h</header>
139 145 </customwidget>
140 146 </customwidgets>
  147 + <tabstops>
  148 + <tabstop>chatText</tabstop>
  149 + <tabstop>inputText</tabstop>
  150 + <tabstop>sendButton</tabstop>
  151 + </tabstops>
141 152 <resources/>
142 153 <connections/>
143 154 </ui>
... ...
QChatClient/loginscreen.cpp
... ... @@ -15,6 +15,12 @@ LoginScreen::LoginScreen(Socket* s, QWidget *parent) :
15 15 connect(ui->cancelButton,SIGNAL(clicked()),this,SLOT(cancelLogin()));
16 16 }
17 17  
  18 +bool LoginScreen::validateURL(QString& URL)
  19 +{
  20 + QRegExp regex("([a-zA-Z.]+|((\\d{1,3}\\.){3}\\d{1,3})):\\d+");
  21 + return regex.exactMatch(URL);
  22 +}
  23 +
18 24 bool LoginScreen::parseURL(QString& URL)
19 25 {
20 26 if(validateURL(URL))
... ... @@ -32,12 +38,6 @@ bool LoginScreen::parseURL(QString&amp; URL)
32 38 }
33 39 }
34 40  
35   -bool LoginScreen::validateURL(QString& URL)
36   -{
37   - QRegExp regex("([a-zA-Z.]+|((\\d{1,3}\\.){3}\\d{1,3})):\\d+");
38   - return regex.exactMatch(URL);
39   -}
40   -
41 41 void LoginScreen::connectToChat()
42 42 {
43 43 QString nick;
... ...
QChatClient/loginscreen.h
... ... @@ -3,8 +3,9 @@
3 3  
4 4 #include <QDialog>
5 5 #include <QRegExp>
6   -#include "Socket.h"
7 6 #include "chatroom.h"
  7 +#include "Socket.h"
  8 +
8 9  
9 10 namespace Ui {
10 11 class LoginScreen;
... ... @@ -26,9 +27,9 @@ public slots:
26 27  
27 28 private:
28 29 Ui::LoginScreen *ui;
29   - int port;
30   - QString host;
31 30 Socket* s;
  31 + QString host;
  32 + int port;
32 33 };
33 34  
34 35 #endif // LOGINSCREEN_H
... ...
build-QChatClient-Desktop-Debug/Makefile
1 1 #############################################################################
2 2 # Makefile for building: QChatClient
3   -# Generated by qmake (3.0) (Qt 5.0.2) on: miรฉ dic 25 23:23:03 2013
  3 +# Generated by qmake (3.0) (Qt 5.0.2) on: vie dic 27 07:18:49 2013
4 4 # Project: ../QChatClient/QChatClient.pro
5 5 # Template: app
6 6 # Command: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake -spec linux-g++-64 CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile ../QChatClient/QChatClient.pro
... ... @@ -414,14 +414,16 @@ moc_loginscreen.cpp: /usr/include/qt5/QtWidgets/QDialog \
414 414 /usr/include/qt5/QtGui/qvector2d.h \
415 415 /usr/include/qt5/QtGui/qtouchdevice.h \
416 416 /usr/include/qt5/QtCore/QRegExp \
417   - ../QChatClient/Socket.h \
418   - ../QChatClient/SocketException.h \
419 417 ../QChatClient/chatroom.h \
420 418 /usr/include/qt5/QtWidgets/QMainWindow \
421 419 /usr/include/qt5/QtWidgets/qmainwindow.h \
422 420 /usr/include/qt5/QtWidgets/qtabwidget.h \
423 421 /usr/include/qt5/QtGui/qicon.h \
  422 + /usr/include/qt5/QtCore/QModelIndex \
  423 + /usr/include/qt5/QtCore/qabstractitemmodel.h \
424 424 ../QChatClient/loginscreen.h \
  425 + ../QChatClient/Socket.h \
  426 + ../QChatClient/SocketException.h \
425 427 ../QChatClient/chatwindow.h \
426 428 ../QChatClient/loginscreen.h
427 429 /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/loginscreen.h -o moc_loginscreen.cpp
... ... @@ -536,14 +538,16 @@ moc_chatroom.cpp: /usr/include/qt5/QtWidgets/QMainWindow \
536 538 /usr/include/qt5/QtGui/qtouchdevice.h \
537 539 /usr/include/qt5/QtWidgets/qtabwidget.h \
538 540 /usr/include/qt5/QtGui/qicon.h \
539   - ../QChatClient/Socket.h \
540   - ../QChatClient/SocketException.h \
  541 + /usr/include/qt5/QtCore/QModelIndex \
  542 + /usr/include/qt5/QtCore/qabstractitemmodel.h \
541 543 ../QChatClient/loginscreen.h \
542 544 /usr/include/qt5/QtWidgets/QDialog \
543 545 /usr/include/qt5/QtWidgets/qdialog.h \
544 546 /usr/include/qt5/QtCore/QRegExp \
545 547 ../QChatClient/chatroom.h \
546 548 ../QChatClient/chatwindow.h \
  549 + ../QChatClient/Socket.h \
  550 + ../QChatClient/SocketException.h \
547 551 ../QChatClient/chatroom.h
548 552 /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/chatroom.h -o moc_chatroom.cpp
549 553  
... ... @@ -662,6 +666,13 @@ moc_chatwidget.cpp: /usr/include/qt5/QtWidgets/QTextEdit \
662 666 /usr/include/qt5/QtGui/qtextcursor.h \
663 667 /usr/include/qt5/QtGui/qtextformat.h \
664 668 /usr/include/qt5/QtGui/qpen.h \
  669 + /usr/include/qt5/QtWidgets/QFileDialog \
  670 + /usr/include/qt5/QtWidgets/qfiledialog.h \
  671 + /usr/include/qt5/QtCore/qdir.h \
  672 + /usr/include/qt5/QtCore/qfileinfo.h \
  673 + /usr/include/qt5/QtWidgets/qdialog.h \
  674 + /usr/include/qt5/QtCore/QFile \
  675 + /usr/include/qt5/QtCore/QTextStream \
665 676 ../QChatClient/chatwidget.h
666 677 /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/chatwidget.h -o moc_chatwidget.cpp
667 678  
... ... @@ -775,6 +786,16 @@ moc_chatwindow.cpp: /usr/include/qt5/QtWidgets/QMainWindow \
775 786 /usr/include/qt5/QtGui/qtouchdevice.h \
776 787 /usr/include/qt5/QtWidgets/qtabwidget.h \
777 788 /usr/include/qt5/QtGui/qicon.h \
  789 + ../QChatClient/chatroom.h \
  790 + /usr/include/qt5/QtCore/QModelIndex \
  791 + /usr/include/qt5/QtCore/qabstractitemmodel.h \
  792 + ../QChatClient/loginscreen.h \
  793 + /usr/include/qt5/QtWidgets/QDialog \
  794 + /usr/include/qt5/QtWidgets/qdialog.h \
  795 + /usr/include/qt5/QtCore/QRegExp \
  796 + ../QChatClient/Socket.h \
  797 + ../QChatClient/SocketException.h \
  798 + ../QChatClient/chatwindow.h \
778 799 ../QChatClient/chatwindow.h
779 800 /usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) ../QChatClient/chatwindow.h -o moc_chatwindow.cpp
780 801  
... ... @@ -1022,6 +1043,13 @@ ui_chatwindow.h: ../QChatClient/chatwindow.ui \
1022 1043 /usr/include/qt5/QtGui/qtextcursor.h \
1023 1044 /usr/include/qt5/QtGui/qtextformat.h \
1024 1045 /usr/include/qt5/QtGui/qpen.h \
  1046 + /usr/include/qt5/QtWidgets/QFileDialog \
  1047 + /usr/include/qt5/QtWidgets/qfiledialog.h \
  1048 + /usr/include/qt5/QtCore/qdir.h \
  1049 + /usr/include/qt5/QtCore/qfileinfo.h \
  1050 + /usr/include/qt5/QtWidgets/qdialog.h \
  1051 + /usr/include/qt5/QtCore/QFile \
  1052 + /usr/include/qt5/QtCore/QTextStream \
1025 1053 /usr/include/qt5/QtWidgets/QTextEdit \
1026 1054 /usr/include/qt5/QtWidgets/qtextedit.h \
1027 1055 /usr/include/qt5/QtWidgets/qabstractscrollarea.h \
... ... @@ -1261,6 +1289,13 @@ ui_chatroom.h: ../QChatClient/chatroom.ui \
1261 1289 /usr/include/qt5/QtGui/qtextcursor.h \
1262 1290 /usr/include/qt5/QtGui/qtextformat.h \
1263 1291 /usr/include/qt5/QtGui/qpen.h \
  1292 + /usr/include/qt5/QtWidgets/QFileDialog \
  1293 + /usr/include/qt5/QtWidgets/qfiledialog.h \
  1294 + /usr/include/qt5/QtCore/qdir.h \
  1295 + /usr/include/qt5/QtCore/qfileinfo.h \
  1296 + /usr/include/qt5/QtWidgets/qdialog.h \
  1297 + /usr/include/qt5/QtCore/QFile \
  1298 + /usr/include/qt5/QtCore/QTextStream \
1264 1299 /usr/include/qt5/QtWidgets/QTextEdit \
1265 1300 /usr/include/qt5/QtWidgets/qtextedit.h \
1266 1301 /usr/include/qt5/QtWidgets/qabstractscrollarea.h \
... ... @@ -1499,14 +1534,16 @@ main.o: ../QChatClient/main.cpp ../QChatClient/loginscreen.h \
1499 1534 /usr/include/qt5/QtGui/qvector2d.h \
1500 1535 /usr/include/qt5/QtGui/qtouchdevice.h \
1501 1536 /usr/include/qt5/QtCore/QRegExp \
1502   - ../QChatClient/Socket.h \
1503   - ../QChatClient/SocketException.h \
1504 1537 ../QChatClient/chatroom.h \
1505 1538 /usr/include/qt5/QtWidgets/QMainWindow \
1506 1539 /usr/include/qt5/QtWidgets/qmainwindow.h \
1507 1540 /usr/include/qt5/QtWidgets/qtabwidget.h \
1508 1541 /usr/include/qt5/QtGui/qicon.h \
  1542 + /usr/include/qt5/QtCore/QModelIndex \
  1543 + /usr/include/qt5/QtCore/qabstractitemmodel.h \
1509 1544 ../QChatClient/chatwindow.h \
  1545 + ../QChatClient/Socket.h \
  1546 + ../QChatClient/SocketException.h \
1510 1547 /usr/include/qt5/QtWidgets/QApplication \
1511 1548 /usr/include/qt5/QtWidgets/qapplication.h \
1512 1549 /usr/include/qt5/QtCore/qcoreapplication.h \
... ... @@ -1626,62 +1663,17 @@ loginscreen.o: ../QChatClient/loginscreen.cpp ../QChatClient/loginscreen.h \
1626 1663 /usr/include/qt5/QtGui/qvector2d.h \
1627 1664 /usr/include/qt5/QtGui/qtouchdevice.h \
1628 1665 /usr/include/qt5/QtCore/QRegExp \
1629   - ../QChatClient/Socket.h \
1630   - ../QChatClient/SocketException.h \
1631 1666 ../QChatClient/chatroom.h \
1632 1667 /usr/include/qt5/QtWidgets/QMainWindow \
1633 1668 /usr/include/qt5/QtWidgets/qmainwindow.h \
1634 1669 /usr/include/qt5/QtWidgets/qtabwidget.h \
1635 1670 /usr/include/qt5/QtGui/qicon.h \
1636   - ../QChatClient/chatwindow.h \
1637   - ui_loginscreen.h \
1638   - /usr/include/qt5/QtCore/QVariant \
1639   - /usr/include/qt5/QtWidgets/QAction \
1640   - /usr/include/qt5/QtWidgets/qaction.h \
1641   - /usr/include/qt5/QtWidgets/qactiongroup.h \
1642   - /usr/include/qt5/QtWidgets/QApplication \
1643   - /usr/include/qt5/QtWidgets/qapplication.h \
1644   - /usr/include/qt5/QtCore/qcoreapplication.h \
1645   - /usr/include/qt5/QtCore/qeventloop.h \
1646   - /usr/include/qt5/QtWidgets/qdesktopwidget.h \
1647   - /usr/include/qt5/QtGui/qguiapplication.h \
1648   - /usr/include/qt5/QtGui/qinputmethod.h \
1649   - /usr/include/qt5/QtWidgets/QButtonGroup \
1650   - /usr/include/qt5/QtWidgets/qbuttongroup.h \
1651   - /usr/include/qt5/QtWidgets/QGridLayout \
1652   - /usr/include/qt5/QtWidgets/qgridlayout.h \
1653   - /usr/include/qt5/QtWidgets/qlayout.h \
1654   - /usr/include/qt5/QtWidgets/qlayoutitem.h \
1655   - /usr/include/qt5/QtWidgets/qboxlayout.h \
1656   - /usr/include/qt5/QtWidgets/QHeaderView \
1657   - /usr/include/qt5/QtWidgets/qheaderview.h \
1658   - /usr/include/qt5/QtWidgets/qabstractitemview.h \
1659   - /usr/include/qt5/QtWidgets/qabstractscrollarea.h \
1660   - /usr/include/qt5/QtWidgets/qframe.h \
  1671 + /usr/include/qt5/QtCore/QModelIndex \
1661 1672 /usr/include/qt5/QtCore/qabstractitemmodel.h \
1662   - /usr/include/qt5/QtCore/qitemselectionmodel.h \
1663   - /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \
1664   - /usr/include/qt5/QtWidgets/qstyleoption.h \
1665   - /usr/include/qt5/QtWidgets/qabstractspinbox.h \
1666   - /usr/include/qt5/QtGui/qvalidator.h \
1667   - /usr/include/qt5/QtWidgets/qslider.h \
1668   - /usr/include/qt5/QtWidgets/qabstractslider.h \
1669   - /usr/include/qt5/QtWidgets/qstyle.h \
1670   - /usr/include/qt5/QtWidgets/qtabbar.h \
1671   - /usr/include/qt5/QtWidgets/qrubberband.h \
1672   - /usr/include/qt5/QtWidgets/QLabel \
1673   - /usr/include/qt5/QtWidgets/qlabel.h \
1674   - /usr/include/qt5/QtWidgets/QLineEdit \
1675   - /usr/include/qt5/QtWidgets/qlineedit.h \
1676   - /usr/include/qt5/QtGui/qtextcursor.h \
1677   - /usr/include/qt5/QtGui/qtextformat.h \
1678   - /usr/include/qt5/QtGui/qpen.h \
1679   - /usr/include/qt5/QtGui/qtextoption.h \
1680   - /usr/include/qt5/QtWidgets/QPushButton \
1681   - /usr/include/qt5/QtWidgets/qpushbutton.h \
1682   - /usr/include/qt5/QtWidgets/qabstractbutton.h \
1683   - /usr/include/qt5/QtWidgets/QSpacerItem \
1684   - /usr/include/qt5/QtWidgets/QWidget
  1673 + ../QChatClient/chatwindow.h \
  1674 + ../QChatClient/Socket.h \
  1675 + ../QChatClient/SocketException.h \
  1676 + ui_loginscreen.h
1685 1677 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o loginscreen.o ../QChatClient/loginscreen.cpp
1686 1678  
1687 1679 chatroom.o: ../QChatClient/chatroom.cpp ../QChatClient/chatroom.h \
... ... @@ -1795,71 +1787,16 @@ chatroom.o: ../QChatClient/chatroom.cpp ../QChatClient/chatroom.h \
1795 1787 /usr/include/qt5/QtGui/qtouchdevice.h \
1796 1788 /usr/include/qt5/QtWidgets/qtabwidget.h \
1797 1789 /usr/include/qt5/QtGui/qicon.h \
1798   - ../QChatClient/Socket.h \
1799   - ../QChatClient/SocketException.h \
  1790 + /usr/include/qt5/QtCore/QModelIndex \
  1791 + /usr/include/qt5/QtCore/qabstractitemmodel.h \
1800 1792 ../QChatClient/loginscreen.h \
1801 1793 /usr/include/qt5/QtWidgets/QDialog \
1802 1794 /usr/include/qt5/QtWidgets/qdialog.h \
1803 1795 /usr/include/qt5/QtCore/QRegExp \
  1796 + ../QChatClient/Socket.h \
  1797 + ../QChatClient/SocketException.h \
1804 1798 ../QChatClient/chatwindow.h \
1805   - ui_chatroom.h \
1806   - /usr/include/qt5/QtCore/QVariant \
1807   - /usr/include/qt5/QtWidgets/QAction \
1808   - /usr/include/qt5/QtWidgets/qaction.h \
1809   - /usr/include/qt5/QtWidgets/qactiongroup.h \
1810   - /usr/include/qt5/QtWidgets/QApplication \
1811   - /usr/include/qt5/QtWidgets/qapplication.h \
1812   - /usr/include/qt5/QtCore/qcoreapplication.h \
1813   - /usr/include/qt5/QtCore/qeventloop.h \
1814   - /usr/include/qt5/QtWidgets/qdesktopwidget.h \
1815   - /usr/include/qt5/QtGui/qguiapplication.h \
1816   - /usr/include/qt5/QtGui/qinputmethod.h \
1817   - /usr/include/qt5/QtWidgets/QButtonGroup \
1818   - /usr/include/qt5/QtWidgets/qbuttongroup.h \
1819   - /usr/include/qt5/QtWidgets/QGridLayout \
1820   - /usr/include/qt5/QtWidgets/qgridlayout.h \
1821   - /usr/include/qt5/QtWidgets/qlayout.h \
1822   - /usr/include/qt5/QtWidgets/qlayoutitem.h \
1823   - /usr/include/qt5/QtWidgets/qboxlayout.h \
1824   - /usr/include/qt5/QtWidgets/QHeaderView \
1825   - /usr/include/qt5/QtWidgets/qheaderview.h \
1826   - /usr/include/qt5/QtWidgets/qabstractitemview.h \
1827   - /usr/include/qt5/QtWidgets/qabstractscrollarea.h \
1828   - /usr/include/qt5/QtWidgets/qframe.h \
1829   - /usr/include/qt5/QtCore/qabstractitemmodel.h \
1830   - /usr/include/qt5/QtCore/qitemselectionmodel.h \
1831   - /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \
1832   - /usr/include/qt5/QtWidgets/qstyleoption.h \
1833   - /usr/include/qt5/QtWidgets/qabstractspinbox.h \
1834   - /usr/include/qt5/QtGui/qvalidator.h \
1835   - /usr/include/qt5/QtWidgets/qslider.h \
1836   - /usr/include/qt5/QtWidgets/qabstractslider.h \
1837   - /usr/include/qt5/QtWidgets/qstyle.h \
1838   - /usr/include/qt5/QtWidgets/qtabbar.h \
1839   - /usr/include/qt5/QtWidgets/qrubberband.h \
1840   - /usr/include/qt5/QtWidgets/QListWidget \
1841   - /usr/include/qt5/QtWidgets/qlistwidget.h \
1842   - /usr/include/qt5/QtWidgets/qlistview.h \
1843   - /usr/include/qt5/QtWidgets/QMenu \
1844   - /usr/include/qt5/QtWidgets/qmenu.h \
1845   - /usr/include/qt5/QtWidgets/QMenuBar \
1846   - /usr/include/qt5/QtWidgets/qmenubar.h \
1847   - /usr/include/qt5/QtWidgets/QPushButton \
1848   - /usr/include/qt5/QtWidgets/qpushbutton.h \
1849   - /usr/include/qt5/QtWidgets/qabstractbutton.h \
1850   - /usr/include/qt5/QtWidgets/QSplitter \
1851   - /usr/include/qt5/QtWidgets/qsplitter.h \
1852   - /usr/include/qt5/QtWidgets/QWidget \
1853   - ../QChatClient/chatinputtext.h \
1854   - /usr/include/qt5/QtWidgets/QTextEdit \
1855   - /usr/include/qt5/QtWidgets/qtextedit.h \
1856   - /usr/include/qt5/QtGui/qtextdocument.h \
1857   - /usr/include/qt5/QtGui/qtextoption.h \
1858   - /usr/include/qt5/QtGui/qtextcursor.h \
1859   - /usr/include/qt5/QtGui/qtextformat.h \
1860   - /usr/include/qt5/QtGui/qpen.h \
1861   - /usr/include/qt5/QtGui/QKeyEvent \
1862   - ../QChatClient/chatwidget.h
  1799 + ui_chatroom.h
1863 1800 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatroom.o ../QChatClient/chatroom.cpp
1864 1801  
1865 1802 Socket.o: ../QChatClient/Socket.cpp ../QChatClient/Socket.h \
... ... @@ -1981,7 +1918,14 @@ chatwidget.o: ../QChatClient/chatwidget.cpp ../QChatClient/chatwidget.h \
1981 1918 /usr/include/qt5/QtGui/qtextoption.h \
1982 1919 /usr/include/qt5/QtGui/qtextcursor.h \
1983 1920 /usr/include/qt5/QtGui/qtextformat.h \
1984   - /usr/include/qt5/QtGui/qpen.h
  1921 + /usr/include/qt5/QtGui/qpen.h \
  1922 + /usr/include/qt5/QtWidgets/QFileDialog \
  1923 + /usr/include/qt5/QtWidgets/qfiledialog.h \
  1924 + /usr/include/qt5/QtCore/qdir.h \
  1925 + /usr/include/qt5/QtCore/qfileinfo.h \
  1926 + /usr/include/qt5/QtWidgets/qdialog.h \
  1927 + /usr/include/qt5/QtCore/QFile \
  1928 + /usr/include/qt5/QtCore/QTextStream
1985 1929 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatwidget.o ../QChatClient/chatwidget.cpp
1986 1930  
1987 1931 chatwindow.o: ../QChatClient/chatwindow.cpp ../QChatClient/chatwindow.h \
... ... @@ -2095,62 +2039,16 @@ chatwindow.o: ../QChatClient/chatwindow.cpp ../QChatClient/chatwindow.h \
2095 2039 /usr/include/qt5/QtGui/qtouchdevice.h \
2096 2040 /usr/include/qt5/QtWidgets/qtabwidget.h \
2097 2041 /usr/include/qt5/QtGui/qicon.h \
2098   - ui_chatwindow.h \
2099   - /usr/include/qt5/QtCore/QVariant \
2100   - /usr/include/qt5/QtWidgets/QAction \
2101   - /usr/include/qt5/QtWidgets/qaction.h \
2102   - /usr/include/qt5/QtWidgets/qactiongroup.h \
2103   - /usr/include/qt5/QtWidgets/QApplication \
2104   - /usr/include/qt5/QtWidgets/qapplication.h \
2105   - /usr/include/qt5/QtCore/qcoreapplication.h \
2106   - /usr/include/qt5/QtCore/qeventloop.h \
2107   - /usr/include/qt5/QtWidgets/qdesktopwidget.h \
2108   - /usr/include/qt5/QtGui/qguiapplication.h \
2109   - /usr/include/qt5/QtGui/qinputmethod.h \
2110   - /usr/include/qt5/QtWidgets/QButtonGroup \
2111   - /usr/include/qt5/QtWidgets/qbuttongroup.h \
2112   - /usr/include/qt5/QtWidgets/QGridLayout \
2113   - /usr/include/qt5/QtWidgets/qgridlayout.h \
2114   - /usr/include/qt5/QtWidgets/qlayout.h \
2115   - /usr/include/qt5/QtWidgets/qlayoutitem.h \
2116   - /usr/include/qt5/QtWidgets/qboxlayout.h \
2117   - /usr/include/qt5/QtWidgets/QHeaderView \
2118   - /usr/include/qt5/QtWidgets/qheaderview.h \
2119   - /usr/include/qt5/QtWidgets/qabstractitemview.h \
2120   - /usr/include/qt5/QtWidgets/qabstractscrollarea.h \
2121   - /usr/include/qt5/QtWidgets/qframe.h \
  2042 + ../QChatClient/chatroom.h \
  2043 + /usr/include/qt5/QtCore/QModelIndex \
2122 2044 /usr/include/qt5/QtCore/qabstractitemmodel.h \
2123   - /usr/include/qt5/QtCore/qitemselectionmodel.h \
2124   - /usr/include/qt5/QtWidgets/qabstractitemdelegate.h \
2125   - /usr/include/qt5/QtWidgets/qstyleoption.h \
2126   - /usr/include/qt5/QtWidgets/qabstractspinbox.h \
2127   - /usr/include/qt5/QtGui/qvalidator.h \
2128   - /usr/include/qt5/QtWidgets/qslider.h \
2129   - /usr/include/qt5/QtWidgets/qabstractslider.h \
2130   - /usr/include/qt5/QtWidgets/qstyle.h \
2131   - /usr/include/qt5/QtWidgets/qtabbar.h \
2132   - /usr/include/qt5/QtWidgets/qrubberband.h \
2133   - /usr/include/qt5/QtWidgets/QMenu \
2134   - /usr/include/qt5/QtWidgets/qmenu.h \
2135   - /usr/include/qt5/QtWidgets/QMenuBar \
2136   - /usr/include/qt5/QtWidgets/qmenubar.h \
2137   - /usr/include/qt5/QtWidgets/QPushButton \
2138   - /usr/include/qt5/QtWidgets/qpushbutton.h \
2139   - /usr/include/qt5/QtWidgets/qabstractbutton.h \
2140   - /usr/include/qt5/QtWidgets/QSpacerItem \
2141   - /usr/include/qt5/QtWidgets/QSplitter \
2142   - /usr/include/qt5/QtWidgets/qsplitter.h \
2143   - /usr/include/qt5/QtWidgets/QWidget \
2144   - ../QChatClient/chatinputtext.h \
2145   - /usr/include/qt5/QtWidgets/QTextEdit \
2146   - /usr/include/qt5/QtWidgets/qtextedit.h \
2147   - /usr/include/qt5/QtGui/qtextdocument.h \
2148   - /usr/include/qt5/QtGui/qtextoption.h \
2149   - /usr/include/qt5/QtGui/qtextcursor.h \
2150   - /usr/include/qt5/QtGui/qtextformat.h \
2151   - /usr/include/qt5/QtGui/qpen.h \
2152   - /usr/include/qt5/QtGui/QKeyEvent \
2153   - ../QChatClient/chatwidget.h
  2045 + ../QChatClient/loginscreen.h \
  2046 + /usr/include/qt5/QtWidgets/QDialog \
  2047 + /usr/include/qt5/QtWidgets/qdialog.h \
  2048 + /usr/include/qt5/QtCore/QRegExp \
  2049 + ../QChatClient/Socket.h \
  2050 + ../QChatClient/SocketException.h \
  2051 + ui_chatwindow.h
2154 2052 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatwindow.o ../QChatClient/chatwindow.cpp
2155 2053  
2156 2054 chatinputtext.o: ../QChatClient/chatinputtext.cpp ../QChatClient/chatinputtext.h \
... ... @@ -2269,7 +2167,9 @@ chatinputtext.o: ../QChatClient/chatinputtext.cpp ../QChatClient/chatinputtext.h
2269 2167 /usr/include/qt5/QtGui/qtextcursor.h \
2270 2168 /usr/include/qt5/QtGui/qtextformat.h \
2271 2169 /usr/include/qt5/QtGui/qpen.h \
2272   - /usr/include/qt5/QtGui/QKeyEvent
  2170 + /usr/include/qt5/QtGui/QKeyEvent \
  2171 + /usr/include/qt5/QtCore/QTextCodec \
  2172 + /usr/include/qt5/QtCore/qtextcodec.h
2273 2173 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o chatinputtext.o ../QChatClient/chatinputtext.cpp
2274 2174  
2275 2175 moc_loginscreen.o: moc_loginscreen.cpp
... ...
build-QChatClient-Desktop-Debug/QChatClient
No preview for this file type
build-QChatClient-Desktop-Debug/Socket.o
No preview for this file type
build-QChatClient-Desktop-Debug/chatwidget.o
No preview for this file type
build-QChatClient-Desktop-Debug/chatwindow.o
No preview for this file type
build-QChatClient-Desktop-Debug/loginscreen.o
No preview for this file type
build-QChatClient-Desktop-Debug/main.o
No preview for this file type
build-QChatClient-Desktop-Debug/moc_chatroom.cpp
... ... @@ -19,8 +19,8 @@
19 19  
20 20 QT_BEGIN_MOC_NAMESPACE
21 21 struct qt_meta_stringdata_Chatroom_t {
22   - QByteArrayData data[11];
23   - char stringdata[118];
  22 + QByteArrayData data[13];
  23 + char stringdata[134];
24 24 };
25 25 #define QT_MOC_LITERAL(idx, ofs, len) \
26 26 Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
... ... @@ -32,19 +32,21 @@ static const qt_meta_stringdata_Chatroom_t qt_meta_stringdata_Chatroom = {
32 32 QT_MOC_LITERAL(0, 0, 8),
33 33 QT_MOC_LITERAL(1, 9, 15),
34 34 QT_MOC_LITERAL(2, 25, 0),
35   -QT_MOC_LITERAL(3, 26, 4),
36   -QT_MOC_LITERAL(4, 31, 15),
37   -QT_MOC_LITERAL(5, 47, 12),
38   -QT_MOC_LITERAL(6, 60, 7),
39   -QT_MOC_LITERAL(7, 68, 8),
40   -QT_MOC_LITERAL(8, 77, 13),
41   -QT_MOC_LITERAL(9, 91, 6),
42   -QT_MOC_LITERAL(10, 98, 18)
  35 +QT_MOC_LITERAL(3, 26, 10),
  36 +QT_MOC_LITERAL(4, 37, 6),
  37 +QT_MOC_LITERAL(5, 44, 7),
  38 +QT_MOC_LITERAL(6, 52, 8),
  39 +QT_MOC_LITERAL(7, 61, 12),
  40 +QT_MOC_LITERAL(8, 74, 7),
  41 +QT_MOC_LITERAL(9, 82, 18),
  42 +QT_MOC_LITERAL(10, 101, 16),
  43 +QT_MOC_LITERAL(11, 118, 5),
  44 +QT_MOC_LITERAL(12, 124, 8)
43 45 },
44   - "Chatroom\0threadsFinished\0\0exit\0"
45   - "messagesToPrint\0startSession\0sendMsg\0"
46   - "printMsg\0finishThreads\0finish\0"
47   - "disconnectChatroom\0"
  46 + "Chatroom\0messagesToPrint\0\0createChat\0"
  47 + "sender\0newChat\0peerNick\0startSession\0"
  48 + "sendMsg\0disconnectChatroom\0launchChatWindow\0"
  49 + "index\0printMsg\0"
48 50 };
49 51 #undef QT_MOC_LITERAL
50 52  
... ... @@ -62,27 +64,27 @@ static const uint qt_meta_data_Chatroom[] = {
62 64 2, // signalCount
63 65  
64 66 // signals: name, argc, parameters, tag, flags
65   - 1, 1, 54, 2, 0x05,
66   - 4, 0, 57, 2, 0x05,
  67 + 1, 0, 54, 2, 0x05,
  68 + 3, 1, 55, 2, 0x05,
67 69  
68 70 // slots: name, argc, parameters, tag, flags
69   - 5, 0, 58, 2, 0x0a,
70   - 6, 0, 59, 2, 0x0a,
71   - 7, 0, 60, 2, 0x0a,
72   - 8, 1, 61, 2, 0x08,
73   - 9, 0, 64, 2, 0x08,
74   - 10, 0, 65, 2, 0x08,
  71 + 5, 1, 58, 2, 0x08,
  72 + 7, 0, 61, 2, 0x0a,
  73 + 8, 0, 62, 2, 0x0a,
  74 + 9, 0, 63, 2, 0x0a,
  75 + 10, 1, 64, 2, 0x0a,
  76 + 12, 0, 67, 2, 0x08,
75 77  
76 78 // signals: parameters
77   - QMetaType::Void, QMetaType::Bool, 3,
78 79 QMetaType::Void,
  80 + QMetaType::Void, QMetaType::QString, 4,
79 81  
80 82 // slots: parameters
  83 + QMetaType::Void, QMetaType::QString, 6,
81 84 QMetaType::Void,
82 85 QMetaType::Void,
83 86 QMetaType::Void,
84   - QMetaType::Void, QMetaType::Bool, 3,
85   - QMetaType::Void,
  87 + QMetaType::Void, QMetaType::QModelIndex, 11,
86 88 QMetaType::Void,
87 89  
88 90 0 // eod
... ... @@ -93,28 +95,28 @@ void Chatroom::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, vo
93 95 if (_c == QMetaObject::InvokeMetaMethod) {
94 96 Chatroom *_t = static_cast<Chatroom *>(_o);
95 97 switch (_id) {
96   - case 0: _t->threadsFinished((*reinterpret_cast< bool(*)>(_a[1]))); break;
97   - case 1: _t->messagesToPrint(); break;
98   - case 2: _t->startSession(); break;
99   - case 3: _t->sendMsg(); break;
100   - case 4: _t->printMsg(); break;
101   - case 5: _t->finishThreads((*reinterpret_cast< bool(*)>(_a[1]))); break;
102   - case 6: _t->finish(); break;
103   - case 7: _t->disconnectChatroom(); break;
  98 + case 0: _t->messagesToPrint(); break;
  99 + case 1: _t->createChat((*reinterpret_cast< QString(*)>(_a[1]))); break;
  100 + case 2: _t->newChat((*reinterpret_cast< QString(*)>(_a[1]))); break;
  101 + case 3: _t->startSession(); break;
  102 + case 4: _t->sendMsg(); break;
  103 + case 5: _t->disconnectChatroom(); break;
  104 + case 6: _t->launchChatWindow((*reinterpret_cast< QModelIndex(*)>(_a[1]))); break;
  105 + case 7: _t->printMsg(); break;
104 106 default: ;
105 107 }
106 108 } else if (_c == QMetaObject::IndexOfMethod) {
107 109 int *result = reinterpret_cast<int *>(_a[0]);
108 110 void **func = reinterpret_cast<void **>(_a[1]);
109 111 {
110   - typedef void (Chatroom::*_t)(bool );
111   - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::threadsFinished)) {
  112 + typedef void (Chatroom::*_t)();
  113 + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::messagesToPrint)) {
112 114 *result = 0;
113 115 }
114 116 }
115 117 {
116   - typedef void (Chatroom::*_t)();
117   - if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::messagesToPrint)) {
  118 + typedef void (Chatroom::*_t)(QString );
  119 + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&Chatroom::createChat)) {
118 120 *result = 1;
119 121 }
120 122 }
... ... @@ -158,15 +160,15 @@ int Chatroom::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
158 160 }
159 161  
160 162 // SIGNAL 0
161   -void Chatroom::threadsFinished(bool _t1)
  163 +void Chatroom::messagesToPrint()
162 164 {
163   - void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
164   - QMetaObject::activate(this, &staticMetaObject, 0, _a);
  165 + QMetaObject::activate(this, &staticMetaObject, 0, 0);
165 166 }
166 167  
167 168 // SIGNAL 1
168   -void Chatroom::messagesToPrint()
  169 +void Chatroom::createChat(QString _t1)
169 170 {
170   - QMetaObject::activate(this, &staticMetaObject, 1, 0);
  171 + void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
  172 + QMetaObject::activate(this, &staticMetaObject, 1, _a);
171 173 }
172 174 QT_END_MOC_NAMESPACE
... ...
build-QChatClient-Desktop-Debug/moc_chatroom.o
No preview for this file type
build-QChatClient-Desktop-Debug/moc_chatwidget.cpp
... ... @@ -19,8 +19,8 @@
19 19  
20 20 QT_BEGIN_MOC_NAMESPACE
21 21 struct qt_meta_stringdata_ChatWidget_t {
22   - QByteArrayData data[1];
23   - char stringdata[12];
  22 + QByteArrayData data[3];
  23 + char stringdata[28];
24 24 };
25 25 #define QT_MOC_LITERAL(idx, ofs, len) \
26 26 Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
... ... @@ -29,9 +29,11 @@ struct qt_meta_stringdata_ChatWidget_t {
29 29 )
30 30 static const qt_meta_stringdata_ChatWidget_t qt_meta_stringdata_ChatWidget = {
31 31 {
32   -QT_MOC_LITERAL(0, 0, 10)
  32 +QT_MOC_LITERAL(0, 0, 10),
  33 +QT_MOC_LITERAL(1, 11, 14),
  34 +QT_MOC_LITERAL(2, 26, 0)
33 35 },
34   - "ChatWidget\0"
  36 + "ChatWidget\0saveChatToFile\0\0"
35 37 };
36 38 #undef QT_MOC_LITERAL
37 39  
... ... @@ -41,21 +43,31 @@ static const uint qt_meta_data_ChatWidget[] = {
41 43 7, // revision
42 44 0, // classname
43 45 0, 0, // classinfo
44   - 0, 0, // methods
  46 + 1, 14, // methods
45 47 0, 0, // properties
46 48 0, 0, // enums/sets
47 49 0, 0, // constructors
48 50 0, // flags
49 51 0, // signalCount
50 52  
  53 + // slots: name, argc, parameters, tag, flags
  54 + 1, 0, 19, 2, 0x0a,
  55 +
  56 + // slots: parameters
  57 + QMetaType::Void,
  58 +
51 59 0 // eod
52 60 };
53 61  
54 62 void ChatWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
55 63 {
56   - Q_UNUSED(_o);
57   - Q_UNUSED(_id);
58   - Q_UNUSED(_c);
  64 + if (_c == QMetaObject::InvokeMetaMethod) {
  65 + ChatWidget *_t = static_cast<ChatWidget *>(_o);
  66 + switch (_id) {
  67 + case 0: _t->saveChatToFile(); break;
  68 + default: ;
  69 + }
  70 + }
59 71 Q_UNUSED(_a);
60 72 }
61 73  
... ... @@ -83,6 +95,15 @@ int ChatWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
83 95 _id = QTextEdit::qt_metacall(_c, _id, _a);
84 96 if (_id < 0)
85 97 return _id;
  98 + if (_c == QMetaObject::InvokeMetaMethod) {
  99 + if (_id < 1)
  100 + qt_static_metacall(this, _c, _id, _a);
  101 + _id -= 1;
  102 + } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
  103 + if (_id < 1)
  104 + *reinterpret_cast<int*>(_a[0]) = -1;
  105 + _id -= 1;
  106 + }
86 107 return _id;
87 108 }
88 109 QT_END_MOC_NAMESPACE
... ...
build-QChatClient-Desktop-Debug/moc_chatwidget.o
No preview for this file type
build-QChatClient-Desktop-Debug/moc_chatwindow.cpp
... ... @@ -19,8 +19,8 @@
19 19  
20 20 QT_BEGIN_MOC_NAMESPACE
21 21 struct qt_meta_stringdata_ChatWindow_t {
22   - QByteArrayData data[1];
23   - char stringdata[12];
  22 + QByteArrayData data[7];
  23 + char stringdata[49];
24 24 };
25 25 #define QT_MOC_LITERAL(idx, ofs, len) \
26 26 Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
... ... @@ -29,9 +29,16 @@ struct qt_meta_stringdata_ChatWindow_t {
29 29 )
30 30 static const qt_meta_stringdata_ChatWindow_t qt_meta_stringdata_ChatWindow = {
31 31 {
32   -QT_MOC_LITERAL(0, 0, 10)
  32 +QT_MOC_LITERAL(0, 0, 10),
  33 +QT_MOC_LITERAL(1, 11, 10),
  34 +QT_MOC_LITERAL(2, 22, 0),
  35 +QT_MOC_LITERAL(3, 23, 3),
  36 +QT_MOC_LITERAL(4, 27, 7),
  37 +QT_MOC_LITERAL(5, 35, 8),
  38 +QT_MOC_LITERAL(6, 44, 3)
33 39 },
34   - "ChatWindow\0"
  40 + "ChatWindow\0msgToPrint\0\0msg\0sendMsg\0"
  41 + "printMsg\0str\0"
35 42 };
36 43 #undef QT_MOC_LITERAL
37 44  
... ... @@ -41,22 +48,50 @@ static const uint qt_meta_data_ChatWindow[] = {
41 48 7, // revision
42 49 0, // classname
43 50 0, 0, // classinfo
44   - 0, 0, // methods
  51 + 3, 14, // methods
45 52 0, 0, // properties
46 53 0, 0, // enums/sets
47 54 0, 0, // constructors
48 55 0, // flags
49   - 0, // signalCount
  56 + 1, // signalCount
  57 +
  58 + // signals: name, argc, parameters, tag, flags
  59 + 1, 1, 29, 2, 0x05,
  60 +
  61 + // slots: name, argc, parameters, tag, flags
  62 + 4, 0, 32, 2, 0x0a,
  63 + 5, 1, 33, 2, 0x08,
  64 +
  65 + // signals: parameters
  66 + QMetaType::Void, QMetaType::QString, 3,
  67 +
  68 + // slots: parameters
  69 + QMetaType::Void,
  70 + QMetaType::Void, QMetaType::QString, 6,
50 71  
51 72 0 // eod
52 73 };
53 74  
54 75 void ChatWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
55 76 {
56   - Q_UNUSED(_o);
57   - Q_UNUSED(_id);
58   - Q_UNUSED(_c);
59   - Q_UNUSED(_a);
  77 + if (_c == QMetaObject::InvokeMetaMethod) {
  78 + ChatWindow *_t = static_cast<ChatWindow *>(_o);
  79 + switch (_id) {
  80 + case 0: _t->msgToPrint((*reinterpret_cast< QString(*)>(_a[1]))); break;
  81 + case 1: _t->sendMsg(); break;
  82 + case 2: _t->printMsg((*reinterpret_cast< QString(*)>(_a[1]))); break;
  83 + default: ;
  84 + }
  85 + } else if (_c == QMetaObject::IndexOfMethod) {
  86 + int *result = reinterpret_cast<int *>(_a[0]);
  87 + void **func = reinterpret_cast<void **>(_a[1]);
  88 + {
  89 + typedef void (ChatWindow::*_t)(QString );
  90 + if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&ChatWindow::msgToPrint)) {
  91 + *result = 0;
  92 + }
  93 + }
  94 + }
60 95 }
61 96  
62 97 const QMetaObject ChatWindow::staticMetaObject = {
... ... @@ -83,6 +118,22 @@ int ChatWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
83 118 _id = QMainWindow::qt_metacall(_c, _id, _a);
84 119 if (_id < 0)
85 120 return _id;
  121 + if (_c == QMetaObject::InvokeMetaMethod) {
  122 + if (_id < 3)
  123 + qt_static_metacall(this, _c, _id, _a);
  124 + _id -= 3;
  125 + } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
  126 + if (_id < 3)
  127 + *reinterpret_cast<int*>(_a[0]) = -1;
  128 + _id -= 3;
  129 + }
86 130 return _id;
87 131 }
  132 +
  133 +// SIGNAL 0
  134 +void ChatWindow::msgToPrint(QString _t1)
  135 +{
  136 + void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
  137 + QMetaObject::activate(this, &staticMetaObject, 0, _a);
  138 +}
88 139 QT_END_MOC_NAMESPACE
... ...
build-QChatClient-Desktop-Debug/moc_chatwindow.o
No preview for this file type
build-QChatClient-Desktop-Debug/moc_loginscreen.o
No preview for this file type
build-QChatClient-Desktop-Debug/ui_chatroom.h
... ... @@ -33,6 +33,7 @@ public:
33 33 QAction *actionConnect;
34 34 QAction *actionExit;
35 35 QAction *actionDisconnect;
  36 + QAction *actionSave_chat;
36 37 QWidget *centralwidget;
37 38 QGridLayout *gridLayout_2;
38 39 QSplitter *windowSplitter;
... ... @@ -57,6 +58,9 @@ public:
57 58 actionExit->setObjectName(QStringLiteral("actionExit"));
58 59 actionDisconnect = new QAction(Chatroom);
59 60 actionDisconnect->setObjectName(QStringLiteral("actionDisconnect"));
  61 + actionDisconnect->setEnabled(false);
  62 + actionSave_chat = new QAction(Chatroom);
  63 + actionSave_chat->setObjectName(QStringLiteral("actionSave_chat"));
60 64 centralwidget = new QWidget(Chatroom);
61 65 centralwidget->setObjectName(QStringLiteral("centralwidget"));
62 66 gridLayout_2 = new QGridLayout(centralwidget);
... ... @@ -75,7 +79,7 @@ public:
75 79 chatSplitter->setOrientation(Qt::Vertical);
76 80 chatText = new ChatWidget(chatSplitter);
77 81 chatText->setObjectName(QStringLiteral("chatText"));
78   - chatText->setReadOnly(false);
  82 + chatText->setReadOnly(true);
79 83 chatSplitter->addWidget(chatText);
80 84 inputText = new chatInputText(chatSplitter);
81 85 inputText->setObjectName(QStringLiteral("inputText"));
... ... @@ -106,6 +110,7 @@ public:
106 110  
107 111 sendButton = new QPushButton(centralwidget);
108 112 sendButton->setObjectName(QStringLiteral("sendButton"));
  113 + sendButton->setEnabled(false);
109 114 QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);
110 115 sizePolicy2.setHorizontalStretch(0);
111 116 sizePolicy2.setVerticalStretch(0);
... ... @@ -121,10 +126,14 @@ public:
121 126 menuChat = new QMenu(menuBar);
122 127 menuChat->setObjectName(QStringLiteral("menuChat"));
123 128 Chatroom->setMenuBar(menuBar);
  129 + QWidget::setTabOrder(chatText, inputText);
  130 + QWidget::setTabOrder(inputText, userList);
  131 + QWidget::setTabOrder(userList, sendButton);
124 132  
125 133 menuBar->addAction(menuChat->menuAction());
126 134 menuChat->addAction(actionConnect);
127 135 menuChat->addAction(actionDisconnect);
  136 + menuChat->addAction(actionSave_chat);
128 137 menuChat->addAction(actionExit);
129 138  
130 139 retranslateUi(Chatroom);
... ... @@ -138,6 +147,7 @@ public:
138 147 actionConnect->setText(QApplication::translate("Chatroom", "Connect...", 0));
139 148 actionExit->setText(QApplication::translate("Chatroom", "Exit", 0));
140 149 actionDisconnect->setText(QApplication::translate("Chatroom", "Disconnect", 0));
  150 + actionSave_chat->setText(QApplication::translate("Chatroom", "Save chat...", 0));
141 151 sendButton->setText(QApplication::translate("Chatroom", "Send", 0));
142 152 menuChat->setTitle(QApplication::translate("Chatroom", "Chat", 0));
143 153 } // retranslateUi
... ...
build-QChatClient-Desktop-Debug/ui_chatwindow.h
... ... @@ -31,6 +31,7 @@ class Ui_ChatWindow
31 31 {
32 32 public:
33 33 QAction *actionExit;
  34 + QAction *actionSave_chat;
34 35 QWidget *centralWidget;
35 36 QGridLayout *gridLayout;
36 37 QSpacerItem *horizontalSpacer;
... ... @@ -50,6 +51,8 @@ public:
50 51 ChatWindow->resize(400, 502);
51 52 actionExit = new QAction(ChatWindow);
52 53 actionExit->setObjectName(QStringLiteral("actionExit"));
  54 + actionSave_chat = new QAction(ChatWindow);
  55 + actionSave_chat->setObjectName(QStringLiteral("actionSave_chat"));
53 56 centralWidget = new QWidget(ChatWindow);
54 57 centralWidget->setObjectName(QStringLiteral("centralWidget"));
55 58 centralWidget->setEnabled(true);
... ... @@ -100,7 +103,7 @@ public:
100 103 inputText->setMinimumSize(QSize(0, 0));
101 104 inputText->setMaximumSize(QSize(16777215, 16777215));
102 105 inputText->setBaseSize(QSize(0, 0));
103   - inputText->setReadOnly(true);
  106 + inputText->setReadOnly(false);
104 107 splitter->addWidget(inputText);
105 108  
106 109 gridLayout_2->addWidget(splitter, 0, 0, 1, 1);
... ... @@ -115,8 +118,11 @@ public:
115 118 menuChat = new QMenu(menuBar);
116 119 menuChat->setObjectName(QStringLiteral("menuChat"));
117 120 ChatWindow->setMenuBar(menuBar);
  121 + QWidget::setTabOrder(chatText, inputText);
  122 + QWidget::setTabOrder(inputText, sendButton);
118 123  
119 124 menuBar->addAction(menuChat->menuAction());
  125 + menuChat->addAction(actionSave_chat);
120 126 menuChat->addAction(actionExit);
121 127  
122 128 retranslateUi(ChatWindow);
... ... @@ -128,6 +134,7 @@ public:
128 134 {
129 135 ChatWindow->setWindowTitle(QApplication::translate("ChatWindow", "QChatClient", 0));
130 136 actionExit->setText(QApplication::translate("ChatWindow", "Exit", 0));
  137 + actionSave_chat->setText(QApplication::translate("ChatWindow", "Save chat...", 0));
131 138 sendButton->setText(QApplication::translate("ChatWindow", "Send", 0));
132 139 menuChat->setTitle(QApplication::translate("ChatWindow", "Chat", 0));
133 140 } // retranslateUi
... ...