forked from xcj2012/Configuration-61850
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adddatesetdlg.cpp.bak
137 lines (130 loc) · 3.43 KB
/
adddatesetdlg.cpp.bak
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
130
131
132
133
134
135
136
137
#include "adddatesetdlg.h"
#include "ui_adddatesetdlg.h"
AddDateSetdlg::AddDateSetdlg(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddDateSetdlg)
{
ui->setupUi(this);
ui->pushButton_ok->setText(tr("Ok"));
ui->pushButton_cancel->setText(tr("Cancel"));
ui->label_name->setText(tr("Name"));
ui->label_desc->setText(tr("Desc"));
ui->groupBox->setTitle(tr("Naming conventions"));
connect(ui->pushButton_ok, SIGNAL(clicked()), this, SLOT(pushbutton_ok()));
connect(ui->pushButton_cancel, SIGNAL(clicked()), this, SLOT(pushbutton_cancel()));
NameList << "dsAin" << "dsDin" << "dsAlarm" << "dsWarning" << "dsCommState" << "dsParameter"
<< "dsInterLock" << "dsGOOSE" << "dsTripInfo" << "dsRelayDin" << "dsRelayEna" << "dsRelayRec"
<< "dsRelayAin" << "dsSetting" << "dsSV" << "dsLog";
QStringList DescList;
DescList<< "Analog in" << "Digital in" << "Alarm Signal" << "Warning Signal" << "Communication state" << "Set parameter"
<< "Interlocking state" << "GOOSE Signal" << "Trip Info" << "Relay Digital in" << "Relay Ena" << "Relay Rec"
<< "Relay Analog in" << "Setting" << "SV" << "Log";
ui->textBrowser->append(tr("The format of name is Name+Index"));
ui->textBrowser->append(tr("Example:One Group Goose named dsGOOSE, more than one ,named dsGOOSE1"));
for(int i =0;i<NameList.size();i++)
{
QString str;
str =NameList.at(i)+"::"+DescList.at(i);
ui->textBrowser->append(str);
}
}
AddDateSetdlg::~AddDateSetdlg()
{
delete ui;
}
void AddDateSetdlg::pushbutton_ok()
{
if (ui->lineEdit_name->text().isEmpty())
{
QMessageBox::about(0, tr("Alarm"), tr("The name of dataset must be input"));
return;
}
if (ui->lineEdit_desc->text().isEmpty())
{
QMessageBox::about(0, tr("Alarm"), tr("The desc of dataset must be input"));
return;
}
str_DataSetName = ui->lineEdit_name->text();
str_DataSetDesc = ui->lineEdit_desc->text();
if (CheckDataSetName(str_DataSetName) == false)
{
str_DataSetName.clear();
str_DataSetDesc.clear();
return;
}
accept();
}
void AddDateSetdlg::pushbutton_cancel()
{
reject();
}
void AddDateSetdlg::init_dlg()
{
if (i_state == 1)
{
setWindowTitle(tr(" Add new DataSet"));
}
else if (i_state == 2)
{
setWindowTitle(tr("Rename DataSet"));
ui->lineEdit_name->setText(str_DataSetName);
ui->lineEdit_desc->setText(QString(str_DataSetDesc));
}
}
void AddDateSetdlg::setstate(int state)
{
i_state = state;
}
void AddDateSetdlg::SetDataSetName(QString strname)
{
str_DataSetName = strname;
}
void AddDateSetdlg::SetDataSetDesc(QString strDesc)
{
str_DataSetDesc = strDesc;
}
QString AddDateSetdlg::GetDataSetName()
{
return str_DataSetName;
}
QString AddDateSetdlg::GetDataSetDesc()
{
return str_DataSetDesc;
}
bool AddDateSetdlg::CheckDataSetName(QString Name)
{
int k = 0;
for (int i = 0; i < NameList.size(); i++)
{
if (Name.contains(NameList.at(i), Qt::CaseInsensitive))
{
k = i + 1;
break;
}
}
if (k == 0)
{
QMessageBox::about(this, tr("Notice"), tr("The format of name is wrong"));
return false;
}
else
{
int index;
index = Name.indexOf(NameList.at(k - 1));
if (index != 0)
{
QMessageBox::about(this, tr("Notice"), tr("Can not add prefix"));
return false;
}
QString str = Name.remove(NameList.at(k - 1));
for (int i = 0; i < str.size(); i++)
{
if ((str.at(i)<'0') || (str.at(i)>'9'))
{
QMessageBox::about(this, tr("Notice"), tr("The Index only can be number"));
return false;
}
}
}
return true;
}