Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor symbol/renderer widgets to use QgsSymbolWidgetContext
instead of individually setting map canvas, expression context, etc

Will make it more easy in future to add additional parameters
to the widget context
  • Loading branch information
nyalldawson committed Sep 29, 2016
1 parent fbdc93f commit fd0c5ef
Show file tree
Hide file tree
Showing 48 changed files with 643 additions and 613 deletions.
41 changes: 41 additions & 0 deletions doc/api_break.dox
Expand Up @@ -850,6 +850,12 @@ plugins calling this method will need to be updated.</li>
<li>labelsWithinRect() was removed. Use takeResults() and methods of QgsLabelingResults.</li>
</ul>

\subsection qgis_api_break_3_0_QgsLayerPropertiesWidget QgsLayerPropertiesWidget

<ul>
<li>expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()</li>
</ul>

\subsection qgis_api_break_3_0_QgsLayerTreeGroup QgsLayerTreeGroup

<ul>
Expand Down Expand Up @@ -1176,6 +1182,20 @@ be returned instead of a null pointer if no transformation is required.</li>
<li>setCoordinateTransform() now takes a QgsCoordinateTransform reference, not a pointer. An invalid QgsCoordinateTransform should be used instead of a null pointer if no transformation is required.</li>
</ul>

\subsection qgis_api_break_3_0_QgsRendererWidget QgsRendererWidget

<ul>
<li>expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()</li>
</ul>

\subsection qgis_api_break_3_0_QgsRendererRulePropsWidget QgsRendererRulePropsWidget

<ul>
<li>expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()</li>
</ul>



\subsection qgis_api_break_3_0_QgsRubberBand QgsRubberBand

<ul>
Expand Down Expand Up @@ -1263,6 +1283,13 @@ the variant which takes QgsSymbolRenderContext instead.</li>
<li>expression() was removed. Use getDataDefinedProperty or evaluateDataDefinedProperty instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolLayerWidget QgsSymbolLayerWidget

<ul>
<li>expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()</li>
</ul>


\subsection qgis_api_break_3_0_QgsSymbolRenderContext QgsSymbolRenderContext (renamed from QgsSymbolV2RenderContext)

<ul>
Expand Down Expand Up @@ -1291,6 +1318,20 @@ than an integer value</li>
<li>saveSymbol() was removed.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolSelectorDialog QgsSymbolSelectorDialog

<ul>
<li>expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolsListWidget QgsSymbolsListWidget

<ul>
<li>expressionContext(), setExpressionContext(), setMapCanvas() and mapCanvas() have been removed in favor of setContext()/context()</li>
</ul>



\subsection qgis_api_break_3_0_QgsTolerance QgsTolerance

<ul>
Expand Down
1 change: 1 addition & 0 deletions python/gui/gui.sip
Expand Up @@ -249,6 +249,7 @@
%Include symbology-ng/qgssymbollevelsdialog.sip
%Include symbology-ng/qgssymbolslistwidget.sip
%Include symbology-ng/qgssymbolselectordialog.sip
%Include symbology-ng/qgssymbolwidgetcontext.sip
%Include symbology-ng/qgsvectorfieldsymbollayerwidget.sip

%Include effects/qgseffectdrawmodecombobox.sip
Expand Down
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgsheatmaprendererwidget.sip
Expand Up @@ -21,5 +21,5 @@ class QgsHeatmapRendererWidget : QgsRendererWidget
/** @returns the current feature renderer */
virtual QgsFeatureRenderer* renderer();

void setMapCanvas( QgsMapCanvas* canvas );
virtual void setContext( const QgsSymbolWidgetContext& context );
};
Expand Up @@ -20,5 +20,5 @@ class QgsInvertedPolygonRendererWidget : QgsRendererWidget

/** @returns the current feature renderer */
virtual QgsFeatureRenderer* renderer();
void setMapCanvas( QgsMapCanvas* canvas );
virtual void setContext( const QgsSymbolWidgetContext& context );
};
35 changes: 8 additions & 27 deletions python/gui/symbology-ng/qgslayerpropertieswidget.sip
Expand Up @@ -7,43 +7,24 @@ class QgsLayerPropertiesWidget : QgsPanelWidget
public:
QgsLayerPropertiesWidget( QgsSymbolLayer* layer, const QgsSymbol* symbol, const QgsVectorLayer* vl, QWidget* parent /TransferThis/ = NULL );

/** Returns the expression context used for the widget, if set. This expression context is used for
* evaluating data defined symbol properties and for populating based expression widgets in
* the properties widget.
* @note added in QGIS 2.12
* @see setExpressionContext()
/** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @param context symbol widget context
* @see context()
* @note added in QGIS 3.0
*/
QgsExpressionContext* expressionContext() const;
void setContext( const QgsSymbolWidgetContext& context );

/** Sets a list of additional expression context scopes to show as available within the layer.
* @param scopes list of additional scopes which will be added in order to the end of the default expression context
/** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @see setContext()
* @note added in QGIS 3.0
* @see setExpressionContext()
*/
void setAdditionalExpressionContextScopes( const QList< QgsExpressionContextScope >& scopes );
QgsSymbolWidgetContext context() const;

/** Sets the map canvas associated with the widget. This allows the widget to retrieve the current
* map scale and other properties from the canvas.
* @param canvas map canvas
* @note added in QGIS 2.12
*/
virtual void setMapCanvas( QgsMapCanvas* canvas );

public slots:
void layerTypeChanged();
void emitSignalChanged();

/** Sets the optional expression context used for the widget. This expression context is used for
* evaluating data defined symbol properties and for populating based expression widgets in
* the properties widget.
* @param context expression context pointer. Ownership is not transferred and the object must
* be kept alive for the lifetime of the properties widget.
* @note added in QGIS 2.12
* @see expressionContext()
* @see setAdditionalExpressionContextScopes()
*/
void setExpressionContext( QgsExpressionContext* context );

signals:
void changed();
void changeLayer( QgsSymbolLayer* );
Expand Down
Expand Up @@ -9,5 +9,5 @@ class QgsPointDisplacementRendererWidget: QgsRendererWidget
~QgsPointDisplacementRendererWidget();

QgsFeatureRenderer* renderer();
void setMapCanvas( QgsMapCanvas* canvas );
void setContext( const QgsSymbolWidgetContext& context );
};
48 changes: 17 additions & 31 deletions python/gui/symbology-ng/qgsrendererwidget.sip
Expand Up @@ -15,25 +15,18 @@ class QgsRendererWidget : QgsPanelWidget
//! show a dialog with renderer's symbol level settings
void showSymbolLevelsDialog( QgsFeatureRenderer* r );

/** Sets the map canvas associated with the widget. This allows the widget to retrieve the current
* map scale and other properties from the canvas.
* @param canvas map canvas
* @see mapCanvas()
* @note added in QGIS 2.12
*/
virtual void setMapCanvas( QgsMapCanvas* canvas );

/** Returns the map canvas associated with the widget.
* @see setMapCanvas
* @note added in QGIS 2.12
/** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @param context symbol widget context
* @see context()
* @note added in QGIS 3.0
*/
const QgsMapCanvas* mapCanvas() const;
void setContext( const QgsSymbolWidgetContext& context );

/** Sets a list of additional expression context scopes to show as available within the renderer.
* @param scopes list of additional scopes which will be added in order to the end of the default expression context
/** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @see setContext()
* @note added in QGIS 3.0
*/
void setAdditionalExpressionContextScopes( const QList< QgsExpressionContextScope >& scopes );
QgsSymbolWidgetContext context() const;

/** Returns the vector layer associated with the widget.
* @note added in QGIS 2.12
Expand Down Expand Up @@ -105,31 +98,24 @@ class QgsDataDefinedValueDialog : QDialog
QgsDataDefinedValueDialog( const QList<QgsSymbol*>& symbolList, QgsVectorLayer * layer, const QString & label );
virtual ~QgsDataDefinedValueDialog();

/** Sets the map canvas associated with the dialog. This allows the dialog to retrieve the current
* map scale and other properties from the canvas.
* @param canvas map canvas
* @see mapCanvas()
* @note added in QGIS 2.12
/** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @param context symbol widget context
* @see context()
* @note added in QGIS 3.0
*/
virtual void setMapCanvas( QgsMapCanvas* canvas );
void setContext( const QgsSymbolWidgetContext& context );

/** Returns the map canvas associated with the widget.
* @see setMapCanvas
* @note added in QGIS 2.12
/** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @see setContext()
* @note added in QGIS 3.0
*/
const QgsMapCanvas* mapCanvas() const;
QgsSymbolWidgetContext context() const;

/** Returns the vector layer associated with the widget.
* @note added in QGIS 2.12
*/
const QgsVectorLayer* vectorLayer() const;

/** Sets a list of additional expression context scopes to show as available for the symbol.
* @param scopes list of additional scopes which will be added in order to the end of the default expression context
* @note added in QGIS 3.0
*/
void setAdditionalExpressionContextScopes( const QList< QgsExpressionContextScope >& scopes );

public slots:
void dataDefinedChanged();

Expand Down
13 changes: 11 additions & 2 deletions python/gui/symbology-ng/qgsrulebasedrendererwidget.sip
Expand Up @@ -109,7 +109,15 @@ class QgsRendererRulePropsWidget: QgsPanelWidget
%End

public:
QgsRendererRulePropsWidget( QgsRuleBasedRenderer::Rule* rule, QgsVectorLayer* layer, QgsStyle* style, QWidget* parent /TransferThis/ = 0, QgsMapCanvas* mapCanvas = 0 );
/**
* Widget to edit the details of a rule based renderer rule.
* @param rule The rule to edit.
* @param layer The layer used to pull layer related information.
* @param style The active QGIS style.
* @param parent The parent widget.
* @param context the symbol widget context
*/
QgsRendererRulePropsWidget( QgsRuleBasedRenderer::Rule* rule, QgsVectorLayer* layer, QgsStyle* style, QWidget* parent /TransferThis/ = 0, const QgsSymbolWidgetContext& context= QgsSymbolWidgetContext() );
~QgsRendererRulePropsWidget();

QgsRuleBasedRenderer::Rule* rule();
Expand All @@ -129,7 +137,8 @@ class QgsRendererRulePropsDialog : QDialog
%End

public:
QgsRendererRulePropsDialog( QgsRuleBasedRenderer::Rule* rule, QgsVectorLayer* layer, QgsStyle* style, QWidget* parent /TransferThis/ = 0, QgsMapCanvas* mapCanvas = 0 );

QgsRendererRulePropsDialog( QgsRuleBasedRenderer::Rule* rule, QgsVectorLayer* layer, QgsStyle* style, QWidget* parent /TransferThis/ = 0, const QgsSymbolWidgetContext& context = QgsSymbolWidgetContext() );
~QgsRendererRulePropsDialog();

QgsRuleBasedRenderer::Rule* rule();
Expand Down
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgssinglesymbolrendererwidget.sip
Expand Up @@ -11,7 +11,7 @@ class QgsSingleSymbolRendererWidget : QgsRendererWidget

virtual QgsFeatureRenderer* renderer();

virtual void setMapCanvas( QgsMapCanvas* canvas );
virtual void setContext( const QgsSymbolWidgetContext& context );

virtual void setDockMode( bool dockMode );

Expand Down
45 changes: 8 additions & 37 deletions python/gui/symbology-ng/qgssymbollayerwidget.sip
Expand Up @@ -11,53 +11,24 @@ class QgsSymbolLayerWidget : QWidget
virtual void setSymbolLayer( QgsSymbolLayer* layer ) = 0;
virtual QgsSymbolLayer* symbolLayer() = 0;

/** Returns the expression context used for the widget, if set. This expression context is used for
* evaluating data defined symbol properties and for populating based expression widgets in
* the layer widget.
* @note added in QGIS 2.12
* @see setExpressionContext()
*/
QgsExpressionContext* expressionContext() const;

/** Sets a list of additional expression context scopes to show as available within the layer.
* @param scopes list of additional scopes which will be added in order to the end of the default expression context
/** Sets the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @param context symbol widget context
* @see context()
* @note added in QGIS 3.0
* @see setExpressionContext()
*/
void setAdditionalExpressionContextScopes( const QList< QgsExpressionContextScope >& scopes );
void setContext( const QgsSymbolWidgetContext& context );

/** Sets the map canvas associated with the widget. This allows the widget to retrieve the current
* map scale and other properties from the canvas.
* @param canvas map canvas
* @see mapCanvas()
* @note added in QGIS 2.12
*/
virtual void setMapCanvas( QgsMapCanvas* canvas );

/** Returns the map canvas associated with the widget.
* @see setMapCanvas
* @note added in QGIS 2.12
/** Returns the context in which the symbol widget is shown, eg the associated map canvas and expression contexts.
* @see setContext()
* @note added in QGIS 3.0
*/
const QgsMapCanvas* mapCanvas() const;
QgsSymbolWidgetContext context() const;

/** Returns the vector layer associated with the widget.
* @note added in QGIS 2.12
*/
const QgsVectorLayer* vectorLayer() const;

public slots:

/** Sets the optional expression context used for the widget. This expression context is used for
* evaluating data defined symbol properties and for populating based expression widgets in
* the layer widget.
* @param context expression context pointer. Ownership is not transferred and the object must
* be kept alive for the lifetime of the layer widget.
* @note added in QGIS 2.12
* @see expressionContext()
* @see setAdditionalExpressionContextScopes()
*/
void setExpressionContext( QgsExpressionContext* context );

protected:
void registerDataDefinedButton( QgsDataDefinedButton* button, const QString& propertyName, QgsDataDefinedButton::DataType type, const QString& description );

Expand Down

0 comments on commit fd0c5ef

Please sign in to comment.