QGIS API Documentation 3.99.0-Master (d270888f95f)
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#include <QString>
31
32#include "moc_qgsnumericformatwidget.cpp"
33
34using namespace Qt::StringLiterals;
35
37{
38 mExpressionContextGenerator = generator;
39}
40
42{
43 if ( mExpressionContextGenerator )
44 return mExpressionContextGenerator->createExpressionContext();
45 return QgsExpressionContext();
46}
47
48//
49// QgsBasicNumericFormatWidget
50//
52 : QgsNumericFormatWidget( parent )
53{
54 setupUi( this );
55 setFormat( format->clone() );
56
57 mDecimalsSpinBox->setClearValue( 6 );
58 mThousandsLineEdit->setShowClearButton( true );
59 mDecimalLineEdit->setShowClearButton( true );
60
61 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
62 mFormat->setShowPlusSign( checked );
63 if ( !mBlockSignals )
64 emit changed();
65 } );
66
67 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
68 mFormat->setShowTrailingZeros( checked );
69 if ( !mBlockSignals )
70 emit changed();
71 } );
72
73 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
74 mFormat->setShowThousandsSeparator( checked );
75 if ( !mBlockSignals )
76 emit changed();
77 } );
78
79 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
80 mFormat->setNumberDecimalPlaces( value );
81 if ( !mBlockSignals )
82 emit changed();
83 } );
84
85 connect( mRadDecimalPlaces, &QRadioButton::toggled, this, [this]( bool checked ) {
86 if ( !checked )
87 return;
88
89 mFormat->setRoundingType( QgsBasicNumericFormat::DecimalPlaces );
90 if ( !mBlockSignals )
91 emit changed();
92 } );
93
94 connect( mRadSignificantFigures, &QRadioButton::toggled, this, [this]( bool checked ) {
95 if ( !checked )
96 return;
97
98 mFormat->setRoundingType( QgsBasicNumericFormat::SignificantFigures );
99 if ( !mBlockSignals )
100 emit changed();
101 } );
102
103 connect( mThousandsLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
104 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
105 if ( !mBlockSignals )
106 emit changed();
107 } );
108
109 connect( mDecimalLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
110 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
111 if ( !mBlockSignals )
112 emit changed();
113 } );
114}
115
117
119{
120 mFormat.reset( static_cast<QgsBasicNumericFormat *>( format ) );
121
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() )
130 {
132 mRadDecimalPlaces->setChecked( true );
133 break;
134
136 mRadSignificantFigures->setChecked( true );
137 break;
138 }
139
140 mBlockSignals = false;
141}
142
147
148//
149// QgsBearingNumericFormatWidget
150//
151
153 : QgsNumericFormatWidget( parent )
154{
155 setupUi( this );
156
157 mDecimalsSpinBox->setClearValue( 6 );
158 mFormatComboBox->addItem( QObject::tr( "0 to 180°, with E/W suffix" ), QgsBearingNumericFormat::UseRange0To180WithEWDirectionalSuffix );
159 mFormatComboBox->addItem( QObject::tr( "-180 to +180°" ), QgsBearingNumericFormat::UseRangeNegative180ToPositive180 );
160 mFormatComboBox->addItem( QObject::tr( "0 to 360°" ), QgsBearingNumericFormat::UseRange0To360 );
161
162 setFormat( format->clone() );
163
164 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
165 mFormat->setShowTrailingZeros( checked );
166 if ( !mBlockSignals )
167 emit changed();
168 } );
169
170 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
171 mFormat->setNumberDecimalPlaces( value );
172 if ( !mBlockSignals )
173 emit changed();
174 } );
175
176 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
177 mFormat->setDirectionFormat( static_cast<QgsBearingNumericFormat::FormatDirectionOption>( mFormatComboBox->currentData().toInt() ) );
178 if ( !mBlockSignals )
179 emit changed();
180 } );
181}
182
184
186{
187 mFormat.reset( static_cast<QgsBearingNumericFormat *>( format ) );
188
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;
194}
195
200
201//
202// QgsBearingNumericFormatDialog
203//
204
206 : QDialog( parent )
207{
208 setLayout( new QVBoxLayout() );
209 mWidget = new QgsBearingNumericFormatWidget( format );
210 QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
211
212 connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
213 connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
214
215 layout()->addWidget( mWidget );
216 layout()->addWidget( buttonBox );
217
218 connect( mWidget, &QgsPanelWidget::panelAccepted, this, &QDialog::reject );
219
220 setObjectName( u"QgsBearingNumericFormatDialog"_s );
222}
223
225{
226 return static_cast<QgsBearingNumericFormat *>( mWidget->format() );
227}
228
229
230//
231// QgsGeographicCoordinateNumericFormatWidget
232//
233
235 : QgsNumericFormatWidget( parent )
236{
237 setupUi( this );
238
239 mDecimalsSpinBox->setClearValue( 6 );
240 mFormatComboBox->addItem( QObject::tr( "Decimal Degrees" ), static_cast<int>( QgsGeographicCoordinateNumericFormat::AngleFormat::DecimalDegrees ) );
241 mFormatComboBox->addItem( QObject::tr( "Degrees, Minutes" ), static_cast<int>( QgsGeographicCoordinateNumericFormat::AngleFormat::DegreesMinutes ) );
242 mFormatComboBox->addItem( QObject::tr( "Degrees, Minutes, Seconds" ), static_cast<int>( QgsGeographicCoordinateNumericFormat::AngleFormat::DegreesMinutesSeconds ) );
243
244 if ( hidePrecisionControl )
245 {
246 mLabelDecimalPlaces->hide();
247 mDecimalsSpinBox->hide();
248 }
249 setFormat( format->clone() );
250
251 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
252 mFormat->setShowTrailingZeros( checked );
253 if ( !mBlockSignals )
254 emit changed();
255 } );
256
257 connect( mShowDirectionalSuffixCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
258 mFormat->setShowDirectionalSuffix( checked );
259 if ( !mBlockSignals )
260 emit changed();
261 } );
262
263 connect( mShowLeadingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
264 mFormat->setShowLeadingZeros( checked );
265 if ( !mBlockSignals )
266 emit changed();
267 } );
268
269 connect( mShowLeadingZerosForDegreesCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
270 mFormat->setShowDegreeLeadingZeros( checked );
271 if ( !mBlockSignals )
272 emit changed();
273 } );
274
275 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
276 mFormat->setNumberDecimalPlaces( value );
277 if ( !mBlockSignals )
278 emit changed();
279 } );
280
281 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
282 mFormat->setAngleFormat( static_cast<QgsGeographicCoordinateNumericFormat::AngleFormat>( mFormatComboBox->currentData().toInt() ) );
283 if ( !mBlockSignals )
284 emit changed();
285 } );
286}
287
289
291{
292 mFormat.reset( static_cast<QgsGeographicCoordinateNumericFormat *>( format ) );
293
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;
302}
303
308
309//
310// QgsGeographicCoordinateNumericFormatDialog
311//
312
314 : QDialog( parent )
315{
316 setLayout( new QVBoxLayout() );
317 mWidget = new QgsGeographicCoordinateNumericFormatWidget( format, hidePrecisionControl );
318 QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
319
320 connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
321 connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
322
323 layout()->addWidget( mWidget );
324 layout()->addWidget( buttonBox );
325
326 connect( mWidget, &QgsPanelWidget::panelAccepted, this, &QDialog::reject );
327
328 setObjectName( u"QgsGeographicCoordinateNumericFormatDialog"_s );
330}
331
336
337
338//
339// QgsCurrencyNumericFormatWidget
340//
342 : QgsNumericFormatWidget( parent )
343{
344 setupUi( this );
345 mDecimalsSpinBox->setClearValue( 2 );
346 setFormat( format->clone() );
347
348 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
349 mFormat->setShowPlusSign( checked );
350 if ( !mBlockSignals )
351 emit changed();
352 } );
353
354 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
355 mFormat->setShowTrailingZeros( checked );
356 if ( !mBlockSignals )
357 emit changed();
358 } );
359
360 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
361 mFormat->setShowThousandsSeparator( checked );
362 if ( !mBlockSignals )
363 emit changed();
364 } );
365
366 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
367 mFormat->setNumberDecimalPlaces( value );
368 if ( !mBlockSignals )
369 emit changed();
370 } );
371
372 connect( mPrefixLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
373 mFormat->setPrefix( text );
374 if ( !mBlockSignals )
375 emit changed();
376 } );
377
378 connect( mSuffixLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
379 mFormat->setSuffix( text );
380 if ( !mBlockSignals )
381 emit changed();
382 } );
383}
384
386
388{
389 mFormat.reset( static_cast<QgsCurrencyNumericFormat *>( format ) );
390
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() );
398
399 mBlockSignals = false;
400}
401
406
407
408//
409// QgsPercentageNumericFormatWidget
410//
411
413 : QgsNumericFormatWidget( parent )
414{
415 setupUi( this );
416
417 mDecimalsSpinBox->setClearValue( 6 );
418 mScalingComboBox->addItem( QObject::tr( "Values are Percentages (e.g. 50)" ), QgsPercentageNumericFormat::ValuesArePercentage );
419 mScalingComboBox->addItem( QObject::tr( "Values are Fractions (e.g. 0.5)" ), QgsPercentageNumericFormat::ValuesAreFractions );
420
421 setFormat( format->clone() );
422
423 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
424 mFormat->setShowTrailingZeros( checked );
425 if ( !mBlockSignals )
426 emit changed();
427 } );
428
429 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
430 mFormat->setShowPlusSign( checked );
431 if ( !mBlockSignals )
432 emit changed();
433 } );
434
435 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
436 mFormat->setShowThousandsSeparator( checked );
437 if ( !mBlockSignals )
438 emit changed();
439 } );
440
441 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
442 mFormat->setNumberDecimalPlaces( value );
443 if ( !mBlockSignals )
444 emit changed();
445 } );
446
447 connect( mScalingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [this]( int ) {
448 mFormat->setInputValues( static_cast<QgsPercentageNumericFormat::InputValues>( mScalingComboBox->currentData().toInt() ) );
449 if ( !mBlockSignals )
450 emit changed();
451 } );
452}
453
455
457{
458 mFormat.reset( static_cast<QgsPercentageNumericFormat *>( format ) );
459
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;
467}
468
473
474//
475// QgsScientificNumericFormatWidget
476//
478 : QgsNumericFormatWidget( parent )
479{
480 setupUi( this );
481 mDecimalsSpinBox->setClearValue( 6 );
482 setFormat( format->clone() );
483
484 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
485 mFormat->setShowPlusSign( checked );
486 if ( !mBlockSignals )
487 emit changed();
488 } );
489
490 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
491 mFormat->setShowTrailingZeros( checked );
492 if ( !mBlockSignals )
493 emit changed();
494 } );
495
496 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [this]( int value ) {
497 mFormat->setNumberDecimalPlaces( value );
498 if ( !mBlockSignals )
499 emit changed();
500 } );
501}
502
504
506{
507 mFormat.reset( static_cast<QgsScientificNumericFormat *>( format ) );
508
509 mBlockSignals = true;
510 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
511 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
512 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
513 mBlockSignals = false;
514}
515
520
521
522//
523// QgsFractionNumericFormatWidget
524//
526 : QgsNumericFormatWidget( parent )
527{
528 setupUi( this );
529 setFormat( format->clone() );
530
531 mThousandsLineEdit->setShowClearButton( true );
532
533 connect( mUseDedicatedUnicodeCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
534 mFormat->setUseDedicatedUnicodeCharacters( checked );
535 if ( !mBlockSignals )
536 emit changed();
537 } );
538
539 connect( mUseUnicodeSupersubscriptCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
540 mFormat->setUseUnicodeSuperSubscript( checked );
541 if ( !mBlockSignals )
542 emit changed();
543 } );
544
545 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
546 mFormat->setShowPlusSign( checked );
547 if ( !mBlockSignals )
548 emit changed();
549 } );
550
551 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [this]( bool checked ) {
552 mFormat->setShowThousandsSeparator( checked );
553 if ( !mBlockSignals )
554 emit changed();
555 } );
556
557 connect( mThousandsLineEdit, &QLineEdit::textChanged, this, [this]( const QString &text ) {
558 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
559 if ( !mBlockSignals )
560 emit changed();
561 } );
562}
563
565
567{
568 mFormat.reset( static_cast<QgsFractionNumericFormat *>( format ) );
569
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;
577}
578
583
584
585//
586// QgsExpressionBasedNumericFormatWidget
587//
589 : QgsNumericFormatWidget( parent )
590{
591 setupUi( this );
592 setFormat( format->clone() );
593
594 mExpressionSelector->setMultiLine( true );
595 mExpressionSelector->registerExpressionContextGenerator( this );
596
597 connect( mExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, [this]( const QString &text ) {
598 mFormat->setExpression( text );
599 if ( !mBlockSignals )
600 emit changed();
601 } );
602}
603
614
616
618{
619 mFormat.reset( static_cast<QgsExpressionBasedNumericFormat *>( format ) );
620
621 mBlockSignals = true;
622 mExpressionSelector->setExpression( mFormat->expression() );
623 mBlockSignals = false;
624}
625
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:224
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.