-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialognewnet.cpp
83 lines (73 loc) · 2.7 KB
/
dialognewnet.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
#include <QtWidgets/QMessageBox>
#include <iostream>
#include "dialognewnet.h"
#include "ui_dialognewnet.h"
dialogNewNet::dialogNewNet(QWidget *parent) :
QDialog(parent),
ui(new Ui::dialogNewNet)
{
ui->setupUi(this);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("New Network"));
uiMan = new manager();
delete ui->lineEdit_2;
delete ui->label_2;
setupBtns();
}
dialogNewNet::~dialogNewNet()
{
delete ui;
}
void dialogNewNet::setupBtns() {
connect(ui->buttonBox, SIGNAL (accepted()), this, SLOT (apply()));
connect(ui->buttonBox, SIGNAL (rejected()), this, SLOT (abort()));
}
void dialogNewNet::apply() {
QString name = ui->lineEdit->text();
string nameS = name.toStdString();
//QString subnet = ui->lineEdit_2->text();
//string subnetS = subnet.toStdString();
if( nameS != "" && uiMan->isNotWhiteSpace(nameS)/* && subnetS != "" && uiMan->isNotWhiteSpace(subnetS)*/){
//string gw = uiMan->createGwForExam(subnetS);
string result = "error";
//result = uiMan->getDocker()->addNet(nameS, subnetS, gw);
result = uiMan->addNetExam(nameS);
//cout << result;
if(result != "invalid" && result != "already" && result != "") {
emit refresh();
delete this;
return;
}
if(result == "invalid") {
QMessageBox messageBox;
//messageBox.critical(0,"Error","Can't create network! Check your subnet and network name. Use just letters and number to specify the network name");
messageBox.critical(0,"Error","Can't create network! Check your network name. Use just letters and number to specify the network name");
messageBox.setFixedSize(100,50);
delete this;
return;
}
if(result == "already"){
QMessageBox messageBox;
//messageBox.critical(0,"Error","Can't create network! Subnet or name already in use!");
messageBox.critical(0,"Error","Can't create network! Name already in use!");
messageBox.setFixedSize(100,50);
delete this;
return;
}
} else {
QMessageBox messageBox;
messageBox.critical(0,"Error","Specify a name!");
//messageBox.critical(0,"Error","Specify a name and a subnet (for example 10.0.0.1/24)");
messageBox.setFixedSize(100,50);
delete this;
return;
}
/*QMessageBox messageBox;
messageBox.critical(0,"Error","Unspecified error. Use just letters and number to specify the network name");
messageBox.setFixedSize(100,50);
delete this;
return;*/
}
void dialogNewNet::abort() {
delete this;
}