QGIS API Documentation
3.99.0-Master (e9821da5c6b)
Loading...
Searching...
No Matches
src
core
qgslocaldefaultsettings.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgslocaldefaultsettings.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
16
#include "
qgslocaldefaultsettings.h
"
17
18
#include <memory>
19
20
#include "
qgis.h
"
21
#include "
qgsbearingnumericformat.h
"
22
#include "
qgscoordinatenumericformat.h
"
23
#include "
qgsreadwritecontext.h
"
24
25
#include <QSettings>
26
#include <QString>
27
28
using namespace
Qt::StringLiterals;
29
30
void
QgsLocalDefaultSettings::setBearingFormat
(
const
QgsBearingNumericFormat
*format )
31
{
32
const
QVariantMap config = format->
configuration
(
QgsReadWriteContext
() );
33
34
QSettings s;
35
s.beginGroup( u
"defaults/bearing_format"
_s );
36
for
(
auto
it = config.constBegin(); it != config.constEnd(); ++it )
37
{
38
s.setValue( it.key(), it.value() );
39
}
40
s.endGroup();
41
}
42
43
QgsBearingNumericFormat
*
QgsLocalDefaultSettings::bearingFormat
()
44
{
45
QVariantMap config;
46
QSettings s;
47
s.beginGroup( u
"defaults/bearing_format"
_s );
48
const
QStringList keys = s.childKeys();
49
for
(
const
QString &key : keys )
50
{
51
const
QVariant value = s.value( key );
52
config.insert( key, value );
53
}
54
s.endGroup();
55
56
auto
res = std::make_unique< QgsBearingNumericFormat >();
57
res->setConfiguration( config,
QgsReadWriteContext
() );
58
return
res.release();
59
}
60
61
void
QgsLocalDefaultSettings::setGeographicCoordinateFormat
(
const
QgsGeographicCoordinateNumericFormat
*format )
62
{
63
const
QVariantMap config = format->
configuration
(
QgsReadWriteContext
() );
64
65
QSettings s;
66
s.beginGroup( u
"defaults/coordinate_format"
_s );
67
for
(
auto
it = config.constBegin(); it != config.constEnd(); ++it )
68
{
69
s.setValue( it.key(), it.value() );
70
}
71
s.endGroup();
72
}
73
74
QgsGeographicCoordinateNumericFormat
*
QgsLocalDefaultSettings::geographicCoordinateFormat
()
75
{
76
QVariantMap config;
77
QSettings s;
78
s.beginGroup( u
"defaults/coordinate_format"
_s );
79
const
QStringList keys = s.childKeys();
80
for
(
const
QString &key : keys )
81
{
82
const
QVariant value = s.value( key );
83
config.insert( key, value );
84
}
85
s.endGroup();
86
87
auto
res = std::make_unique< QgsGeographicCoordinateNumericFormat >();
88
res->setConfiguration( config,
QgsReadWriteContext
() );
89
return
res.release();
90
}
QgsBearingNumericFormat
A numeric formatter which returns a text representation of a direction/bearing.
Definition
qgsbearingnumericformat.h:29
QgsBearingNumericFormat::configuration
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
Definition
qgsbearingnumericformat.cpp:104
QgsGeographicCoordinateNumericFormat
A numeric formatter which returns a text representation of a geographic coordinate (latitude or longi...
Definition
qgscoordinatenumericformat.h:29
QgsGeographicCoordinateNumericFormat::configuration
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
Definition
qgscoordinatenumericformat.cpp:113
QgsLocalDefaultSettings::geographicCoordinateFormat
static QgsGeographicCoordinateNumericFormat * geographicCoordinateFormat()
Returns the default geographic coordinate format, which controls how geographic coordinates are displ...
Definition
qgslocaldefaultsettings.cpp:74
QgsLocalDefaultSettings::setBearingFormat
static void setBearingFormat(const QgsBearingNumericFormat *format)
Sets the default bearing format, which controls how angular bearings are displayed.
Definition
qgslocaldefaultsettings.cpp:30
QgsLocalDefaultSettings::setGeographicCoordinateFormat
static void setGeographicCoordinateFormat(const QgsGeographicCoordinateNumericFormat *format)
Sets the default geographic coordinate format, which controls how geographic coordinates are displaye...
Definition
qgslocaldefaultsettings.cpp:61
QgsLocalDefaultSettings::bearingFormat
static QgsBearingNumericFormat * bearingFormat()
Returns the default bearing format, which controls how angular bearings are displayed.
Definition
qgslocaldefaultsettings.cpp:43
QgsReadWriteContext
A container for the context for various read/write operations on objects.
Definition
qgsreadwritecontext.h:38
qgis.h
qgsbearingnumericformat.h
qgscoordinatenumericformat.h
qgslocaldefaultsettings.h
qgsreadwritecontext.h
Generated on
for QGIS API Documentation by
1.15.0