29#include <QDialogButtonBox>
32#include "moc_qgsnumericformatwidget.cpp"
34using namespace Qt::StringLiterals;
38 mExpressionContextGenerator = generator;
43 if ( mExpressionContextGenerator )
44 return mExpressionContextGenerator->createExpressionContext();
57 mDecimalsSpinBox->setClearValue( 6 );
58 mThousandsLineEdit->setShowClearButton(
true );
59 mDecimalLineEdit->setShowClearButton(
true );
61 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
62 mFormat->setShowPlusSign( checked );
67 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
68 mFormat->setShowTrailingZeros( checked );
73 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
74 mFormat->setShowThousandsSeparator( checked );
79 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
80 mFormat->setNumberDecimalPlaces( value );
85 connect( mRadDecimalPlaces, &QRadioButton::toggled,
this, [
this](
bool checked ) {
94 connect( mRadSignificantFigures, &QRadioButton::toggled,
this, [
this](
bool checked ) {
103 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
104 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
105 if ( !mBlockSignals )
109 connect( mDecimalLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
110 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
111 if ( !mBlockSignals )
122 mBlockSignals =
true;
123 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
124 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
125 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
126 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
127 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
128 mDecimalLineEdit->setText( mFormat->decimalSeparator().isNull() ? QString() : mFormat->decimalSeparator() );
129 switch ( mFormat->roundingType() )
132 mRadDecimalPlaces->setChecked(
true );
136 mRadSignificantFigures->setChecked(
true );
140 mBlockSignals =
false;
145 return mFormat->
clone();
157 mDecimalsSpinBox->setClearValue( 6 );
164 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
165 mFormat->setShowTrailingZeros( checked );
166 if ( !mBlockSignals )
170 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
171 mFormat->setNumberDecimalPlaces( value );
172 if ( !mBlockSignals )
176 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
178 if ( !mBlockSignals )
189 mBlockSignals =
true;
190 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
191 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
192 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast<int>( mFormat->directionFormat() ) ) );
193 mBlockSignals =
false;
198 return mFormat->
clone();
208 setLayout(
new QVBoxLayout() );
210 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
212 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
213 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
215 layout()->addWidget( mWidget );
216 layout()->addWidget( buttonBox );
220 setObjectName( u
"QgsBearingNumericFormatDialog"_s );
239 mDecimalsSpinBox->setClearValue( 6 );
244 if ( hidePrecisionControl )
246 mLabelDecimalPlaces->hide();
247 mDecimalsSpinBox->hide();
251 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
252 mFormat->setShowTrailingZeros( checked );
253 if ( !mBlockSignals )
257 connect( mShowDirectionalSuffixCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
258 mFormat->setShowDirectionalSuffix( checked );
259 if ( !mBlockSignals )
263 connect( mShowLeadingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
264 mFormat->setShowLeadingZeros( checked );
265 if ( !mBlockSignals )
269 connect( mShowLeadingZerosForDegreesCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
270 mFormat->setShowDegreeLeadingZeros( checked );
271 if ( !mBlockSignals )
275 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
276 mFormat->setNumberDecimalPlaces( value );
277 if ( !mBlockSignals )
281 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
283 if ( !mBlockSignals )
294 mBlockSignals =
true;
295 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
296 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
297 mShowDirectionalSuffixCheckBox->setChecked( mFormat->showDirectionalSuffix() );
298 mShowLeadingZerosCheckBox->setChecked( mFormat->showLeadingZeros() );
299 mShowLeadingZerosForDegreesCheckBox->setChecked( mFormat->showDegreeLeadingZeros() );
300 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast<int>( mFormat->angleFormat() ) ) );
301 mBlockSignals =
false;
306 return mFormat->
clone();
316 setLayout(
new QVBoxLayout() );
318 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
320 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
321 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
323 layout()->addWidget( mWidget );
324 layout()->addWidget( buttonBox );
328 setObjectName( u
"QgsGeographicCoordinateNumericFormatDialog"_s );
345 mDecimalsSpinBox->setClearValue( 2 );
348 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
349 mFormat->setShowPlusSign( checked );
350 if ( !mBlockSignals )
354 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
355 mFormat->setShowTrailingZeros( checked );
356 if ( !mBlockSignals )
360 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
361 mFormat->setShowThousandsSeparator( checked );
362 if ( !mBlockSignals )
366 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
367 mFormat->setNumberDecimalPlaces( value );
368 if ( !mBlockSignals )
372 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
373 mFormat->setPrefix( text );
374 if ( !mBlockSignals )
378 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
379 mFormat->setSuffix( text );
380 if ( !mBlockSignals )
391 mBlockSignals =
true;
392 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
393 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
394 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
395 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
396 mPrefixLineEdit->setText( mFormat->prefix() );
397 mSuffixLineEdit->setText( mFormat->suffix() );
399 mBlockSignals =
false;
404 return mFormat->
clone();
417 mDecimalsSpinBox->setClearValue( 6 );
423 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
424 mFormat->setShowTrailingZeros( checked );
425 if ( !mBlockSignals )
429 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
430 mFormat->setShowPlusSign( checked );
431 if ( !mBlockSignals )
435 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
436 mFormat->setShowThousandsSeparator( checked );
437 if ( !mBlockSignals )
441 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
442 mFormat->setNumberDecimalPlaces( value );
443 if ( !mBlockSignals )
447 connect( mScalingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
449 if ( !mBlockSignals )
460 mBlockSignals =
true;
461 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
462 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
463 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
464 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
465 mScalingComboBox->setCurrentIndex( mScalingComboBox->findData(
static_cast<int>( mFormat->inputValues() ) ) );
466 mBlockSignals =
false;
471 return mFormat->
clone();
481 mDecimalsSpinBox->setClearValue( 6 );
484 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
485 mFormat->setShowPlusSign( checked );
486 if ( !mBlockSignals )
490 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
491 mFormat->setShowTrailingZeros( checked );
492 if ( !mBlockSignals )
496 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
497 mFormat->setNumberDecimalPlaces( value );
498 if ( !mBlockSignals )
509 mBlockSignals =
true;
510 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
511 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
512 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
513 mBlockSignals =
false;
518 return mFormat->
clone();
531 mThousandsLineEdit->setShowClearButton(
true );
533 connect( mUseDedicatedUnicodeCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
534 mFormat->setUseDedicatedUnicodeCharacters( checked );
535 if ( !mBlockSignals )
539 connect( mUseUnicodeSupersubscriptCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
540 mFormat->setUseUnicodeSuperSubscript( checked );
541 if ( !mBlockSignals )
545 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
546 mFormat->setShowPlusSign( checked );
547 if ( !mBlockSignals )
551 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
552 mFormat->setShowThousandsSeparator( checked );
553 if ( !mBlockSignals )
557 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
558 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
559 if ( !mBlockSignals )
570 mBlockSignals =
true;
571 mUseDedicatedUnicodeCheckBox->setChecked( mFormat->useDedicatedUnicodeCharacters() );
572 mUseUnicodeSupersubscriptCheckBox->setChecked( mFormat->useUnicodeSuperSubscript() );
573 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
574 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
575 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
576 mBlockSignals =
false;
581 return mFormat->
clone();
594 mExpressionSelector->setMultiLine(
true );
595 mExpressionSelector->registerExpressionContextGenerator(
this );
598 mFormat->setExpression( text );
599 if ( !mBlockSignals )
621 mBlockSignals =
true;
622 mExpressionSelector->setExpression( mFormat->expression() );
623 mBlockSignals =
false;
628 return mFormat->
clone();
Abstract interface for generating an expression context.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Single variable definition for use within a QgsExpressionContextScope.