16#include "moc_qgsprojectgpssettings.cpp" 
   32  if ( mDestinationLayer )
 
 
   42  mAutoAddTrackVertices = 
false;
 
   43  mAutoCommitFeatures = 
false;
 
   44  mDestinationFollowsActiveLayer = 
true;
 
   46  mDestinationLayer.
setLayer( 
nullptr );
 
   47  mDestinationTimestampFields.clear();
 
 
   58  mAutoAddTrackVertices = element.attribute( QStringLiteral( 
"autoAddTrackVertices" ), 
"0" ).toInt();
 
   59  mAutoCommitFeatures = element.attribute( QStringLiteral( 
"autoCommitFeatures" ), 
"0" ).toInt();
 
   60  mDestinationFollowsActiveLayer = element.attribute( QStringLiteral( 
"destinationFollowsActiveLayer" ), 
"1" ).toInt();
 
   62  const QString layerId = element.attribute( QStringLiteral( 
"destinationLayer" ) );
 
   63  const QString layerName = element.attribute( QStringLiteral( 
"destinationLayerName" ) );
 
   64  const QString layerSource = element.attribute( QStringLiteral( 
"destinationLayerSource" ) );
 
   65  const QString layerProvider = element.attribute( QStringLiteral( 
"destinationLayerProvider" ) );
 
   67  mDestinationLayer = 
QgsVectorLayerRef( layerId, layerName, layerSource, layerProvider );
 
   69  mDestinationTimestampFields.clear();
 
   71    const QDomElement timeStampElement = element.firstChildElement( QStringLiteral( 
"timeStampFields" ) );
 
   72    QDomElement layerElement = timeStampElement.firstChildElement();
 
   73    while ( !layerElement.isNull() )
 
   75      const QString layerId = layerElement.attribute( QStringLiteral( 
"destinationLayer" ) );
 
   76      const QString field = layerElement.attribute( QStringLiteral( 
"field" ) );
 
   77      mDestinationTimestampFields[ layerId ] = field;
 
   78      layerElement = layerElement.nextSiblingElement();
 
 
   92  QDomElement element = doc.createElement( QStringLiteral( 
"ProjectGpsSettings" ) );
 
   94  element.setAttribute( QStringLiteral( 
"autoAddTrackVertices" ),  mAutoAddTrackVertices ? 1 : 0 );
 
   95  element.setAttribute( QStringLiteral( 
"autoCommitFeatures" ),  mAutoCommitFeatures ? 1 : 0 );
 
   96  element.setAttribute( QStringLiteral( 
"destinationFollowsActiveLayer" ),  mDestinationFollowsActiveLayer ? 1 : 0 );
 
   98  if ( mDestinationLayer )
 
  100    element.setAttribute( QStringLiteral( 
"destinationLayer" ), mDestinationLayer.
layerId );
 
  101    element.setAttribute( QStringLiteral( 
"destinationLayerName" ), mDestinationLayer.
name );
 
  102    element.setAttribute( QStringLiteral( 
"destinationLayerSource" ), mDestinationLayer.
source );
 
  103    element.setAttribute( QStringLiteral( 
"destinationLayerProvider" ), mDestinationLayer.
provider );
 
  107    element.setAttribute( QStringLiteral( 
"destinationLayer" ), QString() );
 
  111    QDomElement timeStampElement = doc.createElement( QStringLiteral( 
"timeStampFields" ) );
 
  112    for ( 
auto it = mDestinationTimestampFields.constBegin(); it != mDestinationTimestampFields.constEnd(); ++it )
 
  114      const QString layerId = it.key();
 
  115      if ( 
QgsProject *project = qobject_cast< QgsProject * >( parent() ) )
 
  118        if ( !project->mapLayer( layerId ) )
 
  122      QDomElement layerElement = doc.createElement( QStringLiteral( 
"field" ) );
 
  123      layerElement.setAttribute( QStringLiteral( 
"destinationLayer" ), layerId );
 
  124      layerElement.setAttribute( QStringLiteral( 
"field" ), it.value() );
 
  125      timeStampElement.appendChild( layerElement );
 
  127    element.appendChild( timeStampElement );
 
 
  135  return mAutoAddTrackVertices;
 
 
  140  return mAutoCommitFeatures;
 
 
  145  return mDestinationFollowsActiveLayer;
 
 
  150  return mDestinationLayer.
get();
 
 
  155  return mDestinationTimestampFields;
 
 
  162    return mDestinationTimestampFields.value( vl->id() );
 
 
  169  if ( enabled == mAutoAddTrackVertices )
 
  172  mAutoAddTrackVertices = enabled;
 
 
  178  if ( enabled == mAutoCommitFeatures )
 
  181  mAutoCommitFeatures = enabled;
 
 
  187  if ( follow == mDestinationFollowsActiveLayer )
 
  190  mDestinationFollowsActiveLayer = follow;
 
 
  196  if ( layer == mDestinationLayer.
get() )
 
  201  mDestinationLayer.
setLayer( layer );
 
 
  219  if ( mDestinationTimestampFields.value( layer->
id() ) != field )
 
  221    mDestinationTimestampFields.insert( layer->
id(), field );
 
 
void setAutomaticallyCommitFeatures(bool enabled)
Sets whether features created from GPS locations should be immediately committed to their target laye...
 
bool automaticallyCommitFeatures
 
void destinationFollowsActiveLayerChanged(bool follows)
Emitted whenever the destinationFollowsActiveLayer() setting is changed.
 
bool automaticallyAddTrackVertices
 
void destinationLayerChanged(QgsVectorLayer *layer)
Emitted whenever the destination layer for features digitized from GPS is changed.
 
void setDestinationFollowsActiveLayer(bool follow)
Sets whether the destination layer for storing features digitized from GPS should follow the current ...
 
QMap< QString, QString > destinationTimeStampFields() const
Returns the map of destination layer ID to target time stamp field name.
 
bool readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the settings's state from a DOM element.
 
QgsProjectGpsSettings(QObject *parent=nullptr)
Constructor for QgsProjectGpsSettings with the specified parent object.
 
void reset()
Resets the settings to a default state.
 
QgsVectorLayer * destinationLayer
 
void setDestinationLayer(QgsVectorLayer *layer)
Sets the destination layer to be used for storing features digitized from GPS.
 
void setAutomaticallyAddTrackVertices(bool enabled)
Sets whether track vertices should be automatically created whenever new locations are received from ...
 
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Returns a DOM element representing the settings.
 
void resolveReferences(const QgsProject *project)
Resolves reference to layers from stored layer ID (if it has not been resolved already)
 
void setDestinationTimeStampField(QgsVectorLayer *layer, const QString &field)
Sets the destination field name for automatically storing timestamps in the specified destination lay...
 
bool destinationFollowsActiveLayer() const
Returns true if the destination layer for storing features digitized from GPS should follow the curre...
 
void destinationTimeStampFieldChanged(const QString &field)
Emitted whenever the destination field for automatic time stamps is changed.
 
~QgsProjectGpsSettings() override
 
void automaticallyCommitFeaturesChanged(bool enabled)
Emitted whenever the automaticallyCommitFeatures() setting is changed.
 
void automaticallyAddTrackVerticesChanged(bool enabled)
Emitted whenever the automaticallyAddTrackVertices() setting is changed.
 
QString destinationTimeStampField() const
Returns the destination time stamp field name for the current destinationLayer(), or an empty string ...
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
 
A container for the context for various read/write operations on objects.
 
Represents a vector layer which manages a vector based dataset.
 
_LayerRef< QgsVectorLayer > QgsVectorLayerRef
 
TYPE * resolveWeakly(const QgsProject *project, MatchType matchType=MatchType::All)
Resolves the map layer by attempting to find a matching layer in a project using a weak match.
 
QString source
Weak reference to layer public source.
 
QString name
Weak reference to layer name.
 
TYPE * get() const
Returns a pointer to the layer, or nullptr if the reference has not yet been matched to a layer.
 
QString provider
Weak reference to layer provider.
 
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
 
QString layerId
Original layer ID.