Skip to content
Permalink
Browse files
Don't show symbol levels actions in renderer widgets for renderers
which are subrenderers for other renderers

Symbol layers have no effect in this situation (e.g. when a categorized
renderer is used as a subrenderer for point displacement renderer), so
don't show the option in the GUI

(cherry picked from commit a3af108)
  • Loading branch information
nyalldawson committed May 31, 2021
1 parent a624eff commit c57b51b1589005833c9bda28ba6df2d9968d893f
@@ -34,7 +34,7 @@ Returns pointer to the renderer (no transfer of ownership)

void showSymbolLevelsDialog( QgsFeatureRenderer *r );
%Docstring
show a dialog with renderer's symbol level settings
Show a dialog with renderer's symbol level settings.
%End

virtual void setContext( const QgsSymbolWidgetContext &context );
@@ -72,6 +72,7 @@ This method should be called whenever the renderer is actually set on the layer.
virtual void setDockMode( bool dockMode );



signals:

void layerVariablesChanged();
@@ -81,9 +82,12 @@ vector layers have been changed. Will request the parent dialog
to re-synchronize with the variables.
%End

void symbolLevelsChanged();
void symbolLevelsChanged() /Deprecated/;
%Docstring
Emitted when the symbol levels settings have been changed.

.. deprecated:: QGIS 3.20
-- no longer emitted.
%End

protected:
@@ -26,15 +26,8 @@ class QgsSingleSymbolRendererWidget : QgsRendererWidget

virtual void setContext( const QgsSymbolWidgetContext &context );


virtual void setDockMode( bool dockMode );

%Docstring
Set the widget in dock mode which tells the widget to emit panel
widgets and not open dialogs

:param dockMode: ``True`` to enable dock mode.
%End

protected:
virtual void setSymbolLevels( const QList< QgsLegendSymbolItem > &levels, bool enabled );
@@ -578,7 +578,7 @@ QgsCategorizedSymbolRendererWidget::QgsCategorizedSymbolRendererWidget( QgsVecto

advMenu->addAction( tr( "Match to Saved Symbols" ), this, SLOT( matchToSymbolsFromLibrary() ) );
advMenu->addAction( tr( "Match to Symbols from File…" ), this, SLOT( matchToSymbolsFromXml() ) );
advMenu->addAction( tr( "Symbol Levels…" ), this, SLOT( showSymbolLevels() ) );
mActionLevels = advMenu->addAction( tr( "Symbol Levels…" ), this, SLOT( showSymbolLevels() ) );
if ( mCategorizedSymbol && mCategorizedSymbol->type() == QgsSymbol::Marker )
{
QAction *actionDdsLegend = advMenu->addAction( tr( "Data-defined Size Legend…" ) );
@@ -645,6 +645,12 @@ void QgsCategorizedSymbolRendererWidget::setContext( const QgsSymbolWidgetContex
btnChangeCategorizedSymbol->setMessageBar( context.messageBar() );
}

void QgsCategorizedSymbolRendererWidget::disableSymbolLevels()
{
delete mActionLevels;
mActionLevels = nullptr;
}

void QgsCategorizedSymbolRendererWidget::changeSelectedSymbols()
{
QList<int> selectedCats = selectedCategories();
@@ -100,6 +100,7 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,

QgsFeatureRenderer *renderer() override;
void setContext( const QgsSymbolWidgetContext &context ) override;
void disableSymbolLevels() override SIP_SKIP;

/**
* Replaces category symbols with the symbols from a style that have a matching
@@ -219,6 +220,7 @@ class GUI_EXPORT QgsCategorizedSymbolRendererWidget : public QgsRendererWidget,
QMenu *mContextMenu = nullptr;
QAction *mMergeCategoriesAction = nullptr;
QAction *mUnmergeCategoriesAction = nullptr;
QAction *mActionLevels = nullptr;

QgsExpressionContext createExpressionContext() const override;

@@ -575,7 +575,7 @@ QgsGraduatedSymbolRendererWidget::QgsGraduatedSymbolRendererWidget( QgsVectorLay
// menus for data-defined rotation/size
QMenu *advMenu = new QMenu( this );

advMenu->addAction( tr( "Symbol Levels…" ), this, SLOT( showSymbolLevels() ) );
mActionLevels = advMenu->addAction( tr( "Symbol Levels…" ), this, SLOT( showSymbolLevels() ) );
if ( mGraduatedSymbol && mGraduatedSymbol->type() == QgsSymbol::Marker )
{
QAction *actionDdsLegend = advMenu->addAction( tr( "Data-defined Size Legend…" ) );
@@ -621,6 +621,12 @@ void QgsGraduatedSymbolRendererWidget::setContext( const QgsSymbolWidgetContext
btnChangeGraduatedSymbol->setMessageBar( context.messageBar() );
}

void QgsGraduatedSymbolRendererWidget::disableSymbolLevels()
{
delete mActionLevels;
mActionLevels = nullptr;
}

// Connect/disconnect event handlers which trigger updating renderer
void QgsGraduatedSymbolRendererWidget::connectUpdateHandlers()
{
@@ -100,6 +100,7 @@ class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, pr

QgsFeatureRenderer *renderer() override;
void setContext( const QgsSymbolWidgetContext &context ) override;
void disableSymbolLevels() override SIP_SKIP;

public slots:
void graduatedColumnChanged( const QString &field );
@@ -197,7 +198,7 @@ class GUI_EXPORT QgsGraduatedSymbolRendererWidget : public QgsRendererWidget, pr
QgsRangeList mCopyBuffer;

QDoubleValidator *mSymmetryPointValidator = nullptr;

QAction *mActionLevels = nullptr;
std::vector< std::unique_ptr< QgsAbstractProcessingParameterWidgetWrapper >> mParameterWidgetWrappers;
};

@@ -139,6 +139,7 @@ void QgsInvertedPolygonRendererWidget::mRendererComboBox_currentIndexChanged( in
mEmbeddedRendererWidget.reset( m->createRendererWidget( mLayer, mStyle, oldRenderer.get() ) );
connect( mEmbeddedRendererWidget.get(), &QgsRendererWidget::widgetChanged, this, &QgsInvertedPolygonRendererWidget::widgetChanged );
mEmbeddedRendererWidget->setContext( mContext );
mEmbeddedRendererWidget->disableSymbolLevels();
mEmbeddedRendererWidget->setDockMode( this->dockMode() );
connect( mEmbeddedRendererWidget.get(), &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );

@@ -161,6 +161,7 @@ void QgsPointClusterRendererWidget::mRendererSettingsButton_clicked()
QgsSymbolWidgetContext context = mContext;
context.setAdditionalExpressionContextScopes( scopes );
w->setContext( context );
w->disableSymbolLevels();
connect( w, &QgsPanelWidget::widgetChanged, this, &QgsPointClusterRendererWidget::updateRendererFromWidget );
w->setDockMode( this->dockMode() );
openPanel( w );
@@ -278,6 +278,7 @@ void QgsPointDisplacementRendererWidget::mRendererSettingsButton_clicked()
QList< QgsExpressionContextScope > scopes = context.additionalExpressionContextScopes();
scopes << scope;
context.setAdditionalExpressionContextScopes( scopes );
w->disableSymbolLevels();
w->setContext( context );

connect( w, &QgsPanelWidget::widgetChanged, this, &QgsPointDisplacementRendererWidget::updateRendererFromWidget );
@@ -364,6 +364,10 @@ void QgsRendererWidget::setDockMode( bool dockMode )
QgsPanelWidget::setDockMode( dockMode );
}

void QgsRendererWidget::disableSymbolLevels()
{
}

QgsDataDefinedSizeLegendWidget *QgsRendererWidget::createDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend )
{
QgsProperty ddSize = symbol->dataDefinedSize();
@@ -82,6 +82,14 @@ class GUI_EXPORT QgsRendererWidget : public QgsPanelWidget

void setDockMode( bool dockMode ) override;

/**
* Disables symbol level modification on the widget.
*
* \note Not available in Python bindings
* \since QGIS 3.20
*/
virtual void disableSymbolLevels() SIP_SKIP;

signals:

/**
@@ -66,7 +66,7 @@ QgsSingleSymbolRendererWidget::QgsSingleSymbolRendererWidget( QgsVectorLayer *la
// advanced actions - data defined rendering
QMenu *advMenu = mSelector->advancedMenu();

QAction *actionLevels = advMenu->addAction( tr( "Symbol Levels…" ) );
mActionLevels = advMenu->addAction( tr( "Symbol Levels…" ) );
connect( actionLevels, &QAction::triggered, this, &QgsSingleSymbolRendererWidget::showSymbolLevels );
if ( mSingleSymbol && mSingleSymbol->type() == QgsSymbol::Marker )
{
@@ -102,6 +102,12 @@ void QgsSingleSymbolRendererWidget::setDockMode( bool dockMode )
mSelector->setDockMode( dockMode );
}

void QgsSingleSymbolRendererWidget::disableSymbolLevels()
{
delete mActionLevels;
mActionLevels = nullptr;
}

void QgsSingleSymbolRendererWidget::setSymbolLevels( const QList<QgsLegendSymbolItem> &levels, bool enabled )
{
mSingleSymbol.reset( levels.at( 0 ).symbol()->clone() );
@@ -41,13 +41,8 @@ class GUI_EXPORT QgsSingleSymbolRendererWidget : public QgsRendererWidget
QgsFeatureRenderer *renderer() override;

void setContext( const QgsSymbolWidgetContext &context ) override;

/**
* Set the widget in dock mode which tells the widget to emit panel
* widgets and not open dialogs
* \param dockMode TRUE to enable dock mode.
*/
void setDockMode( bool dockMode ) override;
void disableSymbolLevels() override SIP_SKIP;

protected:
void setSymbolLevels( const QList< QgsLegendSymbolItem > &levels, bool enabled ) override;
@@ -64,6 +59,7 @@ class GUI_EXPORT QgsSingleSymbolRendererWidget : public QgsRendererWidget
std::unique_ptr< QgsSingleSymbolRenderer > mRenderer;
QgsSymbolSelectorWidget *mSelector = nullptr;
std::unique_ptr< QgsSymbol > mSingleSymbol;
QAction *mActionLevels = nullptr;
};


0 comments on commit c57b51b

Please sign in to comment.