mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Ensure layer tree indicator icons are repainted on changes
This commit is contained in:
parent
bd44f53236
commit
33ee00f3f6
@ -52,6 +52,13 @@ Sets tool tip text
|
||||
void clicked( const QModelIndex &index );
|
||||
%Docstring
|
||||
Emitted when user clicks on the indicator
|
||||
%End
|
||||
|
||||
void changed();
|
||||
%Docstring
|
||||
Emitted when the indicator changes state (e.g. icon).
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
};
|
||||
|
@ -398,12 +398,17 @@ QList<QgsMapLayer *> QgsLayerTreeView::selectedLayersRecursive() const
|
||||
void QgsLayerTreeView::addIndicator( QgsLayerTreeNode *node, QgsLayerTreeViewIndicator *indicator )
|
||||
{
|
||||
if ( !mIndicators[node].contains( indicator ) )
|
||||
{
|
||||
mIndicators[node].append( indicator );
|
||||
connect( indicator, &QgsLayerTreeViewIndicator::changed, this, [ = ] { update(); } );
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void QgsLayerTreeView::removeIndicator( QgsLayerTreeNode *node, QgsLayerTreeViewIndicator *indicator )
|
||||
{
|
||||
mIndicators[node].removeOne( indicator );
|
||||
update();
|
||||
}
|
||||
|
||||
QList<QgsLayerTreeViewIndicator *> QgsLayerTreeView::indicators( QgsLayerTreeNode *node ) const
|
||||
|
@ -42,7 +42,7 @@ class GUI_EXPORT QgsLayerTreeViewIndicator : public QObject
|
||||
//! Indicator icon that will be displayed in the layer tree view
|
||||
QIcon icon() const { return mIcon; }
|
||||
//! Sets indicator icon that will be displayed in the layer tree view
|
||||
void setIcon( const QIcon &icon ) { mIcon = icon; }
|
||||
void setIcon( const QIcon &icon ) { mIcon = icon; emit changed(); }
|
||||
|
||||
//! Returns tool tip text that will be shown when user hovers mouse over the indicator
|
||||
QString toolTip() const { return mToolTip; }
|
||||
@ -53,6 +53,12 @@ class GUI_EXPORT QgsLayerTreeViewIndicator : public QObject
|
||||
//! Emitted when user clicks on the indicator
|
||||
void clicked( const QModelIndex &index );
|
||||
|
||||
/**
|
||||
* Emitted when the indicator changes state (e.g. icon).
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void changed();
|
||||
|
||||
private:
|
||||
QIcon mIcon;
|
||||
QString mToolTip;
|
||||
|
Loading…
x
Reference in New Issue
Block a user