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