QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
numericformats
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
17
#include "
qgsscientificnumericformat.h
"
18
19
#include "
qgis.h
"
20
21
#include <QString>
22
23
using namespace
Qt::StringLiterals;
24
25
QgsScientificNumericFormat::QgsScientificNumericFormat
()
26
{
27
mUseScientific
=
true
;
28
}
29
30
QString
QgsScientificNumericFormat::id
()
const
31
{
32
return
u
"scientific"
_s;
33
}
34
35
QString
QgsScientificNumericFormat::visibleName
()
const
36
{
37
return
QObject::tr(
"Scientific"
);
38
}
39
40
int
QgsScientificNumericFormat::sortKey
()
41
{
42
return
DEFAULT_SORT_KEY
;
43
}
44
45
QString
QgsScientificNumericFormat::formatDouble
(
double
value,
const
QgsNumericFormatContext
&context )
const
46
{
47
return
QgsBasicNumericFormat::formatDouble
( value, context );
48
}
49
50
QgsNumericFormat
*
QgsScientificNumericFormat::clone
()
const
51
{
52
return
new
QgsScientificNumericFormat
( *
this
);
53
}
54
55
QgsNumericFormat
*
QgsScientificNumericFormat::create
(
const
QVariantMap &
configuration
,
const
QgsReadWriteContext
&context )
const
56
{
57
auto
res = std::make_unique< QgsScientificNumericFormat >();
58
res->setConfiguration(
configuration
, context );
59
res->setRoundingType(
QgsBasicNumericFormat::DecimalPlaces
);
60
return
res.release();
61
}
62
63
QVariantMap
QgsScientificNumericFormat::configuration
(
const
QgsReadWriteContext
&context )
const
64
{
65
QVariantMap res =
QgsBasicNumericFormat::configuration
( context );
66
return
res;
67
}
68
69
void
QgsScientificNumericFormat::setNumberDecimalPlaces
(
int
numberDecimalPlaces
)
70
{
71
QgsBasicNumericFormat::setNumberDecimalPlaces
( std::max(
numberDecimalPlaces
, 1 ) );
72
}
QgsBasicNumericFormat::DecimalPlaces
@ DecimalPlaces
Maximum number of decimal places.
Definition
qgsbasicnumericformat.h:40
QgsBasicNumericFormat::mUseScientific
bool mUseScientific
Definition
qgsbasicnumericformat.h:167
QgsBasicNumericFormat::formatDouble
QString formatDouble(double value, const QgsNumericFormatContext &context) const override
Returns a formatted string representation of a numeric double value.
Definition
qgsbasicnumericformat.cpp:67
QgsBasicNumericFormat::setNumberDecimalPlaces
virtual void setNumberDecimalPlaces(int places)
Sets the maximum number of decimal places to show.
Definition
qgsbasicnumericformat.cpp:185
QgsBasicNumericFormat::numberDecimalPlaces
int numberDecimalPlaces() const
Returns the maximum number of decimal places to show.
Definition
qgsbasicnumericformat.cpp:180
QgsBasicNumericFormat::configuration
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
Definition
qgsbasicnumericformat.cpp:156
QgsNumericFormatContext
A context for numeric formats.
Definition
qgsnumericformat.h:35
QgsNumericFormat::DEFAULT_SORT_KEY
static constexpr int DEFAULT_SORT_KEY
Definition
qgsnumericformat.h:323
QgsNumericFormat::QgsNumericFormat
QgsNumericFormat()=default
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
QgsScientificNumericFormat::setNumberDecimalPlaces
void setNumberDecimalPlaces(int places) override
Sets the maximum number of decimal places to show.
Definition
qgsscientificnumericformat.cpp:69
QgsScientificNumericFormat::sortKey
int sortKey() override
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
Definition
qgsscientificnumericformat.cpp:40
QgsScientificNumericFormat::id
QString id() const override
Returns a unique id for this numeric format.
Definition
qgsscientificnumericformat.cpp:30
QgsScientificNumericFormat::visibleName
QString visibleName() const override
Returns the translated, user-visible name for this format.
Definition
qgsscientificnumericformat.cpp:35
QgsScientificNumericFormat::create
QgsNumericFormat * create(const QVariantMap &configuration, const QgsReadWriteContext &context) const override
Creates a new copy of the format, using the supplied configuration.
Definition
qgsscientificnumericformat.cpp:55
QgsScientificNumericFormat::formatDouble
QString formatDouble(double value, const QgsNumericFormatContext &context) const override
Returns a formatted string representation of a numeric double value.
Definition
qgsscientificnumericformat.cpp:45
QgsScientificNumericFormat::clone
QgsNumericFormat * clone() const override
Clones the format, returning a new object.
Definition
qgsscientificnumericformat.cpp:50
QgsScientificNumericFormat::configuration
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
Definition
qgsscientificnumericformat.cpp:63
QgsScientificNumericFormat::QgsScientificNumericFormat
QgsScientificNumericFormat()
Default constructor.
Definition
qgsscientificnumericformat.cpp:25
qgis.h
qgsscientificnumericformat.h
Generated on
for QGIS API Documentation by
1.17.0