-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneralform.cpp
129 lines (109 loc) · 3.75 KB
/
generalform.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* Mobius Software LTD
* Copyright 2015-2018, Mobius Software LTD
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
#include "generalform.h"
#include "ui_generalform.h"
#include "iot-protocols/classes/iotenumprotocol.h"
GeneralForm::GeneralForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::GeneralForm)
{
ui->setupUi(this);
this->setStyleSheet(".QFrame {background-image: url(:/resources/resources/iot_broker_background.jpg) }");
ui->progressBar->setValue(0);
connect(ui->topicsTab, SIGNAL(addNewTopic(TopicEntity)), this, SLOT(willSubscribeToTopicSlot(TopicEntity)));
connect(ui->topicsTab, SIGNAL(deleteTopic(TopicEntity)), this, SLOT(willUnsubscribeFromTopicSlot(TopicEntity)));
connect(ui->sendMessageTab, SIGNAL(donePublishForSending(MessageEntity)), this, SLOT(willPublishSlot(MessageEntity)));
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChangedSlot(int)));
connect(ui->tabWidget, SIGNAL(tabBarClicked(int)), this, SLOT(tabBarClicked()));
}
void GeneralForm::willSubscribeToTopicSlot(TopicEntity topicEntity)
{
emit willSubscribeToTopic(topicEntity);
}
void GeneralForm::willUnsubscribeFromTopicSlot(TopicEntity topicEntity)
{
emit willUnsubscribeFromTopic(topicEntity);
}
void GeneralForm::willPublishSlot(MessageEntity message)
{
emit willPublish(message);
}
void GeneralForm::currentTabChangedSlot(int index)
{
int topicsTabIndex = ui->tabWidget->indexOf(ui->topicsTab);
int messagesTabIndex = ui->tabWidget->indexOf(ui->messagesListTab);
int logoutTabIndex = ui->tabWidget->indexOf(ui->logoutTab);
if (index == topicsTabIndex) {
emit topicsTabDidClick();
} else if (index == messagesTabIndex) {
emit messagesTabDidCLick();
} else if (index == logoutTabIndex) {
ui->tabWidget->setCurrentIndex(this->previousIndex);
emit logoutTabDidCLick();
}
}
void GeneralForm::tabBarClicked()
{
this->previousIndex = ui->tabWidget->currentIndex();
}
void GeneralForm::setMessages(QList<MessageEntity> list)
{
ui->messagesListTab->setMessageList(list);
}
void GeneralForm::setQoSForMessagesAndTopicsTab(int protocol)
{
QList<QString> qosList = QList<QString>();
qosList.append(QString::number(1));
if(protocol != AMQP_PROTOCOL)
qosList.append(QString::number(0));
if(protocol != AMQP_PROTOCOL && protocol != COAP_PROTOCOL)
qosList.append(QString::number(2));
qosList.sort();
ui->sendMessageTab->setQoSForSendMessagesTab(qosList);
ui->topicsTab->setQosForTopicsListTab(qosList);
}
void GeneralForm::setTopics(QList<TopicEntity> list)
{
ui->topicsTab->setTopicsList(list);
}
int GeneralForm::getProgress()
{
return ui->progressBar->value();
}
void GeneralForm::setProgress(int value)
{
ui->progressBar->setValue(value);
}
int GeneralForm::getProgressMax()
{
return ui->progressBar->maximum();
}
int GeneralForm::getProgressMin()
{
return ui->progressBar->minimum();
}
QSize GeneralForm::getSize()
{
return QSize(392, 533);
}
GeneralForm::~GeneralForm()
{
delete ui;
}