Skip to content

Commit

Permalink
Cleanup dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 7, 2022
1 parent 50dc408 commit 8b42768
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 31 deletions.
34 changes: 7 additions & 27 deletions src/app/gps/qgsgpstoolbar.cpp
Expand Up @@ -176,7 +176,7 @@ QgsGpsToolBar::QgsGpsToolBar( QgsAppGpsConnection *connection, QgsMapCanvas *can
} );

connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::destinationLayerChanged,
this, &QgsGpsToolBar::updateCloseFeatureButton );
this, &QgsGpsToolBar::destinationLayerChanged );

connect( QgsProject::instance()->gpsSettings(), &QgsProjectGpsSettings::automaticallyAddTrackVerticesChanged, this, [ = ]( bool enabled ) { setAddVertexButtonEnabled( !enabled ); } );
setAddVertexButtonEnabled( !QgsProject::instance()->gpsSettings()->automaticallyAddTrackVertices() );
Expand Down Expand Up @@ -206,32 +206,17 @@ void QgsGpsToolBar::updateLocationLabel( const QgsPoint &point )
}
}

void QgsGpsToolBar::updateCloseFeatureButton( QgsVectorLayer *vlayer )
void QgsGpsToolBar::destinationLayerChanged( QgsVectorLayer *vlayer )
{
if ( !( vlayer && vlayer->isValid() ) )
if ( vlayer )
{
mAddFeatureAction->setEnabled( false );
return;

}

// Add feature button tracks edit state of layer
if ( vlayer != mLastLayer )
if ( !( vlayer && vlayer->isValid() ) )
{
if ( mLastLayer ) // disconnect previous layer
{
disconnect( mLastLayer, &QgsVectorLayer::editingStarted,
this, &QgsGpsToolBar::layerEditStateChanged );
disconnect( mLastLayer, &QgsVectorLayer::editingStopped,
this, &QgsGpsToolBar::layerEditStateChanged );
}
if ( vlayer ) // connect new layer
{
connect( vlayer, &QgsVectorLayer::editingStarted,
this, &QgsGpsToolBar::layerEditStateChanged );
connect( vlayer, &QgsVectorLayer::editingStopped,
this, &QgsGpsToolBar::layerEditStateChanged );
}
mLastLayer = vlayer;
mAddFeatureAction->setEnabled( false );
return;
}

QString buttonLabel = tr( "Create Feature" );
Expand Down Expand Up @@ -279,11 +264,6 @@ void QgsGpsToolBar::updateCloseFeatureButton( QgsVectorLayer *vlayer )
mAddFeatureAction->setToolTip( buttonToolTip );
}

void QgsGpsToolBar::layerEditStateChanged()
{
updateCloseFeatureButton( mLastLayer );
}

void QgsGpsToolBar::destinationMenuAboutToShow()
{
mDestinationLayerMenu->clear();
Expand Down
5 changes: 1 addition & 4 deletions src/app/gps/qgsgpstoolbar.h
Expand Up @@ -51,8 +51,7 @@ class QgsGpsToolBar : public QToolBar
private slots:

void updateLocationLabel( const QgsPoint &point );
void updateCloseFeatureButton( QgsVectorLayer *lyr );
void layerEditStateChanged();
void destinationLayerChanged( QgsVectorLayer *lyr );
void destinationMenuAboutToShow();

private:
Expand All @@ -73,8 +72,6 @@ class QgsGpsToolBar : public QToolBar
QgsCoordinateReferenceSystem mWgs84CRS;
bool mEnableAddVertexButton = true;

QPointer< QgsVectorLayer > mLastLayer;

QgsMapLayerProxyModel *mDestinationLayerModel = nullptr;
};

Expand Down

0 comments on commit 8b42768

Please sign in to comment.