mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Create new QgsProjectGpsSettings class
Destinated for a storage location for GPS settings which are project specific
This commit is contained in:
parent
a75d250916
commit
816eb16460
@ -821,12 +821,21 @@ Returns the project's elevation properties, which contains the project's elevati
|
|||||||
|
|
||||||
QgsProjectDisplaySettings *displaySettings();
|
QgsProjectDisplaySettings *displaySettings();
|
||||||
%Docstring
|
%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.
|
to how a QgsProject should display values such as map coordinates and bearings.
|
||||||
|
|
||||||
.. versionadded:: 3.12
|
.. versionadded:: 3.12
|
||||||
%End
|
%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;
|
QgsLayerTree *layerTreeRoot() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
Returns pointer to the root (invisible) node of the project's layer tree
|
Returns pointer to the root (invisible) node of the project's layer tree
|
||||||
|
128
python/core/auto_generated/project/qgsprojectgpssettings.sip.in
Normal file
128
python/core/auto_generated/project/qgsprojectgpssettings.sip.in
Normal 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 *
|
||||||
|
************************************************************************/
|
@ -554,6 +554,7 @@
|
|||||||
%Include auto_generated/project/qgsprojectdisplaysettings.sip
|
%Include auto_generated/project/qgsprojectdisplaysettings.sip
|
||||||
%Include auto_generated/project/qgsprojectelevationproperties.sip
|
%Include auto_generated/project/qgsprojectelevationproperties.sip
|
||||||
%Include auto_generated/project/qgsprojectfiletransform.sip
|
%Include auto_generated/project/qgsprojectfiletransform.sip
|
||||||
|
%Include auto_generated/project/qgsprojectgpssettings.sip
|
||||||
%Include auto_generated/project/qgsprojectproperty.sip
|
%Include auto_generated/project/qgsprojectproperty.sip
|
||||||
%Include auto_generated/project/qgsprojectservervalidator.sip
|
%Include auto_generated/project/qgsprojectservervalidator.sip
|
||||||
%Include auto_generated/project/qgsprojectstorage.sip
|
%Include auto_generated/project/qgsprojectstorage.sip
|
||||||
|
@ -660,6 +660,7 @@ set(QGIS_CORE_SRCS
|
|||||||
project/qgsprojectelevationproperties.cpp
|
project/qgsprojectelevationproperties.cpp
|
||||||
project/qgsprojectfiletransform.cpp
|
project/qgsprojectfiletransform.cpp
|
||||||
project/qgsprojectdisplaysettings.cpp
|
project/qgsprojectdisplaysettings.cpp
|
||||||
|
project/qgsprojectgpssettings.cpp
|
||||||
project/qgsprojectproperty.cpp
|
project/qgsprojectproperty.cpp
|
||||||
project/qgsprojectservervalidator.cpp
|
project/qgsprojectservervalidator.cpp
|
||||||
project/qgsprojectstorage.cpp
|
project/qgsprojectstorage.cpp
|
||||||
@ -1666,6 +1667,7 @@ set(QGIS_CORE_HDRS
|
|||||||
project/qgsprojectdisplaysettings.h
|
project/qgsprojectdisplaysettings.h
|
||||||
project/qgsprojectelevationproperties.h
|
project/qgsprojectelevationproperties.h
|
||||||
project/qgsprojectfiletransform.h
|
project/qgsprojectfiletransform.h
|
||||||
|
project/qgsprojectgpssettings.h
|
||||||
project/qgsprojectproperty.h
|
project/qgsprojectproperty.h
|
||||||
project/qgsprojectservervalidator.h
|
project/qgsprojectservervalidator.h
|
||||||
project/qgsprojectstorage.h
|
project/qgsprojectstorage.h
|
||||||
|
@ -35,10 +35,8 @@
|
|||||||
#include "qgsprojectversion.h"
|
#include "qgsprojectversion.h"
|
||||||
#include "qgsrasterlayer.h"
|
#include "qgsrasterlayer.h"
|
||||||
#include "qgsreadwritecontext.h"
|
#include "qgsreadwritecontext.h"
|
||||||
#include "qgsrectangle.h"
|
|
||||||
#include "qgsrelationmanager.h"
|
#include "qgsrelationmanager.h"
|
||||||
#include "qgsannotationmanager.h"
|
#include "qgsannotationmanager.h"
|
||||||
#include "qgsvectorlayerjoininfo.h"
|
|
||||||
#include "qgsvectorlayerjoinbuffer.h"
|
#include "qgsvectorlayerjoinbuffer.h"
|
||||||
#include "qgsmapthemecollection.h"
|
#include "qgsmapthemecollection.h"
|
||||||
#include "qgslayerdefinition.h"
|
#include "qgslayerdefinition.h"
|
||||||
@ -47,7 +45,6 @@
|
|||||||
#include "qgstransactiongroup.h"
|
#include "qgstransactiongroup.h"
|
||||||
#include "qgsvectordataprovider.h"
|
#include "qgsvectordataprovider.h"
|
||||||
#include "qgsprojectbadlayerhandler.h"
|
#include "qgsprojectbadlayerhandler.h"
|
||||||
#include "qgsmaplayerlistutils_p.h"
|
|
||||||
#include "qgsmeshlayer.h"
|
#include "qgsmeshlayer.h"
|
||||||
#include "qgslayoutmanager.h"
|
#include "qgslayoutmanager.h"
|
||||||
#include "qgsbookmarkmanager.h"
|
#include "qgsbookmarkmanager.h"
|
||||||
@ -70,6 +67,7 @@
|
|||||||
#include "qgsmapviewsmanager.h"
|
#include "qgsmapviewsmanager.h"
|
||||||
#include "qgsprojectelevationproperties.h"
|
#include "qgsprojectelevationproperties.h"
|
||||||
#include "qgscombinedstylemodel.h"
|
#include "qgscombinedstylemodel.h"
|
||||||
|
#include "qgsprojectgpssettings.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -381,6 +379,7 @@ QgsProject::QgsProject( QObject *parent, Qgis::ProjectCapabilities capabilities
|
|||||||
, mTimeSettings( new QgsProjectTimeSettings( this ) )
|
, mTimeSettings( new QgsProjectTimeSettings( this ) )
|
||||||
, mElevationProperties( new QgsProjectElevationProperties( this ) )
|
, mElevationProperties( new QgsProjectElevationProperties( this ) )
|
||||||
, mDisplaySettings( new QgsProjectDisplaySettings( this ) )
|
, mDisplaySettings( new QgsProjectDisplaySettings( this ) )
|
||||||
|
, mGpsSettings( new QgsProjectGpsSettings( this ) )
|
||||||
, mRootGroup( new QgsLayerTree )
|
, mRootGroup( new QgsLayerTree )
|
||||||
, mLabelingEngineSettings( new QgsLabelingEngineSettings )
|
, mLabelingEngineSettings( new QgsLabelingEngineSettings )
|
||||||
, mArchive( new QgsArchive() )
|
, mArchive( new QgsArchive() )
|
||||||
@ -974,6 +973,7 @@ void QgsProject::clear()
|
|||||||
mTimeSettings->reset();
|
mTimeSettings->reset();
|
||||||
mElevationProperties->reset();
|
mElevationProperties->reset();
|
||||||
mDisplaySettings->reset();
|
mDisplaySettings->reset();
|
||||||
|
mGpsSettings->reset();
|
||||||
mSnappingConfig.reset();
|
mSnappingConfig.reset();
|
||||||
mAvoidIntersectionsMode = Qgis::AvoidIntersectionsMode::AllowIntersections;
|
mAvoidIntersectionsMode = Qgis::AvoidIntersectionsMode::AllowIntersections;
|
||||||
emit avoidIntersectionsModeChanged();
|
emit avoidIntersectionsModeChanged();
|
||||||
@ -2009,9 +2009,18 @@ bool QgsProject::readProjectFile( const QString &filename, Qgis::ProjectReadFlag
|
|||||||
mElevationProperties->resolveReferences( this );
|
mElevationProperties->resolveReferences( this );
|
||||||
|
|
||||||
profile.switchTask( tr( "Loading display settings" ) );
|
profile.switchTask( tr( "Loading display settings" ) );
|
||||||
const QDomElement displaySettingsElement = doc->documentElement().firstChildElement( QStringLiteral( "ProjectDisplaySettings" ) );
|
{
|
||||||
if ( !displaySettingsElement.isNull() )
|
const QDomElement displaySettingsElement = doc->documentElement().firstChildElement( QStringLiteral( "ProjectDisplaySettings" ) );
|
||||||
mDisplaySettings->readXml( displaySettingsElement, context );
|
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" ) );
|
profile.switchTask( tr( "Updating variables" ) );
|
||||||
emit customVariablesChanged();
|
emit customVariablesChanged();
|
||||||
@ -2745,32 +2754,55 @@ bool QgsProject::writeProjectFile( const QString &filename )
|
|||||||
mMetadata.writeMetadataXml( metadataElem, *doc );
|
mMetadata.writeMetadataXml( metadataElem, *doc );
|
||||||
qgisNode.appendChild( metadataElem );
|
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
|
// now wrap it up and ship it to the project file
|
||||||
doc->normalize(); // XXX I'm not entirely sure what this does
|
doc->normalize(); // XXX I'm not entirely sure what this does
|
||||||
@ -3518,6 +3550,16 @@ QgsProjectDisplaySettings *QgsProject::displaySettings()
|
|||||||
return mDisplaySettings;
|
return mDisplaySettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QgsProjectGpsSettings *QgsProject::gpsSettings() const
|
||||||
|
{
|
||||||
|
return mGpsSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
QgsProjectGpsSettings *QgsProject::gpsSettings()
|
||||||
|
{
|
||||||
|
return mGpsSettings;
|
||||||
|
}
|
||||||
|
|
||||||
QgsLayerTree *QgsProject::layerTreeRoot() const
|
QgsLayerTree *QgsProject::layerTreeRoot() const
|
||||||
{
|
{
|
||||||
return mRootGroup;
|
return mRootGroup;
|
||||||
|
@ -86,6 +86,7 @@ class QgsAttributeEditorContainer;
|
|||||||
class QgsPropertyCollection;
|
class QgsPropertyCollection;
|
||||||
class QgsMapViewsManager;
|
class QgsMapViewsManager;
|
||||||
class QgsProjectElevationProperties;
|
class QgsProjectElevationProperties;
|
||||||
|
class QgsProjectGpsSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup core
|
* \ingroup core
|
||||||
@ -862,7 +863,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
|
|||||||
QgsProjectElevationProperties *elevationProperties();
|
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.
|
* to how a QgsProject should display values such as map coordinates and bearings.
|
||||||
* \note not available in Python bindings
|
* \note not available in Python bindings
|
||||||
* \since QGIS 3.12
|
* \since QGIS 3.12
|
||||||
@ -870,12 +871,27 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
|
|||||||
const QgsProjectDisplaySettings *displaySettings() const SIP_SKIP;
|
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.
|
* to how a QgsProject should display values such as map coordinates and bearings.
|
||||||
* \since QGIS 3.12
|
* \since QGIS 3.12
|
||||||
*/
|
*/
|
||||||
QgsProjectDisplaySettings *displaySettings();
|
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
|
* Returns pointer to the root (invisible) node of the project's layer tree
|
||||||
* \since QGIS 2.4
|
* \since QGIS 2.4
|
||||||
@ -2248,6 +2264,8 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
|
|||||||
|
|
||||||
QgsProjectDisplaySettings *mDisplaySettings = nullptr;
|
QgsProjectDisplaySettings *mDisplaySettings = nullptr;
|
||||||
|
|
||||||
|
QgsProjectGpsSettings *mGpsSettings = nullptr;
|
||||||
|
|
||||||
QgsLayerTree *mRootGroup = nullptr;
|
QgsLayerTree *mRootGroup = nullptr;
|
||||||
|
|
||||||
QgsLayerTreeRegistryBridge *mLayerTreeRegistryBridge = nullptr;
|
QgsLayerTreeRegistryBridge *mLayerTreeRegistryBridge = nullptr;
|
||||||
|
82
src/core/project/qgsprojectgpssettings.cpp
Normal file
82
src/core/project/qgsprojectgpssettings.cpp
Normal 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 );
|
||||||
|
}
|
136
src/core/project/qgsprojectgpssettings.h
Normal file
136
src/core/project/qgsprojectgpssettings.h
Normal 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
|
@ -276,6 +276,7 @@ ADD_PYTHON_TEST(PyQgsProfilePoint test_qgsprofilepoint.py)
|
|||||||
ADD_PYTHON_TEST(PyQgsProfileRequest test_qgsprofilerequest.py)
|
ADD_PYTHON_TEST(PyQgsProfileRequest test_qgsprofilerequest.py)
|
||||||
ADD_PYTHON_TEST(PyQgsProjectionSelectionWidgets test_qgsprojectionselectionwidgets.py)
|
ADD_PYTHON_TEST(PyQgsProjectionSelectionWidgets test_qgsprojectionselectionwidgets.py)
|
||||||
ADD_PYTHON_TEST(PyQgsProjectElevationProperties test_qgsprojectelevationproperties.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(PyQgsProjectMetadata test_qgsprojectmetadata.py)
|
||||||
ADD_PYTHON_TEST(PyQgsProjectServerValidator test_qgsprojectservervalidator.py)
|
ADD_PYTHON_TEST(PyQgsProjectServerValidator test_qgsprojectservervalidator.py)
|
||||||
ADD_PYTHON_TEST(PyQgsProjectUtils test_qgsprojectutils.py)
|
ADD_PYTHON_TEST(PyQgsProjectUtils test_qgsprojectutils.py)
|
||||||
|
122
tests/src/python/test_qgsprojectgpssettings.py
Normal file
122
tests/src/python/test_qgsprojectgpssettings.py
Normal 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()
|
Loading…
x
Reference in New Issue
Block a user