QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsnumericformatwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsnumericformatwidget.cpp
3 --------------------------
4 begin : January 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgis.h"
25#include "qgsgui.h"
28
29#include <QDialogButtonBox>
30
31#include "moc_qgsnumericformatwidget.cpp"
32
34{
35 mExpressionContextGenerator = generator;
36}
37
39{
40 if ( mExpressionContextGenerator )
41 return mExpressionContextGenerator->createExpressionContext();
42 return QgsExpressionContext();
43}
44
45//
46// QgsBasicNumericFormatWidget
47//
49 : QgsNumericFormatWidget( parent )
50{
51 setupUi( this );
52 setFormat( format->clone() );
53
54 mDecimalsSpinBox->setClearValue( 6 );
55 mThousandsLineEdit->setShowClearButton( true );
56 mDecimalLineEdit->setShowClearButton( true );
57
58 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
59 mFormat->setShowPlusSign( checked );
60 if ( !mBlockSignals )
61 emit changed();
62 } );
63
64 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
65 mFormat->setShowTrailingZeros( checked );
66 if ( !mBlockSignals )
67 emit changed();
68 } );
69
70 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
71 mFormat->setShowThousandsSeparator( checked );
72 if ( !mBlockSignals )
73 emit changed();
74 } );
75
76 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
77 mFormat->setNumberDecimalPlaces( value );
78 if ( !mBlockSignals )
79 emit changed();
80 } );
81
82 connect( mRadDecimalPlaces, &QRadioButton::toggled, this, [this]( bool checked ) {
83 if ( !checked )
84 return;
85
86 mFormat->setRoundingType( QgsBasicNumericFormat::DecimalPlaces );
87 if ( !mBlockSignals )
88 emit changed();
89 } );
90
91 connect( mRadSignificantFigures, &QRadioButton::toggled, this, [this]( bool checked ) {
92 if ( !checked )
93 return;
94
95 mFormat->setRoundingType( QgsBasicNumericFormat::SignificantFigures );
96 if ( !mBlockSignals )
97 emit changed();
98 } );
99
100 connect( mThousandsLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
101 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
102 if ( !mBlockSignals )
103 emit changed();
104 } );
105
106 connect( mDecimalLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
107 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
108 if ( !mBlockSignals )
109 emit changed();
110 } );
111}
112
114
116{
117 mFormat.reset( static_cast<QgsBasicNumericFormat *>( format ) );
118
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() )
127 {
129 mRadDecimalPlaces->setChecked( true );
130 break;
131
133 mRadSignificantFigures->setChecked( true );
134 break;
135 }
136
137 mBlockSignals = false;
138}
139
144
145//
146// QgsBearingNumericFormatWidget
147//
148
150 : QgsNumericFormatWidget( parent )
151{
152 setupUi( this );
153
154 mDecimalsSpinBox->setClearValue( 6 );
155 mFormatComboBox->addItem( QObject::tr( "0 to 180°, with E/W suffix" ), QgsBearingNumericFormat::UseRange0To180WithEWDirectionalSuffix );
156 mFormatComboBox->addItem( QObject::tr( "-180 to +180°" ), QgsBearingNumericFormat::UseRangeNegative180ToPositive180 );
157 mFormatComboBox->addItem( QObject::tr( "0 to 360°" ), QgsBearingNumericFormat::UseRange0To360 );
158
159 setFormat( format->clone() );
160
161 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
162 mFormat->setShowTrailingZeros( checked );
163 if ( !mBlockSignals )
164 emit changed();
165 } );
166
167 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
168 mFormat->setNumberDecimalPlaces( value );
169 if ( !mBlockSignals )
170 emit changed();
171 } );
172
173 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
174 mFormat->setDirectionFormat( static_cast<QgsBearingNumericFormat::FormatDirectionOption>( mFormatComboBox->currentData().toInt() ) );
175 if ( !mBlockSignals )
176 emit changed();
177 } );
178}
179
181
183{
184 mFormat.reset( static_cast<QgsBearingNumericFormat *>( format ) );
185
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;
191}
192
197
198//
199// QgsBearingNumericFormatDialog
200//
201
203 : QDialog( parent )
204{
205 setLayout( new QVBoxLayout() );
206 mWidget = new QgsBearingNumericFormatWidget( format );
207 QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
208
209 connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
210 connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
211
212 layout()->addWidget( mWidget );
213 layout()->addWidget( buttonBox );
214
215 connect( mWidget, &QgsPanelWidget::panelAccepted, this, &QDialog::reject );
216
217 setObjectName( QStringLiteral( "QgsBearingNumericFormatDialog" ) );
219}
220
222{
223 return static_cast<QgsBearingNumericFormat *>( mWidget->format() );
224}
225
226
227//
228// QgsGeographicCoordinateNumericFormatWidget
229//
230
232 : QgsNumericFormatWidget( parent )
233{
234 setupUi( this );
235
236 mDecimalsSpinBox->setClearValue( 6 );
237 mFormatComboBox->addItem( QObject::tr( "Decimal Degrees" ), static_cast<int>( QgsGeographicCoordinateNumericFormat::AngleFormat::DecimalDegrees ) );
238 mFormatComboBox->addItem( QObject::tr( "Degrees, Minutes" ), static_cast<int>( QgsGeographicCoordinateNumericFormat::AngleFormat::DegreesMinutes ) );
239 mFormatComboBox->addItem( QObject::tr( "Degrees, Minutes, Seconds" ), static_cast<int>( QgsGeographicCoordinateNumericFormat::AngleFormat::DegreesMinutesSeconds ) );
240
241 if ( hidePrecisionControl )
242 {
243 mLabelDecimalPlaces->hide();
244 mDecimalsSpinBox->hide();
245 }
246 setFormat( format->clone() );
247
248 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
249 mFormat->setShowTrailingZeros( checked );
250 if ( !mBlockSignals )
251 emit changed();
252 } );
253
254 connect( mShowDirectionalSuffixCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
255 mFormat->setShowDirectionalSuffix( checked );
256 if ( !mBlockSignals )
257 emit changed();
258 } );
259
260 connect( mShowLeadingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
261 mFormat->setShowLeadingZeros( checked );
262 if ( !mBlockSignals )
263 emit changed();
264 } );
265
266 connect( mShowLeadingZerosForDegreesCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
267 mFormat->setShowDegreeLeadingZeros( checked );
268 if ( !mBlockSignals )
269 emit changed();
270 } );
271
272 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
273 mFormat->setNumberDecimalPlaces( value );
274 if ( !mBlockSignals )
275 emit changed();
276 } );
277
278 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
279 mFormat->setAngleFormat( static_cast<QgsGeographicCoordinateNumericFormat::AngleFormat>( mFormatComboBox->currentData().toInt() ) );
280 if ( !mBlockSignals )
281 emit changed();
282 } );
283}
284
286
288{
289 mFormat.reset( static_cast<QgsGeographicCoordinateNumericFormat *>( format ) );
290
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;
299}
300
305
306//
307// QgsGeographicCoordinateNumericFormatDialog
308//
309
311 : QDialog( parent )
312{
313 setLayout( new QVBoxLayout() );
314 mWidget = new QgsGeographicCoordinateNumericFormatWidget( format, hidePrecisionControl );
315 QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
316
317 connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
318 connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
319
320 layout()->addWidget( mWidget );
321 layout()->addWidget( buttonBox );
322
323 connect( mWidget, &QgsPanelWidget::panelAccepted, this, &QDialog::reject );
324
325 setObjectName( QStringLiteral( "QgsGeographicCoordinateNumericFormatDialog" ) );
327}
328
333
334
335//
336// QgsCurrencyNumericFormatWidget
337//
339 : QgsNumericFormatWidget( parent )
340{
341 setupUi( this );
342 mDecimalsSpinBox->setClearValue( 2 );
343 setFormat( format->clone() );
344
345 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
346 mFormat->setShowPlusSign( checked );
347 if ( !mBlockSignals )
348 emit changed();
349 } );
350
351 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
352 mFormat->setShowTrailingZeros( checked );
353 if ( !mBlockSignals )
354 emit changed();
355 } );
356
357 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
358 mFormat->setShowThousandsSeparator( checked );
359 if ( !mBlockSignals )
360 emit changed();
361 } );
362
363 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
364 mFormat->setNumberDecimalPlaces( value );
365 if ( !mBlockSignals )
366 emit changed();
367 } );
368
369 connect( mPrefixLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
370 mFormat->setPrefix( text );
371 if ( !mBlockSignals )
372 emit changed();
373 } );
374
375 connect( mSuffixLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
376 mFormat->setSuffix( text );
377 if ( !mBlockSignals )
378 emit changed();
379 } );
380}
381
383
385{
386 mFormat.reset( static_cast<QgsCurrencyNumericFormat *>( format ) );
387
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() );
395
396 mBlockSignals = false;
397}
398
403
404
405//
406// QgsPercentageNumericFormatWidget
407//
408
410 : QgsNumericFormatWidget( parent )
411{
412 setupUi( this );
413
414 mDecimalsSpinBox->setClearValue( 6 );
415 mScalingComboBox->addItem( QObject::tr( "Values are Percentages (e.g. 50)" ), QgsPercentageNumericFormat::ValuesArePercentage );
416 mScalingComboBox->addItem( QObject::tr( "Values are Fractions (e.g. 0.5)" ), QgsPercentageNumericFormat::ValuesAreFractions );
417
418 setFormat( format->clone() );
419
420 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
421 mFormat->setShowTrailingZeros( checked );
422 if ( !mBlockSignals )
423 emit changed();
424 } );
425
426 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
427 mFormat->setShowPlusSign( checked );
428 if ( !mBlockSignals )
429 emit changed();
430 } );
431
432 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
433 mFormat->setShowThousandsSeparator( checked );
434 if ( !mBlockSignals )
435 emit changed();
436 } );
437
438 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
439 mFormat->setNumberDecimalPlaces( value );
440 if ( !mBlockSignals )
441 emit changed();
442 } );
443
444 connect( mScalingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
445 mFormat->setInputValues( static_cast<QgsPercentageNumericFormat::InputValues>( mScalingComboBox->currentData().toInt() ) );
446 if ( !mBlockSignals )
447 emit changed();
448 } );
449}
450
452
454{
455 mFormat.reset( static_cast<QgsPercentageNumericFormat *>( format ) );
456
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;
464}
465
470
471//
472// QgsScientificNumericFormatWidget
473//
475 : QgsNumericFormatWidget( parent )
476{
477 setupUi( this );
478 mDecimalsSpinBox->setClearValue( 6 );
479 setFormat( format->clone() );
480
481 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
482 mFormat->setShowPlusSign( checked );
483 if ( !mBlockSignals )
484 emit changed();
485 } );
486
487 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
488 mFormat->setShowTrailingZeros( checked );
489 if ( !mBlockSignals )
490 emit changed();
491 } );
492
493 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
494 mFormat->setNumberDecimalPlaces( value );
495 if ( !mBlockSignals )
496 emit changed();
497 } );
498}
499
501
503{
504 mFormat.reset( static_cast<QgsScientificNumericFormat *>( format ) );
505
506 mBlockSignals = true;
507 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
508 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
509 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
510 mBlockSignals = false;
511}
512
517
518
519//
520// QgsFractionNumericFormatWidget
521//
523 : QgsNumericFormatWidget( parent )
524{
525 setupUi( this );
526 setFormat( format->clone() );
527
528 mThousandsLineEdit->setShowClearButton( true );
529
530 connect( mUseDedicatedUnicodeCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
531 mFormat->setUseDedicatedUnicodeCharacters( checked );
532 if ( !mBlockSignals )
533 emit changed();
534 } );
535
536 connect( mUseUnicodeSupersubscriptCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
537 mFormat->setUseUnicodeSuperSubscript( checked );
538 if ( !mBlockSignals )
539 emit changed();
540 } );
541
542 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
543 mFormat->setShowPlusSign( checked );
544 if ( !mBlockSignals )
545 emit changed();
546 } );
547
548 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
549 mFormat->setShowThousandsSeparator( checked );
550 if ( !mBlockSignals )
551 emit changed();
552 } );
553
554 connect( mThousandsLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
555 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
556 if ( !mBlockSignals )
557 emit changed();
558 } );
559}
560
562
564{
565 mFormat.reset( static_cast<QgsFractionNumericFormat *>( format ) );
566
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;
574}
575
580
581
582//
583// QgsExpressionBasedNumericFormatWidget
584//
586 : QgsNumericFormatWidget( parent )
587{
588 setupUi( this );
589 setFormat( format->clone() );
590
591 mExpressionSelector->setMultiLine( true );
592 mExpressionSelector->registerExpressionContextGenerator( this );
593
594 connect( mExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, [this]( const QString &text ) {
595 mFormat->setExpression( text );
596 if ( !mBlockSignals )
597 emit changed();
598 } );
599}
600
602{
604
606 scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "value" ), 1234.5678 ) );
607 context.appendScope( scope );
608 context.setHighlightedVariables( { QStringLiteral( "value" ) } );
609 return context;
610}
611
613
615{
616 mFormat.reset( static_cast<QgsExpressionBasedNumericFormat *>( format ) );
617
618 mBlockSignals = true;
619 mExpressionSelector->setExpression( mFormat->expression() );
620 mBlockSignals = false;
621}
622
QgsBasicNumericFormatWidget(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsBasicNumericFormatWidget, initially showing the specified format.
~QgsBasicNumericFormatWidget() override
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
A numeric formatter which returns a simple text representation of a value.
@ DecimalPlaces
Maximum number of decimal places.
@ SignificantFigures
Maximum number of significant figures.
QgsBearingNumericFormatDialog(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsBearingNumericFormatDialog, initially showing the specified format.
QgsBearingNumericFormat * format()
Returns the format defined by the current settings in the dialog.
A widget which allows control over the properties of a QgsBearingNumericFormat.
QgsBearingNumericFormatWidget(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsBearingNumericFormatWidget, initially showing the specified format.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
~QgsBearingNumericFormatWidget() override
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
A numeric formatter which returns a text representation of a direction/bearing.
FormatDirectionOption
Directional formatting option, which controls how bearing direction is described in the returned stri...
@ UseRange0To180WithEWDirectionalSuffix
Return values between 0 and 180, with a E or W directional suffix.
@ UseRange0To360
Return values between 0 to 360.
@ UseRangeNegative180ToPositive180
Return values between -180 and 180.
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
QgsCurrencyNumericFormatWidget(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsCurrencyNumericFormatWidget, initially showing the specified format.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
~QgsCurrencyNumericFormatWidget() override
A numeric formatter which returns a text representation of a currency value.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
QgsExpressionBasedNumericFormatWidget(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsExpressionBasedNumericFormatWidget, initially showing the specified format.
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
QgsExpressionContext createExpressionContext() const final
This method needs to be reimplemented in all classes which implement this interface and return an exp...
A numeric formatter which uses a QgsExpression to calculate the text representation of a value.
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.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
~QgsFractionNumericFormatWidget() override
QgsFractionNumericFormatWidget(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsFractionNumericFormatWidget, initially showing the specified format.
A numeric formatter which returns a vulgar fractional representation of a decimal value (e....
QgsGeographicCoordinateNumericFormatDialog(const QgsNumericFormat *format, bool hidePrecisionControl=false, QWidget *parent=nullptr)
Constructor for QgsGeographicCoordinateNumericFormatDialog, initially showing the specified format.
QgsGeographicCoordinateNumericFormat * format()
Returns the format defined by the current settings in the dialog.
A widget which allows control over the properties of a QgsGeographicCoordinateNumericFormat.
QgsGeographicCoordinateNumericFormatWidget(const QgsNumericFormat *format, bool hidePrecisionControl=false, QWidget *parent=nullptr)
Constructor for QgsGeographicCoordinateNumericFormatWidget, initially showing the specified format.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
A numeric formatter which returns a text representation of a geographic coordinate (latitude or longi...
@ DegreesMinutes
Degrees and decimal minutes, eg 30 degrees 45.55'.
@ DegreesMinutesSeconds
Degrees, minutes and seconds, eg 30 degrees 45'30.
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...
Definition qgsgui.cpp:221
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
QgsNumericFormatWidget(QWidget *parent=nullptr)
Constructor for QgsNumericFormatWidget.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void changed()
Emitted whenever the configuration of the numeric format is changed.
Abstract base class for numeric formatters, which allow for formatting a numeric value for display.
virtual QgsNumericFormat * clone() const =0
Clones the format, returning a new object.
void panelAccepted(QgsPanelWidget *panel)
Emitted when the panel is accepted by the user.
QgsPercentageNumericFormatWidget(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsPercentageNumericFormatWidget, initially showing the specified format.
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
A numeric formatter which returns a text representation of a percentage value.
InputValues
Input value format, which specifies the format of the incoming values.
@ ValuesAreFractions
Incoming values are numeric fractions (e.g. 0.5 for 50%).
@ ValuesArePercentage
Incoming values are percentage values (e.g. 50 for 50%).
void setFormat(QgsNumericFormat *format) final
Sets the format to show in the widget.
QgsScientificNumericFormatWidget(const QgsNumericFormat *format, QWidget *parent=nullptr)
Constructor for QgsScientificNumericFormatWidget, initially showing the specified format.
QgsNumericFormat * format() final
Returns the format defined by the current settings in the widget.
A numeric formatter which returns a scientific notation representation of a value.
Single variable definition for use within a QgsExpressionContextScope.