diff --git a/python/core/auto_generated/raster/qgsrasterlayer.sip.in b/python/core/auto_generated/raster/qgsrasterlayer.sip.in index f1af964b36c..8a351793f35 100644 --- a/python/core/auto_generated/raster/qgsrasterlayer.sip.in +++ b/python/core/auto_generated/raster/qgsrasterlayer.sip.in @@ -448,6 +448,24 @@ to be drawn outside the data extent. virtual QgsMapLayerElevationProperties *elevationProperties(); + QString mapTipTemplate() const; +%Docstring +The mapTip is a pretty, html representation for feature information. + +It may also contain embedded expressions. + +.. versionadded:: 3.30 +%End + + void setMapTipTemplate( const QString &mapTip ); +%Docstring +The mapTip is a pretty, html representation for feature information. + +It may also contain embedded expressions. + +.. versionadded:: 3.30 +%End + public slots: void showStatusMessage( const QString &message ); @@ -467,6 +485,14 @@ Emitted when the layer's subset string has changed. .. versionadded:: 3.12 %End + void mapTipTemplateChanged(); +%Docstring +Emitted when the map tip changes + +.. versionadded:: 3.30 +%End + + protected: virtual bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ); diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index ed5add847f7..288df75167c 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -1213,6 +1213,21 @@ QgsMapLayerElevationProperties *QgsRasterLayer::elevationProperties() return mElevationProperties; } +QString QgsRasterLayer::mapTipTemplate() const +{ + return mMapTipTemplate; +} + +void QgsRasterLayer::setMapTipTemplate( const QString &mapTip ) +{ + if ( mMapTipTemplate == mapTip ) + return; + + mMapTipTemplate = mapTip; + emit mapTipTemplateChanged(); + +} + void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnhancementAlgorithm algorithm, QgsRasterMinMaxOrigin::Limits limits, const QgsRectangle &extent, int sampleSize, bool generateLookupTableFlag ) { setContrastEnhancement( algorithm, diff --git a/src/core/raster/qgsrasterlayer.h b/src/core/raster/qgsrasterlayer.h index 85809d39e03..d8f90f40220 100644 --- a/src/core/raster/qgsrasterlayer.h +++ b/src/core/raster/qgsrasterlayer.h @@ -76,6 +76,9 @@ typedef QList < QPair< QString, QColor > > QgsLegendColorList; class CORE_EXPORT QgsRasterLayer : public QgsMapLayer, public QgsAbstractProfileSource { 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 @@ -491,6 +494,24 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer, public QgsAbstractProfile QgsMapLayerTemporalProperties *temporalProperties() override; QgsMapLayerElevationProperties *elevationProperties() override; + /** + * The mapTip is a pretty, html representation for feature information. + * + * It may also contain embedded expressions. + * + * \since QGIS 3.30 + */ + QString mapTipTemplate() const; + + /** + * The mapTip is a pretty, html representation for feature information. + * + * It may also contain embedded expressions. + * + * \since QGIS 3.30 + */ + void setMapTipTemplate( const QString &mapTip ); + public slots: void showStatusMessage( const QString &message ); @@ -509,6 +530,14 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer, public QgsAbstractProfile */ void subsetStringChanged(); + /** + * Emitted when the map tip changes + * + * \since QGIS 3.30 + */ + void mapTipTemplateChanged(); + + protected: bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) override; @@ -608,6 +637,8 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer, public QgsAbstractProfile QDomDocument mOriginalStyleDocument; QDomElement mOriginalStyleElement; + + QString mMapTipTemplate; }; // clazy:excludeall=qstring-allocations