17#include "moc_qgsnumericformatwidget.cpp"
28#include <QDialogButtonBox>
32 mExpressionContextGenerator = generator;
37 if ( mExpressionContextGenerator )
51 mDecimalsSpinBox->setClearValue( 6 );
52 mThousandsLineEdit->setShowClearButton(
true );
53 mDecimalLineEdit->setShowClearButton(
true );
55 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
57 mFormat->setShowPlusSign( checked );
62 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
64 mFormat->setShowTrailingZeros( checked );
69 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
71 mFormat->setShowThousandsSeparator( checked );
76 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [ = ](
int value )
78 mFormat->setNumberDecimalPlaces( value );
83 connect( mRadDecimalPlaces, &QRadioButton::toggled,
this, [ = ](
bool checked )
93 connect( mRadSignificantFigures, &QRadioButton::toggled,
this, [ = ](
bool checked )
103 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
105 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
106 if ( !mBlockSignals )
110 connect( mDecimalLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
112 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
113 if ( !mBlockSignals )
124 mBlockSignals =
true;
125 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
126 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
127 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
128 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
129 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
130 mDecimalLineEdit->setText( mFormat->decimalSeparator().isNull() ? QString() : mFormat->decimalSeparator() );
131 switch ( mFormat->roundingType() )
134 mRadDecimalPlaces->setChecked(
true );
138 mRadSignificantFigures->setChecked(
true );
142 mBlockSignals =
false;
147 return mFormat->clone();
159 mDecimalsSpinBox->setClearValue( 6 );
166 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
168 mFormat->setShowTrailingZeros( checked );
169 if ( !mBlockSignals )
173 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [ = ](
int value )
175 mFormat->setNumberDecimalPlaces( value );
176 if ( !mBlockSignals )
180 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
183 if ( !mBlockSignals )
194 mBlockSignals =
true;
195 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
196 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
197 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast< int >( mFormat->directionFormat() ) ) );
198 mBlockSignals =
false;
203 return mFormat->clone();
213 setLayout(
new QVBoxLayout() );
215 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
217 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
218 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
220 layout()->addWidget( mWidget );
221 layout()->addWidget( buttonBox );
225 setObjectName( QStringLiteral(
"QgsBearingNumericFormatDialog" ) );
247 mDecimalsSpinBox->setClearValue( 6 );
252 if ( hidePrecisionControl )
254 mLabelDecimalPlaces->hide();
255 mDecimalsSpinBox->hide();
259 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
261 mFormat->setShowTrailingZeros( checked );
262 if ( !mBlockSignals )
266 connect( mShowDirectionalSuffixCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
268 mFormat->setShowDirectionalSuffix( checked );
269 if ( !mBlockSignals )
273 connect( mShowLeadingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
275 mFormat->setShowLeadingZeros( checked );
276 if ( !mBlockSignals )
280 connect( mShowLeadingZerosForDegreesCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
282 mFormat->setShowDegreeLeadingZeros( checked );
283 if ( !mBlockSignals )
287 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [ = ](
int value )
289 mFormat->setNumberDecimalPlaces( value );
290 if ( !mBlockSignals )
294 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
297 if ( !mBlockSignals )
308 mBlockSignals =
true;
309 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
310 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
311 mShowDirectionalSuffixCheckBox->setChecked( mFormat->showDirectionalSuffix() );
312 mShowLeadingZerosCheckBox->setChecked( mFormat->showLeadingZeros() );
313 mShowLeadingZerosForDegreesCheckBox->setChecked( mFormat->showDegreeLeadingZeros() );
314 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast< int >( mFormat->angleFormat() ) ) );
315 mBlockSignals =
false;
320 return mFormat->clone();
330 setLayout(
new QVBoxLayout() );
332 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
334 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
335 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
337 layout()->addWidget( mWidget );
338 layout()->addWidget( buttonBox );
342 setObjectName( QStringLiteral(
"QgsGeographicCoordinateNumericFormatDialog" ) );
361 mDecimalsSpinBox->setClearValue( 2 );
364 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
366 mFormat->setShowPlusSign( checked );
367 if ( !mBlockSignals )
371 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
373 mFormat->setShowTrailingZeros( checked );
374 if ( !mBlockSignals )
378 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
380 mFormat->setShowThousandsSeparator( checked );
381 if ( !mBlockSignals )
385 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [ = ](
int value )
387 mFormat->setNumberDecimalPlaces( value );
388 if ( !mBlockSignals )
392 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
394 mFormat->setPrefix( text );
395 if ( !mBlockSignals )
399 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
401 mFormat->setSuffix( text );
402 if ( !mBlockSignals )
413 mBlockSignals =
true;
414 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
415 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
416 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
417 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
418 mPrefixLineEdit->setText( mFormat->prefix() );
419 mSuffixLineEdit->setText( mFormat->suffix() );
421 mBlockSignals =
false;
426 return mFormat->clone();
439 mDecimalsSpinBox->setClearValue( 6 );
445 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
447 mFormat->setShowTrailingZeros( checked );
448 if ( !mBlockSignals )
452 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
454 mFormat->setShowPlusSign( checked );
455 if ( !mBlockSignals )
459 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
461 mFormat->setShowThousandsSeparator( checked );
462 if ( !mBlockSignals )
466 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [ = ](
int value )
468 mFormat->setNumberDecimalPlaces( value );
469 if ( !mBlockSignals )
473 connect( mScalingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ](
int )
476 if ( !mBlockSignals )
487 mBlockSignals =
true;
488 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
489 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
490 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
491 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
492 mScalingComboBox->setCurrentIndex( mScalingComboBox->findData(
static_cast< int >( mFormat->inputValues() ) ) );
493 mBlockSignals =
false;
498 return mFormat->clone();
508 mDecimalsSpinBox->setClearValue( 6 );
511 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
513 mFormat->setShowPlusSign( checked );
514 if ( !mBlockSignals )
518 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
520 mFormat->setShowTrailingZeros( checked );
521 if ( !mBlockSignals )
525 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [ = ](
int value )
527 mFormat->setNumberDecimalPlaces( value );
528 if ( !mBlockSignals )
539 mBlockSignals =
true;
540 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
541 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
542 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
543 mBlockSignals =
false;
548 return mFormat->clone();
562 mThousandsLineEdit->setShowClearButton(
true );
564 connect( mUseDedicatedUnicodeCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
566 mFormat->setUseDedicatedUnicodeCharacters( checked );
567 if ( !mBlockSignals )
571 connect( mUseUnicodeSupersubscriptCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
573 mFormat->setUseUnicodeSuperSubscript( checked );
574 if ( !mBlockSignals )
578 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
580 mFormat->setShowPlusSign( checked );
581 if ( !mBlockSignals )
585 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [ = ](
bool checked )
587 mFormat->setShowThousandsSeparator( checked );
588 if ( !mBlockSignals )
592 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
594 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
595 if ( !mBlockSignals )
607 mBlockSignals =
true;
608 mUseDedicatedUnicodeCheckBox->setChecked( mFormat->useDedicatedUnicodeCharacters() );
609 mUseUnicodeSupersubscriptCheckBox->setChecked( mFormat->useUnicodeSuperSubscript() );
610 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
611 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
612 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
613 mBlockSignals =
false;
618 return mFormat->clone();
631 mExpressionSelector->setMultiLine(
true );
632 mExpressionSelector->registerExpressionContextGenerator(
this );
636 mFormat->setExpression( text );
637 if ( !mBlockSignals )
660 mBlockSignals =
true;
661 mExpressionSelector->setExpression( mFormat->expression() );
662 mBlockSignals =
false;
667 return mFormat->clone();
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
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.