QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
18 #include "qgis.h"
19 #include "qgsreadwritecontext.h"
20 #include "qgssettings.h"
21 #include "qgsapplication.h"
23 
24 #include <memory>
25 
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 
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
Definition: qgsreadwritecontext.h:34
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
Definition: qgsbearingnumericformat.h:28
QgsLocalDefaultSettings::bearingFormat
static QgsBearingNumericFormat * bearingFormat()
Returns the default bearing format, which controls how angular bearings are displayed.
Definition: qgslocaldefaultsettings.cpp:39