21 #include <QGridLayout>
23 #include <QHBoxLayout>
27 #include <QVBoxLayout>
38 const double *scaleLength) :
39 QDialog (&mainWindow),
40 m_modelCoords (modelCoords),
41 m_modelGeneral (modelGeneral),
42 m_modelMainWindow (modelMainWindow)
46 QVBoxLayout *layout =
new QVBoxLayout;
49 setCursor (QCursor (Qt::ArrowCursor));
51 setWindowTitle (tr (
"Edit Axis Point"));
53 createScaleLength (layout);
55 createOkCancel (layout);
57 initializeScaleLength (scaleLength);
67 void DlgEditScale::createHint (QVBoxLayout *layoutOuter)
72 QWidget *widget =
new QWidget;
73 layoutOuter->addWidget (widget, 0, Qt::AlignCenter);
75 QHBoxLayout *layout =
new QHBoxLayout;
76 widget->setLayout (layout);
79 QString hint = QString (
"%1: %2")
80 .arg (tr (
"Number format"))
82 QLabel *label =
new QLabel (hint);
83 layout->addWidget (label);
86 void DlgEditScale::createOkCancel (QVBoxLayout *layoutOuter)
88 QWidget *panel =
new QWidget (
this);
89 layoutOuter->addWidget (panel, 0, Qt::AlignCenter);
91 QHBoxLayout *layout =
new QHBoxLayout (panel);
92 panel->setLayout (layout);
94 m_btnOk =
new QPushButton (tr (
"Ok"),
this);
95 layout->addWidget(m_btnOk);
96 connect (m_btnOk, SIGNAL (released ()),
this, SLOT (accept ()));
98 m_btnCancel =
new QPushButton (tr (
"Cancel"),
this);
99 layout->addWidget(m_btnCancel);
100 connect (m_btnCancel, SIGNAL (released ()),
this, SLOT (reject ()));
103 void DlgEditScale::createScaleLength (QVBoxLayout *layoutOuter)
110 QGroupBox *panel =
new QGroupBox (tr (
"Scale Length"),
this);
111 layoutOuter->addWidget (panel);
113 QHBoxLayout *layout =
new QHBoxLayout (panel);
114 panel->setLayout (layout);
117 m_editScaleLength =
new QLineEdit;
119 m_editScaleLength->setAlignment (
ALIGNMENT);
120 m_editScaleLength->setValidator (m_validatorScaleLength);
122 m_editScaleLength->setWhatsThis (tr (
"Enter the scale bar length"));
123 layout->addWidget(m_editScaleLength, 0);
124 connect (m_editScaleLength, SIGNAL (textChanged (
const QString &)),
this, SLOT (slotTextChanged (
const QString &)));
127 void DlgEditScale::initializeScaleLength (
const double *scaleLength)
129 if (scaleLength !=
nullptr) {
130 m_editScaleLength->setText (QString::number (*scaleLength));
136 double xTheta, yRadius;
137 const QString DUMMY_Y (
"0");
152 void DlgEditScale::slotTextChanged (
const QString &)
157 void DlgEditScale::updateControls ()
159 QString textScaleLength = m_editScaleLength->text();
164 m_btnOk->setEnabled (!textScaleLength.isEmpty () &&
165 (m_validatorScaleLength->
validate(textScaleLength, posScaleLength) == QValidator::Acceptable));
Model for DlgSettingsGeneral and CmdSettingsGeneral.
DlgValidatorAbstract * createAboveZero(const QLocale &locale) const
Factory method for generating validators for scale length which must be a number greater than zero...
virtual QValidator::State validate(QString &input, int &pos) const =0
Validate according to the numeric format specific to the leaf class.
#define LOG4CPP_INFO_S(logger)
Model for DlgSettingsMainWindow.
Model for DlgSettingsCoords and CmdSettingsCoords.
const int MIN_WIDTH_TO_FIT_STRANGE_UNITS
const Qt::Alignment ALIGNMENT
log4cpp::Category * mainCat
double scaleLength() const
Return the scale bar length specified by the user. Only applies if dialog was accepted.
QLocale locale() const
Get method for locale.
DlgEditScale(MainWindow &mainWindow, const DocumentModelCoords &modelCoords, const DocumentModelGeneral &modelGeneral, const MainWindowModel &modelMainWindow, const double *scaleLength=0)
Single constructor.
QString QLocaleToString(const QLocale &locale)
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...