Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Nov 11, 2022
1 parent 7fce30b commit 4f0239c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
14 changes: 3 additions & 11 deletions src/app/qgisapp.cpp
Expand Up @@ -14412,23 +14412,15 @@ void QgisApp::removeMapToolMessage()
void QgisApp::showMapTip()
{
// Only show maptips if the mouse is still over the map canvas when timer is triggered
if ( mMapCanvas->underMouse() )
if ( mMapTipsVisible && mMapCanvas->underMouse() )
{
QPoint myPointerPos = mMapCanvas->mouseLastXY();

// Make sure there is an active layer before proceeding
QgsMapLayer *mypLayer = mMapCanvas->currentLayer();
if ( mypLayer )
if ( mypLayer && !mypLayer->mapTipTemplate().isEmpty() )
{
// only process vector and raster layers
if ( mypLayer->type() == QgsMapLayerType::VectorLayer || mypLayer->type() == QgsMapLayerType::RasterLayer )
{
// Show the maptip if the maptips button is depressed
if ( mMapTipsVisible )
{
mpMaptip->showMapTip( mypLayer, mLastMapPosition, myPointerPos, mMapCanvas );
}
}
mpMaptip->showMapTip( mypLayer, mLastMapPosition, myPointerPos, mMapCanvas );
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/expression/qgsexpression.cpp
Expand Up @@ -826,6 +826,7 @@ void QgsExpression::initVariableHelp()

// map canvas item variables
sVariableHelpTexts()->insert( QStringLiteral( "canvas_cursor_point" ), QCoreApplication::translate( "variable_help", "Last cursor position on the canvas in the project's geographical coordinates." ) );
sVariableHelpTexts()->insert( QStringLiteral( "layer_cursor_point" ), QCoreApplication::translate( "variable_help", "Last cursor position on the canvas in the current layers's geographical coordinates." ) );

// legend canvas item variables
sVariableHelpTexts()->insert( QStringLiteral( "legend_title" ), QCoreApplication::translate( "variable_help", "Title of the legend." ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/expression/qgsexpressioncontextutils.cpp
Expand Up @@ -538,7 +538,7 @@ QgsExpressionContextScope *QgsExpressionContextUtils::mapToolCaptureScope( const
QgsExpressionContextScope *QgsExpressionContextUtils::mapLayerPositionScope( const QgsPointXY &position )
{
QgsExpressionContextScope *scope = new QgsExpressionContextScope( QObject::tr( "Map Layer Position" ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layer_position" ), QVariant::fromValue( QgsGeometry::fromPointXY( position ) ) ) );
scope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "layer_cursor_point" ), QVariant::fromValue( QgsGeometry::fromPointXY( position ) ) ) );
return scope;
}

Expand Down
2 changes: 0 additions & 2 deletions src/core/raster/qgsrasterlayer.h
Expand Up @@ -77,8 +77,6 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer, public QgsAbstractProfile
{
Q_OBJECT

Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )

public:

//! \brief Default sample size (number of pixels) for estimated statistics/histogram calculation
Expand Down
6 changes: 4 additions & 2 deletions src/gui/qgsmaptip.cpp
Expand Up @@ -234,7 +234,8 @@ QString QgsMapTip::fetchFeature( QgsMapLayer *layer, QgsPointXY &mapPosition, Qg
if ( !vlayer || !vlayer->isSpatial() )
return QString();

if ( !layer->isInScaleRange( mapCanvas->mapSettings().scale() ) )
if ( !layer->isInScaleRange( mapCanvas->mapSettings().scale() ) ||
( mapCanvas->mapSettings().isTemporal() && !layer->temporalProperties()->isVisibleInTemporalRange( mapCanvas->temporalRange() ) ) )
{
return QString();
}
Expand Down Expand Up @@ -334,7 +335,8 @@ QString QgsMapTip::fetchRaster( QgsMapLayer *layer, QgsPointXY &mapPosition, Qgs
if ( !rlayer )
return QString();

if ( !layer->isInScaleRange( mapCanvas->mapSettings().scale() ) )
if ( !layer->isInScaleRange( mapCanvas->mapSettings().scale() ) ||
( mapCanvas->mapSettings().isTemporal() && !layer->temporalProperties()->isVisibleInTemporalRange( mapCanvas->temporalRange() ) ) )
{
return QString();
}
Expand Down

0 comments on commit 4f0239c

Please sign in to comment.