Create new QgsProjectGpsSettings class

Destinated for a storage location for GPS settings which are
project specific
This commit is contained in:
Nyall Dawson 2022-11-03 11:08:23 +10:00
parent a75d250916
commit 816eb16460
10 changed files with 568 additions and 27 deletions

View File

@ -821,12 +821,21 @@ Returns the project's elevation properties, which contains the project's elevati
QgsProjectDisplaySettings *displaySettings();
%Docstring
Returns the project's display settings, which settings and properties relating
Returns the project's display settings, which contains settings and properties relating
to how a QgsProject should display values such as map coordinates and bearings.
.. versionadded:: 3.12
%End
QgsProjectGpsSettings *gpsSettings();
%Docstring
Returns the project's GPS settings, which contains settings and properties relating
to how a QgsProject should interact with a GPS device.
.. versionadded:: 3.30
%End
QgsLayerTree *layerTreeRoot() const;
%Docstring
Returns pointer to the root (invisible) node of the project's layer tree

View File

@ -0,0 +1,128 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/project/qgsprojectgpssettings.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsProjectGpsSettings : QObject
{
%Docstring(signature="appended")
Contains settings and properties relating to how a :py:class:`QgsProject` should interact
with a GPS device.
.. versionadded:: 3.30
%End
%TypeHeaderCode
#include "qgsprojectgpssettings.h"
%End
public:
QgsProjectGpsSettings( QObject *parent = 0 );
%Docstring
Constructor for QgsProjectGpsSettings with the specified ``parent`` object.
%End
~QgsProjectGpsSettings();
void reset();
%Docstring
Resets the settings to a default state.
%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
bool automaticallyAddTrackPoints() const;
%Docstring
Returns ``True`` if track points should be automatically created whenever
new locations are received from the GPS device.
.. seealso:: :py:func:`setAutomaticallyAddTrackPoints`
.. seealso:: :py:func:`automaticallyAddTrackPointsChanged`
%End
bool automaticallyCommitFeatures() const;
%Docstring
Returns ``True`` if features created from GPS locations should be
immediately commited to their target layers (skipping the usual
layer edit buffer).
.. seealso:: :py:func:`setAutomaticallyCommitFeatures`
.. seealso:: :py:func:`automaticallyCommitFeaturesChanged`
%End
public slots:
void setAutomaticallyAddTrackPoints( bool enabled );
%Docstring
Sets whether track points should be automatically created whenever
new locations are received from the GPS device.
.. seealso:: :py:func:`automaticallyAddTrackPoints`
.. seealso:: :py:func:`automaticallyAddTrackPointsChanged`
%End
void setAutomaticallyCommitFeatures( bool enabled );
%Docstring
Sets whether features created from GPS locations should be
immediately commited to their target layers (skipping the usual
layer edit buffer).
.. seealso:: :py:func:`automaticallyCommitFeatures`
.. seealso:: :py:func:`automaticallyCommitFeaturesChanged`
%End
signals:
void automaticallyAddTrackPointsChanged( bool enabled );
%Docstring
Emitted whenever the :py:func:`~QgsProjectGpsSettings.automaticallyAddTrackPoints` setting
is changed.
.. seealso:: :py:func:`automaticallyAddTrackPoints`
.. seealso:: :py:func:`setAutomaticallyAddTrackPoints`
%End
void automaticallyCommitFeaturesChanged( bool enabled );
%Docstring
Emitted whenever the :py:func:`~QgsProjectGpsSettings.automaticallyCommitFeatures` setting
is changed.
.. seealso:: :py:func:`automaticallyCommitFeatures`
.. seealso:: :py:func:`setAutomaticallyCommitFeatures`
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/project/qgsprojectgpssettings.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -554,6 +554,7 @@
%Include auto_generated/project/qgsprojectdisplaysettings.sip
%Include auto_generated/project/qgsprojectelevationproperties.sip
%Include auto_generated/project/qgsprojectfiletransform.sip
%Include auto_generated/project/qgsprojectgpssettings.sip
%Include auto_generated/project/qgsprojectproperty.sip
%Include auto_generated/project/qgsprojectservervalidator.sip
%Include auto_generated/project/qgsprojectstorage.sip

View File

@ -660,6 +660,7 @@ set(QGIS_CORE_SRCS
project/qgsprojectelevationproperties.cpp
project/qgsprojectfiletransform.cpp
project/qgsprojectdisplaysettings.cpp
project/qgsprojectgpssettings.cpp
project/qgsprojectproperty.cpp
project/qgsprojectservervalidator.cpp
project/qgsprojectstorage.cpp
@ -1666,6 +1667,7 @@ set(QGIS_CORE_HDRS
project/qgsprojectdisplaysettings.h
project/qgsprojectelevationproperties.h
project/qgsprojectfiletransform.h
project/qgsprojectgpssettings.h
project/qgsprojectproperty.h
project/qgsprojectservervalidator.h
project/qgsprojectstorage.h

View File

@ -35,10 +35,8 @@
#include "qgsprojectversion.h"
#include "qgsrasterlayer.h"
#include "qgsreadwritecontext.h"
#include "qgsrectangle.h"
#include "qgsrelationmanager.h"
#include "qgsannotationmanager.h"
#include "qgsvectorlayerjoininfo.h"
#include "qgsvectorlayerjoinbuffer.h"
#include "qgsmapthemecollection.h"
#include "qgslayerdefinition.h"
@ -47,7 +45,6 @@
#include "qgstransactiongroup.h"
#include "qgsvectordataprovider.h"
#include "qgsprojectbadlayerhandler.h"
#include "qgsmaplayerlistutils_p.h"
#include "qgsmeshlayer.h"
#include "qgslayoutmanager.h"
#include "qgsbookmarkmanager.h"
@ -70,6 +67,7 @@
#include "qgsmapviewsmanager.h"
#include "qgsprojectelevationproperties.h"
#include "qgscombinedstylemodel.h"
#include "qgsprojectgpssettings.h"
#include <algorithm>
#include <QApplication>
@ -381,6 +379,7 @@ QgsProject::QgsProject( QObject *parent, Qgis::ProjectCapabilities capabilities
, mTimeSettings( new QgsProjectTimeSettings( this ) )
, mElevationProperties( new QgsProjectElevationProperties( this ) )
, mDisplaySettings( new QgsProjectDisplaySettings( this ) )
, mGpsSettings( new QgsProjectGpsSettings( this ) )
, mRootGroup( new QgsLayerTree )
, mLabelingEngineSettings( new QgsLabelingEngineSettings )
, mArchive( new QgsArchive() )
@ -974,6 +973,7 @@ void QgsProject::clear()
mTimeSettings->reset();
mElevationProperties->reset();
mDisplaySettings->reset();
mGpsSettings->reset();
mSnappingConfig.reset();
mAvoidIntersectionsMode = Qgis::AvoidIntersectionsMode::AllowIntersections;
emit avoidIntersectionsModeChanged();
@ -2009,9 +2009,18 @@ bool QgsProject::readProjectFile( const QString &filename, Qgis::ProjectReadFlag
mElevationProperties->resolveReferences( this );
profile.switchTask( tr( "Loading display settings" ) );
const QDomElement displaySettingsElement = doc->documentElement().firstChildElement( QStringLiteral( "ProjectDisplaySettings" ) );
if ( !displaySettingsElement.isNull() )
mDisplaySettings->readXml( displaySettingsElement, context );
{
const QDomElement displaySettingsElement = doc->documentElement().firstChildElement( QStringLiteral( "ProjectDisplaySettings" ) );
if ( !displaySettingsElement.isNull() )
mDisplaySettings->readXml( displaySettingsElement, context );
}
profile.switchTask( tr( "Loading GPS settings" ) );
{
const QDomElement gpsSettingsElement = doc->documentElement().firstChildElement( QStringLiteral( "ProjectGpsSettings" ) );
if ( !gpsSettingsElement.isNull() )
mGpsSettings->readXml( gpsSettingsElement, context );
}
profile.switchTask( tr( "Updating variables" ) );
emit customVariablesChanged();
@ -2745,32 +2754,55 @@ bool QgsProject::writeProjectFile( const QString &filename )
mMetadata.writeMetadataXml( metadataElem, *doc );
qgisNode.appendChild( metadataElem );
const QDomElement annotationsElem = mAnnotationManager->writeXml( *doc, context );
qgisNode.appendChild( annotationsElem );
{
const QDomElement annotationsElem = mAnnotationManager->writeXml( *doc, context );
qgisNode.appendChild( annotationsElem );
}
const QDomElement layoutElem = mLayoutManager->writeXml( *doc );
qgisNode.appendChild( layoutElem );
{
const QDomElement layoutElem = mLayoutManager->writeXml( *doc );
qgisNode.appendChild( layoutElem );
}
const QDomElement views3DElem = m3DViewsManager->writeXml( *doc );
qgisNode.appendChild( views3DElem );
{
const QDomElement views3DElem = m3DViewsManager->writeXml( *doc );
qgisNode.appendChild( views3DElem );
}
const QDomElement bookmarkElem = mBookmarkManager->writeXml( *doc );
qgisNode.appendChild( bookmarkElem );
{
const QDomElement bookmarkElem = mBookmarkManager->writeXml( *doc );
qgisNode.appendChild( bookmarkElem );
}
const QDomElement viewSettingsElem = mViewSettings->writeXml( *doc, context );
qgisNode.appendChild( viewSettingsElem );
{
const QDomElement viewSettingsElem = mViewSettings->writeXml( *doc, context );
qgisNode.appendChild( viewSettingsElem );
}
const QDomElement styleSettingsElem = mStyleSettings->writeXml( *doc, context );
qgisNode.appendChild( styleSettingsElem );
{
const QDomElement styleSettingsElem = mStyleSettings->writeXml( *doc, context );
qgisNode.appendChild( styleSettingsElem );
}
const QDomElement timeSettingsElement = mTimeSettings->writeXml( *doc, context );
qgisNode.appendChild( timeSettingsElement );
{
const QDomElement timeSettingsElement = mTimeSettings->writeXml( *doc, context );
qgisNode.appendChild( timeSettingsElement );
}
const QDomElement elevationPropertiesElement = mElevationProperties->writeXml( *doc, context );
qgisNode.appendChild( elevationPropertiesElement );
{
const QDomElement elevationPropertiesElement = mElevationProperties->writeXml( *doc, context );
qgisNode.appendChild( elevationPropertiesElement );
}
const QDomElement displaySettingsElem = mDisplaySettings->writeXml( *doc, context );
qgisNode.appendChild( displaySettingsElem );
{
const QDomElement displaySettingsElem = mDisplaySettings->writeXml( *doc, context );
qgisNode.appendChild( displaySettingsElem );
}
{
const QDomElement gpsSettingsElem = mGpsSettings->writeXml( *doc, context );
qgisNode.appendChild( gpsSettingsElem );
}
// now wrap it up and ship it to the project file
doc->normalize(); // XXX I'm not entirely sure what this does
@ -3518,6 +3550,16 @@ QgsProjectDisplaySettings *QgsProject::displaySettings()
return mDisplaySettings;
}
const QgsProjectGpsSettings *QgsProject::gpsSettings() const
{
return mGpsSettings;
}
QgsProjectGpsSettings *QgsProject::gpsSettings()
{
return mGpsSettings;
}
QgsLayerTree *QgsProject::layerTreeRoot() const
{
return mRootGroup;

View File

@ -86,6 +86,7 @@ class QgsAttributeEditorContainer;
class QgsPropertyCollection;
class QgsMapViewsManager;
class QgsProjectElevationProperties;
class QgsProjectGpsSettings;
/**
* \ingroup core
@ -862,7 +863,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
QgsProjectElevationProperties *elevationProperties();
/**
* Returns the project's display settings, which settings and properties relating
* Returns the project's display settings, which contains settings and properties relating
* to how a QgsProject should display values such as map coordinates and bearings.
* \note not available in Python bindings
* \since QGIS 3.12
@ -870,12 +871,27 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
const QgsProjectDisplaySettings *displaySettings() const SIP_SKIP;
/**
* Returns the project's display settings, which settings and properties relating
* Returns the project's display settings, which contains settings and properties relating
* to how a QgsProject should display values such as map coordinates and bearings.
* \since QGIS 3.12
*/
QgsProjectDisplaySettings *displaySettings();
/**
* Returns the project's GPS settings, which contains settings and properties relating
* to how a QgsProject should interact with a GPS device.
* \note not available in Python bindings
* \since QGIS 3.30
*/
const QgsProjectGpsSettings *gpsSettings() const SIP_SKIP;
/**
* Returns the project's GPS settings, which contains settings and properties relating
* to how a QgsProject should interact with a GPS device.
* \since QGIS 3.30
*/
QgsProjectGpsSettings *gpsSettings();
/**
* Returns pointer to the root (invisible) node of the project's layer tree
* \since QGIS 2.4
@ -2248,6 +2264,8 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
QgsProjectDisplaySettings *mDisplaySettings = nullptr;
QgsProjectGpsSettings *mGpsSettings = nullptr;
QgsLayerTree *mRootGroup = nullptr;
QgsLayerTreeRegistryBridge *mLayerTreeRegistryBridge = nullptr;

View File

@ -0,0 +1,82 @@
/***************************************************************************
qgsprojectgpssettings.cpp
---------------------------
begin : November 2022
copyright : (C) 2022 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 "qgsprojectgpssettings.h"
#include <QDomElement>
QgsProjectGpsSettings::QgsProjectGpsSettings( QObject *parent )
: QObject( parent )
{
}
QgsProjectGpsSettings::~QgsProjectGpsSettings() = default;
void QgsProjectGpsSettings::reset()
{
mAutoAddTrackPoints = false;
mAutoCommitFeatures = false;
emit automaticallyAddTrackPointsChanged( false );
emit automaticallyCommitFeaturesChanged( false );
}
bool QgsProjectGpsSettings::readXml( const QDomElement &element, const QgsReadWriteContext & )
{
mAutoAddTrackPoints = element.attribute( QStringLiteral( "autoAddTrackPoints" ), "0" ).toInt();
mAutoCommitFeatures = element.attribute( QStringLiteral( "autoCommitFeatures" ), "0" ).toInt();
emit automaticallyAddTrackPointsChanged( mAutoAddTrackPoints );
emit automaticallyCommitFeaturesChanged( mAutoCommitFeatures );
return true;
}
QDomElement QgsProjectGpsSettings::writeXml( QDomDocument &doc, const QgsReadWriteContext & ) const
{
QDomElement element = doc.createElement( QStringLiteral( "ProjectGpsSettings" ) );
element.setAttribute( QStringLiteral( "autoAddTrackPoints" ), mAutoAddTrackPoints ? 1 : 0 );
element.setAttribute( QStringLiteral( "autoCommitFeatures" ), mAutoCommitFeatures ? 1 : 0 );
return element;
}
bool QgsProjectGpsSettings::automaticallyAddTrackPoints() const
{
return mAutoAddTrackPoints;
}
bool QgsProjectGpsSettings::automaticallyCommitFeatures() const
{
return mAutoCommitFeatures;
}
void QgsProjectGpsSettings::setAutomaticallyAddTrackPoints( bool enabled )
{
if ( enabled == mAutoAddTrackPoints )
return;
mAutoAddTrackPoints = enabled;
emit automaticallyAddTrackPointsChanged( enabled );
}
void QgsProjectGpsSettings::setAutomaticallyCommitFeatures( bool enabled )
{
if ( enabled == mAutoCommitFeatures )
return;
mAutoCommitFeatures = enabled;
emit automaticallyCommitFeaturesChanged( enabled );
}

View File

@ -0,0 +1,136 @@
/***************************************************************************
qgsprojectgpssettings.h
---------------------------
begin : November 2022
copyright : (C) 2022 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. *
* *
***************************************************************************/
#ifndef QGSPROJECTGPSSETTINGS_H
#define QGSPROJECTGPSSETTINGS_H
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgis.h"
#include <QObject>
class QDomElement;
class QgsReadWriteContext;
class QDomDocument;
/**
* \brief Contains settings and properties relating to how a QgsProject should interact
* with a GPS device.
*
* \ingroup core
* \since QGIS 3.30
*/
class CORE_EXPORT QgsProjectGpsSettings : public QObject
{
Q_OBJECT
public:
Q_PROPERTY( bool automaticallyAddTrackPoints READ automaticallyAddTrackPoints WRITE setAutomaticallyAddTrackPoints NOTIFY automaticallyAddTrackPointsChanged )
/**
* Constructor for QgsProjectGpsSettings with the specified \a parent object.
*/
QgsProjectGpsSettings( QObject *parent = nullptr );
~QgsProjectGpsSettings() override;
/**
* Resets the settings to a default state.
*/
void reset();
/**
* Reads the settings's state from a DOM element.
* \see writeXml()
*/
bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
/**
* Returns a DOM element representing the settings.
* \see readXml()
*/
QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
/**
* Returns TRUE if track points should be automatically created whenever
* new locations are received from the GPS device.
*
* \see setAutomaticallyAddTrackPoints()
* \see automaticallyAddTrackPointsChanged()
*/
bool automaticallyAddTrackPoints() const;
/**
* Returns TRUE if features created from GPS locations should be
* immediately commited to their target layers (skipping the usual
* layer edit buffer).
*
* \see setAutomaticallyCommitFeatures()
* \see automaticallyCommitFeaturesChanged()
*/
bool automaticallyCommitFeatures() const;
public slots:
/**
* Sets whether track points should be automatically created whenever
* new locations are received from the GPS device.
*
* \see automaticallyAddTrackPoints()
* \see automaticallyAddTrackPointsChanged()
*/
void setAutomaticallyAddTrackPoints( bool enabled );
/**
* Sets whether features created from GPS locations should be
* immediately commited to their target layers (skipping the usual
* layer edit buffer).
*
* \see automaticallyCommitFeatures()
* \see automaticallyCommitFeaturesChanged()
*/
void setAutomaticallyCommitFeatures( bool enabled );
signals:
/**
* Emitted whenever the automaticallyAddTrackPoints() setting
* is changed.
*
* \see automaticallyAddTrackPoints()
* \see setAutomaticallyAddTrackPoints()
*/
void automaticallyAddTrackPointsChanged( bool enabled );
/**
* Emitted whenever the automaticallyCommitFeatures() setting
* is changed.
*
* \see automaticallyCommitFeatures()
* \see setAutomaticallyCommitFeatures()
*/
void automaticallyCommitFeaturesChanged( bool enabled );
private:
bool mAutoAddTrackPoints = false;
bool mAutoCommitFeatures = false;
};
#endif // QGSPROJECTGPSSETTINGS_H

View File

@ -276,6 +276,7 @@ ADD_PYTHON_TEST(PyQgsProfilePoint test_qgsprofilepoint.py)
ADD_PYTHON_TEST(PyQgsProfileRequest test_qgsprofilerequest.py)
ADD_PYTHON_TEST(PyQgsProjectionSelectionWidgets test_qgsprojectionselectionwidgets.py)
ADD_PYTHON_TEST(PyQgsProjectElevationProperties test_qgsprojectelevationproperties.py)
ADD_PYTHON_TEST(PyQgsProjectGpsSettings test_qgsprojectgpssettings.py)
ADD_PYTHON_TEST(PyQgsProjectMetadata test_qgsprojectmetadata.py)
ADD_PYTHON_TEST(PyQgsProjectServerValidator test_qgsprojectservervalidator.py)
ADD_PYTHON_TEST(PyQgsProjectUtils test_qgsprojectutils.py)

View File

@ -0,0 +1,122 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsProjectGpsSettings.
.. note:: 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.
"""
__author__ = 'Nyall Dawson'
__date__ = '03/11/2022'
__copyright__ = 'Copyright 2022, The QGIS Project'
import qgis # NOQA
from qgis.core import (QgsProjectGpsSettings,
QgsReadWriteContext,
QgsBearingNumericFormat,
QgsGeographicCoordinateNumericFormat,
QgsSettings,
QgsLocalDefaultSettings,
QgsUnitTypes,
QgsCoordinateReferenceSystem,
Qgis)
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtTest import QSignalSpy
from qgis.PyQt.QtXml import QDomDocument
from qgis.testing import start_app, unittest
from utilities import (unitTestDataPath)
app = start_app()
TEST_DATA_DIR = unitTestDataPath()
class TestQgsProjectGpsSettings(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain("TestPyQgsProjectGpsSettings.com")
QCoreApplication.setApplicationName("TestPyQgsProjectGpsSettings")
QgsSettings().clear()
start_app()
def testSettings(self):
p = QgsProjectGpsSettings()
self.assertFalse(p.automaticallyCommitFeatures())
self.assertFalse(p.automaticallyAddTrackPoints())
spy_add_track = QSignalSpy(p.automaticallyAddTrackPointsChanged)
spy_auto_commit = QSignalSpy(p.automaticallyCommitFeaturesChanged)
p.setAutomaticallyAddTrackPoints(True)
self.assertEqual(len(spy_add_track), 1)
self.assertTrue(spy_add_track[-1][0])
p.setAutomaticallyAddTrackPoints(True)
self.assertEqual(len(spy_add_track), 1)
self.assertTrue(p.automaticallyAddTrackPoints())
p.setAutomaticallyAddTrackPoints(False)
self.assertEqual(len(spy_add_track), 2)
self.assertFalse(spy_add_track[-1][0])
p.setAutomaticallyCommitFeatures(True)
self.assertEqual(len(spy_auto_commit), 1)
self.assertTrue(spy_auto_commit[-1][0])
p.setAutomaticallyCommitFeatures(True)
self.assertEqual(len(spy_auto_commit), 1)
self.assertTrue(p.automaticallyCommitFeatures())
p.setAutomaticallyCommitFeatures(False)
self.assertEqual(len(spy_auto_commit), 2)
self.assertFalse(spy_auto_commit[-1][0])
def testReset(self):
"""
Test that resetting inherits local default settings
"""
p = QgsProjectGpsSettings()
self.assertFalse(p.automaticallyCommitFeatures())
self.assertFalse(p.automaticallyAddTrackPoints())
p.setAutomaticallyCommitFeatures(True)
p.setAutomaticallyAddTrackPoints(True)
spy_add_track = QSignalSpy(p.automaticallyAddTrackPointsChanged)
spy_auto_commit = QSignalSpy(p.automaticallyCommitFeaturesChanged)
p.reset()
self.assertFalse(p.automaticallyAddTrackPoints())
self.assertFalse(p.automaticallyCommitFeatures())
self.assertEqual(len(spy_add_track), 1)
self.assertFalse(spy_auto_commit[-1][0])
self.assertEqual(len(spy_auto_commit), 1)
self.assertFalse(spy_auto_commit[-1][0])
def testReadWrite(self):
p = QgsProjectGpsSettings()
p.setAutomaticallyCommitFeatures(True)
p.setAutomaticallyAddTrackPoints(True)
doc = QDomDocument("testdoc")
elem = p.writeXml(doc, QgsReadWriteContext())
p2 = QgsProjectGpsSettings()
spy = QSignalSpy(p2.automaticallyAddTrackPointsChanged)
spy2 = QSignalSpy(p2.automaticallyCommitFeaturesChanged)
self.assertTrue(p2.readXml(elem, QgsReadWriteContext()))
self.assertEqual(len(spy), 1)
self.assertEqual(len(spy2), 1)
self.assertTrue(p.automaticallyCommitFeatures())
self.assertTrue(p.automaticallyAddTrackPoints())
if __name__ == '__main__':
unittest.main()