QGIS API Documentation 3.99.0-Master (e9821da5c6b)
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#include <QString>
27
28using namespace Qt::StringLiterals;
29
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
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
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
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}
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.