mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Fix inverted polygons and displacement renderer don't allow right
click on legend items (fix #14966)
This commit is contained in:
parent
b32afce79d
commit
b2c43cb997
@ -85,6 +85,8 @@ class QgsInvertedPolygonRenderer : QgsFeatureRendererV2
|
||||
void setEmbeddedRenderer( QgsFeatureRendererV2* subRenderer /Transfer/ );
|
||||
const QgsFeatureRendererV2* embeddedRenderer() const;
|
||||
|
||||
virtual void setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol );
|
||||
|
||||
/** @returns true if the geometries are to be preprocessed (merged with an union) before rendering.*/
|
||||
bool preprocessingEnabled() const;
|
||||
/**
|
||||
|
@ -71,6 +71,8 @@ class QgsPointDisplacementRenderer : QgsFeatureRendererV2
|
||||
void setEmbeddedRenderer( QgsFeatureRendererV2* r /Transfer/ );
|
||||
QgsFeatureRendererV2* embeddedRenderer();
|
||||
|
||||
virtual void setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol );
|
||||
|
||||
//! not available in python bindings
|
||||
//! @deprecated since 2.4
|
||||
// void setDisplacementGroups( const QList<QMap<QgsFeatureId, QgsFeature> >& list );
|
||||
|
@ -287,44 +287,44 @@ QMenu* QgsAppLayerTreeViewMenuProvider::createContextMenu()
|
||||
menu->addAction( QgsApplication::getThemeIcon( "/mActionHideAllLayers.png" ), tr( "&Hide All Items" ),
|
||||
symbolNode, SLOT( uncheckAllItems() ) );
|
||||
menu->addSeparator();
|
||||
}
|
||||
|
||||
if ( symbolNode->symbol() )
|
||||
{
|
||||
QgsColorWheel* colorWheel = new QgsColorWheel( menu );
|
||||
colorWheel->setColor( symbolNode->symbol()->color() );
|
||||
QgsColorWidgetAction* colorAction = new QgsColorWidgetAction( colorWheel, menu, menu );
|
||||
colorAction->setDismissOnColorSelection( false );
|
||||
connect( colorAction, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setSymbolLegendNodeColor( const QColor& ) ) );
|
||||
//store the layer id and rule key in action, so we can later retrieve the corresponding
|
||||
//legend node, if it still exists
|
||||
colorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() );
|
||||
colorAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() );
|
||||
menu->addAction( colorAction );
|
||||
|
||||
//add recent colors action
|
||||
QList<QgsRecentColorScheme *> recentSchemes;
|
||||
QgsColorSchemeRegistry::instance()->schemes( recentSchemes );
|
||||
if ( !recentSchemes.isEmpty() )
|
||||
{
|
||||
QgsColorSwatchGridAction* recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menu, "symbology", menu );
|
||||
recentColorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() );
|
||||
recentColorAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() );
|
||||
recentColorAction->setDismissOnColorSelection( false );
|
||||
menu->addAction( recentColorAction );
|
||||
connect( recentColorAction, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setSymbolLegendNodeColor( const QColor& ) ) );
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
}
|
||||
|
||||
QAction* editSymbolAction = new QAction( tr( "Edit Symbol..." ), menu );
|
||||
if ( symbolNode->symbol() )
|
||||
{
|
||||
QgsColorWheel* colorWheel = new QgsColorWheel( menu );
|
||||
colorWheel->setColor( symbolNode->symbol()->color() );
|
||||
QgsColorWidgetAction* colorAction = new QgsColorWidgetAction( colorWheel, menu, menu );
|
||||
colorAction->setDismissOnColorSelection( false );
|
||||
connect( colorAction, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setSymbolLegendNodeColor( const QColor& ) ) );
|
||||
//store the layer id and rule key in action, so we can later retrieve the corresponding
|
||||
//legend node, if it still exists
|
||||
editSymbolAction->setProperty( "layerId", symbolNode->layerNode()->layerId() );
|
||||
editSymbolAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() );
|
||||
connect( editSymbolAction, SIGNAL( triggered() ), this, SLOT( editSymbolLegendNodeSymbol() ) );
|
||||
menu->addAction( editSymbolAction );
|
||||
colorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() );
|
||||
colorAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() );
|
||||
menu->addAction( colorAction );
|
||||
|
||||
//add recent colors action
|
||||
QList<QgsRecentColorScheme *> recentSchemes;
|
||||
QgsColorSchemeRegistry::instance()->schemes( recentSchemes );
|
||||
if ( !recentSchemes.isEmpty() )
|
||||
{
|
||||
QgsColorSwatchGridAction* recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menu, "symbology", menu );
|
||||
recentColorAction->setProperty( "layerId", symbolNode->layerNode()->layerId() );
|
||||
recentColorAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() );
|
||||
recentColorAction->setDismissOnColorSelection( false );
|
||||
menu->addAction( recentColorAction );
|
||||
connect( recentColorAction, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setSymbolLegendNodeColor( const QColor& ) ) );
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
}
|
||||
|
||||
QAction* editSymbolAction = new QAction( tr( "Edit Symbol..." ), menu );
|
||||
//store the layer id and rule key in action, so we can later retrieve the corresponding
|
||||
//legend node, if it still exists
|
||||
editSymbolAction->setProperty( "layerId", symbolNode->layerNode()->layerId() );
|
||||
editSymbolAction->setProperty( "ruleKey", symbolNode->data( QgsLayerTreeModelLegendNode::RuleKeyRole ).toString() );
|
||||
connect( editSymbolAction, SIGNAL( triggered() ), this, SLOT( editSymbolLegendNodeSymbol() ) );
|
||||
menu->addAction( editSymbolAction );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,14 @@ const QgsFeatureRendererV2* QgsInvertedPolygonRenderer::embeddedRenderer() const
|
||||
return mSubRenderer.data();
|
||||
}
|
||||
|
||||
void QgsInvertedPolygonRenderer::setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol )
|
||||
{
|
||||
if ( !mSubRenderer )
|
||||
return;
|
||||
|
||||
mSubRenderer->setLegendSymbolItem( key, symbol );
|
||||
}
|
||||
|
||||
void QgsInvertedPolygonRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
|
||||
{
|
||||
if ( !mSubRenderer )
|
||||
|
@ -121,6 +121,8 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRendererV2
|
||||
void setEmbeddedRenderer( QgsFeatureRendererV2* subRenderer ) override;
|
||||
const QgsFeatureRendererV2* embeddedRenderer() const override;
|
||||
|
||||
virtual void setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol ) override;
|
||||
|
||||
/** @returns true if the geometries are to be preprocessed (merged with an union) before rendering.*/
|
||||
bool preprocessingEnabled() const { return mPreprocessingEnabled; }
|
||||
/**
|
||||
|
@ -227,6 +227,14 @@ const QgsFeatureRendererV2* QgsPointDisplacementRenderer::embeddedRenderer() con
|
||||
return mRenderer;
|
||||
}
|
||||
|
||||
void QgsPointDisplacementRenderer::setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol )
|
||||
{
|
||||
if ( !mRenderer )
|
||||
return;
|
||||
|
||||
mRenderer->setLegendSymbolItem( key, symbol );
|
||||
}
|
||||
|
||||
QList<QString> QgsPointDisplacementRenderer::usedAttributes()
|
||||
{
|
||||
QList<QString> attributeList;
|
||||
|
@ -98,6 +98,8 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsFeatureRendererV2
|
||||
void setEmbeddedRenderer( QgsFeatureRendererV2* r ) override;
|
||||
const QgsFeatureRendererV2* embeddedRenderer() const override;
|
||||
|
||||
virtual void setLegendSymbolItem( const QString& key, QgsSymbolV2* symbol ) override;
|
||||
|
||||
//! not available in python bindings
|
||||
//! @deprecated since 2.4
|
||||
Q_DECL_DEPRECATED void setDisplacementGroups( const QList<QMap<QgsFeatureId, QgsFeature> >& list ) { Q_UNUSED( list ); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user