Skip to content
Permalink
Browse files
changed std::auto_ptr for QScopedPointer
  • Loading branch information
vmora committed Jan 14, 2014
1 parent 7d404d9 commit e8205c9
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 116 deletions.
@@ -41,7 +41,7 @@ QgsRendererCategoryV2::QgsRendererCategoryV2( QVariant value, QgsSymbolV2* symbo

QgsRendererCategoryV2::QgsRendererCategoryV2( const QgsRendererCategoryV2& cat )
: mValue( cat.mValue )
, mSymbol( cat.mSymbol.get() ? cat.mSymbol->clone() : NULL )
, mSymbol( cat.mSymbol.data() ? cat.mSymbol->clone() : NULL )
, mLabel( cat.mLabel )
{
}
@@ -67,7 +67,7 @@ QVariant QgsRendererCategoryV2::value() const

QgsSymbolV2* QgsRendererCategoryV2::symbol() const
{
return mSymbol.get();
return mSymbol.data();
}

QString QgsRendererCategoryV2::label() const
@@ -82,7 +82,7 @@ void QgsRendererCategoryV2::setValue( const QVariant &value )

void QgsRendererCategoryV2::setSymbol( QgsSymbolV2* s )
{
if ( mSymbol.get() != s ) mSymbol.reset( s );
if ( mSymbol.data() != s ) mSymbol.reset( s );
}

void QgsRendererCategoryV2::setLabel( const QString &label )
@@ -97,7 +97,7 @@ QString QgsRendererCategoryV2::dump() const

void QgsRendererCategoryV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
{
if ( !mSymbol.get() || props.value( "attribute", "" ).isEmpty() )
if ( !mSymbol.data() || props.value( "attribute", "" ).isEmpty() )
return;

QString attrName = props[ "attribute" ];
@@ -187,7 +187,7 @@ QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& featu
QVariant value;
if ( mAttrNum == -1 )
{
Q_ASSERT( mExpression.get() );
Q_ASSERT( mExpression.data() );
value = mExpression->evaluate( &feature );
}
else
@@ -203,12 +203,12 @@ QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& featu
return symbolForValue( QVariant( "" ) );
}

if ( !mRotation.get() && !mSizeScale.get() )
if ( !mRotation.data() && !mSizeScale.data() )
return symbol; // no data-defined rotation/scaling - just return the symbol

// find out rotation, size scale
const double rotation = mRotation.get() ? mRotation->evaluate( feature ).toDouble() : 0;
const double sizeScale = mSizeScale.get() ? mSizeScale->evaluate( feature ).toDouble() : 1.;
const double rotation = mRotation.data() ? mRotation->evaluate( feature ).toDouble() : 0;
const double sizeScale = mSizeScale.data() ? mSizeScale->evaluate( feature ).toDouble() : 1.;

// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[attrs[mAttrNum].toString()];
@@ -357,11 +357,11 @@ void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, con
{
it->symbol()->startRender( context, vlayer );

if ( mRotation.get() || mSizeScale.get() )
if ( mRotation.data() || mSizeScale.data() )
{
QgsSymbolV2* tempSymbol = it->symbol()->clone();
tempSymbol->setRenderHints(( mRotation.get() ? QgsSymbolV2::DataDefinedRotation : 0 ) |
( mSizeScale.get() ? QgsSymbolV2::DataDefinedSizeScale : 0 ) );
tempSymbol->setRenderHints(( mRotation.data() ? QgsSymbolV2::DataDefinedRotation : 0 ) |
( mSizeScale.data() ? QgsSymbolV2::DataDefinedSizeScale : 0 ) );
tempSymbol->startRender( context, vlayer );
mTempSymbols[ it->value().toString()] = tempSymbol;
}
@@ -390,8 +390,8 @@ QList<QString> QgsCategorizedSymbolRendererV2::usedAttributes()
{
QgsExpression exp( mAttrName );
QSet<QString> attributes( exp.referencedColumns().toSet() );
if ( mRotation.get() ) attributes.unite( mRotation->referencedColumns().toSet() );
if ( mSizeScale.get() ) attributes.unite( mSizeScale->referencedColumns().toSet() );
if ( mRotation.data() ) attributes.unite( mRotation->referencedColumns().toSet() );
if ( mSizeScale.data() ) attributes.unite( mSizeScale->referencedColumns().toSet() );

QgsCategoryList::const_iterator catIt = mCategories.constBegin();
for ( ; catIt != mCategories.constEnd(); ++catIt )
@@ -416,9 +416,9 @@ QString QgsCategorizedSymbolRendererV2::dump() const
QgsFeatureRendererV2* QgsCategorizedSymbolRendererV2::clone()
{
QgsCategorizedSymbolRendererV2* r = new QgsCategorizedSymbolRendererV2( mAttrName, mCategories );
if ( mSourceSymbol.get() )
if ( mSourceSymbol.data() )
r->setSourceSymbol( mSourceSymbol->clone() );
if ( mSourceColorRamp.get() )
if ( mSourceColorRamp.data() )
{
r->setSourceColorRamp( mSourceColorRamp->clone() );
r->setInvertedColorRamp( mInvertedColorRamp );
@@ -434,9 +434,9 @@ void QgsCategorizedSymbolRendererV2::toSld( QDomDocument &doc, QDomElement &elem
{
QgsStringMap props;
props[ "attribute" ] = mAttrName;
if ( !mRotation.get() )
if ( !mRotation.data() )
props[ "angle" ] = qgsXmlEncode( mRotation->expression() ).append( "\"" ).prepend( "\"" );
if ( !mSizeScale.get() )
if ( !mSizeScale.data() )
props[ "scale" ] = qgsXmlEncode( mSizeScale->expression() ).append( "\"" ).prepend( "\"" );

// create a Rule for each range
@@ -562,31 +562,31 @@ QDomElement QgsCategorizedSymbolRendererV2::save( QDomDocument& doc )
rendererElem.appendChild( symbolsElem );

// save source symbol
if ( mSourceSymbol.get() )
if ( mSourceSymbol.data() )
{
QgsSymbolV2Map sourceSymbols;
sourceSymbols.insert( "0", mSourceSymbol.get() );
sourceSymbols.insert( "0", mSourceSymbol.data() );
QDomElement sourceSymbolElem = QgsSymbolLayerV2Utils::saveSymbols( sourceSymbols, "source-symbol", doc );
rendererElem.appendChild( sourceSymbolElem );
}

// save source color ramp
if ( mSourceColorRamp.get() )
if ( mSourceColorRamp.data() )
{
QDomElement colorRampElem = QgsSymbolLayerV2Utils::saveColorRamp( "[source]", mSourceColorRamp.get(), doc );
QDomElement colorRampElem = QgsSymbolLayerV2Utils::saveColorRamp( "[source]", mSourceColorRamp.data(), doc );
rendererElem.appendChild( colorRampElem );
QDomElement invertedElem = doc.createElement( "invertedcolorramp" );
invertedElem.setAttribute( "value", mInvertedColorRamp );
rendererElem.appendChild( invertedElem );
}

QDomElement rotationElem = doc.createElement( "rotation" );
if ( mRotation.get() )
if ( mRotation.data() )
rotationElem.setAttribute( "field", qgsXmlEncode( mRotation->expression() ) );
rendererElem.appendChild( rotationElem );

QDomElement sizeScaleElem = doc.createElement( "sizescale" );
if ( mSizeScale.get() )
if ( mSizeScale.data() )
sizeScaleElem.setAttribute( "field", qgsXmlEncode( mSizeScale->expression() ) );
sizeScaleElem.setAttribute( "scalemethod", QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod ) );
rendererElem.appendChild( sizeScaleElem );
@@ -640,7 +640,7 @@ QgsLegendSymbolList QgsCategorizedSymbolRendererV2::legendSymbolItems( double sc

QgsSymbolV2* QgsCategorizedSymbolRendererV2::sourceSymbol()
{
return mSourceSymbol.get();
return mSourceSymbol.data();
}
void QgsCategorizedSymbolRendererV2::setSourceSymbol( QgsSymbolV2* sym )
{
@@ -649,7 +649,7 @@ void QgsCategorizedSymbolRendererV2::setSourceSymbol( QgsSymbolV2* sym )

QgsVectorColorRampV2* QgsCategorizedSymbolRendererV2::sourceColorRamp()
{
return mSourceColorRamp.get();
return mSourceColorRamp.data();
}
void QgsCategorizedSymbolRendererV2::setSourceColorRamp( QgsVectorColorRampV2* ramp )
{
@@ -20,7 +20,7 @@
#include "qgsexpression.h"

#include <QHash>
#include <memory>
#include <QScopedPointer>

class QgsVectorColorRampV2;
class QgsVectorLayer;
@@ -54,7 +54,7 @@ class CORE_EXPORT QgsRendererCategoryV2

protected:
QVariant mValue;
std::auto_ptr<QgsSymbolV2> mSymbol;
QScopedPointer<QgsSymbolV2> mSymbol;
QString mLabel;

void swap( QgsRendererCategoryV2 & other );
@@ -141,19 +141,19 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2
void setRotationField( QString expression )
{
mRotation.reset( expression.isEmpty() ? NULL : new QgsExpression( expression ) );
Q_ASSERT( !mRotation.get() || !mRotation->hasParserError() );
Q_ASSERT( !mRotation.data() || !mRotation->hasParserError() );
}
//! @note added in 1.6
QString rotationField() const { return mRotation.get() ? mRotation->expression() : "";}
QString rotationField() const { return mRotation.data() ? mRotation->expression() : "";}

//! @note added in 1.6
void setSizeScaleField( QString expression )
{
mSizeScale.reset( expression.isEmpty() ? NULL : new QgsExpression( expression ) );
Q_ASSERT( !mSizeScale.get() || !mSizeScale->hasParserError() );
Q_ASSERT( !mSizeScale.data() || !mSizeScale->hasParserError() );
}
//! @note added in 1.6
QString sizeScaleField() const { return mSizeScale.get() ? mSizeScale->expression() : ""; }
QString sizeScaleField() const { return mSizeScale.data() ? mSizeScale->expression() : ""; }

//! @note added in 2.0
void setScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
@@ -163,13 +163,13 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2
protected:
QString mAttrName;
QgsCategoryList mCategories;
std::auto_ptr<QgsSymbolV2> mSourceSymbol;
std::auto_ptr<QgsVectorColorRampV2> mSourceColorRamp;
QScopedPointer<QgsSymbolV2> mSourceSymbol;
QScopedPointer<QgsVectorColorRampV2> mSourceColorRamp;
bool mInvertedColorRamp;
std::auto_ptr<QgsExpression> mRotation;
std::auto_ptr<QgsExpression> mSizeScale;
QScopedPointer<QgsExpression> mRotation;
QScopedPointer<QgsExpression> mSizeScale;
QgsSymbolV2::ScaleMethod mScaleMethod;
std::auto_ptr<QgsExpression> mExpression;
QScopedPointer<QgsExpression> mExpression;

//! attribute index (derived from attribute name in startRender)
int mAttrNum;
@@ -46,7 +46,7 @@ QgsRendererRangeV2::QgsRendererRangeV2( double lowerValue, double upperValue, Qg
QgsRendererRangeV2::QgsRendererRangeV2( const QgsRendererRangeV2& range )
: mLowerValue( range.mLowerValue )
, mUpperValue( range.mUpperValue )
, mSymbol( range.mSymbol.get() ? range.mSymbol->clone() : NULL )
, mSymbol( range.mSymbol.data() ? range.mSymbol->clone() : NULL )
, mLabel( range.mLabel )
{
}
@@ -78,7 +78,7 @@ double QgsRendererRangeV2::upperValue() const

QgsSymbolV2* QgsRendererRangeV2::symbol() const
{
return mSymbol.get();
return mSymbol.data();
}

QString QgsRendererRangeV2::label() const
@@ -88,7 +88,7 @@ QString QgsRendererRangeV2::label() const

void QgsRendererRangeV2::setSymbol( QgsSymbolV2* s )
{
if ( mSymbol.get() != s ) mSymbol.reset( s );
if ( mSymbol.data() != s ) mSymbol.reset( s );
}

void QgsRendererRangeV2::setLabel( QString label )
@@ -113,7 +113,7 @@ QString QgsRendererRangeV2::dump() const

void QgsRendererRangeV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
{
if ( !mSymbol.get() || props.value( "attribute", "" ).isEmpty() )
if ( !mSymbol.data() || props.value( "attribute", "" ).isEmpty() )
return;

QString attrName = props[ "attribute" ];
@@ -192,12 +192,12 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::symbolForFeature( QgsFeature& feature
if ( symbol == NULL )
return NULL;

if ( !mRotation.get() && !mSizeScale.get() )
if ( !mRotation.data() && !mSizeScale.data() )
return symbol; // no data-defined rotation/scaling - just return the symbol

// find out rotation, size scale
const double rotation = mRotation.get() ? mRotation->evaluate( feature ).toDouble() : 0;
const double sizeScale = mSizeScale.get() ? mSizeScale->evaluate( feature ).toDouble() : 1.;
const double rotation = mRotation.data() ? mRotation->evaluate( feature ).toDouble() : 0;
const double sizeScale = mSizeScale.data() ? mSizeScale->evaluate( feature ).toDouble() : 1.;

// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[symbol];
@@ -234,11 +234,11 @@ void QgsGraduatedSymbolRendererV2::startRender( QgsRenderContext& context, const
{
it->symbol()->startRender( context, vlayer );

if ( mRotation.get() || mSizeScale.get() )
if ( mRotation.data() || mSizeScale.data() )
{
QgsSymbolV2* tempSymbol = it->symbol()->clone();
tempSymbol->setRenderHints(( mRotation.get() ? QgsSymbolV2::DataDefinedRotation : 0 ) |
( mSizeScale.get() ? QgsSymbolV2::DataDefinedSizeScale : 0 ) );
tempSymbol->setRenderHints(( mRotation.data() ? QgsSymbolV2::DataDefinedRotation : 0 ) |
( mSizeScale.data() ? QgsSymbolV2::DataDefinedSizeScale : 0 ) );
tempSymbol->startRender( context, vlayer );
mTempSymbols[ it->symbol()] = tempSymbol;
}
@@ -265,8 +265,8 @@ QList<QString> QgsGraduatedSymbolRendererV2::usedAttributes()
{
QgsExpression exp( mAttrName );
QSet<QString> attributes( exp.referencedColumns().toSet() );
if ( mRotation.get() ) attributes.unite( mRotation->referencedColumns().toSet() );
if ( mSizeScale.get() ) attributes.unite( mSizeScale->referencedColumns().toSet() );
if ( mRotation.data() ) attributes.unite( mRotation->referencedColumns().toSet() );
if ( mSizeScale.data() ) attributes.unite( mSizeScale->referencedColumns().toSet() );

QgsRangeList::const_iterator range_it = mRanges.constBegin();
for ( ; range_it != mRanges.constEnd(); ++range_it )
@@ -324,9 +324,9 @@ QgsFeatureRendererV2* QgsGraduatedSymbolRendererV2::clone()
{
QgsGraduatedSymbolRendererV2* r = new QgsGraduatedSymbolRendererV2( mAttrName, mRanges );
r->setMode( mMode );
if ( mSourceSymbol.get() )
if ( mSourceSymbol.data() )
r->setSourceSymbol( mSourceSymbol->clone() );
if ( mSourceColorRamp.get() )
if ( mSourceColorRamp.data() )
{
r->setSourceColorRamp( mSourceColorRamp->clone() );
r->setInvertedColorRamp( mInvertedColorRamp );
@@ -342,9 +342,9 @@ void QgsGraduatedSymbolRendererV2::toSld( QDomDocument& doc, QDomElement &elemen
{
QgsStringMap props;
props[ "attribute" ] = mAttrName;
if ( !mRotation.get() )
if ( !mRotation.data() )
props[ "angle" ] = qgsXmlEncode( mRotation->expression() ).append( "\"" ).prepend( "\"" );
if ( !mSizeScale.get() )
if ( !mSizeScale.data() )
props[ "scale" ] = qgsXmlEncode( mSizeScale->expression() ).append( "\"" ).prepend( "\"" );

// create a Rule for each range
@@ -1002,18 +1002,18 @@ QDomElement QgsGraduatedSymbolRendererV2::save( QDomDocument& doc )
rendererElem.appendChild( symbolsElem );

// save source symbol
if ( mSourceSymbol.get() )
if ( mSourceSymbol.data() )
{
QgsSymbolV2Map sourceSymbols;
sourceSymbols.insert( "0", mSourceSymbol.get() );
sourceSymbols.insert( "0", mSourceSymbol.data() );
QDomElement sourceSymbolElem = QgsSymbolLayerV2Utils::saveSymbols( sourceSymbols, "source-symbol", doc );
rendererElem.appendChild( sourceSymbolElem );
}

// save source color ramp
if ( mSourceColorRamp.get() )
if ( mSourceColorRamp.data() )
{
QDomElement colorRampElem = QgsSymbolLayerV2Utils::saveColorRamp( "[source]", mSourceColorRamp.get(), doc );
QDomElement colorRampElem = QgsSymbolLayerV2Utils::saveColorRamp( "[source]", mSourceColorRamp.data(), doc );
rendererElem.appendChild( colorRampElem );
QDomElement invertedElem = doc.createElement( "invertedcolorramp" );
invertedElem.setAttribute( "value", mInvertedColorRamp );
@@ -1040,12 +1040,12 @@ QDomElement QgsGraduatedSymbolRendererV2::save( QDomDocument& doc )
}

QDomElement rotationElem = doc.createElement( "rotation" );
if ( mRotation.get() )
if ( mRotation.data() )
rotationElem.setAttribute( "field", qgsXmlEncode( mRotation->expression() ) );
rendererElem.appendChild( rotationElem );

QDomElement sizeScaleElem = doc.createElement( "sizescale" );
if ( mSizeScale.get() )
if ( mSizeScale.data() )
sizeScaleElem.setAttribute( "field", qgsXmlEncode( mSizeScale->expression() ) );
sizeScaleElem.setAttribute( "scalemethod", QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod ) );
rendererElem.appendChild( sizeScaleElem );
@@ -1091,7 +1091,7 @@ QgsLegendSymbolList QgsGraduatedSymbolRendererV2::legendSymbolItems( double scal
if ( rule.isEmpty() || range.label() == rule )
{
QgsSymbolV2* symbol;
if ( !mRotation.get() && !mSizeScale.get() )
if ( !mRotation.data() && !mSizeScale.data() )
{
symbol = range.symbol();
}
@@ -1107,7 +1107,7 @@ QgsLegendSymbolList QgsGraduatedSymbolRendererV2::legendSymbolItems( double scal

QgsSymbolV2* QgsGraduatedSymbolRendererV2::sourceSymbol()
{
return mSourceSymbol.get();
return mSourceSymbol.data();
}
void QgsGraduatedSymbolRendererV2::setSourceSymbol( QgsSymbolV2* sym )
{
@@ -1116,7 +1116,7 @@ void QgsGraduatedSymbolRendererV2::setSourceSymbol( QgsSymbolV2* sym )

QgsVectorColorRampV2* QgsGraduatedSymbolRendererV2::sourceColorRamp()
{
return mSourceColorRamp.get();
return mSourceColorRamp.data();
}

void QgsGraduatedSymbolRendererV2::setSourceColorRamp( QgsVectorColorRampV2* ramp )

0 comments on commit e8205c9

Please sign in to comment.