QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
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
#include "
qgsbearingnumericformat.h
"
18
#include "
qgis.h
"
19
#include "
qgsreadwritecontext.h
"
20
#include "
qgssettings.h
"
21
#include "
qgsapplication.h
"
22
#include "
qgsnumericformatregistry.h
"
23
24
#include <memory>
25
26
void
QgsLocalDefaultSettings::setBearingFormat
(
const
QgsBearingNumericFormat
*format )
27
{
28
const
QVariantMap config = format->
configuration
(
QgsReadWriteContext
() );
29
30
QSettings s;
31
s.beginGroup( QStringLiteral(
"defaults/bearing_format"
) );
32
for
(
auto
it = config.constBegin(); it != config.constEnd(); ++it )
33
{
34
s.setValue( it.key(), it.value() );
35
}
36
s.endGroup();
37
}
38
39
QgsBearingNumericFormat
*
QgsLocalDefaultSettings::bearingFormat
()
40
{
41
QVariantMap config;
42
QSettings s;
43
s.beginGroup( QStringLiteral(
"defaults/bearing_format"
) );
44
const
QStringList keys = s.childKeys();
45
for
(
const
QString &key : keys )
46
{
47
const
QVariant value = s.value( key );
48
config.insert( key, value );
49
}
50
s.endGroup();
51
52
std::unique_ptr< QgsBearingNumericFormat > res = qgis::make_unique< QgsBearingNumericFormat >();
53
res->setConfiguration( config,
QgsReadWriteContext
() );
54
return
res.release();
55
}
qgsnumericformatregistry.h
qgslocaldefaultsettings.h
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition:
qgsreadwritecontext.h:35
qgsreadwritecontext.h
qgis.h
qgsbearingnumericformat.h
qgsapplication.h
QgsBearingNumericFormat::configuration
QVariantMap configuration(const QgsReadWriteContext &context) const override
Returns the current configuration of the formatter.
Definition:
qgsbearingnumericformat.cpp:100
QgsLocalDefaultSettings::setBearingFormat
static void setBearingFormat(const QgsBearingNumericFormat *format)
Sets the default bearing format, which controls how angular bearings are displayed.
Definition:
qgslocaldefaultsettings.cpp:26
qgssettings.h
QgsBearingNumericFormat
A numeric formatter which returns a text representation of a direction/bearing.
Definition:
qgsbearingnumericformat.h:29
QgsLocalDefaultSettings::bearingFormat
static QgsBearingNumericFormat * bearingFormat()
Returns the default bearing format, which controls how angular bearings are displayed.
Definition:
qgslocaldefaultsettings.cpp:39
Generated on Sat Oct 24 2020 17:43:09 for QGIS API Documentation by
1.8.20