Skip to content
Permalink
Browse files

Remove last deprecated methods from symbology

  • Loading branch information
nyalldawson committed Sep 13, 2016
1 parent 4d4aec6 commit ae9023fe0f2a18965421865fecd8c513214b5fd3
@@ -941,6 +941,10 @@ parameters or QgsSymbol::OutputUnitList parameters now take QgsUnitTypes::Render
<ul>
<li>The deprecated prepareExpressions( const QgsFields* fields, double scale = -1.0 ) method has been removed. Use
the variant which takes QgsSymbolRenderContext instead.</li>
<li>The deprecated methods dataDefinedProperty( const QString& property ) and dataDefinedPropertyString() were removed. Use getDataDefinedProperty() instead.</li>
<li>setDataDefinedProperty( const QString& property, const QString& expressionString ) was removed. Use setDataDefinedProperty( const QString& property, QgsDataDefined* dataDefined ) instead.</li>
<li>evaluateDataDefinedProperty( const QString& property, const QgsFeature* feature ) was removed. Use the variant which takes QgsSymbolRenderContext instead.</li>
<li>expression() was removed. Use getDataDefinedProperty or evaluateDataDefinedProperty instead.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolRenderContext QgsSymbolRenderContext (renamed from QgsSymbolV2RenderContext)
@@ -957,6 +961,18 @@ the variant which takes QgsSymbolRenderContext instead.</li>
<li>The signatures for wellKnownMarkerToSld() and wellKnownMarkerFromSld() were changed.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolSelectorDialog QgsSymbolSelectorDialog

<ul>
<li>saveSymbol() was removed.</li>
</ul>

\subsection qgis_api_break_3_0_QgsSymbolSelectorWidget QgsSymbolSelectorWidget

<ul>
<li>saveSymbol() was removed.</li>
</ul>

\subsection qgis_api_break_3_0_QgsTolerance QgsTolerance

<ul>
@@ -172,21 +172,6 @@ class QgsSymbolLayer
*/
virtual QSet<QString> usedAttributes() const;

/** Returns a data defined expression for a property, if set
* @deprecated use getDataDefinedProperty instead
*/
virtual const QgsExpression* dataDefinedProperty( const QString& property ) const /Deprecated/;

/** Returns a data defined expression for a property, if set
* @deprecated use getDataDefinedProperty instead
*/
virtual QString dataDefinedPropertyString( const QString& property ) const /Deprecated/;

/** Sets a data defined expression for a property
* @deprecated use setDataDefinedProperty( const QString& property, QgsDataDefined* dataDefined ) instead
*/
virtual void setDataDefinedProperty( const QString& property, const QString& expressionString ) /Deprecated/;

/** Returns the data defined property corresponding to the specified property key
* @param property property key
* @returns matching data defined property if it exists
@@ -239,23 +224,6 @@ class QgsSymbolLayer
*/
virtual bool hasDataDefinedProperty( const QString& property ) const;

/** Evaluates the matching data defined property and returns the calculated
* value. Prior to evaluation the data defined property must be prepared
* by calling @link prepareExpressions @endlink.
* @param property property key
* @param feature pointer to the feature to use during expression or field
* evaluation
* @param defaultVal default value to return if evaluation was not successful
* @param ok if specified, will be set to true if evaluation was successful
* @returns calculated value for data defined property, or default value
* if property does not exist or is deactived.
* @see hasDataDefinedProperty
* @see getDataDefinedProperty
* @note added in QGIS 2.9
* @deprecated use variant which takes QgsSymbolRenderContext instead
*/
virtual QVariant evaluateDataDefinedProperty( const QString& property, const QgsFeature* feature ) const /Deprecated/;

/** Evaluates the matching data defined property and returns the calculated
* value. Prior to evaluation the data defined property must be prepared
* by calling @link prepareExpressions @endlink.
@@ -308,11 +276,6 @@ class QgsSymbolLayer
*/
virtual void prepareExpressions( const QgsSymbolRenderContext& context );

/** Returns the data defined expression associated with a property
* @deprecated use getDataDefinedProperty or evaluateDataDefinedProperty instead
*/
virtual QgsExpression* expression( const QString& property ) const /Deprecated/;

/** Saves all data defined properties to a string map.
* @param stringMap destination string map
* @see restoreDataDefinedProperties
@@ -72,8 +72,6 @@ class QgsSymbolSelectorWidget : QgsPanelWidget

void lockLayer();

void saveSymbol() /Deprecated/;

//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
//! @note added in QGIS 2.14
void duplicateLayer();
@@ -159,8 +157,6 @@ class QgsSymbolSelectorDialog : QDialog

void lockLayer();

void saveSymbol() /Deprecated/;

//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
//! @note added in QGIS 2.14
void duplicateLayer();
@@ -90,13 +90,6 @@ const QString QgsSymbolLayer::EXPR_OFFSET_ALONG_LINE( "offset_along_line" );
const QString QgsSymbolLayer::EXPR_HORIZONTAL_ANCHOR_POINT( "horizontal_anchor_point" );
const QString QgsSymbolLayer::EXPR_VERTICAL_ANCHOR_POINT( "vertical_anchor_point" );

const QgsExpression* QgsSymbolLayer::dataDefinedProperty( const QString& property ) const
{
Q_NOWARN_DEPRECATED_PUSH
return expression( property );
Q_NOWARN_DEPRECATED_POP
}

QgsDataDefined *QgsSymbolLayer::getDataDefinedProperty( const QString &property ) const
{
if ( mDataDefinedProperties.isEmpty() )
@@ -110,23 +103,6 @@ QgsDataDefined *QgsSymbolLayer::getDataDefinedProperty( const QString &property
return nullptr;
}

QgsExpression* QgsSymbolLayer::expression( const QString& property ) const
{
QgsDataDefined* dd = getDataDefinedProperty( property );
return dd ? dd->expression() : nullptr;
}

QString QgsSymbolLayer::dataDefinedPropertyString( const QString& property ) const
{
const QgsDataDefined* dd = getDataDefinedProperty( property );
return dd ? dd->expressionString() : QString();
}

void QgsSymbolLayer::setDataDefinedProperty( const QString& property, const QString& expressionString )
{
setDataDefinedProperty( property, new QgsDataDefined( expressionString ) );
}

void QgsSymbolLayer::setDataDefinedProperty( const QString &property, QgsDataDefined *dataDefined )
{
removeDataDefinedProperty( property );
@@ -173,48 +149,6 @@ bool QgsSymbolLayer::hasDataDefinedProperty( const QString& property ) const
return dd && dd->isActive();
}

QVariant QgsSymbolLayer::evaluateDataDefinedProperty( const QString &property, const QgsFeature* feature, const QVariant& defaultVal, bool *ok ) const
{
if ( ok )
*ok = false;

QgsDataDefined* dd = getDataDefinedProperty( property );
if ( !dd || !dd->isActive() )
return defaultVal;

if ( dd->useExpression() )
{
if ( dd->expression() )
{
QgsExpressionContext context = feature ? QgsExpressionContextUtils::createFeatureBasedContext( *feature, QgsFields() ) : QgsExpressionContext();
QVariant result = dd->expression()->evaluate( &context );
if ( result.isValid() )
{
if ( ok )
*ok = true;
return result;
}
else
return defaultVal;
}
else
{
return defaultVal;
}
}
else if ( feature && !dd->field().isEmpty() && !mFields.isEmpty() )
{
int attributeIndex = mFields.fieldNameIndex( dd->field() );
if ( attributeIndex >= 0 )
{
if ( ok )
*ok = true;
return feature->attribute( attributeIndex );
}
}
return defaultVal;
}

QVariant QgsSymbolLayer::evaluateDataDefinedProperty( const QString& property, const QgsSymbolRenderContext& context, const QVariant& defaultVal, bool* ok ) const
{
if ( ok )
@@ -154,21 +154,6 @@ class CORE_EXPORT QgsSymbolLayer
*/
virtual QSet<QString> usedAttributes() const;

/** Returns a data defined expression for a property, if set
* @deprecated use getDataDefinedProperty instead
*/
Q_DECL_DEPRECATED virtual const QgsExpression* dataDefinedProperty( const QString& property ) const;

/** Returns a data defined expression for a property, if set
* @deprecated use getDataDefinedProperty instead
*/
Q_DECL_DEPRECATED virtual QString dataDefinedPropertyString( const QString& property ) const;

/** Sets a data defined expression for a property
* @deprecated use setDataDefinedProperty( const QString& property, QgsDataDefined* dataDefined ) instead
*/
Q_DECL_DEPRECATED virtual void setDataDefinedProperty( const QString& property, const QString& expressionString );

/** Returns the data defined property corresponding to the specified property key
* @param property property key
* @returns matching data defined property if it exists
@@ -221,23 +206,6 @@ class CORE_EXPORT QgsSymbolLayer
*/
virtual bool hasDataDefinedProperty( const QString& property ) const;

/** Evaluates the matching data defined property and returns the calculated
* value. Prior to evaluation the data defined property must be prepared
* by calling @link prepareExpressions @endlink.
* @param property property key
* @param feature pointer to the feature to use during expression or field
* evaluation
* @param defaultVal default value to return if evaluation was not successful
* @param ok if specified, will be set to true if evaluation was successful
* @returns calculated value for data defined property, or default value
* if property does not exist or is deactived.
* @see hasDataDefinedProperty
* @see getDataDefinedProperty
* @note added in QGIS 2.9
* @deprecated use variant which takes QgsSymbolRenderContext instead
*/
Q_DECL_DEPRECATED virtual QVariant evaluateDataDefinedProperty( const QString& property, const QgsFeature* feature, const QVariant& defaultVal = QVariant(), bool *ok = nullptr ) const;

/** Evaluates the matching data defined property and returns the calculated
* value. Prior to evaluation the data defined property must be prepared
* by calling @link prepareExpressions @endlink.
@@ -318,11 +286,6 @@ class CORE_EXPORT QgsSymbolLayer
*/
virtual void prepareExpressions( const QgsSymbolRenderContext& context );

/** Returns the data defined expression associated with a property
* @deprecated use getDataDefinedProperty or evaluateDataDefinedProperty instead
*/
Q_DECL_DEPRECATED virtual QgsExpression* expression( const QString& property ) const;

/** Saves all data defined properties to a string map.
* @param stringMap destination string map
* @see restoreDataDefinedProperties
@@ -139,29 +139,6 @@ void QgsSymbolLayerWidget::updateDataDefinedProperty()
emit changed();
}

QString QgsSymbolLayerWidget::dataDefinedPropertyLabel( const QString &entryName )
{
QString label = entryName;
if ( entryName == "size" )
{
label = tr( "Size" );
QgsMarkerSymbolLayer * layer = dynamic_cast<QgsMarkerSymbolLayer *>( symbolLayer() );
if ( layer )
{
switch ( layer->scaleMethod() )
{
case QgsSymbol::ScaleArea:
label += " (" + tr( "area" ) + ')';
break;
case QgsSymbol::ScaleDiameter:
label += " (" + tr( "diameter" ) + ')';
break;
}
}
}
return label;
}

QgsSimpleLineSymbolLayerWidget::QgsSimpleLineSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerWidget( parent, vl )
{
@@ -97,13 +97,6 @@ class GUI_EXPORT QgsSymbolLayerWidget : public QWidget, protected QgsExpressionC

QgsMapCanvas* mMapCanvas;

/** Get label for data defined entry.
* Implemented only for 'size' of marker symbols
* @note added in 2.1
* @deprecated no longer used
*/
Q_DECL_DEPRECATED virtual QString dataDefinedPropertyLabel( const QString &entryName );

signals:
/**
* Should be emitted whenever configuration changes happened on this symbol layer configuration.
@@ -641,34 +641,6 @@ void QgsSymbolSelectorWidget::duplicateLayer()
updatePreview();
}

void QgsSymbolSelectorWidget::saveSymbol()
{
bool ok;
QString name = QInputDialog::getText( this, tr( "Symbol name" ),
tr( "Please enter name for the symbol:" ), QLineEdit::Normal, tr( "New symbol" ), &ok );
if ( !ok || name.isEmpty() )
return;

// check if there is no symbol with same name
if ( mStyle->symbolNames().contains( name ) )
{
int res = QMessageBox::warning( this, tr( "Save symbol" ),
tr( "Symbol with name '%1' already exists. Overwrite?" )
.arg( name ),
QMessageBox::Yes | QMessageBox::No );
if ( res != QMessageBox::Yes )
{
return;
}
}

// add new symbol to style and re-populate the list
mStyle->addSymbol( name, mSymbol->clone() );

// make sure the symbol is stored
mStyle->saveSymbol( name, mSymbol->clone(), 0, QStringList() );
}

void QgsSymbolSelectorWidget::changeLayer( QgsSymbolLayer* newLayer )
{
SymbolLayerItem* item = currentLayerItem();
@@ -832,13 +804,6 @@ void QgsSymbolSelectorDialog::lockLayer()
mSelectorWidget->lockLayer();
}

void QgsSymbolSelectorDialog::saveSymbol()
{
Q_NOWARN_DEPRECATED_PUSH
mSelectorWidget->saveSymbol();
Q_NOWARN_DEPRECATED_POP
}

void QgsSymbolSelectorDialog::duplicateLayer()
{
mSelectorWidget->duplicateLayer();
@@ -206,11 +206,6 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs
*/
void lockLayer();

/**
* Save the current active symbol layer into the users saved styles.
*/
Q_DECL_DEPRECATED void saveSymbol();

//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
//! @note added in QGIS 2.14
void duplicateLayer();
@@ -330,8 +325,6 @@ class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog

void lockLayer();

Q_DECL_DEPRECATED void saveSymbol();

//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
//! @note added in QGIS 2.14
void duplicateLayer();

0 comments on commit ae9023f

Please sign in to comment.
You can’t perform that action at this time.