29#include <QDialogButtonBox>
31#include "moc_qgsnumericformatwidget.cpp"
35 mExpressionContextGenerator = generator;
40 if ( mExpressionContextGenerator )
41 return mExpressionContextGenerator->createExpressionContext();
54 mDecimalsSpinBox->setClearValue( 6 );
55 mThousandsLineEdit->setShowClearButton(
true );
56 mDecimalLineEdit->setShowClearButton(
true );
58 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
59 mFormat->setShowPlusSign( checked );
64 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
65 mFormat->setShowTrailingZeros( checked );
70 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
71 mFormat->setShowThousandsSeparator( checked );
76 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
77 mFormat->setNumberDecimalPlaces( value );
82 connect( mRadDecimalPlaces, &QRadioButton::toggled,
this, [
this](
bool checked ) {
91 connect( mRadSignificantFigures, &QRadioButton::toggled,
this, [
this](
bool checked ) {
100 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
101 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
102 if ( !mBlockSignals )
106 connect( mDecimalLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
107 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
108 if ( !mBlockSignals )
119 mBlockSignals =
true;
120 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
121 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
122 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
123 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
124 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
125 mDecimalLineEdit->setText( mFormat->decimalSeparator().isNull() ? QString() : mFormat->decimalSeparator() );
126 switch ( mFormat->roundingType() )
129 mRadDecimalPlaces->setChecked(
true );
133 mRadSignificantFigures->setChecked(
true );
137 mBlockSignals =
false;
142 return mFormat->
clone();
154 mDecimalsSpinBox->setClearValue( 6 );
161 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
162 mFormat->setShowTrailingZeros( checked );
163 if ( !mBlockSignals )
167 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
168 mFormat->setNumberDecimalPlaces( value );
169 if ( !mBlockSignals )
173 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
175 if ( !mBlockSignals )
186 mBlockSignals =
true;
187 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
188 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
189 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast<int>( mFormat->directionFormat() ) ) );
190 mBlockSignals =
false;
195 return mFormat->
clone();
205 setLayout(
new QVBoxLayout() );
207 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
209 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
210 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
212 layout()->addWidget( mWidget );
213 layout()->addWidget( buttonBox );
217 setObjectName( QStringLiteral(
"QgsBearingNumericFormatDialog" ) );
236 mDecimalsSpinBox->setClearValue( 6 );
241 if ( hidePrecisionControl )
243 mLabelDecimalPlaces->hide();
244 mDecimalsSpinBox->hide();
248 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
249 mFormat->setShowTrailingZeros( checked );
250 if ( !mBlockSignals )
254 connect( mShowDirectionalSuffixCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
255 mFormat->setShowDirectionalSuffix( checked );
256 if ( !mBlockSignals )
260 connect( mShowLeadingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
261 mFormat->setShowLeadingZeros( checked );
262 if ( !mBlockSignals )
266 connect( mShowLeadingZerosForDegreesCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
267 mFormat->setShowDegreeLeadingZeros( checked );
268 if ( !mBlockSignals )
272 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
273 mFormat->setNumberDecimalPlaces( value );
274 if ( !mBlockSignals )
278 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
280 if ( !mBlockSignals )
291 mBlockSignals =
true;
292 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
293 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
294 mShowDirectionalSuffixCheckBox->setChecked( mFormat->showDirectionalSuffix() );
295 mShowLeadingZerosCheckBox->setChecked( mFormat->showLeadingZeros() );
296 mShowLeadingZerosForDegreesCheckBox->setChecked( mFormat->showDegreeLeadingZeros() );
297 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData(
static_cast<int>( mFormat->angleFormat() ) ) );
298 mBlockSignals =
false;
303 return mFormat->
clone();
313 setLayout(
new QVBoxLayout() );
315 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
317 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
318 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
320 layout()->addWidget( mWidget );
321 layout()->addWidget( buttonBox );
325 setObjectName( QStringLiteral(
"QgsGeographicCoordinateNumericFormatDialog" ) );
342 mDecimalsSpinBox->setClearValue( 2 );
345 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
346 mFormat->setShowPlusSign( checked );
347 if ( !mBlockSignals )
351 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
352 mFormat->setShowTrailingZeros( checked );
353 if ( !mBlockSignals )
357 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
358 mFormat->setShowThousandsSeparator( checked );
359 if ( !mBlockSignals )
363 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
364 mFormat->setNumberDecimalPlaces( value );
365 if ( !mBlockSignals )
369 connect( mPrefixLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
370 mFormat->setPrefix( text );
371 if ( !mBlockSignals )
375 connect( mSuffixLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
376 mFormat->setSuffix( text );
377 if ( !mBlockSignals )
388 mBlockSignals =
true;
389 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
390 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
391 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
392 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
393 mPrefixLineEdit->setText( mFormat->prefix() );
394 mSuffixLineEdit->setText( mFormat->suffix() );
396 mBlockSignals =
false;
401 return mFormat->
clone();
414 mDecimalsSpinBox->setClearValue( 6 );
420 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
421 mFormat->setShowTrailingZeros( checked );
422 if ( !mBlockSignals )
426 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
427 mFormat->setShowPlusSign( checked );
428 if ( !mBlockSignals )
432 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
433 mFormat->setShowThousandsSeparator( checked );
434 if ( !mBlockSignals )
438 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
439 mFormat->setNumberDecimalPlaces( value );
440 if ( !mBlockSignals )
444 connect( mScalingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this](
int ) {
446 if ( !mBlockSignals )
457 mBlockSignals =
true;
458 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
459 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
460 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
461 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
462 mScalingComboBox->setCurrentIndex( mScalingComboBox->findData(
static_cast<int>( mFormat->inputValues() ) ) );
463 mBlockSignals =
false;
468 return mFormat->
clone();
478 mDecimalsSpinBox->setClearValue( 6 );
481 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
482 mFormat->setShowPlusSign( checked );
483 if ( !mBlockSignals )
487 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
488 mFormat->setShowTrailingZeros( checked );
489 if ( !mBlockSignals )
493 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ),
this, [
this](
int value ) {
494 mFormat->setNumberDecimalPlaces( value );
495 if ( !mBlockSignals )
506 mBlockSignals =
true;
507 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
508 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
509 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
510 mBlockSignals =
false;
515 return mFormat->
clone();
528 mThousandsLineEdit->setShowClearButton(
true );
530 connect( mUseDedicatedUnicodeCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
531 mFormat->setUseDedicatedUnicodeCharacters( checked );
532 if ( !mBlockSignals )
536 connect( mUseUnicodeSupersubscriptCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
537 mFormat->setUseUnicodeSuperSubscript( checked );
538 if ( !mBlockSignals )
542 connect( mShowPlusCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
543 mFormat->setShowPlusSign( checked );
544 if ( !mBlockSignals )
548 connect( mShowThousandsCheckBox, &QCheckBox::toggled,
this, [
this](
bool checked ) {
549 mFormat->setShowThousandsSeparator( checked );
550 if ( !mBlockSignals )
554 connect( mThousandsLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &text ) {
555 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
556 if ( !mBlockSignals )
567 mBlockSignals =
true;
568 mUseDedicatedUnicodeCheckBox->setChecked( mFormat->useDedicatedUnicodeCharacters() );
569 mUseUnicodeSupersubscriptCheckBox->setChecked( mFormat->useUnicodeSuperSubscript() );
570 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
571 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
572 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
573 mBlockSignals =
false;
578 return mFormat->
clone();
591 mExpressionSelector->setMultiLine(
true );
592 mExpressionSelector->registerExpressionContextGenerator(
this );
595 mFormat->setExpression( text );
596 if ( !mBlockSignals )
618 mBlockSignals =
true;
619 mExpressionSelector->setExpression( mFormat->expression() );
620 mBlockSignals =
false;
625 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.