Swap QScopedPointer to std::unique_ptr

Why?
- no benefits to QScopedPointer over std::unique_ptr
- unlike QScopedPointer, std::unique_ptr has no overhead
over regular pointers
- using standard language features makes it more likely that
compilers can optimise this use and static analysers can
correctly handle code using unique_ptrs
- QScopedPointer has an (IMO) uncertain future (given that
Qt is dropping features which have become part of the c++
standard). Better to port now before wider use of QScopedPointer
in the codebase!
This commit is contained in:
Nyall Dawson 2017-02-07 12:03:31 +10:00
parent 9475850f39
commit aed6c735a6
170 changed files with 680 additions and 659 deletions

View File

@ -913,7 +913,7 @@ void QgsComposer::setTitle( const QString& title )
bool QgsComposer::loadFromTemplate( const QDomDocument& templateDoc, bool clearExisting )
{
// provide feedback, since composer will be hidden when loading template (much faster)
QScopedPointer< QDialog > dlg( new QgsBusyIndicatorDialog( tr( "Loading template into composer..." ), this ) );
std::unique_ptr< QDialog > dlg( new QgsBusyIndicatorDialog( tr( "Loading template into composer..." ), this ) );
dlg->setStyleSheet( mQgis->styleSheet() );
dlg->show();

View File

@ -155,7 +155,7 @@ void QgsDwgImportDialog::on_pbLoadDatabase_clicked()
bool lblVisible = false;
QScopedPointer<QgsVectorLayer> d( new QgsVectorLayer( QString( "%1|layername=drawing" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
std::unique_ptr<QgsVectorLayer> d( new QgsVectorLayer( QString( "%1|layername=drawing" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
if ( d && d->isValid() )
{
int idxPath = d->fields().lookupField( "path" );
@ -190,7 +190,7 @@ void QgsDwgImportDialog::on_pbLoadDatabase_clicked()
lblMessage->setVisible( lblVisible );
QScopedPointer<QgsVectorLayer> l( new QgsVectorLayer( QString( "%1|layername=layers" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
std::unique_ptr<QgsVectorLayer> l( new QgsVectorLayer( QString( "%1|layername=layers" ).arg( leDatabase->text() ), "layers", "ogr", false ) );
if ( l && l->isValid() )
{
int idxName = l->fields().lookupField( "name" );

View File

@ -44,6 +44,7 @@
#include <cpl_string.h>
#include <gdal.h>
#include <ogr_srs_api.h>
#include <memory>
#define LOG( x ) { QgsDebugMsg( x ); QgsMessageLog::logMessage( x, QObject::tr( "DWG/DXF import" ) ); }
#define ONCE( x ) { static bool show=true; if( show ) LOG( x ); show=false; }
@ -614,7 +615,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
if ( fi.suffix().toLower() == "dxf" )
{
//loads dxf
QScopedPointer<dxfRW> dxf( new dxfRW( drawing.toUtf8() ) );
std::unique_ptr<dxfRW> dxf( new dxfRW( drawing.toUtf8() ) );
if ( !dxf->read( this, false ) )
{
result = DRW::BAD_UNKNOWN;
@ -623,7 +624,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
else if ( fi.suffix().toLower() == "dwg" )
{
//loads dwg
QScopedPointer<dwgR> dwg( new dwgR( drawing.toUtf8() ) );
std::unique_ptr<dwgR> dwg( new dwgR( drawing.toUtf8() ) );
if ( !dwg->read( this, false ) )
{
result = dwg->getError();
@ -1185,12 +1186,12 @@ void QgsDwgImporter::addAppId( const DRW_AppId &data )
bool QgsDwgImporter::createFeature( OGRLayerH layer, OGRFeatureH f, const QgsAbstractGeometry &g0 ) const
{
const QgsAbstractGeometry *g;
QScopedPointer<QgsAbstractGeometry> sg( nullptr );
std::unique_ptr<QgsAbstractGeometry> sg( nullptr );
if ( !mUseCurves && g0.hasCurvedSegments() )
{
sg.reset( g0.segmentize() );
g = sg.data();
g = sg.get();
}
else
{

View File

@ -449,15 +449,15 @@ void QgisApp::layerTreeViewDoubleClicked( const QModelIndex& index )
if ( !originalSymbol )
return;
QScopedPointer< QgsSymbol > symbol( originalSymbol->clone() );
std::unique_ptr< QgsSymbol > symbol( originalSymbol->clone() );
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( node->layerNode()->layer() );
QgsSymbolSelectorDialog dlg( symbol.data(), QgsStyle::defaultStyle(), vlayer, this );
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, this );
QgsSymbolWidgetContext context;
context.setMapCanvas( mMapCanvas );
dlg.setContext( context );
if ( dlg.exec() )
{
node->setSymbol( symbol.take() );
node->setSymbol( symbol.release() );
}
return;
@ -6241,7 +6241,7 @@ void QgisApp::saveAsRasterFile()
// TODO: show error dialogs
// TODO: this code should go somewhere else, but probably not into QgsRasterFileWriter
// clone pipe/provider is not really necessary, ready for threads
QScopedPointer<QgsRasterPipe> pipe( nullptr );
std::unique_ptr<QgsRasterPipe> pipe( nullptr );
if ( d.mode() == QgsRasterLayerSaveAsDialog::RawDataMode )
{
@ -6303,7 +6303,7 @@ void QgisApp::saveAsRasterFile()
fileWriter.setPyramidsFormat( d.pyramidsFormat() );
fileWriter.setPyramidsConfigOptions( d.pyramidsConfigOptions() );
QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe.data(), d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
QgsRasterFileWriter::WriterError err = fileWriter.writeRaster( pipe.get(), d.nColumns(), d.nRows(), d.outputRectangle(), d.outputCrs(), &pd );
if ( err != QgsRasterFileWriter::NoError )
{
QMessageBox::warning( this, tr( "Error" ),

View File

@ -147,7 +147,7 @@ void QgsAnnotationWidget::updateCenterIcon()
{
return;
}
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mMarkerSymbol.data(), mMapMarkerButton->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mMarkerSymbol.get(), mMapMarkerButton->iconSize() );
mMapMarkerButton->setIcon( icon );
}
@ -157,7 +157,7 @@ void QgsAnnotationWidget::updateFillIcon()
{
return;
}
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mFillSymbol.data(), mFrameStyleButton->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mFillSymbol.get(), mFrameStyleButton->iconSize() );
mFrameStyleButton->setIcon( icon );
}

View File

@ -20,6 +20,7 @@
#include "ui_qgsannotationwidgetbase.h"
#include "qgis_app.h"
#include <memory>
class QgsMapCanvasAnnotationItem;
class QgsMarkerSymbol;
@ -47,8 +48,8 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW
private:
QgsMapCanvasAnnotationItem* mItem = nullptr;
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
QScopedPointer< QgsFillSymbol > mFillSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsFillSymbol > mFillSymbol;
void blockAllSignals( bool block );
void updateCenterIcon();

View File

@ -500,15 +500,15 @@ void QgsAppLayerTreeViewMenuProvider::editVectorSymbol()
if ( !singleRenderer )
return;
QScopedPointer< QgsSymbol > symbol( singleRenderer->symbol() ? singleRenderer->symbol()->clone() : nullptr );
QgsSymbolSelectorDialog dlg( symbol.data(), QgsStyle::defaultStyle(), layer, mView->window() );
std::unique_ptr< QgsSymbol > symbol( singleRenderer->symbol() ? singleRenderer->symbol()->clone() : nullptr );
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), layer, mView->window() );
dlg.setWindowTitle( tr( "Symbol selector" ) );
QgsSymbolWidgetContext context;
context.setMapCanvas( mCanvas );
dlg.setContext( context );
if ( dlg.exec() )
{
singleRenderer->setSymbol( symbol.take() );
singleRenderer->setSymbol( symbol.release() );
layer->triggerRepaint();
mView->refreshLayerSymbology( layer->id() );
}
@ -576,16 +576,16 @@ void QgsAppLayerTreeViewMenuProvider::editSymbolLegendNodeSymbol()
if ( !originalSymbol )
return;
QScopedPointer< QgsSymbol > symbol( originalSymbol->clone() );
std::unique_ptr< QgsSymbol > symbol( originalSymbol->clone() );
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( node->layerNode()->layer() );
QgsSymbolSelectorDialog dlg( symbol.data(), QgsStyle::defaultStyle(), vlayer, mView->window() );
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, mView->window() );
dlg.setWindowTitle( tr( "Symbol selector" ) );
QgsSymbolWidgetContext context;
context.setMapCanvas( mCanvas );
dlg.setContext( context );
if ( dlg.exec() )
{
node->setSymbol( symbol.take() );
node->setSymbol( symbol.release() );
if ( vlayer )
{
vlayer->emitStyleChanged();

View File

@ -101,7 +101,7 @@ QgsBookmarks::QgsBookmarks( QWidget *parent )
mProjectModel = new QgsProjectBookmarksTableModel();
mModel.reset( new QgsMergedBookmarksTableModel( *mQgisModel, *mProjectModel, lstBookmarks ) );
lstBookmarks->setModel( mModel.data() );
lstBookmarks->setModel( mModel.get() );
QSettings settings;
lstBookmarks->header()->restoreState( settings.value( QStringLiteral( "/Windows/Bookmarks/headerstate" ) ).toByteArray() );

View File

@ -18,7 +18,7 @@
#define QGSBOOKMARKS_H
#include <QSqlTableModel>
#include <QScopedPointer>
#include <memory>
#include "ui_qgsbookmarksbase.h"
#include "qgsdockwidget.h"
@ -121,7 +121,7 @@ class APP_EXPORT QgsBookmarks : public QgsDockWidget, private Ui::QgsBookmarksBa
private:
QSqlTableModel* mQgisModel;
QgsProjectBookmarksTableModel* mProjectModel;
QScopedPointer<QgsMergedBookmarksTableModel> mModel;
std::unique_ptr<QgsMergedBookmarksTableModel> mModel;
void saveWindowLocation();
void restorePosition();

View File

@ -251,7 +251,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
mCheckBoxAttributeLegend->setChecked( dr->attributeLegend() );
mCheckBoxSizeLegend->setChecked( dr->sizeLegend() );
mSizeLegendSymbol.reset( dr->sizeLegendSymbol() ? dr->sizeLegendSymbol()->clone() : QgsMarkerSymbol::createSimple( QgsStringMap() ) );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.data(), mButtonSizeLegendSymbol->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.get(), mButtonSizeLegendSymbol->iconSize() );
mButtonSizeLegendSymbol->setIcon( icon );
//assume single category or linearly interpolated diagram renderer for now
@ -943,7 +943,7 @@ void QgsDiagramProperties::on_mButtonSizeLegendSymbol_clicked()
if ( d.exec() == QDialog::Accepted )
{
mSizeLegendSymbol.reset( newSymbol );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.data(), mButtonSizeLegendSymbol->iconSize() );
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.get(), mButtonSizeLegendSymbol->iconSize() );
mButtonSizeLegendSymbol->setIcon( icon );
}
else

View File

@ -80,7 +80,7 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr
// Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
QString mDiagramType;
QScopedPointer< QgsMarkerSymbol > mSizeLegendSymbol;
std::unique_ptr< QgsMarkerSymbol > mSizeLegendSymbol;
QString guessLegendText( const QString &expression );
QgsMapCanvas *mMapCanvas;

View File

@ -116,7 +116,7 @@ bool QgsFeatureAction::editFeature( bool showModal )
if ( showModal )
{
QScopedPointer<QgsAttributeDialog> dialog( newDialog( false ) );
std::unique_ptr<QgsAttributeDialog> dialog( newDialog( false ) );
if ( !mFeature->isValid() )
dialog->setMode( QgsAttributeForm::AddFeatureMode );

View File

@ -46,13 +46,13 @@ QgsLabelingWidget::QgsLabelingWidget( QgsVectorLayer* layer, QgsMapCanvas* canva
void QgsLabelingWidget::resetSettings()
{
if ( mOldSettings.data() )
if ( mOldSettings )
{
if ( mOldSettings->type() == QLatin1String( "simple" ) )
{
mOldPalSettings.writeToLayer( mLayer );
}
mLayer->setLabeling( mOldSettings.take() );
mLayer->setLabeling( mOldSettings.release() );
}
setLayer( mLayer );
}

View File

@ -65,7 +65,7 @@ class QgsLabelingWidget : public QgsMapLayerConfigWidget, private Ui::QgsLabelin
QWidget* mWidget;
QgsLabelingGui* mLabelGui;
QScopedPointer< QgsAbstractVectorLayerLabeling > mOldSettings;
std::unique_ptr< QgsAbstractVectorLayerLabeling > mOldSettings;
QgsPalLayerSettings mOldPalSettings;
};

View File

@ -233,7 +233,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}
//create QgsFeature with wkb representation
QScopedPointer< QgsFeature > f( new QgsFeature( vlayer->fields(), 0 ) );
std::unique_ptr< QgsFeature > f( new QgsFeature( vlayer->fields(), 0 ) );
//does compoundcurve contain circular strings?
//does provider support circular strings?
@ -288,7 +288,7 @@ void QgsMapToolAddFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}
f->setValid( true );
if ( addFeature( vlayer, f.data(), false ) )
if ( addFeature( vlayer, f.get(), false ) )
{
//add points to other features to keep topology up-to-date
bool topologicalEditing = QgsProject::instance()->topologicalEditing();

View File

@ -77,7 +77,7 @@ void QgsMapToolOffsetPointSymbol::canvasPressOnFeature( QgsMapMouseEvent *e, con
{
Q_UNUSED( e );
mClickedFeature = feature;
createPreviewItem( mMarkerSymbol.data() );
createPreviewItem( mMarkerSymbol.get() );
mOffsetItem->setPointLocation( snappedPoint );
updateOffsetPreviewItem( mClickedPoint, mClickedPoint );
mOffsetting = true;
@ -97,7 +97,7 @@ bool QgsMapToolOffsetPointSymbol::checkSymbolCompatibility( QgsMarkerSymbol* mar
continue;
ok = true;
if ( mMarkerSymbol.isNull() )
if ( !mMarkerSymbol )
{
double symbolRotation = markerSymbol->angle();
if ( layer->dataDefinedProperties().isActive( QgsSymbolLayer::PropertyAngle ) )

View File

@ -60,7 +60,7 @@ class APP_EXPORT QgsMapToolOffsetPointSymbol: public QgsMapToolPointSymbol
QgsPointMarkerItem* mOffsetItem;
//! Clone of first found marker symbol for feature with offset attribute set
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
//! Feature which was clicked on
QgsFeature mClickedFeature;

View File

@ -83,7 +83,7 @@ void QgsMapToolRotatePointSymbols::canvasPressOnFeature( QgsMapMouseEvent *e, co
}
mCurrentRotationFeature = attrVal.toDouble();
createPixmapItem( mMarkerSymbol.data() );
createPixmapItem( mMarkerSymbol.get() );
if ( mRotationItem )
{
mRotationItem->setPointLocation( snappedPoint );
@ -101,7 +101,7 @@ bool QgsMapToolRotatePointSymbols::checkSymbolCompatibility( QgsMarkerSymbol* ma
{
mCurrentRotationAttributes << mActiveLayer->fields().indexFromName( ddAngle.field() );
ok = true;
if ( mMarkerSymbol.isNull() )
if ( !mMarkerSymbol )
{
mMarkerSymbol.reset( markerSymbol->clone() );
}

View File

@ -18,6 +18,7 @@
#include "qgsmaptoolpointsymbol.h"
#include "qgis_app.h"
#include <memory>
class QgsPointRotationItem;
class QgsMarkerSymbol;
@ -62,7 +63,7 @@ class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolPointSymbol
//! True if ctrl was pressed during the last mouse move event
bool mCtrlPressed;
//! Clone of first found marker symbol for feature with rotation attribute set
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
void drawArrow( double azimut ) const;
//! Calculates the azimut between mousePos and mSnappedPoint

View File

@ -94,7 +94,7 @@ void QgsPointMarkerItem::setSymbol( QgsMarkerSymbol *symbol )
QgsMarkerSymbol*QgsPointMarkerItem::symbol()
{
return mMarkerSymbol.data();
return mMarkerSymbol.get();
}
void QgsPointMarkerItem::setFeature( const QgsFeature& feature )

View File

@ -22,6 +22,7 @@
#include <QFontMetricsF>
#include <QPixmap>
#include "qgis_app.h"
#include <memory>
class QgsMarkerSymbol;
@ -91,9 +92,9 @@ class APP_EXPORT QgsPointMarkerItem: public QgsMapCanvasItem
private:
QgsFeature mFeature;
QScopedPointer< QgsMarkerSymbol > mMarkerSymbol;
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
QPointF mLocation;
QScopedPointer< QgsDrawSourceEffect > mOpacityEffect;
std::unique_ptr< QgsDrawSourceEffect > mOpacityEffect;
QgsRenderContext renderContext( QPainter* painter );
};

View File

@ -1718,8 +1718,8 @@ void QgsProjectProperties::populateStyles()
for ( int i = 0; i < colorRamps.count(); ++i )
{
QString name = colorRamps[i];
QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( name ) );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), cboStyleColorRamp->iconSize() );
std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( name ) );
QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), cboStyleColorRamp->iconSize() );
cboStyleColorRamp->addItem( icon, name );
}

View File

@ -39,7 +39,7 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem* it
{
QgsTextAnnotation* annotation = static_cast< QgsTextAnnotation* >( mItem->annotation() );
mTextDocument.reset( annotation->document() ? annotation->document()->clone() : nullptr );
mTextEdit->setDocument( mTextDocument.data() );
mTextEdit->setDocument( mTextDocument.get() );
}
mFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
@ -91,7 +91,7 @@ void QgsTextAnnotationDialog::applyTextToItem()
{
mEmbeddedWidget->apply();
}
annotation->setDocument( mTextDocument.data() );
annotation->setDocument( mTextDocument.get() );
mItem->update();
}
}

View File

@ -20,6 +20,7 @@
#include "ui_qgstextannotationdialogbase.h"
#include "qgis_app.h"
#include <memory>
class QgsAnnotationWidget;
class QgsMapCanvasAnnotationItem;
@ -37,7 +38,7 @@ class APP_EXPORT QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnn
private:
QgsMapCanvasAnnotationItem* mItem = nullptr;
//! Text document (a clone of the annotation items document)
QScopedPointer< QTextDocument > mTextDocument;
std::unique_ptr< QTextDocument > mTextDocument;
QgsAnnotationWidget* mEmbeddedWidget = nullptr;
void blockAllSignals( bool block );

View File

@ -305,7 +305,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
{
layer->parent()->takeChild( layer );
}
mLayersDependenciesTreeModel.reset( new QgsLayerTreeModel( mLayersDependenciesTreeGroup.data() ) );
mLayersDependenciesTreeModel.reset( new QgsLayerTreeModel( mLayersDependenciesTreeGroup.get() ) );
// use visibility as selection
mLayersDependenciesTreeModel->setFlag( QgsLayerTreeModel::AllowNodeChangeVisibility );
@ -321,7 +321,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
layer->setItemVisibilityChecked( dependencySources.contains( layer->layerId() ) );
}
mLayersDependenciesTreeView->setModel( mLayersDependenciesTreeModel.data() );
mLayersDependenciesTreeView->setModel( mLayersDependenciesTreeModel.get() );
} // QgsVectorLayerProperties ctor

View File

@ -196,8 +196,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
QgsExpressionContext createExpressionContext() const override;
QScopedPointer<QgsLayerTreeGroup> mLayersDependenciesTreeGroup;
QScopedPointer<QgsLayerTreeModel> mLayersDependenciesTreeModel;
std::unique_ptr<QgsLayerTreeGroup> mLayersDependenciesTreeGroup;
std::unique_ptr<QgsLayerTreeModel> mLayersDependenciesTreeModel;
private slots:
void openPanel( QgsPanelWidget* panel );

View File

@ -326,7 +326,7 @@ void QgsAnnotation::_writeXml( QDomElement& itemElem, QDomDocument& doc ) const
}
if ( mMarkerSymbol )
{
QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "marker symbol" ), mMarkerSymbol.data(), doc );
QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "marker symbol" ), mMarkerSymbol.get(), doc );
if ( !symbolElem.isNull() )
{
annotationElem.appendChild( symbolElem );
@ -335,7 +335,7 @@ void QgsAnnotation::_writeXml( QDomElement& itemElem, QDomDocument& doc ) const
if ( mFillSymbol )
{
QDomElement fillElem = doc.createElement( QStringLiteral( "fillSymbol" ) );
QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "fill symbol" ), mFillSymbol.data(), doc );
QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "fill symbol" ), mFillSymbol.get(), doc );
if ( !symbolElem.isNull() )
{
fillElem.appendChild( symbolElem );

View File

@ -182,7 +182,7 @@ class CORE_EXPORT QgsAnnotation : public QObject
* Returns the symbol that is used for rendering the annotation frame.
* @see setFillSymbol()
*/
QgsFillSymbol* fillSymbol() const { return mFillSymbol.data(); }
QgsFillSymbol* fillSymbol() const { return mFillSymbol.get(); }
/**
* Renders the annotation to a target render context.
@ -216,7 +216,7 @@ class CORE_EXPORT QgsAnnotation : public QObject
* Returns the symbol that is drawn at the annotation's map position.
* @see setMarkerSymbol()
*/
QgsMarkerSymbol* markerSymbol() const { return mMarkerSymbol.data(); }
QgsMarkerSymbol* markerSymbol() const { return mMarkerSymbol.get(); }
/**
* Returns the map layer associated with the annotation. Annotations can be
@ -331,12 +331,12 @@ class CORE_EXPORT QgsAnnotation : public QObject
QSizeF mFrameSize;
//! Point symbol that is to be drawn at the map reference location
QScopedPointer<QgsMarkerSymbol> mMarkerSymbol;
std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
QgsMargins mContentsMargins;
//! Fill symbol used for drawing annotation
QScopedPointer<QgsFillSymbol> mFillSymbol;
std::unique_ptr<QgsFillSymbol> mFillSymbol;
//! Segment number where the connection to the map point is attached. -1 if no balloon needed (e.g. if point is contained in frame)
int mBalloonSegment = -1;

View File

@ -28,7 +28,7 @@ QgsTextAnnotation::QgsTextAnnotation( QObject* parent )
const QTextDocument* QgsTextAnnotation::document() const
{
return mDocument.data();
return mDocument.get();
}
void QgsTextAnnotation::setDocument( const QTextDocument* doc )

View File

@ -66,7 +66,7 @@ class CORE_EXPORT QgsTextAnnotation: public QgsAnnotation
void renderAnnotation( QgsRenderContext& context, QSizeF size ) const override;
private:
QScopedPointer< QTextDocument > mDocument;
std::unique_ptr< QTextDocument > mDocument;
};
#endif // QGSTEXTANNOTATION_H

View File

@ -137,7 +137,7 @@ int QgsAtlasComposition::updateFeatures()
// select all features with all attributes
QgsFeatureRequest req;
QScopedPointer<QgsExpression> filterExpression;
std::unique_ptr<QgsExpression> filterExpression;
if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
{
filterExpression.reset( new QgsExpression( mFeatureFilter ) );
@ -154,7 +154,7 @@ int QgsAtlasComposition::updateFeatures()
QgsFeatureIterator fit = mCoverageLayer->getFeatures( req );
QScopedPointer<QgsExpression> nameExpression;
std::unique_ptr<QgsExpression> nameExpression;
if ( !mPageNameExpression.isEmpty() )
{
nameExpression.reset( new QgsExpression( mPageNameExpression ) );
@ -180,7 +180,7 @@ int QgsAtlasComposition::updateFeatures()
expressionContext.setFeature( feat );
QString pageName;
if ( !nameExpression.isNull() )
if ( nameExpression )
{
QVariant result = nameExpression->evaluate( &expressionContext );
if ( nameExpression->hasEvalError() )
@ -732,7 +732,7 @@ bool QgsAtlasComposition::updateFilenameExpression()
bool QgsAtlasComposition::evalFeatureFilename( const QgsExpressionContext &context )
{
//generate filename for current atlas feature
if ( !mFilenamePattern.isEmpty() && !mFilenameExpr.isNull() )
if ( !mFilenamePattern.isEmpty() && mFilenameExpr )
{
QVariant filenameRes = mFilenameExpr->evaluate( &context );
if ( mFilenameExpr->hasEvalError() )

View File

@ -340,7 +340,7 @@ class CORE_EXPORT QgsAtlasComposition : public QObject
QgsFeature mCurrentFeature;
QScopedPointer<QgsExpression> mFilenameExpr;
std::unique_ptr<QgsExpression> mFilenameExpr;
// bounding box of the current feature transformed into map crs
QgsRectangle mTransformedFeatureBounds;

View File

@ -404,7 +404,7 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co
context.setFields( layer->fields() );
//prepare filter expression
QScopedPointer<QgsExpression> filterExpression;
std::unique_ptr<QgsExpression> filterExpression;
bool activeFilter = false;
if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
{
@ -465,7 +465,7 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co
{
context.setFeature( f );
//check feature against filter
if ( activeFilter && !filterExpression.isNull() )
if ( activeFilter && filterExpression )
{
QVariant result = filterExpression->evaluate( &context );
// skip this feature if the filter evaluation is false

View File

@ -282,8 +282,8 @@ QString QgsComposerLabel::displayText() const
QgsExpressionContext context = createExpressionContext();
//overwrite layer/feature if they have been set via setExpressionContext
//TODO remove when setExpressionContext is removed
if ( mExpressionFeature.data() )
context.setFeature( *mExpressionFeature.data() );
if ( mExpressionFeature.get() )
context.setFeature( *mExpressionFeature.get() );
if ( mExpressionLayer )
context.setFields( mExpressionLayer->fields() );

View File

@ -200,7 +200,7 @@ class CORE_EXPORT QgsComposerLabel: public QgsComposerItem
//! Creates an encoded stylesheet url using the current font and label appearance settings
QUrl createStylesheetUrl() const;
QScopedPointer<QgsFeature> mExpressionFeature;
std::unique_ptr<QgsFeature> mExpressionFeature;
QgsVectorLayer* mExpressionLayer;
QgsDistanceArea* mDistanceArea;

View File

@ -1467,7 +1467,7 @@ QString QgsComposerMapGrid::gridAnnotationString( double value, QgsComposerMapGr
{
expressionContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "grid_number" ), value, true ) );
expressionContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "grid_axis" ), coord == QgsComposerMapGrid::Longitude ? "x" : "y", true ) );
if ( !mGridAnnotationExpression.data() )
if ( !mGridAnnotationExpression )
{
mGridAnnotationExpression.reset( new QgsExpression( mGridAnnotationExpressionString ) );
mGridAnnotationExpression->prepare( &expressionContext );

View File

@ -898,7 +898,7 @@ class CORE_EXPORT QgsComposerMapGrid : public QgsComposerMapItem
AnnotationFormat mGridAnnotationFormat;
QString mGridAnnotationExpressionString;
mutable QScopedPointer< QgsExpression > mGridAnnotationExpression;
mutable std::unique_ptr< QgsExpression > mGridAnnotationExpression;
FrameStyle mGridFrameStyle;
FrameSideFlags mGridFrameSides;

View File

@ -132,10 +132,10 @@ void QgsComposerNodesItem::drawNodes( QPainter *painter ) const
properties.insert( QStringLiteral( "name" ), QStringLiteral( "cross" ) );
properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "red" ) );
QScopedPointer<QgsMarkerSymbol> symbol;
std::unique_ptr<QgsMarkerSymbol> symbol;
symbol.reset( QgsMarkerSymbol::createSimple( properties ) );
symbol.data()->setSize( rectSize );
symbol.data()->setAngle( 45 );
symbol->setSize( rectSize );
symbol->setAngle( 45 );
QgsRenderContext context = QgsComposerUtils::createRenderContextForComposition( mComposition, painter );
context.setForceVectorOutput( true );
@ -143,12 +143,12 @@ void QgsComposerNodesItem::drawNodes( QPainter *painter ) const
QgsExpressionContext expressionContext = createExpressionContext();
context.setExpressionContext( expressionContext );
symbol.data()->startRender( context );
symbol->startRender( context );
Q_FOREACH ( QPointF pt, mPolygon )
symbol.data()->renderPoint( pt, nullptr, context );
symbol->renderPoint( pt, nullptr, context );
symbol.data()->stopRender( context );
symbol->stopRender( context );
if ( mSelectedNode >= 0 && mSelectedNode < mPolygon.size() )
drawSelectedNode( painter );
@ -164,9 +164,9 @@ void QgsComposerNodesItem::drawSelectedNode( QPainter *painter ) const
properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "blue" ) );
properties.insert( QStringLiteral( "width_border" ), QStringLiteral( "4" ) );
QScopedPointer<QgsMarkerSymbol> symbol;
std::unique_ptr<QgsMarkerSymbol> symbol;
symbol.reset( QgsMarkerSymbol::createSimple( properties ) );
symbol.data()->setSize( rectSize );
symbol->setSize( rectSize );
QgsRenderContext context = QgsComposerUtils::createRenderContextForComposition( mComposition, painter );
context.setForceVectorOutput( true );
@ -174,9 +174,9 @@ void QgsComposerNodesItem::drawSelectedNode( QPainter *painter ) const
QgsExpressionContext expressionContext = createExpressionContext();
context.setExpressionContext( expressionContext );
symbol.data()->startRender( context );
symbol.data()->renderPoint( mPolygon.at( mSelectedNode ), nullptr, context );
symbol.data()->stopRender( context );
symbol->startRender( context );
symbol->renderPoint( mPolygon.at( mSelectedNode ), nullptr, context );
symbol->stopRender( context );
}
void QgsComposerNodesItem::paint( QPainter* painter,

View File

@ -106,7 +106,7 @@ void QgsComposerPolygon::setPolygonStyleSymbol( QgsFillSymbol* symbol )
void QgsComposerPolygon::_writeXmlStyle( QDomDocument &doc, QDomElement &elmt ) const
{
const QDomElement pe = QgsSymbolLayerUtils::saveSymbol( QString(),
mPolygonStyleSymbol.data(),
mPolygonStyleSymbol.get(),
doc );
elmt.appendChild( pe );
}

View File

@ -51,7 +51,7 @@ class CORE_EXPORT QgsComposerPolygon: public QgsComposerNodesItem
virtual QString displayName() const override;
//! Returns the QgsSymbol used to draw the shape.
QgsFillSymbol* polygonStyleSymbol() { return mPolygonStyleSymbol.data(); }
QgsFillSymbol* polygonStyleSymbol() { return mPolygonStyleSymbol.get(); }
//! Set the QgsSymbol used to draw the shape.
void setPolygonStyleSymbol( QgsFillSymbol* symbol );
@ -62,7 +62,7 @@ class CORE_EXPORT QgsComposerPolygon: public QgsComposerNodesItem
protected:
//! QgsSymbol use to draw the shape.
QScopedPointer<QgsFillSymbol> mPolygonStyleSymbol;
std::unique_ptr<QgsFillSymbol> mPolygonStyleSymbol;
/** Add the node newPoint at the given position according to some
* criteres. */

View File

@ -130,7 +130,7 @@ void QgsComposerPolyline::setPolylineStyleSymbol( QgsLineSymbol* symbol )
void QgsComposerPolyline::_writeXmlStyle( QDomDocument &doc, QDomElement &elmt ) const
{
const QDomElement pe = QgsSymbolLayerUtils::saveSymbol( QString(),
mPolylineStyleSymbol.data(),
mPolylineStyleSymbol.get(),
doc );
elmt.appendChild( pe );
}

View File

@ -50,7 +50,7 @@ class CORE_EXPORT QgsComposerPolyline: public QgsComposerNodesItem
virtual QString displayName() const override;
//! Returns the QgsSymbol used to draw the shape.
QgsLineSymbol* polylineStyleSymbol() { return mPolylineStyleSymbol.data(); }
QgsLineSymbol* polylineStyleSymbol() { return mPolylineStyleSymbol.get(); }
//! Set the QgsSymbol used to draw the shape.
void setPolylineStyleSymbol( QgsLineSymbol* symbol );
@ -61,7 +61,7 @@ class CORE_EXPORT QgsComposerPolyline: public QgsComposerNodesItem
protected:
//! QgsSymbol use to draw the shape.
QScopedPointer<QgsLineSymbol> mPolylineStyleSymbol;
std::unique_ptr<QgsLineSymbol> mPolylineStyleSymbol;
/** Add the node newPoint at the given position according to some
* criteres. */

View File

@ -3644,7 +3644,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
if ( !fet->hasGeometry() )
return;
QScopedPointer<QgsAbstractGeometry> geom( fet->geometry().geometry()->clone() );
std::unique_ptr<QgsAbstractGeometry> geom( fet->geometry().geometry()->clone() );
if ( ct.isValid() )
{
geom->transform( ct );
@ -3702,7 +3702,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
if ( penStyle != Qt::NoPen )
{
const QgsAbstractGeometry *tempGeom = geom.data();
const QgsAbstractGeometry *tempGeom = geom.get();
switch ( QgsWkbTypes::flatType( geometryType ) )
{
@ -3716,11 +3716,11 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
if ( !qgsDoubleNear( offset, 0.0 ) )
{
QgsGeos geos( tempGeom );
if ( tempGeom != geom.data() )
if ( tempGeom != geom.get() )
delete tempGeom;
tempGeom = geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
if ( !tempGeom )
tempGeom = geom.data();
tempGeom = geom.get();
}
writePolyline( tempGeom->coordinateSequence().at( 0 ).at( 0 ), layer, lineStyleName, penColor, width );
@ -3737,11 +3737,11 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
if ( !qgsDoubleNear( offset, 0.0 ) )
{
QgsGeos geos( tempGeom );
if ( tempGeom != geom.data() )
if ( tempGeom != geom.get() )
delete tempGeom;
tempGeom = geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
if ( !tempGeom )
tempGeom = geom.data();
tempGeom = geom.get();
}
const QgsCoordinateSequence &cs = tempGeom->coordinateSequence();
@ -3763,11 +3763,11 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
if ( !qgsDoubleNear( offset, 0.0 ) )
{
QgsGeos geos( tempGeom );
if ( tempGeom != geom.data() )
if ( tempGeom != geom.get() )
delete tempGeom;
tempGeom = geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
if ( !tempGeom )
tempGeom = geom.data();
tempGeom = geom.get();
}
const QgsCoordinateSequence &cs = tempGeom->coordinateSequence();
@ -3784,11 +3784,11 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
if ( !qgsDoubleNear( offset, 0.0 ) )
{
QgsGeos geos( tempGeom );
if ( tempGeom != geom.data() )
if ( tempGeom != geom.get() )
delete tempGeom;
tempGeom = geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
if ( !tempGeom )
tempGeom = geom.data();
tempGeom = geom.get();
}
const QgsCoordinateSequence &cs = tempGeom->coordinateSequence();
@ -3803,13 +3803,13 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
break;
}
if ( tempGeom != geom.data() )
if ( tempGeom != geom.get() )
delete tempGeom;
}
if ( brushStyle != Qt::NoBrush )
{
const QgsAbstractGeometry *tempGeom = geom.data();
const QgsAbstractGeometry *tempGeom = geom.get();
switch ( QgsWkbTypes::flatType( geometryType ) )
{
@ -3837,7 +3837,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT
}
if ( tempGeom != geom.data() )
if ( tempGeom != geom.get() )
delete tempGeom;
}
}

View File

@ -2337,7 +2337,7 @@ QgsLineString* smoothCurve( const QgsLineString& line, const unsigned int iterat
const double offset, double squareDistThreshold, double maxAngleRads,
bool isRing )
{
QScopedPointer< QgsLineString > result( new QgsLineString( line ) );
std::unique_ptr< QgsLineString > result( new QgsLineString( line ) );
for ( unsigned int iteration = 0; iteration < iterations; ++iteration )
{
QgsPointSequence outputLine;
@ -2415,7 +2415,7 @@ QgsLineString* smoothCurve( const QgsLineString& line, const unsigned int iterat
result->setPoints( outputLine );
}
return result.take();
return result.release();
}
QgsLineString* QgsGeometry::smoothLine( const QgsLineString& line, const unsigned int iterations, const double offset, double minimumDistance, double maxAngle ) const
@ -2429,7 +2429,7 @@ QgsPolygonV2* QgsGeometry::smoothPolygon( const QgsPolygonV2& polygon, const uns
{
double maxAngleRads = maxAngle * M_PI / 180.0;
double squareDistThreshold = minimumDistance > 0 ? minimumDistance * minimumDistance : -1;
QScopedPointer< QgsPolygonV2 > resultPoly( new QgsPolygonV2 );
std::unique_ptr< QgsPolygonV2 > resultPoly( new QgsPolygonV2 );
resultPoly->setExteriorRing( smoothCurve( *( static_cast< const QgsLineString*>( polygon.exteriorRing() ) ), iterations, offset,
squareDistThreshold, maxAngleRads, true ) );
@ -2439,7 +2439,7 @@ QgsPolygonV2* QgsGeometry::smoothPolygon( const QgsPolygonV2& polygon, const uns
resultPoly->addInteriorRing( smoothCurve( *( static_cast< const QgsLineString*>( polygon.interiorRing( i ) ) ), iterations, offset,
squareDistThreshold, maxAngleRads, true ) );
}
return resultPoly.take();
return resultPoly.release();
}
QgsGeometry QgsGeometry::convertToPoint( bool destMultipart ) const

View File

@ -66,7 +66,7 @@ int QgsGeometryEditUtils::addRing( QgsAbstractGeometry* geom, QgsCurve* ring )
return 3;
}
QScopedPointer<QgsGeometryEngine> ringGeom( QgsGeometry::createGeometryEngine( ring ) );
std::unique_ptr<QgsGeometryEngine> ringGeom( QgsGeometry::createGeometryEngine( ring ) );
ringGeom->prepareGeometry();
//for each polygon, test if inside outer ring and no intersection with other interior ring
@ -228,8 +228,8 @@ QgsAbstractGeometry* QgsGeometryEditUtils::avoidIntersections( const QgsAbstract
const QList<QgsVectorLayer*>& avoidIntersectionsLayers,
QHash<QgsVectorLayer *, QSet<QgsFeatureId> > ignoreFeatures )
{
QScopedPointer<QgsGeometryEngine> geomEngine( QgsGeometry::createGeometryEngine( &geom ) );
if ( geomEngine.isNull() )
std::unique_ptr<QgsGeometryEngine> geomEngine( QgsGeometry::createGeometryEngine( &geom ) );
if ( !geomEngine )
{
return nullptr;
}
@ -277,14 +277,14 @@ QgsAbstractGeometry* QgsGeometryEditUtils::avoidIntersections( const QgsAbstract
}
QgsAbstractGeometry* combinedGeometries = geomEngine.data()->combine( nearGeometries );
QgsAbstractGeometry* combinedGeometries = geomEngine->combine( nearGeometries );
qDeleteAll( nearGeometries );
if ( !combinedGeometries )
{
return nullptr;
}
QgsAbstractGeometry* diffGeom = geomEngine.data()->difference( *combinedGeometries );
QgsAbstractGeometry* diffGeom = geomEngine->difference( *combinedGeometries );
delete combinedGeometries;
return diffGeom;

View File

@ -25,6 +25,7 @@
#include <QTransform>
#include <memory>
#include <queue>
QgsInternalGeometryEngine::QgsInternalGeometryEngine( const QgsGeometry& geometry )
@ -58,7 +59,7 @@ QgsGeometry QgsInternalGeometryEngine::extrude( double x, double y ) const
linesToProcess << static_cast<QgsLineString*>( curve->segmentize() );
}
QScopedPointer<QgsMultiPolygonV2> multipolygon( linesToProcess.size() > 1 ? new QgsMultiPolygonV2() : nullptr );
std::unique_ptr<QgsMultiPolygonV2> multipolygon( linesToProcess.size() > 1 ? new QgsMultiPolygonV2() : nullptr );
QgsPolygonV2 *polygon = nullptr;
if ( !linesToProcess.empty() )
@ -83,7 +84,7 @@ QgsGeometry QgsInternalGeometryEngine::extrude( double x, double y ) const
}
if ( multipolygon )
return QgsGeometry( multipolygon.take() );
return QgsGeometry( multipolygon.release() );
else
return QgsGeometry( polygon );
}
@ -171,12 +172,12 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision ,
if ( !surface )
return QgsGeometry();
QScopedPointer< QgsPolygonV2 > segmentizedPoly;
std::unique_ptr< QgsPolygonV2 > segmentizedPoly;
const QgsPolygonV2* polygon = dynamic_cast< const QgsPolygonV2* >( mGeometry );
if ( !polygon )
{
segmentizedPoly.reset( static_cast< QgsPolygonV2*>( surface->segmentize() ) );
polygon = segmentizedPoly.data();
polygon = segmentizedPoly.get();
}
// start with the bounding box
@ -201,28 +202,28 @@ QgsGeometry QgsInternalGeometryEngine::poleOfInaccessibility( double precision ,
}
// take centroid as the first best guess
QScopedPointer< Cell > bestCell( getCentroidCell( polygon ) );
std::unique_ptr< Cell > bestCell( getCentroidCell( polygon ) );
// special case for rectangular polygons
QScopedPointer< Cell > bboxCell( new Cell( bounds.xMinimum() + bounds.width() / 2.0,
bounds.yMinimum() + bounds.height() / 2.0,
0, polygon ) );
std::unique_ptr< Cell > bboxCell( new Cell( bounds.xMinimum() + bounds.width() / 2.0,
bounds.yMinimum() + bounds.height() / 2.0,
0, polygon ) );
if ( bboxCell->d > bestCell->d )
{
bestCell.reset( bboxCell.take() );
bestCell.reset( bboxCell.release() );
}
while ( cellQueue.size() > 0 )
{
// pick the most promising cell from the queue
QScopedPointer< Cell > cell( cellQueue.top() );
std::unique_ptr< Cell > cell( cellQueue.top() );
cellQueue.pop();
Cell* currentCell = cell.data();
Cell* currentCell = cell.get();
// update the best cell if we found a better one
if ( currentCell->d > bestCell->d )
{
bestCell.reset( cell.take() );
bestCell.reset( cell.release() );
}
// do not drill down further if there's no chance of a better solution
@ -347,7 +348,7 @@ QgsLineString* doOrthogonalize( QgsLineString* ring, int iterations, double tole
bool isClosed = ring->isClosed();
int numPoints = ring->numPoints();
QScopedPointer< QgsLineString > best( ring->clone() );
std::unique_ptr< QgsLineString > best( ring->clone() );
for ( int it = 0; it < iterations; ++it )
{
@ -406,17 +407,17 @@ QgsLineString* doOrthogonalize( QgsLineString* ring, int iterations, double tole
delete ring;
return best.take();
return best.release();
}
QgsAbstractGeometry* orthogonalizeGeom( const QgsAbstractGeometry* geom, int maxIterations, double tolerance, double lowerThreshold, double upperThreshold )
{
QScopedPointer< QgsAbstractGeometry > segmentizedCopy;
std::unique_ptr< QgsAbstractGeometry > segmentizedCopy;
if ( QgsWkbTypes::isCurvedType( geom->wkbType() ) )
{
segmentizedCopy.reset( geom->segmentize() );
geom = segmentizedCopy.data();
geom = segmentizedCopy.get();
}
if ( QgsWkbTypes::geometryType( geom->wkbType() ) == QgsWkbTypes::LineGeometry )

View File

@ -1314,11 +1314,11 @@ QgsRenderContext* QgsLayerTreeModel::createTemporaryRenderContext() const
bool validData = !qgsDoubleNear( mupp, 0.0 ) && dpi != 0 && !qgsDoubleNear( scale, 0.0 );
// setup temporary render context
QScopedPointer<QgsRenderContext> context( new QgsRenderContext );
std::unique_ptr<QgsRenderContext> context( new QgsRenderContext );
context->setScaleFactor( dpi / 25.4 );
context->setRendererScale( scale );
context->setMapToPixel( QgsMapToPixel( mupp ) );
return validData ? context.take() : nullptr;
return validData ? context.release() : nullptr;
}
@ -1518,7 +1518,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
// we do that here because for symbols with size defined in map units
// the symbol sizes changes depends on the zoom level
QScopedPointer<QgsRenderContext> context( createTemporaryRenderContext() );
std::unique_ptr<QgsRenderContext> context( createTemporaryRenderContext() );
Q_FOREACH ( const LayerLegendData& data, mLegend )
{
@ -1529,7 +1529,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData()
QgsSymbolLegendNode* n = dynamic_cast<QgsSymbolLegendNode*>( legendNode );
if ( n )
{
const QSize sz( n->minimumIconSize( context.data() ) );
const QSize sz( n->minimumIconSize( context.get() ) );
const QString parentKey( n->data( QgsLayerTreeModelLegendNode::ParentRuleKeyRole ).toString() );
widthMax[parentKey] = qMax( sz.width(), widthMax.contains( parentKey ) ? widthMax[parentKey] : 0 );
n->setIconSize( sz );

View File

@ -21,6 +21,7 @@
#include <QFont>
#include <QIcon>
#include <QTimer>
#include <memory>
#include "qgsgeometry.h"
@ -191,7 +192,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
//! Returns the current map settings used for the current legend filter (or null if none is enabled)
//! @note added in 2.14
const QgsMapSettings* legendFilterMapSettings() const { return mLegendFilterMapSettings.data(); }
const QgsMapSettings* legendFilterMapSettings() const { return mLegendFilterMapSettings.get(); }
//! Give the layer tree model hints about the currently associated map view
//! so that legend nodes that use map units can be scaled currectly
@ -338,8 +339,8 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
//! scale denominator for filtering of legend nodes (<= 0 means no filtering)
double mLegendFilterByScale;
QScopedPointer<QgsMapSettings> mLegendFilterMapSettings;
QScopedPointer<QgsMapHitTest> mLegendFilterHitTest;
std::unique_ptr<QgsMapSettings> mLegendFilterMapSettings;
std::unique_ptr<QgsMapHitTest> mLegendFilterHitTest;
//! whether to use map filtering
bool mLegendFilterUsesExtent;

View File

@ -151,8 +151,8 @@ Qt::ItemFlags QgsSymbolLegendNode::flags() const
QSize QgsSymbolLegendNode::minimumIconSize() const
{
QScopedPointer<QgsRenderContext> context( createTemporaryRenderContext() );
return minimumIconSize( context.data() );
std::unique_ptr<QgsRenderContext> context( createTemporaryRenderContext() );
return minimumIconSize( context.get() );
}
QSize QgsSymbolLegendNode::minimumIconSize( QgsRenderContext* context ) const
@ -225,11 +225,11 @@ QgsRenderContext * QgsSymbolLegendNode::createTemporaryRenderContext() const
bool validData = !qgsDoubleNear( mupp, 0.0 ) && dpi != 0 && !qgsDoubleNear( scale, 0.0 );
// setup temporary render context
QScopedPointer<QgsRenderContext> context( new QgsRenderContext );
std::unique_ptr<QgsRenderContext> context( new QgsRenderContext );
context->setScaleFactor( dpi / 25.4 );
context->setRendererScale( scale );
context->setMapToPixel( QgsMapToPixel( mupp ) );
return validData ? context.take() : nullptr;
return validData ? context.release() : nullptr;
}
void QgsSymbolLegendNode::checkAll( bool state )
@ -265,8 +265,8 @@ QVariant QgsSymbolLegendNode::data( int role ) const
QPixmap pix;
if ( mItem.symbol() )
{
QScopedPointer<QgsRenderContext> context( createTemporaryRenderContext() );
pix = QgsSymbolLayerUtils::symbolPreviewPixmap( mItem.symbol(), mIconSize, 0, context.data() );
std::unique_ptr<QgsRenderContext> context( createTemporaryRenderContext() );
pix = QgsSymbolLayerUtils::symbolPreviewPixmap( mItem.symbol(), mIconSize, 0, context.get() );
}
else
{
@ -603,9 +603,9 @@ QImage QgsWmsLegendNode::getLegendGraphic() const
mFetcher.reset( prov->getLegendGraphicFetcher( ms ) );
if ( mFetcher )
{
connect( mFetcher.data(), SIGNAL( finish( const QImage& ) ), this, SLOT( getLegendGraphicFinished( const QImage& ) ) );
connect( mFetcher.data(), SIGNAL( error( const QString& ) ), this, SLOT( getLegendGraphicErrored( const QString& ) ) );
connect( mFetcher.data(), SIGNAL( progress( qint64, qint64 ) ), this, SLOT( getLegendGraphicProgress( qint64, qint64 ) ) );
connect( mFetcher.get(), SIGNAL( finish( const QImage& ) ), this, SLOT( getLegendGraphicFinished( const QImage& ) ) );
connect( mFetcher.get(), SIGNAL( error( const QString& ) ), this, SLOT( getLegendGraphicErrored( const QString& ) ) );
connect( mFetcher.get(), SIGNAL( progress( qint64, qint64 ) ), this, SLOT( getLegendGraphicProgress( qint64, qint64 ) ) );
mFetcher->start();
} // else QgsDebugMsg("XXX No legend supported?");

View File

@ -342,7 +342,7 @@ class CORE_EXPORT QgsWmsLegendNode : public QgsLayerTreeModelLegendNode
bool mValid;
mutable QScopedPointer<QgsImageFetcher> mFetcher;
mutable std::unique_ptr<QgsImageFetcher> mFetcher;
};
#endif // QGSLAYERTREEMODELLEGENDNODE_H

View File

@ -54,7 +54,7 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag
QgsExpressionContext defaultContext = mLayer->createExpressionContext();
context = context ? context : &defaultContext;
QScopedPointer<QgsExpression> expression;
std::unique_ptr<QgsExpression> expression;
int attrNum = mLayer->fields().lookupField( fieldOrExpression );
@ -72,13 +72,13 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag
}
QSet<QString> lst;
if ( expression.isNull() )
if ( !expression )
lst.insert( fieldOrExpression );
else
lst = expression->referencedColumns();
QgsFeatureRequest request = QgsFeatureRequest()
.setFlags(( expression.data() && expression->needsGeometry() ) ?
.setFlags(( expression && expression->needsGeometry() ) ?
QgsFeatureRequest::NoFlags :
QgsFeatureRequest::NoGeometry )
.setSubsetOfAttributes( lst, mLayer->fields() );
@ -115,7 +115,7 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag
}
QgsFeatureIterator fit = mLayer->getFeatures( request );
return calculate( aggregate, fit, resultType, attrNum, expression.data(), mDelimiter, context, ok );
return calculate( aggregate, fit, resultType, attrNum, expression.get(), mDelimiter, context, ok );
}
QgsAggregateCalculator::Aggregate QgsAggregateCalculator::stringToAggregate( const QString& string, bool* ok )

View File

@ -142,7 +142,7 @@ QgsConditionalStyle::QgsConditionalStyle( const QgsConditionalStyle &other )
, mTextColor( other.mTextColor )
, mIcon( other.mIcon )
{
if ( other.mSymbol.data() )
if ( other.mSymbol )
mSymbol.reset( other.mSymbol->clone() );
}
@ -155,7 +155,7 @@ QgsConditionalStyle& QgsConditionalStyle::operator=( const QgsConditionalStyle &
mTextColor = other.mTextColor;
mIcon = other.mIcon;
mName = other.mName;
if ( other.mSymbol.data() )
if ( other.mSymbol )
{
mSymbol.reset( other.mSymbol->clone() );
}
@ -180,7 +180,7 @@ void QgsConditionalStyle::setSymbol( QgsSymbol* value )
if ( value )
{
mSymbol.reset( value->clone() );
mIcon = QgsSymbolLayerUtils::symbolPreviewPixmap( mSymbol.data(), QSize( 16, 16 ) );
mIcon = QgsSymbolLayerUtils::symbolPreviewPixmap( mSymbol.get(), QSize( 16, 16 ) );
}
else
{
@ -280,9 +280,9 @@ bool QgsConditionalStyle::writeXml( QDomNode &node, QDomDocument &doc ) const
stylesel.setAttribute( QStringLiteral( "text_color" ), mTextColor.name() );
QDomElement labelFontElem = QgsFontUtils::toXmlElement( mFont, doc, QStringLiteral( "font" ) );
stylesel.appendChild( labelFontElem );
if ( ! mSymbol.isNull() )
if ( mSymbol )
{
QDomElement symbolElm = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "icon" ), mSymbol.data(), doc );
QDomElement symbolElm = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "icon" ), mSymbol.get(), doc );
stylesel.appendChild( symbolElm );
}
node.appendChild( stylesel );

View File

@ -146,7 +146,7 @@ class CORE_EXPORT QgsConditionalStyle
* @brief The symbol used to generate the icon for the style
* @return The QgsSymbol used for the icon
*/
QgsSymbol* symbol() const { return mSymbol.data(); }
QgsSymbol* symbol() const { return mSymbol.get(); }
/**
* @brief The text color set for style
@ -234,7 +234,7 @@ class CORE_EXPORT QgsConditionalStyle
bool mValid;
QString mName;
QString mRule;
QScopedPointer<QgsSymbol> mSymbol;
std::unique_ptr<QgsSymbol> mSymbol;
QFont mFont;
QColor mBackColor;
QColor mTextColor;

View File

@ -1175,7 +1175,7 @@ void QgsZipItem::init()
QgsDebugMsgLevel( "provider " + k, 3 );
// some providers hangs with empty uri (Postgis) etc...
// -> using libraries directly
QScopedPointer< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( k ) );
std::unique_ptr< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( k ) );
if ( library )
{
dataCapabilities_t * dataCapabilities = reinterpret_cast< dataCapabilities_t * >( cast_to_fptr( library->resolve( "dataCapabilities" ) ) );

View File

@ -62,7 +62,7 @@ QgsDataItemProviderRegistry::QgsDataItemProviderRegistry()
Q_FOREACH ( const QString& key, providersList )
{
QScopedPointer< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( key ) );
std::unique_ptr< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( key ) );
if ( !library )
continue;

View File

@ -429,7 +429,7 @@ QgsDiagramRenderer::QgsDiagramRenderer( const QgsDiagramRenderer& other )
: mDiagram( other.mDiagram ? other.mDiagram->clone() : nullptr )
, mShowAttributeLegend( other.mShowAttributeLegend )
, mShowSizeLegend( other.mShowSizeLegend )
, mSizeLegendSymbol( other.mSizeLegendSymbol.data() ? other.mSizeLegendSymbol->clone() : nullptr )
, mSizeLegendSymbol( other.mSizeLegendSymbol ? other.mSizeLegendSymbol->clone() : nullptr )
{
}
@ -438,7 +438,7 @@ QgsDiagramRenderer &QgsDiagramRenderer::operator=( const QgsDiagramRenderer & ot
mDiagram = other.mDiagram ? other.mDiagram->clone() : nullptr;
mShowAttributeLegend = other.mShowAttributeLegend;
mShowSizeLegend = other.mShowSizeLegend;
mSizeLegendSymbol.reset( other.mSizeLegendSymbol.data() ? other.mSizeLegendSymbol->clone() : nullptr );
mSizeLegendSymbol.reset( other.mSizeLegendSymbol ? other.mSizeLegendSymbol->clone() : nullptr );
return *this;
}
@ -573,7 +573,7 @@ void QgsDiagramRenderer::_writeXml( QDomElement& rendererElem, QDomDocument& doc
}
rendererElem.setAttribute( QStringLiteral( "attributeLegend" ), mShowAttributeLegend );
rendererElem.setAttribute( QStringLiteral( "sizeLegend" ), mShowSizeLegend );
QDomElement sizeLegendSymbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "sizeSymbol" ), mSizeLegendSymbol.data(), doc );
QDomElement sizeLegendSymbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "sizeSymbol" ), mSizeLegendSymbol.get(), doc );
rendererElem.appendChild( sizeLegendSymbolElem );
}
@ -765,13 +765,13 @@ QList< QgsLayerTreeModelLegendNode* > QgsLinearlyInterpolatedDiagramRenderer::le
if ( mShowAttributeLegend )
nodes = mSettings.legendItems( nodeLayer );
if ( mShowSizeLegend && mDiagram && mSizeLegendSymbol.data() )
if ( mShowSizeLegend && mDiagram && mSizeLegendSymbol )
{
// add size legend
Q_FOREACH ( double v, QgsSymbolLayerUtils::prettyBreaks( mInterpolationSettings.lowerValue, mInterpolationSettings.upperValue, 4 ) )
{
double size = mDiagram->legendSize( v, mSettings, mInterpolationSettings );
QgsLegendSymbolItem si( mSizeLegendSymbol.data(), QString::number( v ), QString() );
QgsLegendSymbolItem si( mSizeLegendSymbol.get(), QString::number( v ), QString() );
QgsMarkerSymbol * s = static_cast<QgsMarkerSymbol *>( si.symbol() );
s->setSize( size );
s->setSizeUnit( mSettings.sizeType );

View File

@ -550,7 +550,7 @@ class CORE_EXPORT QgsDiagramRenderer
* @see setSizeLegendSymbol()
* @see sizeLegend()
*/
QgsMarkerSymbol* sizeLegendSymbol() const { return mSizeLegendSymbol.data(); }
QgsMarkerSymbol* sizeLegendSymbol() const { return mSizeLegendSymbol.get(); }
/** Sets the marker symbol used for rendering the diagram size legend.
* @param symbol marker symbol, ownership is transferred to the renderer.
@ -604,7 +604,7 @@ class CORE_EXPORT QgsDiagramRenderer
bool mShowSizeLegend;
//! Marker symbol to use in size legends
QScopedPointer< QgsMarkerSymbol > mSizeLegendSymbol;
std::unique_ptr< QgsMarkerSymbol > mSizeLegendSymbol;
};
/** \ingroup core

View File

@ -2439,7 +2439,7 @@ static QVariant fcnRelate( const QVariantList& values, const QgsExpressionContex
if ( fGeom.isNull() || sGeom.isNull() )
return QVariant();
QScopedPointer<QgsGeometryEngine> engine( QgsGeometry::createGeometryEngine( fGeom.geometry() ) );
std::unique_ptr<QgsGeometryEngine> engine( QgsGeometry::createGeometryEngine( fGeom.geometry() ) );
if ( values.length() == 2 )
{

View File

@ -143,7 +143,7 @@ void QgsMapHitTest::runHitTestLayer( QgsVectorLayer* vl, SymbolSet& usedSymbols,
SymbolSet lUsedSymbolsRuleKey;
bool allExpressionFalse = false;
bool hasExpression = mLayerFilterExpression.contains( vl->id() );
QScopedPointer<QgsExpression> expr;
std::unique_ptr<QgsExpression> expr;
if ( hasExpression )
{
expr.reset( new QgsExpression( mLayerFilterExpression[vl->id()] ) );

View File

@ -15,6 +15,7 @@
***************************************************************************/
#include <limits>
#include <memory>
#include "qgsmaptopixelgeometrysimplifier.h"
#include "qgsapplication.h"
@ -140,7 +141,7 @@ QgsGeometry QgsMapToPixelSimplifier::simplifyGeometry(
if ( flatType == QgsWkbTypes::LineString || flatType == QgsWkbTypes::CircularString )
{
const QgsCurve& srcCurve = dynamic_cast<const QgsCurve&>( geometry );
QScopedPointer<QgsCurve> output( createEmptySameTypeGeom( srcCurve ) );
std::unique_ptr<QgsCurve> output( createEmptySameTypeGeom( srcCurve ) );
double x = 0.0, y = 0.0, lastX = 0.0, lastY = 0.0;
QgsRectangle r;
r.setMinimal();
@ -265,31 +266,31 @@ QgsGeometry QgsMapToPixelSimplifier::simplifyGeometry(
}
}
return QgsGeometry( output.take() );
return QgsGeometry( output.release() );
}
else if ( flatType == QgsWkbTypes::Polygon )
{
const QgsPolygonV2& srcPolygon = dynamic_cast<const QgsPolygonV2&>( geometry );
QScopedPointer<QgsPolygonV2> polygon( new QgsPolygonV2() );
std::unique_ptr<QgsPolygonV2> polygon( new QgsPolygonV2() );
polygon->setExteriorRing( dynamic_cast<QgsCurve*>( simplifyGeometry( simplifyFlags, simplifyAlgorithm, srcPolygon.exteriorRing()->wkbType(), *srcPolygon.exteriorRing(), envelope, map2pixelTol, true ).geometry()->clone() ) );
for ( int i = 0; i < srcPolygon.numInteriorRings(); ++i )
{
const QgsCurve* sub = srcPolygon.interiorRing( i );
polygon->addInteriorRing( dynamic_cast<QgsCurve*>( simplifyGeometry( simplifyFlags, simplifyAlgorithm, sub->wkbType(), *sub, envelope, map2pixelTol, true ).geometry()->clone() ) );
}
return QgsGeometry( polygon.take() );
return QgsGeometry( polygon.release() );
}
else if ( QgsWkbTypes::isMultiType( flatType ) )
{
const QgsGeometryCollection& srcCollection = dynamic_cast<const QgsGeometryCollection&>( geometry );
QScopedPointer<QgsGeometryCollection> collection( createEmptySameTypeGeom( srcCollection ) );
std::unique_ptr<QgsGeometryCollection> collection( createEmptySameTypeGeom( srcCollection ) );
const int numGeoms = srcCollection.numGeometries();
for ( int i = 0; i < numGeoms; ++i )
{
const QgsAbstractGeometry* sub = srcCollection.geometryN( i );
collection->addGeometry( simplifyGeometry( simplifyFlags, simplifyAlgorithm, sub->wkbType(), *sub, envelope, map2pixelTol, false ).geometry()->clone() );
}
return QgsGeometry( collection.take() );
return QgsGeometry( collection.release() );
}
return QgsGeometry( geometry.clone() );
}

View File

@ -975,14 +975,14 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
}
//try to keep < 2.12 API - handle no passed render context
QScopedPointer< QgsRenderContext > scopedRc;
std::unique_ptr< QgsRenderContext > scopedRc;
if ( !context )
{
scopedRc.reset( new QgsRenderContext() );
if ( f )
scopedRc->expressionContext().setFeature( *f );
}
QgsRenderContext* rc = context ? context : scopedRc.data();
QgsRenderContext* rc = context ? context : scopedRc.get();
QString wrapchr = wrapChar;
double multilineH = mFormat.lineHeight();
@ -1329,9 +1329,9 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
}
// NOTE: this should come AFTER any option that affects font metrics
QScopedPointer<QFontMetricsF> labelFontMetrics( new QFontMetricsF( labelFont ) );
std::unique_ptr<QFontMetricsF> labelFontMetrics( new QFontMetricsF( labelFont ) );
double labelX, labelY; // will receive label size
calculateLabelSize( labelFontMetrics.data(), labelText, labelX, labelY, mCurFeat, &context );
calculateLabelSize( labelFontMetrics.get(), labelText, labelX, labelY, mCurFeat, &context );
// maximum angle between curved label characters (hardcoded defaults used in QGIS <2.0)
@ -1391,7 +1391,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
// simplify?
const QgsVectorSimplifyMethod &simplifyMethod = context.vectorSimplifyMethod();
QScopedPointer<QgsGeometry> scopedClonedGeom;
std::unique_ptr<QgsGeometry> scopedClonedGeom;
if ( simplifyMethod.simplifyHints() != QgsVectorSimplifyMethod::NoSimplification && simplifyMethod.forceLocalOptimization() )
{
int simplifyHints = simplifyMethod.simplifyHints() | QgsMapToPixelSimplifier::SimplifyEnvelope;
@ -1444,13 +1444,13 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
}
geos_geom_clone = geom.exportToGeos();
QScopedPointer<QgsGeometry> scopedObstacleGeom;
std::unique_ptr<QgsGeometry> scopedObstacleGeom;
if ( isObstacle )
{
if ( obstacleGeometry && QgsPalLabeling::geometryRequiresPreparation( *obstacleGeometry, context, ct, doClip ? &extentGeom : nullptr ) )
{
scopedObstacleGeom.reset( new QgsGeometry( QgsPalLabeling::prepareGeometry( *obstacleGeometry, context, ct, doClip ? &extentGeom : nullptr ) ) );
obstacleGeometry = scopedObstacleGeom.data();
obstacleGeometry = scopedObstacleGeom.get();
}
}
@ -1818,7 +1818,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
// TODO: only for placement which needs character info
// account for any data defined font metrics adjustments
lf->calculateInfo( placement == QgsPalLayerSettings::Curved || placement == QgsPalLayerSettings::PerimeterCurved,
labelFontMetrics.data(), xform, maxcharanglein, maxcharangleout );
labelFontMetrics.get(), xform, maxcharanglein, maxcharangleout );
// for labelFeature the LabelInfo is passed to feat when it is registered
// TODO: allow layer-wide feature dist in PAL...?
@ -1942,7 +1942,7 @@ void QgsPalLayerSettings::registerObstacleFeature( QgsFeature& f, QgsRenderConte
// simplify?
const QgsVectorSimplifyMethod &simplifyMethod = context.vectorSimplifyMethod();
QScopedPointer<QgsGeometry> scopedClonedGeom;
std::unique_ptr<QgsGeometry> scopedClonedGeom;
if ( simplifyMethod.simplifyHints() != QgsVectorSimplifyMethod::NoSimplification && simplifyMethod.forceLocalOptimization() )
{
int simplifyHints = simplifyMethod.simplifyHints() | QgsMapToPixelSimplifier::SimplifyEnvelope;
@ -1952,7 +1952,7 @@ void QgsPalLayerSettings::registerObstacleFeature( QgsFeature& f, QgsRenderConte
}
GEOSGeometry* geos_geom_clone = nullptr;
QScopedPointer<QgsGeometry> scopedPreparedGeom;
std::unique_ptr<QgsGeometry> scopedPreparedGeom;
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, &extentGeom ) )
{

View File

@ -731,7 +731,7 @@ bool QgsProject::read()
{
clearError();
QScopedPointer<QDomDocument> doc( new QDomDocument( QStringLiteral( "qgis" ) ) );
std::unique_ptr<QDomDocument> doc( new QDomDocument( QStringLiteral( "qgis" ) ) );
if ( !mFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
@ -1156,7 +1156,7 @@ bool QgsProject::write()
QDomDocumentType documentType =
DomImplementation.createDocumentType( QStringLiteral( "qgis" ), QStringLiteral( "http://mrcc.com/qgis.dtd" ),
QStringLiteral( "SYSTEM" ) );
QScopedPointer<QDomDocument> doc( new QDomDocument( documentType ) );
std::unique_ptr<QDomDocument> doc( new QDomDocument( documentType ) );
QDomElement qgisNode = doc->createElement( QStringLiteral( "qgis" ) );
qgisNode.setAttribute( QStringLiteral( "projectname" ), title() );
@ -2109,12 +2109,12 @@ QgsLayerTreeGroup *QgsProject::layerTreeRoot() const
QgsMapThemeCollection* QgsProject::mapThemeCollection()
{
return mMapThemeCollection.data();
return mMapThemeCollection.get();
}
QgsAnnotationManager* QgsProject::annotationManager()
{
return mAnnotationManager.data();
return mAnnotationManager.get();
}
void QgsProject::setNonIdentifiableLayers( const QList<QgsMapLayer*>& layers )

View File

@ -962,7 +962,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
QgsRelationManager* mRelationManager;
QScopedPointer<QgsAnnotationManager> mAnnotationManager;
std::unique_ptr<QgsAnnotationManager> mAnnotationManager;
QgsLayerTreeGroup* mRootGroup;
@ -971,7 +971,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
//! map of transaction group: QPair( providerKey, connString ) -> transactionGroup
QMap< QPair< QString, QString>, QgsTransactionGroup*> mTransactionGroups;
QScopedPointer<QgsMapThemeCollection> mMapThemeCollection;
std::unique_ptr<QgsMapThemeCollection> mMapThemeCollection;
QVariantMap mCustomVariables;

View File

@ -681,11 +681,11 @@ bool QgsProperty::readXml( const QDomElement &propertyElem, const QDomDocument &
{
QDomElement transformerElem = transformerNodeList.at( 0 ).toElement();
QgsPropertyTransformer::Type type = static_cast< QgsPropertyTransformer::Type >( transformerElem.attribute( "t", "0" ).toInt() );
QScopedPointer< QgsPropertyTransformer > transformer( QgsPropertyTransformer::create( type ) );
std::unique_ptr< QgsPropertyTransformer > transformer( QgsPropertyTransformer::create( type ) );
if ( transformer )
{
if ( transformer->readXml( transformerElem, doc ) )
d->transformer = transformer.take();
d->transformer = transformer.release();
}
}

View File

@ -245,7 +245,7 @@ bool QgsColorRampTransformer::writeXml( QDomElement &transformerElem, QDomDocume
if ( mGradientRamp )
{
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( "[source]", mGradientRamp.data(), doc );
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( "[source]", mGradientRamp.get(), doc );
transformerElem.appendChild( colorRampElem );
}
transformerElem.setAttribute( "nullColor", QgsSymbolLayerUtils::encodeColor( mNullColor ) );
@ -317,7 +317,7 @@ QColor QgsColorRampTransformer::color( double value ) const
QgsColorRamp *QgsColorRampTransformer::colorRamp() const
{
return mGradientRamp.data();
return mGradientRamp.get();
}
void QgsColorRampTransformer::setColorRamp( QgsColorRamp* ramp )

View File

@ -25,6 +25,7 @@
#include <QDomElement>
#include <QDomDocument>
#include <QColor>
#include <memory>
class QgsColorRamp;
@ -362,7 +363,7 @@ class CORE_EXPORT QgsColorRampTransformer : public QgsPropertyTransformer
private:
QScopedPointer< QgsColorRamp > mGradientRamp;
std::unique_ptr< QgsColorRamp > mGradientRamp;
QColor mNullColor;
QString mRampName;

View File

@ -402,7 +402,7 @@ QgsDataProvider *QgsProviderRegistry::provider( QString const & providerKey, QSt
int QgsProviderRegistry::providerCapabilities( const QString &providerKey ) const
{
QScopedPointer< QLibrary > library( providerLibrary( providerKey ) );
std::unique_ptr< QLibrary > library( providerLibrary( providerKey ) );
if ( !library )
{
return QgsDataProvider::NoDataCapabilities;
@ -452,12 +452,12 @@ QFunctionPointer QgsProviderRegistry::function( QString const & providerKey,
QLibrary* QgsProviderRegistry::providerLibrary( QString const & providerKey ) const
{
QScopedPointer< QLibrary > myLib( new QLibrary( library( providerKey ) ) );
std::unique_ptr< QLibrary > myLib( new QLibrary( library( providerKey ) ) );
QgsDebugMsg( "Library name is " + myLib->fileName() );
if ( myLib->load() )
return myLib.take();
return myLib.release();
QgsDebugMsg( "Cannot load library: " + myLib->errorString() );

View File

@ -209,7 +209,7 @@ void QgsRenderContext::setFeatureFilterProvider( const QgsFeatureFilterProvider*
const QgsFeatureFilterProvider* QgsRenderContext::featureFilterProvider() const
{
return mFeatureFilterProvider.data();
return mFeatureFilterProvider.get();
}
double QgsRenderContext::convertToPainterUnits( double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale& scale ) const

View File

@ -20,6 +20,7 @@
#include "qgis_core.h"
#include <QColor>
#include <memory>
#include "qgsabstractgeometry.h"
#include "qgscoordinatetransform.h"
@ -335,7 +336,7 @@ class CORE_EXPORT QgsRenderContext
const QgsAbstractGeometry* mGeometry = nullptr;
//! The feature filter provider
QScopedPointer< QgsFeatureFilterProvider > mFeatureFilterProvider;
std::unique_ptr< QgsFeatureFilterProvider > mFeatureFilterProvider;
double mSegmentationTolerance = M_PI_2 / 90;

View File

@ -1841,11 +1841,11 @@ void QgsTextRenderer::drawBuffer( QgsRenderContext& context, const QgsTextRender
double QgsTextRenderer::textWidth( const QgsRenderContext& context, const QgsTextFormat& format, const QStringList &textLines, QFontMetricsF* fm )
{
//calculate max width of text lines
QScopedPointer< QFontMetricsF > newFm;
std::unique_ptr< QFontMetricsF > newFm;
if ( !fm )
{
newFm.reset( new QFontMetricsF( format.scaledFont( context ) ) );
fm = newFm.data();
fm = newFm.get();
}
double maxWidth = 0;
@ -1859,11 +1859,11 @@ double QgsTextRenderer::textWidth( const QgsRenderContext& context, const QgsTex
double QgsTextRenderer::textHeight( const QgsRenderContext& context, const QgsTextFormat& format, const QStringList& textLines, DrawMode mode, QFontMetricsF* fm )
{
//calculate max width of text lines
QScopedPointer< QFontMetricsF > newFm;
std::unique_ptr< QFontMetricsF > newFm;
if ( !fm )
{
newFm.reset( new QFontMetricsF( format.scaledFont( context ) ) );
fm = newFm.data();
fm = newFm.get();
}
double labelHeight = fm->ascent() + fm->descent(); // ignore +1 for baseline

View File

@ -29,7 +29,7 @@ typedef QgsTransaction* createTransaction_t( const QString& connString );
QgsTransaction* QgsTransaction::create( const QString& connString, const QString& providerKey )
{
QScopedPointer< QLibrary > lib( QgsProviderRegistry::instance()->providerLibrary( providerKey ) );
std::unique_ptr< QLibrary > lib( QgsProviderRegistry::instance()->providerLibrary( providerKey ) );
if ( !lib )
return nullptr;
@ -164,7 +164,7 @@ bool QgsTransaction::rollback( QString& errorMsg )
bool QgsTransaction::supportsTransaction( const QgsVectorLayer* layer )
{
QScopedPointer< QLibrary > lib( QgsProviderRegistry::instance()->providerLibrary( layer->providerType() ) );
std::unique_ptr< QLibrary > lib( QgsProviderRegistry::instance()->providerLibrary( layer->providerType() ) );
if ( !lib )
return false;

View File

@ -72,7 +72,7 @@ bool QgsTransactionGroup::modified() const
void QgsTransactionGroup::onEditingStarted()
{
if ( !mTransaction.isNull() )
if ( mTransaction )
return;
mTransaction.reset( QgsTransaction::create( mConnString, mProviderKey ) );

View File

@ -19,6 +19,7 @@
#include "qgis_core.h"
#include <QObject>
#include <QSet>
#include <memory>
#include "qgstransaction.h"
class QgsVectorLayer;
@ -89,7 +90,7 @@ class CORE_EXPORT QgsTransactionGroup : public QObject
QSet<QgsVectorLayer*> mLayers;
//! Only set while a transaction is active
QScopedPointer<QgsTransaction> mTransaction;
std::unique_ptr<QgsTransaction> mTransaction;
//! Layers have to be compatible with the connection string
QString mConnString;
QString mProviderKey;

View File

@ -3077,12 +3077,12 @@ QVariant QgsVectorLayer::defaultValue( int index, const QgsFeature& feature, Qgs
return mDataProvider->defaultValue( index );
QgsExpressionContext* evalContext = context;
QScopedPointer< QgsExpressionContext > tempContext;
std::unique_ptr< QgsExpressionContext > tempContext;
if ( !evalContext )
{
// no context passed, so we create a default one
tempContext.reset( new QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( this ) ) );
evalContext = tempContext.data();
evalContext = tempContext.get();
}
if ( feature.isValid() )
@ -3559,7 +3559,7 @@ QList<QVariant> QgsVectorLayer::getValues( const QString &fieldOrExpression, boo
{
QList<QVariant> values;
QScopedPointer<QgsExpression> expression;
std::unique_ptr<QgsExpression> expression;
QgsExpressionContext context;
int attrNum = mFields.lookupField( fieldOrExpression );
@ -3579,7 +3579,7 @@ QList<QVariant> QgsVectorLayer::getValues( const QString &fieldOrExpression, boo
QgsFeature f;
QSet<QString> lst;
if ( expression.isNull() )
if ( !expression )
lst.insert( fieldOrExpression );
else
lst = expression->referencedColumns();
@ -4272,7 +4272,7 @@ QList<QgsRelation> QgsVectorLayer::referencingRelations( int idx ) const
int QgsVectorLayer::listStylesInDatabase( QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError )
{
QScopedPointer<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
std::unique_ptr<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
if ( !myLib )
{
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
@ -4291,7 +4291,7 @@ int QgsVectorLayer::listStylesInDatabase( QStringList &ids, QStringList &names,
QString QgsVectorLayer::getStyleFromDatabase( const QString& styleId, QString &msgError )
{
QScopedPointer<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
std::unique_ptr<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
if ( !myLib )
{
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
@ -4310,7 +4310,7 @@ QString QgsVectorLayer::getStyleFromDatabase( const QString& styleId, QString &m
bool QgsVectorLayer::deleteStyleFromDatabase( const QString& styleId, QString &msgError )
{
QScopedPointer<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
std::unique_ptr<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
if ( !myLib )
{
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
@ -4331,7 +4331,7 @@ void QgsVectorLayer::saveStyleToDatabase( const QString& name, const QString& de
{
QString sldStyle, qmlStyle;
QScopedPointer<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
std::unique_ptr<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
if ( !myLib )
{
msgError = QObject::tr( "Unable to load %1 provider" ).arg( mProviderKey );
@ -4376,7 +4376,7 @@ QString QgsVectorLayer::loadNamedStyle( const QString &theURI, bool &theResultFl
QgsDataSourceUri dsUri( theURI );
if ( !loadFromLocalDB && mDataProvider && mDataProvider->isSaveAndLoadStyleToDBSupported() )
{
QScopedPointer<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
std::unique_ptr<QLibrary> myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) );
if ( myLib )
{
loadStyle_t* loadStyleExternalMethod = reinterpret_cast< loadStyle_t * >( cast_to_fptr( myLib->resolve( "loadStyle" ) ) );

View File

@ -215,11 +215,11 @@ QgsLabelFeature* QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature& fea
}
GEOSGeometry* geomCopy = nullptr;
QScopedPointer<QgsGeometry> scopedPreparedGeom;
std::unique_ptr<QgsGeometry> scopedPreparedGeom;
if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, mSettings.coordinateTransform(), &extentGeom ) )
{
scopedPreparedGeom.reset( new QgsGeometry( QgsPalLabeling::prepareGeometry( geom, context, mSettings.coordinateTransform(), &extentGeom ) ) );
QgsGeometry* preparedGeom = scopedPreparedGeom.data();
QgsGeometry* preparedGeom = scopedPreparedGeom.get();
if ( preparedGeom->isNull() )
return nullptr;
geomCopy = preparedGeom->exportToGeos();
@ -233,7 +233,7 @@ QgsLabelFeature* QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature& fea
return nullptr; // invalid geometry
GEOSGeometry* geosObstacleGeomClone = nullptr;
QScopedPointer<QgsGeometry> scopedObstacleGeom;
std::unique_ptr<QgsGeometry> scopedObstacleGeom;
if ( isObstacle && obstacleGeometry && QgsPalLabeling::geometryRequiresPreparation( *obstacleGeometry, context, mSettings.coordinateTransform(), &extentGeom ) )
{
QgsGeometry preparedObstacleGeom = QgsPalLabeling::prepareGeometry( *obstacleGeometry, context, mSettings.coordinateTransform(), &extentGeom );

View File

@ -550,7 +550,7 @@ void QgsVectorLayerFeatureIterator::prepareExpression( int fieldIdx )
exp->setDistanceUnits( QgsProject::instance()->distanceUnits() );
exp->setAreaUnits( QgsProject::instance()->areaUnits() );
exp->prepare( mExpressionContext.data() );
exp->prepare( mExpressionContext.get() );
mExpressionFieldInfo.insert( fieldIdx, exp );
Q_FOREACH ( const QString& col, exp->referencedColumns() )
@ -745,7 +745,7 @@ void QgsVectorLayerFeatureIterator::addExpressionAttribute( QgsFeature& f, int a
if ( exp )
{
mExpressionContext->setFeature( f );
QVariant val = exp->evaluate( mExpressionContext.data() );
QVariant val = exp->evaluate( mExpressionContext.get() );
mSource->mFields.at( attrIndex ).convertCompatible( val );
f.setAttribute( attrIndex, val );
}

View File

@ -20,6 +20,7 @@
#include "qgsfields.h"
#include <QSet>
#include <memory>
typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
@ -200,7 +201,7 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera
bool mHasVirtualAttributes;
private:
QScopedPointer<QgsExpressionContext> mExpressionContext;
std::unique_ptr<QgsExpressionContext> mExpressionContext;
QgsInterruptionChecker* mInterruptionChecker;

View File

@ -63,7 +63,7 @@ QgsVectorLayerImport::QgsVectorLayerImport( const QString &uri,
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
QScopedPointer< QLibrary > myLib( pReg->providerLibrary( providerKey ) );
std::unique_ptr< QLibrary > myLib( pReg->providerLibrary( providerKey ) );
if ( !myLib )
{
mError = ErrInvalidProvider;

View File

@ -229,7 +229,7 @@ QList<QgsLabelFeature*> QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCon
QgsFeature fet;
while ( fit.nextFeature( fet ) )
{
QScopedPointer<QgsGeometry> obstacleGeometry;
std::unique_ptr<QgsGeometry> obstacleGeometry;
if ( mRenderer )
{
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, ctx );
@ -244,7 +244,7 @@ QList<QgsLabelFeature*> QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCon
}
}
ctx.expressionContext().setFeature( fet );
registerFeature( fet, ctx, obstacleGeometry.data() );
registerFeature( fet, ctx, obstacleGeometry.get() );
}
if ( ctx.expressionContext().lastScope() == symbolScope )

View File

@ -317,7 +317,7 @@ void QgsVectorLayerRenderer::drawRenderer( QgsFeatureIterator& fit )
// new labeling engine
if ( mContext.labelingEngine() && ( mLabelProvider || mDiagramProvider ) )
{
QScopedPointer<QgsGeometry> obstacleGeometry;
std::unique_ptr<QgsGeometry> obstacleGeometry;
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, mContext );
if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
@ -332,11 +332,11 @@ void QgsVectorLayerRenderer::drawRenderer( QgsFeatureIterator& fit )
if ( mLabelProvider )
{
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
}
if ( mDiagramProvider )
{
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
}
}
}
@ -407,7 +407,7 @@ void QgsVectorLayerRenderer::drawRendererLevels( QgsFeatureIterator& fit )
// new labeling engine
if ( mContext.labelingEngine() )
{
QScopedPointer<QgsGeometry> obstacleGeometry;
std::unique_ptr<QgsGeometry> obstacleGeometry;
QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, mContext );
if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
@ -422,11 +422,11 @@ void QgsVectorLayerRenderer::drawRendererLevels( QgsFeatureIterator& fit )
if ( mLabelProvider )
{
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
mLabelProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
}
if ( mDiagramProvider )
{
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.data() );
mDiagramProvider->registerFeature( fet, mContext, obstacleGeometry.get() );
}
}
}

View File

@ -235,12 +235,12 @@ QgsFeature QgsVectorLayerUtils::createFeature( QgsVectorLayer* layer, const QgsG
}
QgsExpressionContext* evalContext = context;
QScopedPointer< QgsExpressionContext > tempContext;
std::unique_ptr< QgsExpressionContext > tempContext;
if ( !evalContext )
{
// no context passed, so we create a default one
tempContext.reset( new QgsExpressionContext( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) ) );
evalContext = tempContext.data();
evalContext = tempContext.get();
}
QgsFields fields = layer->fields();

View File

@ -115,7 +115,7 @@ void QgsColorRampShader::setColorRampType( const QString& theType )
QgsColorRamp* QgsColorRampShader::sourceColorRamp() const
{
return mSourceColorRamp.data();
return mSourceColorRamp.get();
}
void QgsColorRampShader::setSourceColorRamp( QgsColorRamp* colorramp )

View File

@ -24,6 +24,7 @@ originally part of the larger QgsRasterLayer class
#include "qgis_core.h"
#include <QColor>
#include <QVector>
#include <memory>
#include "qgscolorramp.h"
#include "qgsrasterinterface.h"
@ -169,7 +170,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
protected:
//! Source color ramp
QScopedPointer<QgsColorRamp> mSourceColorRamp;
std::unique_ptr<QgsColorRamp> mSourceColorRamp;
private:

View File

@ -926,7 +926,7 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh
if ( myBand != -1 )
{
Qgis::DataType myType = static_cast< Qgis::DataType >( mDataProvider->dataType( myBand ) );
QScopedPointer<QgsContrastEnhancement> myEnhancement( new QgsContrastEnhancement( static_cast< Qgis::DataType >( myType ) ) );
std::unique_ptr<QgsContrastEnhancement> myEnhancement( new QgsContrastEnhancement( static_cast< Qgis::DataType >( myType ) ) );
myEnhancement->setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );
double min;
@ -950,7 +950,7 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh
{
myEnhancement->setMinimumValue( min );
myEnhancement->setMaximumValue( max );
myEnhancements.append( myEnhancement.take() );
myEnhancements.append( myEnhancement.release() );
}
}
else

View File

@ -116,7 +116,7 @@ QDomElement Qgs25DRenderer::save( QDomDocument& doc )
rendererElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "25dRenderer" ) );
QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "symbol" ), mSymbol.data(), doc );
QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "symbol" ), mSymbol.get(), doc );
rendererElem.appendChild( symbolElem );
@ -162,14 +162,14 @@ QgsSymbol*Qgs25DRenderer::symbolForFeature( QgsFeature& feature, QgsRenderContex
{
Q_UNUSED( feature )
Q_UNUSED( context )
return mSymbol.data();
return mSymbol.get();
}
QgsSymbolList Qgs25DRenderer::symbols( QgsRenderContext& context )
{
Q_UNUSED( context );
QgsSymbolList lst;
lst.append( mSymbol.data() );
lst.append( mSymbol.get() );
return lst;
}

View File

@ -119,7 +119,7 @@ class CORE_EXPORT Qgs25DRenderer : public QgsFeatureRenderer
QgsFillSymbolLayer* wallLayer() const;
QgsOuterGlowEffect* glowEffect() const;
QScopedPointer<QgsSymbol> mSymbol;
std::unique_ptr<QgsSymbol> mSymbol;
};
#endif // QGS25DRENDERER_H

View File

@ -696,7 +696,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolRend
return;
}
context.renderContext().expressionContext().appendScope( mExpressionScope.data() );
context.renderContext().expressionContext().appendScope( mExpressionScope.get() );
mExpressionScope->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_COUNT, points.size() + 1, true ) );
mExpressionScope->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_NUM, 1, true ) );
if ( isCurved() )
@ -802,7 +802,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolRend
void QgsArrowSymbolLayer::setColor( const QColor& c )
{
if ( mSymbol.data() )
if ( mSymbol.get() )
mSymbol->setColor( c );
mColor = c;
@ -810,6 +810,6 @@ void QgsArrowSymbolLayer::setColor( const QColor& c )
QColor QgsArrowSymbolLayer::color() const
{
return mSymbol.data() ? mSymbol->color() : mColor;
return mSymbol.get() ? mSymbol->color() : mColor;
}

View File

@ -42,7 +42,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
static QgsSymbolLayer* create( const QgsStringMap& properties = QgsStringMap() );
virtual QgsArrowSymbolLayer* clone() const override;
virtual QgsSymbol* subSymbol() override { return mSymbol.data(); }
virtual QgsSymbol* subSymbol() override { return mSymbol.get(); }
virtual bool setSubSymbol( QgsSymbol* symbol ) override;
virtual QSet<QString> usedAttributes( const QgsRenderContext& context ) const override;
@ -144,7 +144,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
private:
//! Filling sub symbol
QScopedPointer<QgsFillSymbol> mSymbol;
std::unique_ptr<QgsFillSymbol> mSymbol;
double mArrowWidth;
QgsUnitTypes::RenderUnit mArrowWidthUnit;
@ -174,7 +174,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
HeadType mComputedHeadType;
ArrowType mComputedArrowType;
QScopedPointer<QgsExpressionContextScope> mExpressionScope;
std::unique_ptr<QgsExpressionContextScope> mExpressionScope;
void _resolveDataDefined( QgsSymbolRenderContext& );
};

View File

@ -49,7 +49,7 @@ QgsRendererCategory::QgsRendererCategory( const QVariant& value, QgsSymbol* symb
QgsRendererCategory::QgsRendererCategory( const QgsRendererCategory& cat )
: mValue( cat.mValue )
, mSymbol( cat.mSymbol.data() ? cat.mSymbol->clone() : nullptr )
, mSymbol( cat.mSymbol ? cat.mSymbol->clone() : nullptr )
, mLabel( cat.mLabel )
, mRender( cat.mRender )
{
@ -76,7 +76,7 @@ QVariant QgsRendererCategory::value() const
QgsSymbol* QgsRendererCategory::symbol() const
{
return mSymbol.data();
return mSymbol.get();
}
QString QgsRendererCategory::label() const
@ -96,7 +96,7 @@ void QgsRendererCategory::setValue( const QVariant &value )
void QgsRendererCategory::setSymbol( QgsSymbol* s )
{
if ( mSymbol.data() != s ) mSymbol.reset( s );
if ( mSymbol.get() != s ) mSymbol.reset( s );
}
void QgsRendererCategory::setLabel( const QString &label )
@ -116,7 +116,7 @@ QString QgsRendererCategory::dump() const
void QgsRendererCategory::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
{
if ( !mSymbol.data() || props.value( QStringLiteral( "attribute" ), QLatin1String( "" ) ).isEmpty() )
if ( !mSymbol.get() || props.value( QStringLiteral( "attribute" ), QLatin1String( "" ) ).isEmpty() )
return;
QString attrName = props[ QStringLiteral( "attribute" )];
@ -219,7 +219,7 @@ QVariant QgsCategorizedSymbolRenderer::valueForFeature( QgsFeature& feature, Qgs
QVariant value;
if ( mAttrNum == -1 )
{
Q_ASSERT( mExpression.data() );
Q_ASSERT( mExpression );
value = mExpression->evaluate( &context.expressionContext() );
}
@ -462,9 +462,9 @@ QString QgsCategorizedSymbolRenderer::dump() const
QgsCategorizedSymbolRenderer* QgsCategorizedSymbolRenderer::clone() const
{
QgsCategorizedSymbolRenderer* r = new QgsCategorizedSymbolRenderer( mAttrName, mCategories );
if ( mSourceSymbol.data() )
if ( mSourceSymbol )
r->setSourceSymbol( mSourceSymbol->clone() );
if ( mSourceColorRamp.data() )
if ( mSourceColorRamp )
{
r->setSourceColorRamp( mSourceColorRamp->clone() );
}
@ -634,9 +634,9 @@ QgsFeatureRenderer* QgsCategorizedSymbolRenderer::create( QDomElement& element )
{
convertSymbolRotation( cat.symbol(), rotationElem.attribute( QStringLiteral( "field" ) ) );
}
if ( r->mSourceSymbol.data() )
if ( r->mSourceSymbol )
{
convertSymbolRotation( r->mSourceSymbol.data(), rotationElem.attribute( QStringLiteral( "field" ) ) );
convertSymbolRotation( r->mSourceSymbol.get(), rotationElem.attribute( QStringLiteral( "field" ) ) );
}
}
@ -649,9 +649,9 @@ QgsFeatureRenderer* QgsCategorizedSymbolRenderer::create( QDomElement& element )
QgsSymbolLayerUtils::decodeScaleMethod( sizeScaleElem.attribute( QStringLiteral( "scalemethod" ) ) ),
sizeScaleElem.attribute( QStringLiteral( "field" ) ) );
}
if ( r->mSourceSymbol.data() && r->mSourceSymbol->type() == QgsSymbol::Marker )
if ( r->mSourceSymbol && r->mSourceSymbol->type() == QgsSymbol::Marker )
{
convertSymbolSizeScale( r->mSourceSymbol.data(),
convertSymbolSizeScale( r->mSourceSymbol.get(),
QgsSymbolLayerUtils::decodeScaleMethod( sizeScaleElem.attribute( QStringLiteral( "scalemethod" ) ) ),
sizeScaleElem.attribute( QStringLiteral( "field" ) ) );
}
@ -699,18 +699,18 @@ QDomElement QgsCategorizedSymbolRenderer::save( QDomDocument& doc )
}
// save source symbol
if ( mSourceSymbol.data() )
if ( mSourceSymbol )
{
QgsSymbolMap sourceSymbols;
sourceSymbols.insert( QStringLiteral( "0" ), mSourceSymbol.data() );
sourceSymbols.insert( QStringLiteral( "0" ), mSourceSymbol.get() );
QDomElement sourceSymbolElem = QgsSymbolLayerUtils::saveSymbols( sourceSymbols, QStringLiteral( "source-symbol" ), doc );
rendererElem.appendChild( sourceSymbolElem );
}
// save source color ramp
if ( mSourceColorRamp.data() )
if ( mSourceColorRamp )
{
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( QStringLiteral( "[source]" ), mSourceColorRamp.data(), doc );
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( QStringLiteral( "[source]" ), mSourceColorRamp.get(), doc );
rendererElem.appendChild( colorRampElem );
}
@ -766,7 +766,7 @@ QgsLegendSymbolList QgsCategorizedSymbolRenderer::legendSymbolItems( double scal
QgsLegendSymbolListV2 QgsCategorizedSymbolRenderer::legendSymbolItemsV2() const
{
QgsLegendSymbolListV2 lst;
if ( mSourceSymbol.data() && mSourceSymbol->type() == QgsSymbol::Marker )
if ( mSourceSymbol && mSourceSymbol->type() == QgsSymbol::Marker )
{
// check that all symbols that have the same size expression
QgsProperty ddSize;
@ -800,7 +800,7 @@ QgsLegendSymbolListV2 QgsCategorizedSymbolRenderer::legendSymbolItemsV2() const
lst << title;
Q_FOREACH ( double v, QgsSymbolLayerUtils::prettyBreaks( exp.minValue(), exp.maxValue(), 4 ) )
{
QgsLegendSymbolItem si( mSourceSymbol.data(), QString::number( v ), QLatin1String( "" ) );
QgsLegendSymbolItem si( mSourceSymbol.get(), QString::number( v ), QLatin1String( "" ) );
QgsMarkerSymbol * s = static_cast<QgsMarkerSymbol *>( si.symbol() );
s->setDataDefinedSize( QgsProperty() );
s->setSize( exp.size( v ) );
@ -839,7 +839,7 @@ QSet<QString> QgsCategorizedSymbolRenderer::legendKeysForFeature( QgsFeature& fe
QgsSymbol* QgsCategorizedSymbolRenderer::sourceSymbol()
{
return mSourceSymbol.data();
return mSourceSymbol.get();
}
void QgsCategorizedSymbolRenderer::setSourceSymbol( QgsSymbol* sym )
{
@ -848,7 +848,7 @@ void QgsCategorizedSymbolRenderer::setSourceSymbol( QgsSymbol* sym )
QgsColorRamp* QgsCategorizedSymbolRenderer::sourceColorRamp()
{
return mSourceColorRamp.data();
return mSourceColorRamp.get();
}
void QgsCategorizedSymbolRenderer::setSourceColorRamp( QgsColorRamp* ramp )

View File

@ -61,7 +61,7 @@ class CORE_EXPORT QgsRendererCategory
protected:
QVariant mValue;
QScopedPointer<QgsSymbol> mSymbol;
std::unique_ptr<QgsSymbol> mSymbol;
QString mLabel;
bool mRender;
@ -184,9 +184,9 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer
protected:
QString mAttrName;
QgsCategoryList mCategories;
QScopedPointer<QgsSymbol> mSourceSymbol;
QScopedPointer<QgsColorRamp> mSourceColorRamp;
QScopedPointer<QgsExpression> mExpression;
std::unique_ptr<QgsSymbol> mSourceSymbol;
std::unique_ptr<QgsColorRamp> mSourceColorRamp;
std::unique_ptr<QgsExpression> mExpression;
//! attribute index (derived from attribute name in startRender)
int mAttrNum;

View File

@ -95,7 +95,7 @@ class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsSymbolLayer
private:
QgsGeometryGeneratorSymbolLayer( const QString& expression );
QScopedPointer<QgsExpression> mExpression;
std::unique_ptr<QgsExpression> mExpression;
QgsFillSymbol* mFillSymbol;
QgsLineSymbol* mLineSymbol;
QgsMarkerSymbol* mMarkerSymbol;

View File

@ -58,7 +58,7 @@ QgsRendererRange::QgsRendererRange( double lowerValue, double upperValue, QgsSym
QgsRendererRange::QgsRendererRange( const QgsRendererRange& range )
: mLowerValue( range.mLowerValue )
, mUpperValue( range.mUpperValue )
, mSymbol( range.mSymbol.data() ? range.mSymbol->clone() : nullptr )
, mSymbol( range.mSymbol ? range.mSymbol->clone() : nullptr )
, mLabel( range.mLabel )
, mRender( range.mRender )
{
@ -99,7 +99,7 @@ double QgsRendererRange::upperValue() const
QgsSymbol* QgsRendererRange::symbol() const
{
return mSymbol.data();
return mSymbol.get();
}
QString QgsRendererRange::label() const
@ -109,7 +109,7 @@ QString QgsRendererRange::label() const
void QgsRendererRange::setSymbol( QgsSymbol* s )
{
if ( mSymbol.data() != s ) mSymbol.reset( s );
if ( mSymbol.get() != s ) mSymbol.reset( s );
}
void QgsRendererRange::setLabel( const QString& label )
@ -139,12 +139,12 @@ void QgsRendererRange::setRenderState( bool render )
QString QgsRendererRange::dump() const
{
return QStringLiteral( "%1 - %2::%3::%4\n" ).arg( mLowerValue ).arg( mUpperValue ).arg( mLabel, mSymbol.data() ? mSymbol->dump() : QStringLiteral( "(no symbol)" ) );
return QStringLiteral( "%1 - %2::%3::%4\n" ).arg( mLowerValue ).arg( mUpperValue ).arg( mLabel, mSymbol ? mSymbol->dump() : QStringLiteral( "(no symbol)" ) );
}
void QgsRendererRange::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props, bool firstRange ) const
{
if ( !mSymbol.data() || props.value( QStringLiteral( "attribute" ), QLatin1String( "" ) ).isEmpty() )
if ( mSymbol || props.value( QStringLiteral( "attribute" ), QLatin1String( "" ) ).isEmpty() )
return;
QString attrName = props[ QStringLiteral( "attribute" )];
@ -495,9 +495,9 @@ QgsGraduatedSymbolRenderer* QgsGraduatedSymbolRenderer::clone() const
{
QgsGraduatedSymbolRenderer* r = new QgsGraduatedSymbolRenderer( mAttrName, mRanges );
r->setMode( mMode );
if ( mSourceSymbol.data() )
if ( mSourceSymbol )
r->setSourceSymbol( mSourceSymbol->clone() );
if ( mSourceColorRamp.data() )
if ( mSourceColorRamp )
{
r->setSourceColorRamp( mSourceColorRamp->clone() );
}
@ -1007,9 +1007,9 @@ QgsFeatureRenderer* QgsGraduatedSymbolRenderer::create( QDomElement& element )
{
convertSymbolRotation( range.symbol(), rotationElem.attribute( QStringLiteral( "field" ) ) );
}
if ( r->mSourceSymbol.data() )
if ( r->mSourceSymbol )
{
convertSymbolRotation( r->mSourceSymbol.data(), rotationElem.attribute( QStringLiteral( "field" ) ) );
convertSymbolRotation( r->mSourceSymbol.get(), rotationElem.attribute( QStringLiteral( "field" ) ) );
}
}
@ -1022,9 +1022,9 @@ QgsFeatureRenderer* QgsGraduatedSymbolRenderer::create( QDomElement& element )
QgsSymbolLayerUtils::decodeScaleMethod( sizeScaleElem.attribute( QStringLiteral( "scalemethod" ) ) ),
sizeScaleElem.attribute( QStringLiteral( "field" ) ) );
}
if ( r->mSourceSymbol.data() && r->mSourceSymbol->type() == QgsSymbol::Marker )
if ( r->mSourceSymbol && r->mSourceSymbol->type() == QgsSymbol::Marker )
{
convertSymbolSizeScale( r->mSourceSymbol.data(),
convertSymbolSizeScale( r->mSourceSymbol.get(),
QgsSymbolLayerUtils::decodeScaleMethod( sizeScaleElem.attribute( QStringLiteral( "scalemethod" ) ) ),
sizeScaleElem.attribute( QStringLiteral( "field" ) ) );
}
@ -1078,18 +1078,18 @@ QDomElement QgsGraduatedSymbolRenderer::save( QDomDocument& doc )
rendererElem.appendChild( symbolsElem );
// save source symbol
if ( mSourceSymbol.data() )
if ( mSourceSymbol )
{
QgsSymbolMap sourceSymbols;
sourceSymbols.insert( QStringLiteral( "0" ), mSourceSymbol.data() );
sourceSymbols.insert( QStringLiteral( "0" ), mSourceSymbol.get() );
QDomElement sourceSymbolElem = QgsSymbolLayerUtils::saveSymbols( sourceSymbols, QStringLiteral( "source-symbol" ), doc );
rendererElem.appendChild( sourceSymbolElem );
}
// save source color ramp
if ( mSourceColorRamp.data() )
if ( mSourceColorRamp )
{
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( QStringLiteral( "[source]" ), mSourceColorRamp.data(), doc );
QDomElement colorRampElem = QgsSymbolLayerUtils::saveColorRamp( QStringLiteral( "[source]" ), mSourceColorRamp.get(), doc );
rendererElem.appendChild( colorRampElem );
}
@ -1153,7 +1153,7 @@ QgsLegendSymbologyList QgsGraduatedSymbolRenderer::legendSymbologyItems( QSize i
QgsLegendSymbolListV2 QgsGraduatedSymbolRenderer::legendSymbolItemsV2() const
{
QgsLegendSymbolListV2 list;
if ( mSourceSymbol.data() && mSourceSymbol->type() == QgsSymbol::Marker )
if ( mSourceSymbol && mSourceSymbol->type() == QgsSymbol::Marker )
{
// check that all symbols that have the same size expression
QgsProperty ddSize;
@ -1187,7 +1187,7 @@ QgsLegendSymbolListV2 QgsGraduatedSymbolRenderer::legendSymbolItemsV2() const
list << title;
Q_FOREACH ( double v, QgsSymbolLayerUtils::prettyBreaks( exp.minValue(), exp.maxValue(), 4 ) )
{
QgsLegendSymbolItem si( mSourceSymbol.data(), QString::number( v ), QLatin1String( "" ) );
QgsLegendSymbolItem si( mSourceSymbol.get(), QString::number( v ), QLatin1String( "" ) );
QgsMarkerSymbol * s = static_cast<QgsMarkerSymbol *>( si.symbol() );
s->setDataDefinedSize( QgsProperty() );
s->setSize( exp.size( v ) );
@ -1237,7 +1237,7 @@ QgsLegendSymbolList QgsGraduatedSymbolRenderer::legendSymbolItems( double scaleD
QgsSymbol* QgsGraduatedSymbolRenderer::sourceSymbol()
{
return mSourceSymbol.data();
return mSourceSymbol.get();
}
void QgsGraduatedSymbolRenderer::setSourceSymbol( QgsSymbol* sym )
{
@ -1246,7 +1246,7 @@ void QgsGraduatedSymbolRenderer::setSourceSymbol( QgsSymbol* sym )
QgsColorRamp* QgsGraduatedSymbolRenderer::sourceColorRamp()
{
return mSourceColorRamp.data();
return mSourceColorRamp.get();
}
void QgsGraduatedSymbolRenderer::setSourceColorRamp( QgsColorRamp* ramp )
@ -1288,15 +1288,15 @@ void QgsGraduatedSymbolRenderer::setSymbolSizes( double minSize, double maxSize
{
for ( int i = 0; i < mRanges.count(); i++ )
{
QScopedPointer<QgsSymbol> symbol( mRanges.at( i ).symbol() ? mRanges.at( i ).symbol()->clone() : nullptr );
std::unique_ptr<QgsSymbol> symbol( mRanges.at( i ).symbol() ? mRanges.at( i ).symbol()->clone() : nullptr );
const double size = mRanges.count() > 1
? minSize + i * ( maxSize - minSize ) / ( mRanges.count() - 1 )
: .5 * ( maxSize + minSize );
if ( symbol->type() == QgsSymbol::Marker )
static_cast< QgsMarkerSymbol * >( symbol.data() )->setSize( size );
static_cast< QgsMarkerSymbol * >( symbol.get() )->setSize( size );
if ( symbol->type() == QgsSymbol::Line )
static_cast< QgsLineSymbol * >( symbol.data() )->setWidth( size );
updateRangeSymbol( i, symbol.take() );
static_cast< QgsLineSymbol * >( symbol.get() )->setWidth( size );
updateRangeSymbol( i, symbol.release() );
}
}
@ -1334,7 +1334,7 @@ void QgsGraduatedSymbolRenderer::updateSymbols( QgsSymbol *sym )
int i = 0;
Q_FOREACH ( const QgsRendererRange& range, mRanges )
{
QScopedPointer<QgsSymbol> symbol( sym->clone() );
std::unique_ptr<QgsSymbol> symbol( sym->clone() );
if ( mGraduatedMethod == GraduatedColor )
{
symbol->setColor( range.symbol()->color() );
@ -1342,13 +1342,13 @@ void QgsGraduatedSymbolRenderer::updateSymbols( QgsSymbol *sym )
else if ( mGraduatedMethod == GraduatedSize )
{
if ( symbol->type() == QgsSymbol::Marker )
static_cast<QgsMarkerSymbol *>( symbol.data() )->setSize(
static_cast<QgsMarkerSymbol *>( symbol.get() )->setSize(
static_cast<QgsMarkerSymbol *>( range.symbol() )->size() );
else if ( symbol->type() == QgsSymbol::Line )
static_cast<QgsLineSymbol *>( symbol.data() )->setWidth(
static_cast<QgsLineSymbol *>( symbol.get() )->setWidth(
static_cast<QgsLineSymbol *>( range.symbol() )->width() );
}
updateRangeSymbol( i, symbol.take() );
updateRangeSymbol( i, symbol.release() );
++i;
}
setSourceSymbol( sym->clone() );
@ -1431,7 +1431,7 @@ void QgsGraduatedSymbolRenderer::addBreak( double breakValue, bool updateSymbols
switch ( mGraduatedMethod )
{
case GraduatedColor:
updateColorRamp( mSourceColorRamp.data() );
updateColorRamp( mSourceColorRamp.get() );
break;
case GraduatedSize:
setSymbolSizes( minSymbolSize(), maxSymbolSize() );

View File

@ -66,7 +66,7 @@ class CORE_EXPORT QgsRendererRange
protected:
double mLowerValue, mUpperValue;
QScopedPointer<QgsSymbol> mSymbol;
std::unique_ptr<QgsSymbol> mSymbol;
QString mLabel;
bool mRender;
@ -333,11 +333,11 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer
QString mAttrName;
QgsRangeList mRanges;
Mode mMode;
QScopedPointer<QgsSymbol> mSourceSymbol;
QScopedPointer<QgsColorRamp> mSourceColorRamp;
std::unique_ptr<QgsSymbol> mSourceSymbol;
std::unique_ptr<QgsColorRamp> mSourceColorRamp;
QgsRendererRangeLabelFormat mLabelFormat;
QScopedPointer<QgsExpression> mExpression;
std::unique_ptr<QgsExpression> mExpression;
GraduatedMethod mGraduatedMethod;
//! attribute index (derived from attribute name in startRender)
int mAttrNum;

View File

@ -121,7 +121,7 @@ bool QgsHeatmapRenderer::renderFeature( QgsFeature& feature, QgsRenderContext& c
QVariant value;
if ( mWeightAttrNum == -1 )
{
Q_ASSERT( mWeightExpression.data() );
Q_ASSERT( mWeightExpression.get() );
value = mWeightExpression->evaluate( &context.expressionContext() );
}
else

View File

@ -177,7 +177,7 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer
QString mWeightExpressionString;
int mWeightAttrNum;
QScopedPointer<QgsExpression> mWeightExpression;
std::unique_ptr<QgsExpression> mWeightExpression;
QgsColorRamp* mGradientRamp;

View File

@ -57,7 +57,7 @@ void QgsInvertedPolygonRenderer::setEmbeddedRenderer( QgsFeatureRenderer* subRen
const QgsFeatureRenderer* QgsInvertedPolygonRenderer::embeddedRenderer() const
{
return mSubRenderer.data();
return mSubRenderer.get();
}
void QgsInvertedPolygonRenderer::setLegendSymbolItem( const QString& key, QgsSymbol* symbol )
@ -360,13 +360,13 @@ QString QgsInvertedPolygonRenderer::dump() const
QgsInvertedPolygonRenderer* QgsInvertedPolygonRenderer::clone() const
{
QgsInvertedPolygonRenderer* newRenderer;
if ( mSubRenderer.isNull() )
if ( !mSubRenderer )
{
newRenderer = new QgsInvertedPolygonRenderer( nullptr );
}
else
{
newRenderer = new QgsInvertedPolygonRenderer( mSubRenderer.data()->clone() );
newRenderer = new QgsInvertedPolygonRenderer( mSubRenderer.get()->clone() );
}
newRenderer->setPreprocessingEnabled( preprocessingEnabled() );
copyRendererData( newRenderer );

View File

@ -144,7 +144,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer
private:
//! Embedded renderer
QScopedPointer<QgsFeatureRenderer> mSubRenderer;
std::unique_ptr<QgsFeatureRenderer> mSubRenderer;
//! Structure where the reversed geometry is built during renderFeature
struct CombinedFeature

View File

@ -1554,7 +1554,7 @@ QString QgsFilledMarkerSymbolLayer::layerType() const
void QgsFilledMarkerSymbolLayer::startRender( QgsSymbolRenderContext &context )
{
if ( mFill.data() )
if ( mFill.get() )
{
mFill->startRender( context.renderContext(), context.fields() );
}
@ -1564,7 +1564,7 @@ void QgsFilledMarkerSymbolLayer::startRender( QgsSymbolRenderContext &context )
void QgsFilledMarkerSymbolLayer::stopRender( QgsSymbolRenderContext& context )
{
if ( mFill.data() )
if ( mFill.get() )
{
mFill->stopRender( context.renderContext() );
}
@ -1585,7 +1585,7 @@ QgsStringMap QgsFilledMarkerSymbolLayer::properties() const
map[QStringLiteral( "horizontal_anchor_point" )] = QString::number( mHorizontalAnchorPoint );
map[QStringLiteral( "vertical_anchor_point" )] = QString::number( mVerticalAnchorPoint );
if ( mFill.data() )
if ( mFill )
{
map[QStringLiteral( "color" )] = QgsSymbolLayerUtils::encodeColor( mFill->color() );
}
@ -1603,7 +1603,7 @@ QgsFilledMarkerSymbolLayer *QgsFilledMarkerSymbolLayer::clone() const
QgsSymbol* QgsFilledMarkerSymbolLayer::subSymbol()
{
return mFill.data();
return mFill.get();
}
bool QgsFilledMarkerSymbolLayer::setSubSymbol( QgsSymbol *symbol )
@ -1622,9 +1622,9 @@ bool QgsFilledMarkerSymbolLayer::setSubSymbol( QgsSymbol *symbol )
double QgsFilledMarkerSymbolLayer::estimateMaxBleed( const QgsRenderContext& context ) const
{
if ( mFill.data() )
if ( mFill )
{
return QgsSymbolLayerUtils::estimateMaxSymbolBleed( mFill.data(), context );
return QgsSymbolLayerUtils::estimateMaxSymbolBleed( mFill.get(), context );
}
return 0;
}
@ -1632,7 +1632,7 @@ double QgsFilledMarkerSymbolLayer::estimateMaxBleed( const QgsRenderContext& con
QSet<QString> QgsFilledMarkerSymbolLayer::usedAttributes( const QgsRenderContext& context ) const
{
QSet<QString> attr = QgsSimpleMarkerSymbolLayerBase::usedAttributes( context );
if ( mFill.data() )
if ( mFill )
attr.unite( mFill->usedAttributes( context ) );
return attr;
}
@ -1640,13 +1640,13 @@ QSet<QString> QgsFilledMarkerSymbolLayer::usedAttributes( const QgsRenderContext
void QgsFilledMarkerSymbolLayer::setColor( const QColor& c )
{
mColor = c;
if ( mFill.data() )
if ( mFill )
mFill->setColor( c );
}
QColor QgsFilledMarkerSymbolLayer::color() const
{
return mFill.data() ? mFill->color() : mColor;
return mFill ? mFill->color() : mColor;
}
void QgsFilledMarkerSymbolLayer::draw( QgsSymbolRenderContext &context, QgsSimpleMarkerSymbolLayerBase::Shape shape, const QPolygonF &polygon, const QPainterPath &path )

View File

@ -430,7 +430,7 @@ class CORE_EXPORT QgsFilledMarkerSymbolLayer : public QgsSimpleMarkerSymbolLayer
virtual void draw( QgsSymbolRenderContext& context, Shape shape, const QPolygonF& polygon, const QPainterPath& path ) override;
//! Fill subsymbol
QScopedPointer< QgsFillSymbol > mFill;
std::unique_ptr< QgsFillSymbol > mFill;
};
//////////

View File

@ -48,7 +48,7 @@ bool QgsNullSymbolRenderer::renderFeature( QgsFeature &feature, QgsRenderContext
feature.geometry().type() == QgsWkbTypes::UnknownGeometry )
return true;
if ( mSymbol.isNull() )
if ( !mSymbol )
{
//create default symbol
mSymbol.reset( QgsSymbol::defaultSymbol( feature.geometry().type() ) );
@ -68,7 +68,7 @@ void QgsNullSymbolRenderer::startRender( QgsRenderContext& context, const QgsFie
void QgsNullSymbolRenderer::stopRender( QgsRenderContext& context )
{
if ( mSymbol.data() )
if ( mSymbol.get() )
{
mSymbol->stopRender( context );
}

Some files were not shown because too many files have changed in this diff Show More