-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathListOfChannels.cpp
81 lines (73 loc) · 2.29 KB
/
ListOfChannels.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
#include "ListOfChannels.h"
#include "ui_ListOfChannels.h"
#include <QDebug>
ListOfChannels::ListOfChannels(QWidget *parent) :
QDialog(parent),
ui(new Ui::ListOfChannels)
{
ui->setupUi(this);
setWindowIcon(QIcon("icon.png"));
connect(&m_dialog, SIGNAL(createChannel(QString,QString,QString)), this, SLOT(replyCreateSignal(QString,QString,QString)));
connect(ui->createButton, SIGNAL(clicked()), &m_dialog, SLOT(show()));
}
ListOfChannels::~ListOfChannels()
{
delete ui;
}
void ListOfChannels::showEvent(QShowEvent *event)
{
ui->joinStatusLabel->clear();
event->accept();
}
void ListOfChannels::setAllChannelsList(QMap<QString, QString> list)
{
QTableWidgetItem *item;
ui->channelTable->clear();
ui->channelTable->setRowCount(list.size());
QMap<QString, QString>::iterator i = list.begin();
quint8 row = 0;
for(;i != list.end(); ++i)
{
item = new QTableWidgetItem(i.key());
ui->channelTable->setItem(row, 0, item);
item = new QTableWidgetItem(i.value());
ui->channelTable->setItem(row, 1, item);
++row;
}
}
void ListOfChannels::getChannelJoinResult(QString channelName, bool result)
{
//notify user that his join was succesfull. or not
QString newStatus;
if (result)
{
newStatus = "You've sucessfully joined channel " + channelName + ".";
}
else
{
newStatus = "Your attempt to join channel " + channelName + " wasn't successfull.";
}
ui->joinStatusLabel->setText(newStatus);
}
void ListOfChannels::getChannelCreateResult(QString str)
{
ui->joinStatusLabel->setText(str);
}
void ListOfChannels::replyCreateSignal(QString name, QString topic, QString description)
{
emit requestCreateChannel(name, topic, description);
}
void ListOfChannels::on_joinButton_clicked()
{
//send signal requestJoinChannel if row is checked
QModelIndexList indexes = ui->channelTable->selectionModel()->selectedRows();
if (indexes.isEmpty())
{
ui->joinStatusLabel->setText("You must select any channel to join it.");
return;
}
QModelIndex index = indexes[0];
QString channelName = ui->channelTable->item(index.row(), index.column())->text();
emit requestJoinChannel(channelName);
ui->joinStatusLabel->setText("Join request has been sent.");
}