-
Notifications
You must be signed in to change notification settings - Fork 0
/
Message.cpp
53 lines (40 loc) · 950 Bytes
/
Message.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Message.h"
#include <QDebug>
Message::Message() {
this->content = "";
this->sender = "";
}
Message::Message(QByteArray content, QString sender) {
this->content = content;
this->sender = sender;
emit senderChanged();
emit contentChanged();
}
Message::Message(QByteArray content, QString sender, QDateTime date) {
this->content = content;
this->sender = sender;
this->date = date;
emit senderChanged();
emit contentChanged();
emit dateChanged();
}
void Message::parse(QByteArray data) {
QByteArrayList split = data.split(';');
qDebug() << "Sender: " << split[0];
this->sender = split[0];
split.pop_front();
qDebug() << "Content: " << split[0];
this->content = split.join("");
emit senderChanged();
emit contentChanged();
emit dateChanged();
}
QString Message::getSender() {
return this->sender;
}
QString Message::getContent() {
return this->content;
}
QDateTime Message::getDate() {
return this->date;
}