QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
src
core
qgsprojectdisplaysettings.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsprojectdisplaysettings.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 "
qgsprojectdisplaysettings.h
"
17
#include "
qgis.h
"
18
#include "
qgsbearingnumericformat.h
"
19
#include "
qgsnumericformatregistry.h
"
20
#include "
qgsapplication.h
"
21
#include "
qgslocaldefaultsettings.h
"
22
23
#include <QDomElement>
24
25
QgsProjectDisplaySettings::QgsProjectDisplaySettings
( QObject *parent )
26
: QObject( parent )
27
, mBearingFormat( qgis::make_unique<
QgsBearingNumericFormat
>() )
28
{
29
30
}
31
32
QgsProjectDisplaySettings::~QgsProjectDisplaySettings
() =
default
;
33
34
void
QgsProjectDisplaySettings::reset
()
35
{
36
// inherit local default settings
37
mBearingFormat.reset(
QgsLocalDefaultSettings::bearingFormat
() );
38
39
emit
bearingFormatChanged
();
40
}
41
42
void
QgsProjectDisplaySettings::setBearingFormat
(
QgsBearingNumericFormat
*format )
43
{
44
mBearingFormat.reset( format );
45
emit
bearingFormatChanged
();
46
}
47
48
const
QgsBearingNumericFormat
*
QgsProjectDisplaySettings::bearingFormat
()
const
49
{
50
return
mBearingFormat.get();
51
}
52
53
bool
QgsProjectDisplaySettings::readXml
(
const
QDomElement &element,
const
QgsReadWriteContext
&context )
54
{
55
QDomElement bearingElement = element.firstChildElement( QStringLiteral(
"BearingFormat"
) );
56
mBearingFormat.reset(
static_cast<
QgsBearingNumericFormat
*
>
(
QgsApplication::numericFormatRegistry
()->createFromXml( bearingElement, context ) ) );
57
emit
bearingFormatChanged
();
58
59
return
true
;
60
}
61
62
QDomElement
QgsProjectDisplaySettings::writeXml
( QDomDocument &doc,
const
QgsReadWriteContext
&context )
const
63
{
64
QDomElement element = doc.createElement( QStringLiteral(
"ProjectDisplaySettings"
) );
65
66
QDomElement bearingElement = doc.createElement( QStringLiteral(
"BearingFormat"
) );
67
mBearingFormat->writeXml( bearingElement, doc, context );
68
element.appendChild( bearingElement );
69
70
return
element;
71
}
qgsnumericformatregistry.h
QgsProjectDisplaySettings::setBearingFormat
void setBearingFormat(QgsBearingNumericFormat *format)
Sets the project bearing format, which controls how bearings associated with the project are displaye...
Definition:
qgsprojectdisplaysettings.cpp:42
QgsProjectDisplaySettings::QgsProjectDisplaySettings
QgsProjectDisplaySettings(QObject *parent=nullptr)
Constructor for QgsProjectDisplaySettings with the specified parent object.
Definition:
qgsprojectdisplaysettings.cpp:25
qgslocaldefaultsettings.h
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition:
qgsreadwritecontext.h:35
qgis.h
qgsbearingnumericformat.h
QgsProjectDisplaySettings::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Returns a DOM element representing the settings.
Definition:
qgsprojectdisplaysettings.cpp:62
qgsapplication.h
QgsProjectDisplaySettings::readXml
bool readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the settings's state from a DOM element.
Definition:
qgsprojectdisplaysettings.cpp:53
QgsProjectDisplaySettings::reset
void reset()
Resets the settings to a default state.
Definition:
qgsprojectdisplaysettings.cpp:34
QgsProjectDisplaySettings::bearingFormat
const QgsBearingNumericFormat * bearingFormat() const
Returns the project bearing's format, which controls how bearings associated with the project are dis...
Definition:
qgsprojectdisplaysettings.cpp:48
QgsProjectDisplaySettings::bearingFormatChanged
void bearingFormatChanged()
Emitted when the bearing format changes.
QgsApplication::numericFormatRegistry
static QgsNumericFormatRegistry * numericFormatRegistry()
Gets the registry of available numeric formats.
Definition:
qgsapplication.cpp:2273
QgsProjectDisplaySettings::~QgsProjectDisplaySettings
~QgsProjectDisplaySettings() override
QgsBearingNumericFormat
A numeric formatter which returns a text representation of a direction/bearing.
Definition:
qgsbearingnumericformat.h:29
qgsprojectdisplaysettings.h
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