QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
qgsscientificnumericformat.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsscientificnumericformat.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  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
18 #include "qgis.h"
19 
20 
22 {
23  mUseScientific = true;
24 }
25 
27 {
28  return QStringLiteral( "scientific" );
29 }
30 
32 {
33  return QObject::tr( "Scientific" );
34 }
35 
37 {
39 }
40 
41 QString QgsScientificNumericFormat::formatDouble( double value, const QgsNumericFormatContext &context ) const
42 {
43  return QgsBasicNumericFormat::formatDouble( value, context );
44 }
45 
47 {
48  return new QgsScientificNumericFormat( *this );
49 }
50 
52 {
53  std::unique_ptr< QgsScientificNumericFormat > res = qgis::make_unique< QgsScientificNumericFormat >();
54  res->setConfiguration( configuration, context );
55  res->setRoundingType( QgsBasicNumericFormat::DecimalPlaces );
56  return res.release();
57 }
58 
60 {
61  QVariantMap res = QgsBasicNumericFormat::configuration( context );
62  return res;
63 }
64 
66 {
67  QgsBasicNumericFormat::setNumberDecimalPlaces( std::max( numberDecimalPlaces, 1 ) );
68 }
The class is used as a container of context for various read/write operations on other objects...
QgsScientificNumericFormat()
Default constructor.
QString visibleName() const override
Returns the translated, user-visible name for this format.
QgsNumericFormat * clone() const override
Clones the format, returning a new object.
QString id() const override
Returns a unique id for this numeric format.
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
void setNumberDecimalPlaces(int places) override
Sets the maximum number of decimal places to show.
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
int numberDecimalPlaces() const
Returns the maximum number of decimal places to show.
QString formatDouble(double value, const QgsNumericFormatContext &context) const override
Returns a formatted string representation of a numeric double value.
QString formatDouble(double value, const QgsNumericFormatContext &context) const override
Returns a formatted string representation of a numeric double value.
QgsNumericFormat * create(const QVariantMap &configuration, const QgsReadWriteContext &context) const override
Creates a new copy of the format, using the supplied configuration.
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
virtual void setNumberDecimalPlaces(int places)
Sets the maximum number of decimal places to show.
A context for numeric formats.
virtual int sortKey()
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists...
int sortKey() override
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists...
Maximum number of decimal places.