-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditsectorwidget.cpp
More file actions
91 lines (73 loc) · 2.02 KB
/
editsectorwidget.cpp
File metadata and controls
91 lines (73 loc) · 2.02 KB
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
#include "editsectorwidget.h"
#include "tools.h"
#include <QDoubleSpinBox>
#include <QLabel>
#include <QPushButton>
#include <QFormLayout>
#include <QLayout>
EditSectorWidget::EditSectorWidget(QWidget *parent = 0) :
QDialog(parent), degreeChar(0x00B0)
{
setLayout(new QVBoxLayout());
createCentralWidgets();
createButtons();
}
void EditSectorWidget::createCentralWidgets()
{
QVBoxLayout *mainLayout = qobject_cast<QVBoxLayout*>(layout());
if (!mainLayout)
{
return;
}
QFormLayout *widgetsLayout = new QFormLayout;
mainLayout->addLayout(widgetsLayout);
beginSectorSB = new QDoubleSpinBox;
beginSectorSB->setRange(0, 360);
beginSectorSB->setDecimals(2);
beginSectorSB->setSuffix(degreeChar);
endSectorSB = new QDoubleSpinBox;
endSectorSB->setRange(0, 360);
endSectorSB->setDecimals(2);
endSectorSB->setSuffix(degreeChar);
widgetsLayout->addRow("Begin sector: ", beginSectorSB);
widgetsLayout->addRow("End sector: ", endSectorSB);
}
void EditSectorWidget::createButtons()
{
QVBoxLayout *mainLayout = qobject_cast<QVBoxLayout*>(layout());
if (!mainLayout)
{
return;
}
QHBoxLayout *buttonsLayout = new QHBoxLayout;
mainLayout->addLayout(buttonsLayout);
QPushButton *okButton = new QPushButton(tr("Ok"));
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
QPushButton *cancelButton = new QPushButton(tr("Cancel"));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
buttonsLayout->addStretch();
buttonsLayout->addWidget(okButton);
buttonsLayout->addWidget(cancelButton);
}
void EditSectorWidget::setSector(const Sector §or)
{
mSector = sector;
beginSectorSB->setValue(sector.begin);
endSectorSB->setValue(sector.end);
}
Sector EditSectorWidget::sector()
{
mSector.begin = beginSectorSB->value();
mSector.end = endSectorSB->value();
return mSector;
}
void EditSectorWidget::accept()
{
if (beginSectorSB->value() == endSectorSB->value())
{
Tools::information(this, "Information",
"Beginning and ending of sector are equal!", "Correct this");
return;
}
QDialog::accept();
}