Debian Codegraph @

HercConfiguration/TerminalProperties.cpp

raw symbols SCIP
1 /*
2 * File: TerminalProperties.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 7, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25 #include "TerminalProperties.h"
26 #include "ConfigLine.h"
27
28 #include <sstream>
29
30 TerminalProperties::TerminalProperties(ConfigLine & line, QWidget *parent)
31 : GenericDeviceProperties(line, parent)
32 {
33 ui.setupUi(this);
34
35 if (!line.isNew())
36 {
37 ui.deviceNumber->setText(mLine.getToken(0).c_str());
38 ui.terminalCombo->setCurrentIndex( (mLine.getToken(1) == "3287") ? 1 : 0);
39 if (mLine.size() > 2)
40 {
41 int index = 2;
42 if (mLine.getToken(index).compare("SYSGCONS") == 0)
43 index++;
44 if (mLine.getToken(index)[0] == '*')
45 index++;
46 else
47 ui.groupName->setText(mLine.getToken(index++).c_str());
48 if (mLine.size() >= index)
49 ui.IPAddress->setText(mLine.getToken(index).c_str());
50 }
51 }
52
53 connect(ui.OKButton, SIGNAL(clicked()), this, SLOT(ok()));
54 connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
55 }
56
57 TerminalProperties::~TerminalProperties()
58 {
59
60 }
61
62 void TerminalProperties::ok()
63 {
64 if (!deviceNumberValidator(ui.deviceNumber))
65 return;
66 std::stringstream newLineBuff;
67 std::string ip;
68 if (ui.IPAddress->text().toStdString() == "...") // no address
69 ip = "";
70 else
71 {
72 if (!validateIp(ui.IPAddress,false, false))
73 return;
74 ip = ui.IPAddress->text().toStdString();
75 }
76
77 std::string sysgText;
78 if (isSysg()) sysgText = "SYSGCONS ";
79
80 newLineBuff << ui.deviceNumber->text().toStdString()
81 << " " << ui.terminalCombo->currentText().toStdString()
82 << " " << sysgText;
83 if (ui.groupName->text().length() == 0)
84 {
85 newLineBuff << " *";
86 }
87 else
88 {
89 newLineBuff << " " << ui.groupName->text().toStdString();
90 }
91 newLineBuff << " " << ip + "\n";
92 hOutDebug(3,"terminal: new line:" << newLineBuff.str()
93 << " " << &mLine);
94 mLine.replaceLine(newLineBuff.str());
95 emit updateLine(true);
96 this->deleteLater();
97 }
98
99 bool TerminalProperties::isSysg()
100 {
101 return false;
102 }
103
104 void TerminalProperties::cancel()
105 {
106 emit updateLine(false);
107 this->deleteLater();
108 }
109
110
111
112
113