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