QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
src
core
numericformats
qgsnumericformat.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsnumericformat.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 "
qgsnumericformat.h
"
18
#include "
qgsxmlutils.h
"
19
#include "
qgsreadwritecontext.h
"
20
21
#include <QLocale>
22
23
QgsNumericFormatContext::QgsNumericFormatContext
()
24
{
25
QLocale l;
26
mThousandsSep = l.groupSeparator();
27
mDecimalSep = l.decimalPoint();
28
mPercent = l.percent();
29
mZeroDigit = l.zeroDigit();
30
mNegativeSign = l.negativeSign();
31
mPositiveSign = l.positiveSign();
32
mExponential = l.exponential();
33
}
34
35
int
QgsNumericFormat::sortKey
()
36
{
37
return
100;
38
}
39
40
double
QgsNumericFormat::suggestSampleValue
()
const
41
{
42
return
1234.56789123456;
43
}
44
45
void
QgsNumericFormat::writeXml
( QDomElement &element, QDomDocument &document,
const
QgsReadWriteContext
&context )
const
46
{
47
const
QVariantMap config =
configuration
( context );
48
QDomElement configElement =
QgsXmlUtils::writeVariant
( config, document );
49
element.appendChild( configElement );
50
element.setAttribute( QStringLiteral(
"id"
),
id
() );
51
}
52
53
bool
QgsNumericFormat::operator==
(
const
QgsNumericFormat
&other )
const
54
{
55
return
id
() == other.
id
() &&
configuration
(
QgsReadWriteContext
() ) == other.
configuration
(
QgsReadWriteContext
() );
56
}
57
58
bool
QgsNumericFormat::operator!=
(
const
QgsNumericFormat
&other )
const
59
{
60
return
!
operator==
( other );
61
}
62
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition:
qgsreadwritecontext.h:35
qgsreadwritecontext.h
QgsNumericFormat
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
Definition:
qgsnumericformat.h:218
QgsNumericFormat::id
virtual QString id() const =0
Returns a unique id for this numeric format.
QgsNumericFormat::suggestSampleValue
virtual double suggestSampleValue() const
Returns a suggested sample value which nicely represents the current format configuration.
Definition:
qgsnumericformat.cpp:40
QgsNumericFormat::operator!=
bool operator!=(const QgsNumericFormat &other) const
Definition:
qgsnumericformat.cpp:58
qgsxmlutils.h
QgsNumericFormat::configuration
virtual QVariantMap configuration(const QgsReadWriteContext &context) const =0
Returns the current configuration of the formatter.
qgsnumericformat.h
QgsNumericFormat::operator==
bool operator==(const QgsNumericFormat &other) const
Definition:
qgsnumericformat.cpp:53
QgsNumericFormat::writeXml
void writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Writes the format to an XML element.
Definition:
qgsnumericformat.cpp:45
QgsNumericFormatContext::QgsNumericFormatContext
QgsNumericFormatContext()
Constructor for QgsNumericFormatContext.
Definition:
qgsnumericformat.cpp:23
QgsXmlUtils::writeVariant
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
Definition:
qgsxmlutils.cpp:106
QgsNumericFormat::sortKey
virtual int sortKey()
Returns a sorting key value, where formats with a lower sort key will be shown earlier in lists.
Definition:
qgsnumericformat.cpp:35
Generated on Sat Oct 24 2020 17:43:09 for QGIS API Documentation by
1.8.20