-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconversation.cpp
92 lines (76 loc) · 1.85 KB
/
conversation.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "conversation.h"
Conversation::Conversation(QString prefix, QString name, QStandardItemModel *channelListModel)
{
this->name = name;
this->prefix = prefix;
this->channelListModel = channelListModel;
this->text = "";
this->item = new QStandardItem();
item->setData(getFullName(), Qt::DisplayRole);
item->setEditable(false);
channelListModel->appendRow(item);
this->onTheList = true;
}
void Conversation::setRead()
{
QFont serifFont("Sans", 9, QFont::Normal);
item->setFont(serifFont);
}
void Conversation::setUnread()
{
QFont serifFont("Sans", 9, QFont::Bold);
item->setFont(serifFont);
}
void Conversation::addMessage(QString author, QString messageText)
{
QTime time;
text += "<i>(" + time.currentTime().toString() + ")</i> <strong>" + author + "</strong>: " + messageText + "<br>";
setUnread();
}
QString Conversation::getFullName()
{
return prefix + name;
}
QString Conversation::getName()
{
return name;
}
void Conversation::removeFromList()
{
channelListModel->removeRow(channelListModel->indexFromItem(item).row());
this->onTheList = false;
}
QString Conversation::getText()
{
return text;
}
QString Conversation::getPrefix()
{
return prefix;
}
void Conversation::addServerMessage(QString messageText)
{
text += "<i>" + messageText + "</i><br>";
setUnread();
}
int Conversation::getRow()
{
return channelListModel->indexFromItem(item).row();
}
void Conversation::renameConversation(QString newName)
{
this->name = newName;
item->setData(getFullName(), Qt::DisplayRole);
}
void Conversation::reAddToList()
{
this->item = new QStandardItem();
item->setData(getFullName(), Qt::DisplayRole);
item->setEditable(false);
channelListModel->appendRow(item);
this->onTheList = true;
}
bool Conversation::isOnTheList()
{
return onTheList;
}