Create chatroom and message classes to display messages
This commit is contained in:
16
client/inc/models/chatroom.h
Normal file
16
client/inc/models/chatroom.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "models/message.h"
|
||||
#include <QStringList>
|
||||
#include <vector>
|
||||
class Chatroom {
|
||||
public:
|
||||
Chatroom() {}
|
||||
~Chatroom() {}
|
||||
|
||||
void addMessage(Message message);
|
||||
QString getMessagesString();
|
||||
|
||||
private:
|
||||
std::vector<Message> m_messages;
|
||||
};
|
||||
17
client/inc/models/message.h
Normal file
17
client/inc/models/message.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
|
||||
class Message {
|
||||
public:
|
||||
Message(int, QDateTime, QString);
|
||||
~Message() {}
|
||||
|
||||
QString toString() const;
|
||||
|
||||
private:
|
||||
int m_userId;
|
||||
QDateTime m_timestamp;
|
||||
QString m_content;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "models/chatroom.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
Chatroom m_chatroom;
|
||||
|
||||
public slots:
|
||||
void receiveMsg(QString &);
|
||||
|
||||
Reference in New Issue
Block a user