forked from kenygia/MooseEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddNodeDialog.cpp
89 lines (77 loc) · 2.17 KB
/
AddNodeDialog.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
#include "AddNodeDialog.h"
#include "ui_AddNodeDialog.h"
#include <boost/lexical_cast.hpp>
AddNodeDialog::AddNodeDialog(LsbObject *parentObject, std::vector<TAG_LSB *> *tagList, QWidget *parent) :
QDialog(parent), parentObject(parentObject), tagList(tagList),
ui(new Ui::AddNodeDialog)
{
ui->setupUi(this);
QRadioButton *noRadio = this->findChild<QRadioButton *>("noDir");
if (noRadio != 0) {
isDirectory = false;
noRadio->setChecked(true);
}
}
AddNodeDialog::~AddNodeDialog()
{
delete ui;
}
LsbObject *AddNodeDialog::getNewLsbObject() {
return newObject;
}
void AddNodeDialog::on_buttonBox_accepted()
{
if (parentObject != 0 && newObject == 0 && tagList != 0) {
TAG_LSB *tag = LsbObject::createTagIfNeeded(tagName.c_str(), tagList);
if (this->nodeType.length() > 0 || this->isDirectory) {
long type = 0;
try {
type = boost::lexical_cast<long>(nodeType);
} catch (const boost::bad_lexical_cast& e) {
}
newObject = new LsbObject(isDirectory, tag->index, tag->tag, type, parentObject, tagList);
if (this->nodeValue.length() > 0) {
newObject->fromString(this->nodeValue);
}
this->setResult(1);
return;
}
}
this->setResult(0);
}
void AddNodeDialog::on_buttonBox_rejected()
{
this->setResult(0);
}
void AddNodeDialog::on_nameEdit_textChanged(const QString &text)
{
this->tagName = text.toStdString();
}
void AddNodeDialog::on_typeEdit_textChanged(const QString &text)
{
this->nodeType = text.toStdString();
}
void AddNodeDialog::on_valueEdit_textChanged(const QString &text)
{
this->nodeValue = text.toStdString();
}
void AddNodeDialog::on_yesDir_clicked()
{
this->isDirectory = true;
QLineEdit *typeEdit = this->findChild<QLineEdit *>("typeEdit");
QLineEdit *valueEdit = this->findChild<QLineEdit *>("valueEdit");
if (typeEdit != 0 && valueEdit != 0) {
typeEdit->setEnabled(false);
valueEdit->setEnabled(false);
}
}
void AddNodeDialog::on_noDir_clicked()
{
this->isDirectory = false;
QLineEdit *typeEdit = this->findChild<QLineEdit *>("typeEdit");
QLineEdit *valueEdit = this->findChild<QLineEdit *>("valueEdit");
if (typeEdit != 0 && valueEdit != 0) {
typeEdit->setEnabled(true);
valueEdit->setEnabled(true);
}
}