QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
25#include "qgsgui.h"
26#include "qgis.h"
27#include <QDialogButtonBox>
28
30{
31 mExpressionContextGenerator = generator;
32}
33
35{
36 if ( mExpressionContextGenerator )
37 return mExpressionContextGenerator->createExpressionContext();
38 return QgsExpressionContext();
39}
40
41//
42// QgsBasicNumericFormatWidget
43//
45 : QgsNumericFormatWidget( parent )
46{
47 setupUi( this );
49
50 mDecimalsSpinBox->setClearValue( 6 );
51 mThousandsLineEdit->setShowClearButton( true );
52 mDecimalLineEdit->setShowClearButton( true );
53
54 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
55 {
56 mFormat->setShowPlusSign( checked );
57 if ( !mBlockSignals )
58 emit changed();
59 } );
60
61 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
62 {
63 mFormat->setShowTrailingZeros( checked );
64 if ( !mBlockSignals )
65 emit changed();
66 } );
67
68 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
69 {
70 mFormat->setShowThousandsSeparator( checked );
71 if ( !mBlockSignals )
72 emit changed();
73 } );
74
75 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int value )
76 {
77 mFormat->setNumberDecimalPlaces( value );
78 if ( !mBlockSignals )
79 emit changed();
80 } );
81
82 connect( mRadDecimalPlaces, &QRadioButton::toggled, this, [ = ]( bool checked )
83 {
84 if ( !checked )
85 return;
86
87 mFormat->setRoundingType( QgsBasicNumericFormat::DecimalPlaces );
88 if ( !mBlockSignals )
89 emit changed();
90 } );
91
92 connect( mRadSignificantFigures, &QRadioButton::toggled, this, [ = ]( bool checked )
93 {
94 if ( !checked )
95 return;
96
97 mFormat->setRoundingType( QgsBasicNumericFormat::SignificantFigures );
98 if ( !mBlockSignals )
99 emit changed();
100 } );
101
102 connect( mThousandsLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & text )
103 {
104 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
105 if ( !mBlockSignals )
106 emit changed();
107 } );
108
109 connect( mDecimalLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & text )
110 {
111 mFormat->setDecimalSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
112 if ( !mBlockSignals )
113 emit changed();
114 } );
115}
116
118
120{
121 mFormat.reset( static_cast< QgsBasicNumericFormat * >( format ) );
122
123 mBlockSignals = true;
124 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
125 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
126 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
127 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
128 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
129 mDecimalLineEdit->setText( mFormat->decimalSeparator().isNull() ? QString() : mFormat->decimalSeparator() );
130 switch ( mFormat->roundingType() )
131 {
133 mRadDecimalPlaces->setChecked( true );
134 break;
135
137 mRadSignificantFigures->setChecked( true );
138 break;
139 }
140
141 mBlockSignals = false;
142}
143
145{
146 return mFormat->clone();
147}
148
149//
150// QgsBearingNumericFormatWidget
151//
152
154 : QgsNumericFormatWidget( parent )
155{
156 setupUi( this );
157
158 mDecimalsSpinBox->setClearValue( 6 );
159 mFormatComboBox->addItem( QObject::tr( "0 to 180°, with E/W suffix" ), QgsBearingNumericFormat::UseRange0To180WithEWDirectionalSuffix );
160 mFormatComboBox->addItem( QObject::tr( "-180 to +180°" ), QgsBearingNumericFormat::UseRangeNegative180ToPositive180 );
161 mFormatComboBox->addItem( QObject::tr( "0 to 360°" ), QgsBearingNumericFormat::UseRange0To360 );
162
163 setFormat( format->clone() );
164
165 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
166 {
167 mFormat->setShowTrailingZeros( checked );
168 if ( !mBlockSignals )
169 emit changed();
170 } );
171
172 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int value )
173 {
174 mFormat->setNumberDecimalPlaces( value );
175 if ( !mBlockSignals )
176 emit changed();
177 } );
178
179 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
180 {
181 mFormat->setDirectionFormat( static_cast < QgsBearingNumericFormat::FormatDirectionOption >( mFormatComboBox->currentData().toInt() ) );
182 if ( !mBlockSignals )
183 emit changed();
184 } );
185}
186
188
190{
191 mFormat.reset( static_cast< QgsBearingNumericFormat * >( format ) );
192
193 mBlockSignals = true;
194 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
195 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
196 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData( static_cast< int >( mFormat->directionFormat() ) ) );
197 mBlockSignals = false;
198}
199
201{
202 return mFormat->clone();
203}
204
205//
206// QgsBearingNumericFormatDialog
207//
208
210 : QDialog( parent )
211{
212 setLayout( new QVBoxLayout() );
213 mWidget = new QgsBearingNumericFormatWidget( format );
214 QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
215
216 connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
217 connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
218
219 layout()->addWidget( mWidget );
220 layout()->addWidget( buttonBox );
221
222 connect( mWidget, &QgsPanelWidget::panelAccepted, this, &QDialog::reject );
223
224 setObjectName( QStringLiteral( "QgsBearingNumericFormatDialog" ) );
226}
227
232
233
234
235
236
237//
238// QgsGeographicCoordinateNumericFormatWidget
239//
240
242 : QgsNumericFormatWidget( parent )
243{
244 setupUi( this );
245
246 mDecimalsSpinBox->setClearValue( 6 );
247 mFormatComboBox->addItem( QObject::tr( "Decimal Degrees" ), static_cast< int >( QgsGeographicCoordinateNumericFormat::AngleFormat::DecimalDegrees ) );
248 mFormatComboBox->addItem( QObject::tr( "Degrees, Minutes" ), static_cast< int >( QgsGeographicCoordinateNumericFormat::AngleFormat::DegreesMinutes ) );
249 mFormatComboBox->addItem( QObject::tr( "Degrees, Minutes, Seconds" ), static_cast< int >( QgsGeographicCoordinateNumericFormat::AngleFormat::DegreesMinutesSeconds ) );
250
251 if ( hidePrecisionControl )
252 {
253 mLabelDecimalPlaces->hide();
254 mDecimalsSpinBox->hide();
255 }
256 setFormat( format->clone() );
257
258 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
259 {
260 mFormat->setShowTrailingZeros( checked );
261 if ( !mBlockSignals )
262 emit changed();
263 } );
264
265 connect( mShowDirectionalSuffixCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
266 {
267 mFormat->setShowDirectionalSuffix( checked );
268 if ( !mBlockSignals )
269 emit changed();
270 } );
271
272 connect( mShowLeadingZerosCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
273 {
274 mFormat->setShowLeadingZeros( checked );
275 if ( !mBlockSignals )
276 emit changed();
277 } );
278
279 connect( mShowLeadingZerosForDegreesCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
280 {
281 mFormat->setShowDegreeLeadingZeros( checked );
282 if ( !mBlockSignals )
283 emit changed();
284 } );
285
286 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int value )
287 {
288 mFormat->setNumberDecimalPlaces( value );
289 if ( !mBlockSignals )
290 emit changed();
291 } );
292
293 connect( mFormatComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
294 {
295 mFormat->setAngleFormat( static_cast < QgsGeographicCoordinateNumericFormat::AngleFormat >( mFormatComboBox->currentData().toInt() ) );
296 if ( !mBlockSignals )
297 emit changed();
298 } );
299}
300
302
304{
305 mFormat.reset( static_cast< QgsGeographicCoordinateNumericFormat * >( format ) );
306
307 mBlockSignals = true;
308 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
309 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
310 mShowDirectionalSuffixCheckBox->setChecked( mFormat->showDirectionalSuffix() );
311 mShowLeadingZerosCheckBox->setChecked( mFormat->showLeadingZeros() );
312 mShowLeadingZerosForDegreesCheckBox->setChecked( mFormat->showDegreeLeadingZeros() );
313 mFormatComboBox->setCurrentIndex( mFormatComboBox->findData( static_cast< int >( mFormat->angleFormat() ) ) );
314 mBlockSignals = false;
315}
316
321
322//
323// QgsGeographicCoordinateNumericFormatDialog
324//
325
327 : QDialog( parent )
328{
329 setLayout( new QVBoxLayout() );
330 mWidget = new QgsGeographicCoordinateNumericFormatWidget( format, hidePrecisionControl );
331 QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
332
333 connect( buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
334 connect( buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
335
336 layout()->addWidget( mWidget );
337 layout()->addWidget( buttonBox );
338
339 connect( mWidget, &QgsPanelWidget::panelAccepted, this, &QDialog::reject );
340
341 setObjectName( QStringLiteral( "QgsGeographicCoordinateNumericFormatDialog" ) );
343}
344
349
350
351
352
353//
354// QgsCurrencyNumericFormatWidget
355//
357 : QgsNumericFormatWidget( parent )
358{
359 setupUi( this );
360 mDecimalsSpinBox->setClearValue( 2 );
361 setFormat( format->clone() );
362
363 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
364 {
365 mFormat->setShowPlusSign( checked );
366 if ( !mBlockSignals )
367 emit changed();
368 } );
369
370 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
371 {
372 mFormat->setShowTrailingZeros( checked );
373 if ( !mBlockSignals )
374 emit changed();
375 } );
376
377 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
378 {
379 mFormat->setShowThousandsSeparator( checked );
380 if ( !mBlockSignals )
381 emit changed();
382 } );
383
384 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int value )
385 {
386 mFormat->setNumberDecimalPlaces( value );
387 if ( !mBlockSignals )
388 emit changed();
389 } );
390
391 connect( mPrefixLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & text )
392 {
393 mFormat->setPrefix( text );
394 if ( !mBlockSignals )
395 emit changed();
396 } );
397
398 connect( mSuffixLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & text )
399 {
400 mFormat->setSuffix( text );
401 if ( !mBlockSignals )
402 emit changed();
403 } );
404}
405
407
409{
410 mFormat.reset( static_cast< QgsCurrencyNumericFormat * >( format ) );
411
412 mBlockSignals = true;
413 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
414 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
415 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
416 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
417 mPrefixLineEdit->setText( mFormat->prefix() );
418 mSuffixLineEdit->setText( mFormat->suffix() );
419
420 mBlockSignals = false;
421}
422
424{
425 return mFormat->clone();
426}
427
428
429//
430// QgsPercentageNumericFormatWidget
431//
432
434 : QgsNumericFormatWidget( parent )
435{
436 setupUi( this );
437
438 mDecimalsSpinBox->setClearValue( 6 );
439 mScalingComboBox->addItem( QObject::tr( "Values are Percentages (e.g. 50)" ), QgsPercentageNumericFormat::ValuesArePercentage );
440 mScalingComboBox->addItem( QObject::tr( "Values are Fractions (e.g. 0.5)" ), QgsPercentageNumericFormat::ValuesAreFractions );
441
442 setFormat( format->clone() );
443
444 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
445 {
446 mFormat->setShowTrailingZeros( checked );
447 if ( !mBlockSignals )
448 emit changed();
449 } );
450
451 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
452 {
453 mFormat->setShowPlusSign( checked );
454 if ( !mBlockSignals )
455 emit changed();
456 } );
457
458 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
459 {
460 mFormat->setShowThousandsSeparator( checked );
461 if ( !mBlockSignals )
462 emit changed();
463 } );
464
465 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int value )
466 {
467 mFormat->setNumberDecimalPlaces( value );
468 if ( !mBlockSignals )
469 emit changed();
470 } );
471
472 connect( mScalingComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, [ = ]( int )
473 {
474 mFormat->setInputValues( static_cast < QgsPercentageNumericFormat::InputValues >( mScalingComboBox->currentData().toInt() ) );
475 if ( !mBlockSignals )
476 emit changed();
477 } );
478}
479
481
483{
484 mFormat.reset( static_cast< QgsPercentageNumericFormat * >( format ) );
485
486 mBlockSignals = true;
487 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
488 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
489 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
490 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
491 mScalingComboBox->setCurrentIndex( mScalingComboBox->findData( static_cast< int >( mFormat->inputValues() ) ) );
492 mBlockSignals = false;
493}
494
496{
497 return mFormat->clone();
498}
499
500//
501// QgsScientificNumericFormatWidget
502//
504 : QgsNumericFormatWidget( parent )
505{
506 setupUi( this );
507 mDecimalsSpinBox->setClearValue( 6 );
508 setFormat( format->clone() );
509
510 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
511 {
512 mFormat->setShowPlusSign( checked );
513 if ( !mBlockSignals )
514 emit changed();
515 } );
516
517 connect( mShowTrailingZerosCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
518 {
519 mFormat->setShowTrailingZeros( checked );
520 if ( !mBlockSignals )
521 emit changed();
522 } );
523
524 connect( mDecimalsSpinBox, qOverload<int>( &QSpinBox::valueChanged ), this, [ = ]( int value )
525 {
526 mFormat->setNumberDecimalPlaces( value );
527 if ( !mBlockSignals )
528 emit changed();
529 } );
530}
531
533
535{
536 mFormat.reset( static_cast< QgsScientificNumericFormat * >( format ) );
537
538 mBlockSignals = true;
539 mDecimalsSpinBox->setValue( mFormat->numberDecimalPlaces() );
540 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
541 mShowTrailingZerosCheckBox->setChecked( mFormat->showTrailingZeros() );
542 mBlockSignals = false;
543}
544
546{
547 return mFormat->clone();
548}
549
550
551
552//
553// QgsFractionNumericFormatWidget
554//
556 : QgsNumericFormatWidget( parent )
557{
558 setupUi( this );
559 setFormat( format->clone() );
560
561 mThousandsLineEdit->setShowClearButton( true );
562
563 connect( mUseDedicatedUnicodeCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
564 {
565 mFormat->setUseDedicatedUnicodeCharacters( checked );
566 if ( !mBlockSignals )
567 emit changed();
568 } );
569
570 connect( mUseUnicodeSupersubscriptCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
571 {
572 mFormat->setUseUnicodeSuperSubscript( checked );
573 if ( !mBlockSignals )
574 emit changed();
575 } );
576
577 connect( mShowPlusCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
578 {
579 mFormat->setShowPlusSign( checked );
580 if ( !mBlockSignals )
581 emit changed();
582 } );
583
584 connect( mShowThousandsCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
585 {
586 mFormat->setShowThousandsSeparator( checked );
587 if ( !mBlockSignals )
588 emit changed();
589 } );
590
591 connect( mThousandsLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & text )
592 {
593 mFormat->setThousandsSeparator( text.isEmpty() ? QChar() : text.at( 0 ) );
594 if ( !mBlockSignals )
595 emit changed();
596 } );
597
598}
599
601
603{
604 mFormat.reset( static_cast< QgsFractionNumericFormat * >( format ) );
605
606 mBlockSignals = true;
607 mUseDedicatedUnicodeCheckBox->setChecked( mFormat->useDedicatedUnicodeCharacters() );
608 mUseUnicodeSupersubscriptCheckBox->setChecked( mFormat->useUnicodeSuperSubscript() );
609 mShowPlusCheckBox->setChecked( mFormat->showPlusSign() );
610 mShowThousandsCheckBox->setChecked( mFormat->showThousandsSeparator() );
611 mThousandsLineEdit->setText( mFormat->thousandsSeparator().isNull() ? QString() : mFormat->thousandsSeparator() );
612 mBlockSignals = false;
613}
614
616{
617 return mFormat->clone();
618}
619
620
621//
622// QgsExpressionBasedNumericFormatWidget
623//
625 : QgsNumericFormatWidget( parent )
626{
627 setupUi( this );
628 setFormat( format->clone() );
629
630 mExpressionSelector->setMultiLine( true );
631 mExpressionSelector->registerExpressionContextGenerator( this );
632
633 connect( mExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, [ = ]( const QString & text )
634 {
635 mFormat->setExpression( text );
636 if ( !mBlockSignals )
637 emit changed();
638 } );
639
640}
641
643{
645
647 scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "value" ), 1234.5678 ) );
648 context.appendScope( scope );
649 context.setHighlightedVariables( { QStringLiteral( "value" )} );
650 return context;
651}
652
654
656{
657 mFormat.reset( static_cast< QgsExpressionBasedNumericFormat * >( format ) );
658
659 mBlockSignals = true;
660 mExpressionSelector->setExpression( mFormat->expression() );
661 mBlockSignals = false;
662}
663
665{
666 return mFormat->clone();
667}
668
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 allow 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.
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.
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 allow 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'.
@ DecimalDegrees
Decimal degrees, eg 30.7555 degrees.
@ 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:208
Base class for widgets which allow control over the properties of QgsNumericFormat subclasses.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
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.
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
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.