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 ) {
56 mFormat->setShowPlusSign( checked );
61 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
62 mFormat->setShowTrailingZeros( checked );
67 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
68 mFormat->setShowThousandsSeparator( checked );
73 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [=](
int value ) {
74 mFormat->setNumberDecimalPlaces( value );
79 connect( mRadDecimalPlaces, &QRadioButton::toggled,
this, [=](
bool checked ) {
88 connect( mRadSignificantFigures, &QRadioButton::toggled,
this, [=](
bool checked ) {
97 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [=](
const QString &text ) {
98 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
103 connect( mDecimalLineEdit, &QLineEdit::textChanged,
this, [=](
const QString &text ) {
104 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
105 if ( !mBlockSignals )
116 mBlockSignals =
true;
117 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
118 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
119 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
120 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
121 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
122 mDecimalLineEdit->setText( mFormat->decimalSeparator().isNull() ? QString() : mFormat->decimalSeparator() );
123 switch ( mFormat->roundingType() )
126 mRadDecimalPlaces->setChecked(
true );
130 mRadSignificantFigures->setChecked(
true );
134 mBlockSignals =
false;
139 return mFormat->clone();
151 mDecimalsSpinBox->setClearValue( 6 );
158 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
159 mFormat->setShowTrailingZeros( checked );
160 if ( !mBlockSignals )
164 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [=](
int value ) {
165 mFormat->setNumberDecimalPlaces( value );
166 if ( !mBlockSignals )
170 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
172 if ( !mBlockSignals )
183 mBlockSignals =
true;
184 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
185 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
186 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast<int>( mFormat->directionFormat() ) ) );
187 mBlockSignals =
false;
192 return mFormat->clone();
202 setLayout(
new QVBoxLayout() );
204 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
206 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
207 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
209 layout()->addWidget( mWidget );
210 layout()->addWidget( buttonBox );
214 setObjectName( QStringLiteral(
"QgsBearingNumericFormatDialog" ) );
233 mDecimalsSpinBox->setClearValue( 6 );
238 if ( hidePrecisionControl )
240 mLabelDecimalPlaces->hide();
241 mDecimalsSpinBox->hide();
245 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
246 mFormat->setShowTrailingZeros( checked );
247 if ( !mBlockSignals )
251 connect( mShowDirectionalSuffixCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
252 mFormat->setShowDirectionalSuffix( checked );
253 if ( !mBlockSignals )
257 connect( mShowLeadingZerosCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
258 mFormat->setShowLeadingZeros( checked );
259 if ( !mBlockSignals )
263 connect( mShowLeadingZerosForDegreesCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
264 mFormat->setShowDegreeLeadingZeros( checked );
265 if ( !mBlockSignals )
269 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [=](
int value ) {
270 mFormat->setNumberDecimalPlaces( value );
271 if ( !mBlockSignals )
275 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
277 if ( !mBlockSignals )
288 mBlockSignals =
true;
289 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
290 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
291 mShowDirectionalSuffixCheckBox->setChecked( mFormat->showDirectionalSuffix() );
292 mShowLeadingZerosCheckBox->setChecked( mFormat->showLeadingZeros() );
293 mShowLeadingZerosForDegreesCheckBox->setChecked( mFormat->showDegreeLeadingZeros() );
294 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast<int>( mFormat->angleFormat() ) ) );
295 mBlockSignals =
false;
300 return mFormat->clone();
310 setLayout(
new QVBoxLayout() );
312 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
314 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
315 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
317 layout()->addWidget( mWidget );
318 layout()->addWidget( buttonBox );
322 setObjectName( QStringLiteral(
"QgsGeographicCoordinateNumericFormatDialog" ) );
339 mDecimalsSpinBox->setClearValue( 2 );
342 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
343 mFormat->setShowPlusSign( checked );
344 if ( !mBlockSignals )
348 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
349 mFormat->setShowTrailingZeros( checked );
350 if ( !mBlockSignals )
354 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
355 mFormat->setShowThousandsSeparator( checked );
356 if ( !mBlockSignals )
360 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [=](
int value ) {
361 mFormat->setNumberDecimalPlaces( value );
362 if ( !mBlockSignals )
366 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, [=](
const QString &text ) {
367 mFormat->setPrefix( text );
368 if ( !mBlockSignals )
372 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, [=](
const QString &text ) {
373 mFormat->setSuffix( text );
374 if ( !mBlockSignals )
385 mBlockSignals =
true;
386 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
387 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
388 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
389 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
390 mPrefixLineEdit->setText( mFormat->prefix() );
391 mSuffixLineEdit->setText( mFormat->suffix() );
393 mBlockSignals =
false;
398 return mFormat->clone();
411 mDecimalsSpinBox->setClearValue( 6 );
417 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
418 mFormat->setShowTrailingZeros( checked );
419 if ( !mBlockSignals )
423 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
424 mFormat->setShowPlusSign( checked );
425 if ( !mBlockSignals )
429 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
430 mFormat->setShowThousandsSeparator( checked );
431 if ( !mBlockSignals )
435 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [=](
int value ) {
436 mFormat->setNumberDecimalPlaces( value );
437 if ( !mBlockSignals )
441 connect( mScalingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [=](
int ) {
443 if ( !mBlockSignals )
454 mBlockSignals =
true;
455 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
456 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
457 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
458 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
459 mScalingComboBox->setCurrentIndex( mScalingComboBox->findData(
static_cast<int>( mFormat->inputValues() ) ) );
460 mBlockSignals =
false;
465 return mFormat->clone();
475 mDecimalsSpinBox->setClearValue( 6 );
478 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
479 mFormat->setShowPlusSign( checked );
480 if ( !mBlockSignals )
484 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
485 mFormat->setShowTrailingZeros( checked );
486 if ( !mBlockSignals )
490 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [=](
int value ) {
491 mFormat->setNumberDecimalPlaces( value );
492 if ( !mBlockSignals )
503 mBlockSignals =
true;
504 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
505 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
506 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
507 mBlockSignals =
false;
512 return mFormat->clone();
525 mThousandsLineEdit->setShowClearButton(
true );
527 connect( mUseDedicatedUnicodeCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
528 mFormat->setUseDedicatedUnicodeCharacters( checked );
529 if ( !mBlockSignals )
533 connect( mUseUnicodeSupersubscriptCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
534 mFormat->setUseUnicodeSuperSubscript( checked );
535 if ( !mBlockSignals )
539 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
540 mFormat->setShowPlusSign( checked );
541 if ( !mBlockSignals )
545 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [=](
bool checked ) {
546 mFormat->setShowThousandsSeparator( checked );
547 if ( !mBlockSignals )
551 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [=](
const QString &text ) {
552 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
553 if ( !mBlockSignals )
564 mBlockSignals =
true;
565 mUseDedicatedUnicodeCheckBox->setChecked( mFormat->useDedicatedUnicodeCharacters() );
566 mUseUnicodeSupersubscriptCheckBox->setChecked( mFormat->useUnicodeSuperSubscript() );
567 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
568 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
569 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
570 mBlockSignals =
false;
575 return mFormat->clone();
588 mExpressionSelector->setMultiLine(
true );
589 mExpressionSelector->registerExpressionContextGenerator(
this );
592 mFormat->setExpression( text );
593 if ( !mBlockSignals )
615 mBlockSignals =
true;
616 mExpressionSelector->setExpression( mFormat->expression() );
617 mBlockSignals =
false;
622 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.