Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This class (attached to a QgsProject object) provides a place to store and retrieve settings related to project display behavior, e.g. the numeric formats used for bearings and coordinates
- Loading branch information
1 parent
0ba2bcc
commit 410da5e
Showing
10 changed files
with
385 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
python/core/auto_generated/qgsprojectdisplaysettings.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsprojectdisplaysettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
class QgsProjectDisplaySettings : QObject | ||
{ | ||
%Docstring | ||
Contains settings and properties relating to how a QgsProject should display | ||
values such as map coordinates and bearings. | ||
|
||
.. versionadded:: 3.12 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprojectdisplaysettings.h" | ||
%End | ||
public: | ||
|
||
QgsProjectDisplaySettings( QObject *parent = 0 ); | ||
%Docstring | ||
Constructor for QgsProjectDisplaySettings with the specified ``parent`` object. | ||
%End | ||
|
||
~QgsProjectDisplaySettings(); | ||
|
||
void reset(); | ||
%Docstring | ||
Resets the settings to a default state. | ||
%End | ||
|
||
void setBearingFormat( QgsBearingNumericFormat *format /Transfer/ ); | ||
%Docstring | ||
Sets the project bearing ``format``, which controls how bearings associated with the project are displayed. | ||
|
||
Ownership of ``format`` is transferred to the settings. | ||
|
||
.. seealso:: :py:func:`bearingFormat` | ||
|
||
.. seealso:: :py:func:`bearingFormatChanged` | ||
%End | ||
|
||
const QgsBearingNumericFormat *bearingFormat() const; | ||
%Docstring | ||
Returns the project bearing's format, which controls how bearings associated with the project are displayed. | ||
|
||
.. seealso:: :py:func:`setBearingFormat` | ||
|
||
.. seealso:: :py:func:`bearingFormatChanged` | ||
%End | ||
|
||
bool readXml( const QDomElement &element, const QgsReadWriteContext &context ); | ||
%Docstring | ||
Reads the settings's state from a DOM element. | ||
|
||
.. seealso:: :py:func:`writeXml` | ||
%End | ||
|
||
QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const; | ||
%Docstring | ||
Returns a DOM element representing the settings. | ||
|
||
.. seealso:: :py:func:`readXml` | ||
%End | ||
|
||
signals: | ||
|
||
void bearingFormatChanged(); | ||
%Docstring | ||
Emitted when the bearing format changes. | ||
|
||
.. seealso:: :py:func:`setBearingFormat` | ||
|
||
.. seealso:: :py:func:`bearingFormat` | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsprojectdisplaysettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/*************************************************************************** | ||
qgsprojectdisplaysettings.cpp | ||
----------------------------- | ||
begin : January 2020 | ||
copyright : (C) 2020 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsprojectdisplaysettings.h" | ||
#include "qgis.h" | ||
#include "qgsbearingnumericformat.h" | ||
#include "qgsnumericformatregistry.h" | ||
#include "qgsapplication.h" | ||
|
||
#include <QDomElement> | ||
|
||
QgsProjectDisplaySettings::QgsProjectDisplaySettings( QObject *parent ) | ||
: QObject( parent ) | ||
, mBearingFormat( qgis::make_unique< QgsBearingNumericFormat >() ) | ||
{ | ||
|
||
} | ||
|
||
QgsProjectDisplaySettings::~QgsProjectDisplaySettings() = default; | ||
|
||
void QgsProjectDisplaySettings::reset() | ||
{ | ||
mBearingFormat = qgis::make_unique< QgsBearingNumericFormat >(); | ||
|
||
emit bearingFormatChanged(); | ||
} | ||
|
||
void QgsProjectDisplaySettings::setBearingFormat( QgsBearingNumericFormat *format ) | ||
{ | ||
mBearingFormat.reset( format ); | ||
emit bearingFormatChanged(); | ||
} | ||
|
||
const QgsBearingNumericFormat *QgsProjectDisplaySettings::bearingFormat() const | ||
{ | ||
return mBearingFormat.get(); | ||
} | ||
|
||
bool QgsProjectDisplaySettings::readXml( const QDomElement &element, const QgsReadWriteContext &context ) | ||
{ | ||
QDomElement bearingElement = element.firstChildElement( QStringLiteral( "BearingFormat" ) ); | ||
mBearingFormat.reset( static_cast< QgsBearingNumericFormat * >( QgsApplication::numericFormatRegistry()->createFromXml( bearingElement, context ) ) ); | ||
emit bearingFormatChanged(); | ||
|
||
return true; | ||
} | ||
|
||
QDomElement QgsProjectDisplaySettings::writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const | ||
{ | ||
QDomElement element = doc.createElement( QStringLiteral( "ProjectDisplaySettings" ) ); | ||
|
||
QDomElement bearingElement = doc.createElement( QStringLiteral( "BearingFormat" ) ); | ||
mBearingFormat->writeXml( bearingElement, doc, context ); | ||
element.appendChild( bearingElement ); | ||
|
||
return element; | ||
} |
Oops, something went wrong.