Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding tracking layer while recording #3700

Merged
merged 18 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/layersproxymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool LayersProxyModel::recordingAllowed( QgsMapLayer *layer ) const
return false;

QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( layer );
return ( vectorLayer && !vectorLayer->readOnly() && layerHasGeometry( vectorLayer ) && layerVisible( layer ) );
return ( vectorLayer && !vectorLayer->readOnly() && layerHasGeometry( vectorLayer ) && layerVisible( layer ) && !isPositionTrackingLayer( layer ) );
}

bool LayersProxyModel::layerVisible( QgsMapLayer *layer ) const
Expand Down Expand Up @@ -153,3 +153,17 @@ QVariant LayersProxyModel::getData( QModelIndex index, int role ) const
{
return sourceModel()->data( index, role );
}

bool LayersProxyModel::isPositionTrackingLayer( QgsMapLayer *layer ) const
{
if ( !layer )
return false;

QgsProject *project = QgsProject::instance();
VitorVieiraZ marked this conversation as resolved.
Show resolved Hide resolved

if ( !project )
return false;

QString trackingLayerId = project->readEntry( QStringLiteral( "Mergin" ), QStringLiteral( "PositionTracking/TrackingLayer" ), QString() );
return layer->id() == trackingLayerId;
}
4 changes: 4 additions & 0 deletions app/layersproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "qgsmaplayer.h"
#include "qgsmaplayerproxymodel.h"
#include "qgsvectorlayer.h"
#include "inpututils.h"

#include "layersmodel.h"

Expand Down Expand Up @@ -49,6 +50,9 @@ class LayersProxyModel : public QgsMapLayerProxyModel
//! Returns first layer from proxy model's layers list (filtered with filter function)
Q_INVOKABLE QgsMapLayer *firstUsableLayer() const;

//! Returns true if the layer is the position tracking layer
Q_INVOKABLE bool isPositionTrackingLayer( QgsMapLayer *layer ) const;

/**
* @brief layers method return layers from source model filtered with filter function
*/
Expand Down
Loading