-
Notifications
You must be signed in to change notification settings - Fork 12
/
RefDialog.cpp
60 lines (54 loc) · 1.33 KB
/
RefDialog.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
#include "RefDialog.h"
#include "ui_RefDialog.h"
#include <QIntValidator>
RefDialog::RefDialog(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::RefDialog)
{
m_ui->setupUi(this);
QIntValidator* val = new QIntValidator(this);
val->setBottom(0);
m_ui->parentBox->setValidator(val);
val = new QIntValidator(this);
val->setBottom(0);
m_ui->childBox->setValidator(val);
connect(this, SIGNAL(accepted()), this, SLOT(sendRef()));
}
RefDialog::~RefDialog()
{
delete m_ui;
}
void RefDialog::changeEvent(QEvent *e)
{
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
void RefDialog::sendRef() {
bool ok;
uint32_t parent = m_ui->parentBox->text().toUInt(&ok, 10);
if(!ok) {
qWarning("Invalid Parent");
return;
}
uint32_t child = m_ui->childBox->text().toUInt(&ok, 10);
if(!ok) {
qWarning("Invalid Child");
return;
}
if(m_ui->useOwnerBox->checkState())
emit addRef(parent, child, owner);
else
emit addRef(parent, child, 0);
}
void RefDialog::setupRefBox(uint32_t owner, uint32_t parent) {
this->owner = owner;
if(parent) {
m_ui->parentBox->setText(QString("%1").arg(parent, 0, 10));
m_ui->parentBox->setEnabled(false);
}
}