QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsexpressionbasednumericformat.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsexpressionbasednumericformat.h
3 --------------------------
4 begin : August 2024
5 copyright : (C) 2024 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#ifndef QGSEXPRESSIONBASEDNUMERICFORMAT_H
16#define QGSEXPRESSIONBASEDNUMERICFORMAT_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
20#include "qgsnumericformat.h"
21#include "qgsexpression.h"
22
30{
31 public:
32
34
35 QString id() const override;
36 QString visibleName() const override;
37 int sortKey() override;
38 QString formatDouble( double value, const QgsNumericFormatContext &context ) const override;
39 QgsNumericFormat *clone() const override SIP_FACTORY;
40 QgsNumericFormat *create( const QVariantMap &configuration, const QgsReadWriteContext &context ) const override SIP_FACTORY;
41 QVariantMap configuration( const QgsReadWriteContext &context ) const override;
42
50 void setExpression( const QString &expression ); // cppcheck-suppress functionConst
51
57 QString expression() const { return mExpression.expression(); }
58
59 private:
60
61 mutable QgsExpression mExpression;
62};
63
64#endif // QGSEXPRESSIONBASEDNUMERICFORMAT_H
A numeric formatter which uses a QgsExpression to calculate the text representation of a value.
QString expression() const
Returns the expression used to calculate the text representation of a value.
Class for parsing and evaluation of expressions (formerly called "search strings").
A context for numeric formats.
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
virtual QgsNumericFormat * create(const QVariantMap &configuration, const QgsReadWriteContext &context) const =0
Creates a new copy of the format, using the supplied configuration.
virtual QString formatDouble(double value, const QgsNumericFormatContext &context) const =0
Returns a formatted string representation of a numeric double value.
virtual QgsNumericFormat * clone() const =0
Clones the format, returning a new object.
virtual int sortKey()
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
virtual QString visibleName() const =0
Returns the translated, user-visible name for this format.
virtual QString id() const =0
Returns a unique id for this numeric format.
virtual QVariantMap configuration(const QgsReadWriteContext &context) const =0
Returns the current configuration of the formatter.
The class is used as a container of context for various read/write operations on other objects.
#define SIP_FACTORY
Definition qgis_sip.h:76