-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstopservers.cpp
64 lines (51 loc) · 1.57 KB
/
stopservers.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
#include "stopservers.h"
#include "ui_stopservers.h"
#include "servermanager.h"
CStopServers::CStopServers(QWidget *parent) :
QDialog(parent),
CLogable("StopServerLogger"),
ui(new Ui::CStopServers)
{
ui->setupUi(this);
}
CStopServers::~CStopServers()
{
delete ui;
}
void CStopServers::show()
{
std::string errMsg("");
ui->comboBox->clear();
auto data = std::move(CServerManager::getReference().getTableData());
ui->comboBox->addItem("All", QVariant(-1));
for (auto& outer : data)
{
if (ui->comboBox->findText(outer.second[CServerManager::SERVER_NAME]) == -1)
{
//qDebug() << "the status is: " << outer.second[CServerManager::STATUS];
LOGGER_HELPER(DEBUG, errMsg, "the status is:", outer.second[CServerManager::STATUS]);
if (outer.second[CServerManager::STATUS] == CServerManager::ACTIVE)
{
ui->comboBox->addItem(outer.second[CServerManager::SERVER_NAME], QVariant(outer.first));
}
}
}
QDialog::show();
}
void CStopServers::on_pushButton_clicked()
{
std::string errMsg("");
auto currVal = ui->comboBox->currentData().toString();
(currVal == "-1") ? currVal = "All" : "";
//qDebug() << "Stoping server: [ " << currVal << "]";
LOGGER_HELPER(DEBUG, errMsg, "Stopping server: [ " , currVal, " ]");
if (currVal == "All")
{
CServerManager::getReference().deleteAll();
}
else //we just need to start one server
{
CServerManager::getReference().deleteClient(currVal.toInt());
}
hide();
}