QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 = std::make_unique< QgsBearingNumericFormat >();
53  res->setConfiguration( config, QgsReadWriteContext() );
54  return res.release();
55 }
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.
static void setBearingFormat(const QgsBearingNumericFormat *format)
Sets the default bearing format, which controls how angular bearings are displayed.
static QgsBearingNumericFormat * bearingFormat()
Returns the default bearing format, which controls how angular bearings are displayed.
The class is used as a container of context for various read/write operations on other objects.