diff --git a/src/app/composer/qgscomposer.cpp b/src/app/composer/qgscomposer.cpp index b866028dbb0..1c5ace70ca3 100644 --- a/src/app/composer/qgscomposer.cpp +++ b/src/app/composer/qgscomposer.cpp @@ -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(); diff --git a/src/app/dwg/qgsdwgimportdialog.cpp b/src/app/dwg/qgsdwgimportdialog.cpp index 0ef19c62179..1fe7d43fd08 100644 --- a/src/app/dwg/qgsdwgimportdialog.cpp +++ b/src/app/dwg/qgsdwgimportdialog.cpp @@ -155,7 +155,7 @@ void QgsDwgImportDialog::on_pbLoadDatabase_clicked() bool lblVisible = false; - QScopedPointer d( new QgsVectorLayer( QString( "%1|layername=drawing" ).arg( leDatabase->text() ), "layers", "ogr", false ) ); + std::unique_ptr 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 l( new QgsVectorLayer( QString( "%1|layername=layers" ).arg( leDatabase->text() ), "layers", "ogr", false ) ); + std::unique_ptr l( new QgsVectorLayer( QString( "%1|layername=layers" ).arg( leDatabase->text() ), "layers", "ogr", false ) ); if ( l && l->isValid() ) { int idxName = l->fields().lookupField( "name" ); diff --git a/src/app/dwg/qgsdwgimporter.cpp b/src/app/dwg/qgsdwgimporter.cpp index 5fa927fb886..6d1c9d5cb6d 100644 --- a/src/app/dwg/qgsdwgimporter.cpp +++ b/src/app/dwg/qgsdwgimporter.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #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 dxf( new dxfRW( drawing.toUtf8() ) ); + std::unique_ptr 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 dwg( new dwgR( drawing.toUtf8() ) ); + std::unique_ptr 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 sg( nullptr ); + std::unique_ptr sg( nullptr ); if ( !mUseCurves && g0.hasCurvedSegments() ) { sg.reset( g0.segmentize() ); - g = sg.data(); + g = sg.get(); } else { diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index 3f5d3ba420f..0cd39078ad7 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -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( 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 pipe( nullptr ); + std::unique_ptr 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" ), diff --git a/src/app/qgsannotationwidget.cpp b/src/app/qgsannotationwidget.cpp index ebf5a6389e8..04e887de1e4 100644 --- a/src/app/qgsannotationwidget.cpp +++ b/src/app/qgsannotationwidget.cpp @@ -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 ); } diff --git a/src/app/qgsannotationwidget.h b/src/app/qgsannotationwidget.h index 83d7915e3ac..b8a2984cd5a 100644 --- a/src/app/qgsannotationwidget.h +++ b/src/app/qgsannotationwidget.h @@ -20,6 +20,7 @@ #include "ui_qgsannotationwidgetbase.h" #include "qgis_app.h" +#include 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(); diff --git a/src/app/qgsapplayertreeviewmenuprovider.cpp b/src/app/qgsapplayertreeviewmenuprovider.cpp index 7c64807bb03..2e2c67b59b0 100644 --- a/src/app/qgsapplayertreeviewmenuprovider.cpp +++ b/src/app/qgsapplayertreeviewmenuprovider.cpp @@ -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( 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(); diff --git a/src/app/qgsbookmarks.cpp b/src/app/qgsbookmarks.cpp index f8ece64fef5..cb6d61ed2d9 100644 --- a/src/app/qgsbookmarks.cpp +++ b/src/app/qgsbookmarks.cpp @@ -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() ); diff --git a/src/app/qgsbookmarks.h b/src/app/qgsbookmarks.h index 94997f724df..daf4a1cceac 100644 --- a/src/app/qgsbookmarks.h +++ b/src/app/qgsbookmarks.h @@ -18,7 +18,7 @@ #define QGSBOOKMARKS_H #include -#include +#include #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 mModel; + std::unique_ptr mModel; void saveWindowLocation(); void restorePosition(); diff --git a/src/app/qgsdiagramproperties.cpp b/src/app/qgsdiagramproperties.cpp index 43c724a3608..1a18077960c 100644 --- a/src/app/qgsdiagramproperties.cpp +++ b/src/app/qgsdiagramproperties.cpp @@ -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 diff --git a/src/app/qgsdiagramproperties.h b/src/app/qgsdiagramproperties.h index 818fcacca20..33213e6b548 100644 --- a/src/app/qgsdiagramproperties.h +++ b/src/app/qgsdiagramproperties.h @@ -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; diff --git a/src/app/qgsfeatureaction.cpp b/src/app/qgsfeatureaction.cpp index c121871cb98..2e86989a16a 100644 --- a/src/app/qgsfeatureaction.cpp +++ b/src/app/qgsfeatureaction.cpp @@ -116,7 +116,7 @@ bool QgsFeatureAction::editFeature( bool showModal ) if ( showModal ) { - QScopedPointer dialog( newDialog( false ) ); + std::unique_ptr dialog( newDialog( false ) ); if ( !mFeature->isValid() ) dialog->setMode( QgsAttributeForm::AddFeatureMode ); diff --git a/src/app/qgslabelingwidget.cpp b/src/app/qgslabelingwidget.cpp index 56e511fd679..b7c3dd88600 100644 --- a/src/app/qgslabelingwidget.cpp +++ b/src/app/qgslabelingwidget.cpp @@ -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 ); } diff --git a/src/app/qgslabelingwidget.h b/src/app/qgslabelingwidget.h index 2b8adfaf095..2684924e25a 100644 --- a/src/app/qgslabelingwidget.h +++ b/src/app/qgslabelingwidget.h @@ -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; }; diff --git a/src/app/qgsmaptooladdfeature.cpp b/src/app/qgsmaptooladdfeature.cpp index 2c436a1cecc..6e31b5a5deb 100644 --- a/src/app/qgsmaptooladdfeature.cpp +++ b/src/app/qgsmaptooladdfeature.cpp @@ -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(); diff --git a/src/app/qgsmaptooloffsetpointsymbol.cpp b/src/app/qgsmaptooloffsetpointsymbol.cpp index 428f8973e1b..a3bf7c79b2d 100644 --- a/src/app/qgsmaptooloffsetpointsymbol.cpp +++ b/src/app/qgsmaptooloffsetpointsymbol.cpp @@ -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 ) ) diff --git a/src/app/qgsmaptooloffsetpointsymbol.h b/src/app/qgsmaptooloffsetpointsymbol.h index 2cab37b5042..09d6cae34a1 100644 --- a/src/app/qgsmaptooloffsetpointsymbol.h +++ b/src/app/qgsmaptooloffsetpointsymbol.h @@ -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; diff --git a/src/app/qgsmaptoolrotatepointsymbols.cpp b/src/app/qgsmaptoolrotatepointsymbols.cpp index 0656b49d785..ab4539dabf8 100644 --- a/src/app/qgsmaptoolrotatepointsymbols.cpp +++ b/src/app/qgsmaptoolrotatepointsymbols.cpp @@ -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() ); } diff --git a/src/app/qgsmaptoolrotatepointsymbols.h b/src/app/qgsmaptoolrotatepointsymbols.h index dfb0ea6439b..49d002b6a3a 100644 --- a/src/app/qgsmaptoolrotatepointsymbols.h +++ b/src/app/qgsmaptoolrotatepointsymbols.h @@ -18,6 +18,7 @@ #include "qgsmaptoolpointsymbol.h" #include "qgis_app.h" +#include 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 diff --git a/src/app/qgspointmarkeritem.cpp b/src/app/qgspointmarkeritem.cpp index bdaad7800ab..924e99e2c02 100644 --- a/src/app/qgspointmarkeritem.cpp +++ b/src/app/qgspointmarkeritem.cpp @@ -94,7 +94,7 @@ void QgsPointMarkerItem::setSymbol( QgsMarkerSymbol *symbol ) QgsMarkerSymbol*QgsPointMarkerItem::symbol() { - return mMarkerSymbol.data(); + return mMarkerSymbol.get(); } void QgsPointMarkerItem::setFeature( const QgsFeature& feature ) diff --git a/src/app/qgspointmarkeritem.h b/src/app/qgspointmarkeritem.h index 3c728980c31..be5d0f0e3d3 100644 --- a/src/app/qgspointmarkeritem.h +++ b/src/app/qgspointmarkeritem.h @@ -22,6 +22,7 @@ #include #include #include "qgis_app.h" +#include 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 ); }; diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp index 61bedc02661..d046edef50e 100644 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -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 ); } diff --git a/src/app/qgstextannotationdialog.cpp b/src/app/qgstextannotationdialog.cpp index fe2a6ed2793..e2c74f7b98e 100644 --- a/src/app/qgstextannotationdialog.cpp +++ b/src/app/qgstextannotationdialog.cpp @@ -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(); } } diff --git a/src/app/qgstextannotationdialog.h b/src/app/qgstextannotationdialog.h index 049629b741f..477441ca6ef 100644 --- a/src/app/qgstextannotationdialog.h +++ b/src/app/qgstextannotationdialog.h @@ -20,6 +20,7 @@ #include "ui_qgstextannotationdialogbase.h" #include "qgis_app.h" +#include 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 ); diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp index a5948230bdd..382e80e6e77 100644 --- a/src/app/qgsvectorlayerproperties.cpp +++ b/src/app/qgsvectorlayerproperties.cpp @@ -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 diff --git a/src/app/qgsvectorlayerproperties.h b/src/app/qgsvectorlayerproperties.h index 6c780bc72e9..6d5fd7bf099 100644 --- a/src/app/qgsvectorlayerproperties.h +++ b/src/app/qgsvectorlayerproperties.h @@ -196,8 +196,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private QgsExpressionContext createExpressionContext() const override; - QScopedPointer mLayersDependenciesTreeGroup; - QScopedPointer mLayersDependenciesTreeModel; + std::unique_ptr mLayersDependenciesTreeGroup; + std::unique_ptr mLayersDependenciesTreeModel; private slots: void openPanel( QgsPanelWidget* panel ); diff --git a/src/core/annotations/qgsannotation.cpp b/src/core/annotations/qgsannotation.cpp index 5263866bf77..e5e745dd1e2 100644 --- a/src/core/annotations/qgsannotation.cpp +++ b/src/core/annotations/qgsannotation.cpp @@ -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 ); diff --git a/src/core/annotations/qgsannotation.h b/src/core/annotations/qgsannotation.h index aa1c7c842ec..6e24f3a76fa 100644 --- a/src/core/annotations/qgsannotation.h +++ b/src/core/annotations/qgsannotation.h @@ -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 mMarkerSymbol; + std::unique_ptr mMarkerSymbol; QgsMargins mContentsMargins; //! Fill symbol used for drawing annotation - QScopedPointer mFillSymbol; + std::unique_ptr 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; diff --git a/src/core/annotations/qgstextannotation.cpp b/src/core/annotations/qgstextannotation.cpp index 2791431948a..eeae4ac5887 100644 --- a/src/core/annotations/qgstextannotation.cpp +++ b/src/core/annotations/qgstextannotation.cpp @@ -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 ) diff --git a/src/core/annotations/qgstextannotation.h b/src/core/annotations/qgstextannotation.h index cc1562816d7..c811f6162ef 100644 --- a/src/core/annotations/qgstextannotation.h +++ b/src/core/annotations/qgstextannotation.h @@ -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 diff --git a/src/core/composer/qgsatlascomposition.cpp b/src/core/composer/qgsatlascomposition.cpp index 3e5f7b39988..acdabb6fc4f 100644 --- a/src/core/composer/qgsatlascomposition.cpp +++ b/src/core/composer/qgsatlascomposition.cpp @@ -137,7 +137,7 @@ int QgsAtlasComposition::updateFeatures() // select all features with all attributes QgsFeatureRequest req; - QScopedPointer filterExpression; + std::unique_ptr filterExpression; if ( mFilterFeatures && !mFeatureFilter.isEmpty() ) { filterExpression.reset( new QgsExpression( mFeatureFilter ) ); @@ -154,7 +154,7 @@ int QgsAtlasComposition::updateFeatures() QgsFeatureIterator fit = mCoverageLayer->getFeatures( req ); - QScopedPointer nameExpression; + std::unique_ptr 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() ) diff --git a/src/core/composer/qgsatlascomposition.h b/src/core/composer/qgsatlascomposition.h index 6f41175f114..03cb51943de 100644 --- a/src/core/composer/qgsatlascomposition.h +++ b/src/core/composer/qgsatlascomposition.h @@ -340,7 +340,7 @@ class CORE_EXPORT QgsAtlasComposition : public QObject QgsFeature mCurrentFeature; - QScopedPointer mFilenameExpr; + std::unique_ptr mFilenameExpr; // bounding box of the current feature transformed into map crs QgsRectangle mTransformedFeatureBounds; diff --git a/src/core/composer/qgscomposerattributetablev2.cpp b/src/core/composer/qgscomposerattributetablev2.cpp index c3e115224ad..2c852201361 100644 --- a/src/core/composer/qgscomposerattributetablev2.cpp +++ b/src/core/composer/qgscomposerattributetablev2.cpp @@ -404,7 +404,7 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co context.setFields( layer->fields() ); //prepare filter expression - QScopedPointer filterExpression; + std::unique_ptr 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 diff --git a/src/core/composer/qgscomposerlabel.cpp b/src/core/composer/qgscomposerlabel.cpp index d6c52705671..98fbe98fe73 100644 --- a/src/core/composer/qgscomposerlabel.cpp +++ b/src/core/composer/qgscomposerlabel.cpp @@ -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() ); diff --git a/src/core/composer/qgscomposerlabel.h b/src/core/composer/qgscomposerlabel.h index 269720587f8..7e27df56161 100644 --- a/src/core/composer/qgscomposerlabel.h +++ b/src/core/composer/qgscomposerlabel.h @@ -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 mExpressionFeature; + std::unique_ptr mExpressionFeature; QgsVectorLayer* mExpressionLayer; QgsDistanceArea* mDistanceArea; diff --git a/src/core/composer/qgscomposermapgrid.cpp b/src/core/composer/qgscomposermapgrid.cpp index 94c4893d7fb..e32621d86ce 100644 --- a/src/core/composer/qgscomposermapgrid.cpp +++ b/src/core/composer/qgscomposermapgrid.cpp @@ -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 ); diff --git a/src/core/composer/qgscomposermapgrid.h b/src/core/composer/qgscomposermapgrid.h index c8a48e1d988..812ace62ff7 100644 --- a/src/core/composer/qgscomposermapgrid.h +++ b/src/core/composer/qgscomposermapgrid.h @@ -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; diff --git a/src/core/composer/qgscomposernodesitem.cpp b/src/core/composer/qgscomposernodesitem.cpp index b7932516075..1565eeb75c4 100644 --- a/src/core/composer/qgscomposernodesitem.cpp +++ b/src/core/composer/qgscomposernodesitem.cpp @@ -132,10 +132,10 @@ void QgsComposerNodesItem::drawNodes( QPainter *painter ) const properties.insert( QStringLiteral( "name" ), QStringLiteral( "cross" ) ); properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "red" ) ); - QScopedPointer symbol; + std::unique_ptr 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 symbol; + std::unique_ptr 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, diff --git a/src/core/composer/qgscomposerpolygon.cpp b/src/core/composer/qgscomposerpolygon.cpp index c87cb028c19..bfe54acfe49 100644 --- a/src/core/composer/qgscomposerpolygon.cpp +++ b/src/core/composer/qgscomposerpolygon.cpp @@ -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 ); } diff --git a/src/core/composer/qgscomposerpolygon.h b/src/core/composer/qgscomposerpolygon.h index f90270eaeea..a0572349854 100644 --- a/src/core/composer/qgscomposerpolygon.h +++ b/src/core/composer/qgscomposerpolygon.h @@ -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 mPolygonStyleSymbol; + std::unique_ptr mPolygonStyleSymbol; /** Add the node newPoint at the given position according to some * criteres. */ diff --git a/src/core/composer/qgscomposerpolyline.cpp b/src/core/composer/qgscomposerpolyline.cpp index ea8cb9ab27d..8a988ba0727 100644 --- a/src/core/composer/qgscomposerpolyline.cpp +++ b/src/core/composer/qgscomposerpolyline.cpp @@ -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 ); } diff --git a/src/core/composer/qgscomposerpolyline.h b/src/core/composer/qgscomposerpolyline.h index d20a36a56f6..133e0bfab6f 100644 --- a/src/core/composer/qgscomposerpolyline.h +++ b/src/core/composer/qgscomposerpolyline.h @@ -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 mPolylineStyleSymbol; + std::unique_ptr mPolylineStyleSymbol; /** Add the node newPoint at the given position according to some * criteres. */ diff --git a/src/core/dxf/qgsdxfexport.cpp b/src/core/dxf/qgsdxfexport.cpp index 1f60cbd57d5..79eda27d993 100644 --- a/src/core/dxf/qgsdxfexport.cpp +++ b/src/core/dxf/qgsdxfexport.cpp @@ -3644,7 +3644,7 @@ void QgsDxfExport::addFeature( QgsSymbolRenderContext& ctx, const QgsCoordinateT if ( !fet->hasGeometry() ) return; - QScopedPointer geom( fet->geometry().geometry()->clone() ); + std::unique_ptr 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; } } diff --git a/src/core/geometry/qgsgeometry.cpp b/src/core/geometry/qgsgeometry.cpp index d622bf55974..b1695dadd14 100644 --- a/src/core/geometry/qgsgeometry.cpp +++ b/src/core/geometry/qgsgeometry.cpp @@ -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 diff --git a/src/core/geometry/qgsgeometryeditutils.cpp b/src/core/geometry/qgsgeometryeditutils.cpp index c2e1b376b07..8fae15b4932 100644 --- a/src/core/geometry/qgsgeometryeditutils.cpp +++ b/src/core/geometry/qgsgeometryeditutils.cpp @@ -66,7 +66,7 @@ int QgsGeometryEditUtils::addRing( QgsAbstractGeometry* geom, QgsCurve* ring ) return 3; } - QScopedPointer ringGeom( QgsGeometry::createGeometryEngine( ring ) ); + std::unique_ptr 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& avoidIntersectionsLayers, QHash > ignoreFeatures ) { - QScopedPointer geomEngine( QgsGeometry::createGeometryEngine( &geom ) ); - if ( geomEngine.isNull() ) + std::unique_ptr 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; diff --git a/src/core/geometry/qgsinternalgeometryengine.cpp b/src/core/geometry/qgsinternalgeometryengine.cpp index 6a605727ba9..b4b8d759fe8 100644 --- a/src/core/geometry/qgsinternalgeometryengine.cpp +++ b/src/core/geometry/qgsinternalgeometryengine.cpp @@ -25,6 +25,7 @@ #include +#include #include QgsInternalGeometryEngine::QgsInternalGeometryEngine( const QgsGeometry& geometry ) @@ -58,7 +59,7 @@ QgsGeometry QgsInternalGeometryEngine::extrude( double x, double y ) const linesToProcess << static_cast( curve->segmentize() ); } - QScopedPointer multipolygon( linesToProcess.size() > 1 ? new QgsMultiPolygonV2() : nullptr ); + std::unique_ptr 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 ) diff --git a/src/core/layertree/qgslayertreemodel.cpp b/src/core/layertree/qgslayertreemodel.cpp index 6e7907c3fe5..cd2fc33b4a3 100644 --- a/src/core/layertree/qgslayertreemodel.cpp +++ b/src/core/layertree/qgslayertreemodel.cpp @@ -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 context( new QgsRenderContext ); + std::unique_ptr 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 context( createTemporaryRenderContext() ); + std::unique_ptr context( createTemporaryRenderContext() ); Q_FOREACH ( const LayerLegendData& data, mLegend ) { @@ -1529,7 +1529,7 @@ void QgsLayerTreeModel::invalidateLegendMapBasedData() QgsSymbolLegendNode* n = dynamic_cast( 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 ); diff --git a/src/core/layertree/qgslayertreemodel.h b/src/core/layertree/qgslayertreemodel.h index 68d0486c310..501b2031a0a 100644 --- a/src/core/layertree/qgslayertreemodel.h +++ b/src/core/layertree/qgslayertreemodel.h @@ -21,6 +21,7 @@ #include #include #include +#include #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 mLegendFilterMapSettings; - QScopedPointer mLegendFilterHitTest; + std::unique_ptr mLegendFilterMapSettings; + std::unique_ptr mLegendFilterHitTest; //! whether to use map filtering bool mLegendFilterUsesExtent; diff --git a/src/core/layertree/qgslayertreemodellegendnode.cpp b/src/core/layertree/qgslayertreemodellegendnode.cpp index 2f77e3cac92..6d0d561c70d 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.cpp +++ b/src/core/layertree/qgslayertreemodellegendnode.cpp @@ -151,8 +151,8 @@ Qt::ItemFlags QgsSymbolLegendNode::flags() const QSize QgsSymbolLegendNode::minimumIconSize() const { - QScopedPointer context( createTemporaryRenderContext() ); - return minimumIconSize( context.data() ); + std::unique_ptr 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 context( new QgsRenderContext ); + std::unique_ptr 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 context( createTemporaryRenderContext() ); - pix = QgsSymbolLayerUtils::symbolPreviewPixmap( mItem.symbol(), mIconSize, 0, context.data() ); + std::unique_ptr 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?"); diff --git a/src/core/layertree/qgslayertreemodellegendnode.h b/src/core/layertree/qgslayertreemodellegendnode.h index 44a1af2a084..57b0cd7cc2a 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.h +++ b/src/core/layertree/qgslayertreemodellegendnode.h @@ -342,7 +342,7 @@ class CORE_EXPORT QgsWmsLegendNode : public QgsLayerTreeModelLegendNode bool mValid; - mutable QScopedPointer mFetcher; + mutable std::unique_ptr mFetcher; }; #endif // QGSLAYERTREEMODELLEGENDNODE_H diff --git a/src/core/qgsaggregatecalculator.cpp b/src/core/qgsaggregatecalculator.cpp index a0b75d0ca6e..fa396f89368 100644 --- a/src/core/qgsaggregatecalculator.cpp +++ b/src/core/qgsaggregatecalculator.cpp @@ -54,7 +54,7 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag QgsExpressionContext defaultContext = mLayer->createExpressionContext(); context = context ? context : &defaultContext; - QScopedPointer expression; + std::unique_ptr expression; int attrNum = mLayer->fields().lookupField( fieldOrExpression ); @@ -72,13 +72,13 @@ QVariant QgsAggregateCalculator::calculate( QgsAggregateCalculator::Aggregate ag } QSet 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 ) diff --git a/src/core/qgsconditionalstyle.cpp b/src/core/qgsconditionalstyle.cpp index d6c8e7cfd01..d2af3b5e222 100644 --- a/src/core/qgsconditionalstyle.cpp +++ b/src/core/qgsconditionalstyle.cpp @@ -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 ); diff --git a/src/core/qgsconditionalstyle.h b/src/core/qgsconditionalstyle.h index 1a0a010d707..dd522e620d5 100644 --- a/src/core/qgsconditionalstyle.h +++ b/src/core/qgsconditionalstyle.h @@ -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 mSymbol; + std::unique_ptr mSymbol; QFont mFont; QColor mBackColor; QColor mTextColor; diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index 338570100d8..9cdab08e628 100644 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -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" ) ) ); diff --git a/src/core/qgsdataitemproviderregistry.cpp b/src/core/qgsdataitemproviderregistry.cpp index 50340ee3f87..da946114f38 100644 --- a/src/core/qgsdataitemproviderregistry.cpp +++ b/src/core/qgsdataitemproviderregistry.cpp @@ -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; diff --git a/src/core/qgsdiagramrenderer.cpp b/src/core/qgsdiagramrenderer.cpp index bc23516c53f..abb11de2112 100644 --- a/src/core/qgsdiagramrenderer.cpp +++ b/src/core/qgsdiagramrenderer.cpp @@ -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( si.symbol() ); s->setSize( size ); s->setSizeUnit( mSettings.sizeType ); diff --git a/src/core/qgsdiagramrenderer.h b/src/core/qgsdiagramrenderer.h index ff67f37e156..507ce737f2b 100644 --- a/src/core/qgsdiagramrenderer.h +++ b/src/core/qgsdiagramrenderer.h @@ -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 diff --git a/src/core/qgsexpression.cpp b/src/core/qgsexpression.cpp index 1b239b66b6f..848ca5fdcd1 100644 --- a/src/core/qgsexpression.cpp +++ b/src/core/qgsexpression.cpp @@ -2439,7 +2439,7 @@ static QVariant fcnRelate( const QVariantList& values, const QgsExpressionContex if ( fGeom.isNull() || sGeom.isNull() ) return QVariant(); - QScopedPointer engine( QgsGeometry::createGeometryEngine( fGeom.geometry() ) ); + std::unique_ptr engine( QgsGeometry::createGeometryEngine( fGeom.geometry() ) ); if ( values.length() == 2 ) { diff --git a/src/core/qgsmaphittest.cpp b/src/core/qgsmaphittest.cpp index 810fdb7dcb3..8b935104a86 100644 --- a/src/core/qgsmaphittest.cpp +++ b/src/core/qgsmaphittest.cpp @@ -143,7 +143,7 @@ void QgsMapHitTest::runHitTestLayer( QgsVectorLayer* vl, SymbolSet& usedSymbols, SymbolSet lUsedSymbolsRuleKey; bool allExpressionFalse = false; bool hasExpression = mLayerFilterExpression.contains( vl->id() ); - QScopedPointer expr; + std::unique_ptr expr; if ( hasExpression ) { expr.reset( new QgsExpression( mLayerFilterExpression[vl->id()] ) ); diff --git a/src/core/qgsmaptopixelgeometrysimplifier.cpp b/src/core/qgsmaptopixelgeometrysimplifier.cpp index d6d042e12fa..d218bf88310 100644 --- a/src/core/qgsmaptopixelgeometrysimplifier.cpp +++ b/src/core/qgsmaptopixelgeometrysimplifier.cpp @@ -15,6 +15,7 @@ ***************************************************************************/ #include +#include #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( geometry ); - QScopedPointer output( createEmptySameTypeGeom( srcCurve ) ); + std::unique_ptr 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( geometry ); - QScopedPointer polygon( new QgsPolygonV2() ); + std::unique_ptr polygon( new QgsPolygonV2() ); polygon->setExteriorRing( dynamic_cast( 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( 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( geometry ); - QScopedPointer collection( createEmptySameTypeGeom( srcCollection ) ); + std::unique_ptr 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() ); } diff --git a/src/core/qgspallabeling.cpp b/src/core/qgspallabeling.cpp index c8d6705f27e..352f2cdb9aa 100644 --- a/src/core/qgspallabeling.cpp +++ b/src/core/qgspallabeling.cpp @@ -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 labelFontMetrics( new QFontMetricsF( labelFont ) ); + std::unique_ptr 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 scopedClonedGeom; + std::unique_ptr 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 scopedObstacleGeom; + std::unique_ptr 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 scopedClonedGeom; + std::unique_ptr 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 scopedPreparedGeom; + std::unique_ptr scopedPreparedGeom; if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, ct, &extentGeom ) ) { diff --git a/src/core/qgsproject.cpp b/src/core/qgsproject.cpp index c49a56ea0bd..048cc3b72b0 100644 --- a/src/core/qgsproject.cpp +++ b/src/core/qgsproject.cpp @@ -731,7 +731,7 @@ bool QgsProject::read() { clearError(); - QScopedPointer doc( new QDomDocument( QStringLiteral( "qgis" ) ) ); + std::unique_ptr 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 doc( new QDomDocument( documentType ) ); + std::unique_ptr 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& layers ) diff --git a/src/core/qgsproject.h b/src/core/qgsproject.h index 28879d02497..7e44d2e2696 100644 --- a/src/core/qgsproject.h +++ b/src/core/qgsproject.h @@ -962,7 +962,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera QgsRelationManager* mRelationManager; - QScopedPointer mAnnotationManager; + std::unique_ptr 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 mMapThemeCollection; + std::unique_ptr mMapThemeCollection; QVariantMap mCustomVariables; diff --git a/src/core/qgsproperty.cpp b/src/core/qgsproperty.cpp index 1ecd2d073bc..0b1c6d4c7e3 100644 --- a/src/core/qgsproperty.cpp +++ b/src/core/qgsproperty.cpp @@ -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(); } } diff --git a/src/core/qgspropertytransformer.cpp b/src/core/qgspropertytransformer.cpp index 4502b4484ae..222543732ae 100644 --- a/src/core/qgspropertytransformer.cpp +++ b/src/core/qgspropertytransformer.cpp @@ -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 ) diff --git a/src/core/qgspropertytransformer.h b/src/core/qgspropertytransformer.h index 10483cbcc2d..2e7957df943 100644 --- a/src/core/qgspropertytransformer.h +++ b/src/core/qgspropertytransformer.h @@ -25,6 +25,7 @@ #include #include #include +#include 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; diff --git a/src/core/qgsproviderregistry.cpp b/src/core/qgsproviderregistry.cpp index af750570507..2cb8940c603 100644 --- a/src/core/qgsproviderregistry.cpp +++ b/src/core/qgsproviderregistry.cpp @@ -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() ); diff --git a/src/core/qgsrendercontext.cpp b/src/core/qgsrendercontext.cpp index a847e54456d..315d76c2f9e 100644 --- a/src/core/qgsrendercontext.cpp +++ b/src/core/qgsrendercontext.cpp @@ -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 diff --git a/src/core/qgsrendercontext.h b/src/core/qgsrendercontext.h index c076fbee55a..4ddcd98cf5f 100644 --- a/src/core/qgsrendercontext.h +++ b/src/core/qgsrendercontext.h @@ -20,6 +20,7 @@ #include "qgis_core.h" #include +#include #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; diff --git a/src/core/qgstextrenderer.cpp b/src/core/qgstextrenderer.cpp index b78d5ef4e61..959949638a4 100644 --- a/src/core/qgstextrenderer.cpp +++ b/src/core/qgstextrenderer.cpp @@ -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 diff --git a/src/core/qgstransaction.cpp b/src/core/qgstransaction.cpp index cb76dfb5399..abfe86b8ed8 100644 --- a/src/core/qgstransaction.cpp +++ b/src/core/qgstransaction.cpp @@ -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; diff --git a/src/core/qgstransactiongroup.cpp b/src/core/qgstransactiongroup.cpp index 786c8ee86ce..cad5fc4e4bd 100644 --- a/src/core/qgstransactiongroup.cpp +++ b/src/core/qgstransactiongroup.cpp @@ -72,7 +72,7 @@ bool QgsTransactionGroup::modified() const void QgsTransactionGroup::onEditingStarted() { - if ( !mTransaction.isNull() ) + if ( mTransaction ) return; mTransaction.reset( QgsTransaction::create( mConnString, mProviderKey ) ); diff --git a/src/core/qgstransactiongroup.h b/src/core/qgstransactiongroup.h index 284f4c46c53..d1a1a942102 100644 --- a/src/core/qgstransactiongroup.h +++ b/src/core/qgstransactiongroup.h @@ -19,6 +19,7 @@ #include "qgis_core.h" #include #include +#include #include "qgstransaction.h" class QgsVectorLayer; @@ -89,7 +90,7 @@ class CORE_EXPORT QgsTransactionGroup : public QObject QSet mLayers; //! Only set while a transaction is active - QScopedPointer mTransaction; + std::unique_ptr mTransaction; //! Layers have to be compatible with the connection string QString mConnString; QString mProviderKey; diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp index 0c8e85c9bde..bc4df7c6d8a 100644 --- a/src/core/qgsvectorlayer.cpp +++ b/src/core/qgsvectorlayer.cpp @@ -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 QgsVectorLayer::getValues( const QString &fieldOrExpression, boo { QList values; - QScopedPointer expression; + std::unique_ptr expression; QgsExpressionContext context; int attrNum = mFields.lookupField( fieldOrExpression ); @@ -3579,7 +3579,7 @@ QList QgsVectorLayer::getValues( const QString &fieldOrExpression, boo QgsFeature f; QSet lst; - if ( expression.isNull() ) + if ( !expression ) lst.insert( fieldOrExpression ); else lst = expression->referencedColumns(); @@ -4272,7 +4272,7 @@ QList QgsVectorLayer::referencingRelations( int idx ) const int QgsVectorLayer::listStylesInDatabase( QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError ) { - QScopedPointer myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) ); + std::unique_ptr 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 myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) ); + std::unique_ptr 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 myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) ); + std::unique_ptr 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 myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) ); + std::unique_ptr 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 myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) ); + std::unique_ptr myLib( QgsProviderRegistry::instance()->providerLibrary( mProviderKey ) ); if ( myLib ) { loadStyle_t* loadStyleExternalMethod = reinterpret_cast< loadStyle_t * >( cast_to_fptr( myLib->resolve( "loadStyle" ) ) ); diff --git a/src/core/qgsvectorlayerdiagramprovider.cpp b/src/core/qgsvectorlayerdiagramprovider.cpp index 67331be817f..6685593bece 100644 --- a/src/core/qgsvectorlayerdiagramprovider.cpp +++ b/src/core/qgsvectorlayerdiagramprovider.cpp @@ -215,11 +215,11 @@ QgsLabelFeature* QgsVectorLayerDiagramProvider::registerDiagram( QgsFeature& fea } GEOSGeometry* geomCopy = nullptr; - QScopedPointer scopedPreparedGeom; + std::unique_ptr 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 scopedObstacleGeom; + std::unique_ptr scopedObstacleGeom; if ( isObstacle && obstacleGeometry && QgsPalLabeling::geometryRequiresPreparation( *obstacleGeometry, context, mSettings.coordinateTransform(), &extentGeom ) ) { QgsGeometry preparedObstacleGeom = QgsPalLabeling::prepareGeometry( *obstacleGeometry, context, mSettings.coordinateTransform(), &extentGeom ); diff --git a/src/core/qgsvectorlayerfeatureiterator.cpp b/src/core/qgsvectorlayerfeatureiterator.cpp index 28464cfd6a1..149bd0e3580 100644 --- a/src/core/qgsvectorlayerfeatureiterator.cpp +++ b/src/core/qgsvectorlayerfeatureiterator.cpp @@ -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 ); } diff --git a/src/core/qgsvectorlayerfeatureiterator.h b/src/core/qgsvectorlayerfeatureiterator.h index 8a78e299276..b17a76ba63f 100644 --- a/src/core/qgsvectorlayerfeatureiterator.h +++ b/src/core/qgsvectorlayerfeatureiterator.h @@ -20,6 +20,7 @@ #include "qgsfields.h" #include +#include typedef QMap QgsFeatureMap; @@ -200,7 +201,7 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera bool mHasVirtualAttributes; private: - QScopedPointer mExpressionContext; + std::unique_ptr mExpressionContext; QgsInterruptionChecker* mInterruptionChecker; diff --git a/src/core/qgsvectorlayerimport.cpp b/src/core/qgsvectorlayerimport.cpp index 17e09d6cfb5..b6849785292 100644 --- a/src/core/qgsvectorlayerimport.cpp +++ b/src/core/qgsvectorlayerimport.cpp @@ -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; diff --git a/src/core/qgsvectorlayerlabelprovider.cpp b/src/core/qgsvectorlayerlabelprovider.cpp index 563f37f3a6f..2f7f78f21b3 100644 --- a/src/core/qgsvectorlayerlabelprovider.cpp +++ b/src/core/qgsvectorlayerlabelprovider.cpp @@ -229,7 +229,7 @@ QList QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCon QgsFeature fet; while ( fit.nextFeature( fet ) ) { - QScopedPointer obstacleGeometry; + std::unique_ptr obstacleGeometry; if ( mRenderer ) { QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, ctx ); @@ -244,7 +244,7 @@ QList QgsVectorLayerLabelProvider::labelFeatures( QgsRenderCon } } ctx.expressionContext().setFeature( fet ); - registerFeature( fet, ctx, obstacleGeometry.data() ); + registerFeature( fet, ctx, obstacleGeometry.get() ); } if ( ctx.expressionContext().lastScope() == symbolScope ) diff --git a/src/core/qgsvectorlayerrenderer.cpp b/src/core/qgsvectorlayerrenderer.cpp index a4f23a484c2..e84401d1e56 100644 --- a/src/core/qgsvectorlayerrenderer.cpp +++ b/src/core/qgsvectorlayerrenderer.cpp @@ -317,7 +317,7 @@ void QgsVectorLayerRenderer::drawRenderer( QgsFeatureIterator& fit ) // new labeling engine if ( mContext.labelingEngine() && ( mLabelProvider || mDiagramProvider ) ) { - QScopedPointer obstacleGeometry; + std::unique_ptr 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 obstacleGeometry; + std::unique_ptr 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() ); } } } diff --git a/src/core/qgsvectorlayerutils.cpp b/src/core/qgsvectorlayerutils.cpp index dee6dfa4ae5..0e41005ff69 100644 --- a/src/core/qgsvectorlayerutils.cpp +++ b/src/core/qgsvectorlayerutils.cpp @@ -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(); diff --git a/src/core/raster/qgscolorrampshader.cpp b/src/core/raster/qgscolorrampshader.cpp index 69a644a9abb..e1c7101b05e 100644 --- a/src/core/raster/qgscolorrampshader.cpp +++ b/src/core/raster/qgscolorrampshader.cpp @@ -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 ) diff --git a/src/core/raster/qgscolorrampshader.h b/src/core/raster/qgscolorrampshader.h index 6e05e94d1f7..e39e8007dcc 100644 --- a/src/core/raster/qgscolorrampshader.h +++ b/src/core/raster/qgscolorrampshader.h @@ -24,6 +24,7 @@ originally part of the larger QgsRasterLayer class #include "qgis_core.h" #include #include +#include #include "qgscolorramp.h" #include "qgsrasterinterface.h" @@ -169,7 +170,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction protected: //! Source color ramp - QScopedPointer mSourceColorRamp; + std::unique_ptr mSourceColorRamp; private: diff --git a/src/core/raster/qgsrasterlayer.cpp b/src/core/raster/qgsrasterlayer.cpp index a5c1dffc9b6..43b3b005c53 100644 --- a/src/core/raster/qgsrasterlayer.cpp +++ b/src/core/raster/qgsrasterlayer.cpp @@ -926,7 +926,7 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh if ( myBand != -1 ) { Qgis::DataType myType = static_cast< Qgis::DataType >( mDataProvider->dataType( myBand ) ); - QScopedPointer myEnhancement( new QgsContrastEnhancement( static_cast< Qgis::DataType >( myType ) ) ); + std::unique_ptr 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 diff --git a/src/core/symbology-ng/qgs25drenderer.cpp b/src/core/symbology-ng/qgs25drenderer.cpp index 6fa1ae9a6eb..57add4f6799 100644 --- a/src/core/symbology-ng/qgs25drenderer.cpp +++ b/src/core/symbology-ng/qgs25drenderer.cpp @@ -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; } diff --git a/src/core/symbology-ng/qgs25drenderer.h b/src/core/symbology-ng/qgs25drenderer.h index 31c7953831a..317dcd22999 100644 --- a/src/core/symbology-ng/qgs25drenderer.h +++ b/src/core/symbology-ng/qgs25drenderer.h @@ -119,7 +119,7 @@ class CORE_EXPORT Qgs25DRenderer : public QgsFeatureRenderer QgsFillSymbolLayer* wallLayer() const; QgsOuterGlowEffect* glowEffect() const; - QScopedPointer mSymbol; + std::unique_ptr mSymbol; }; #endif // QGS25DRENDERER_H diff --git a/src/core/symbology-ng/qgsarrowsymbollayer.cpp b/src/core/symbology-ng/qgsarrowsymbollayer.cpp index 338316eba80..bbd93246352 100644 --- a/src/core/symbology-ng/qgsarrowsymbollayer.cpp +++ b/src/core/symbology-ng/qgsarrowsymbollayer.cpp @@ -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; } diff --git a/src/core/symbology-ng/qgsarrowsymbollayer.h b/src/core/symbology-ng/qgsarrowsymbollayer.h index b3c8dd9c085..78f88af123b 100644 --- a/src/core/symbology-ng/qgsarrowsymbollayer.h +++ b/src/core/symbology-ng/qgsarrowsymbollayer.h @@ -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 usedAttributes( const QgsRenderContext& context ) const override; @@ -144,7 +144,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer private: //! Filling sub symbol - QScopedPointer mSymbol; + std::unique_ptr mSymbol; double mArrowWidth; QgsUnitTypes::RenderUnit mArrowWidthUnit; @@ -174,7 +174,7 @@ class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer HeadType mComputedHeadType; ArrowType mComputedArrowType; - QScopedPointer mExpressionScope; + std::unique_ptr mExpressionScope; void _resolveDataDefined( QgsSymbolRenderContext& ); }; diff --git a/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp b/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp index c2026a4bde8..478d41286af 100644 --- a/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp +++ b/src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp @@ -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( si.symbol() ); s->setDataDefinedSize( QgsProperty() ); s->setSize( exp.size( v ) ); @@ -839,7 +839,7 @@ QSet 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 ) diff --git a/src/core/symbology-ng/qgscategorizedsymbolrenderer.h b/src/core/symbology-ng/qgscategorizedsymbolrenderer.h index 576b117e5fa..612384d398e 100644 --- a/src/core/symbology-ng/qgscategorizedsymbolrenderer.h +++ b/src/core/symbology-ng/qgscategorizedsymbolrenderer.h @@ -61,7 +61,7 @@ class CORE_EXPORT QgsRendererCategory protected: QVariant mValue; - QScopedPointer mSymbol; + std::unique_ptr mSymbol; QString mLabel; bool mRender; @@ -184,9 +184,9 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer protected: QString mAttrName; QgsCategoryList mCategories; - QScopedPointer mSourceSymbol; - QScopedPointer mSourceColorRamp; - QScopedPointer mExpression; + std::unique_ptr mSourceSymbol; + std::unique_ptr mSourceColorRamp; + std::unique_ptr mExpression; //! attribute index (derived from attribute name in startRender) int mAttrNum; diff --git a/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h b/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h index 9a40906f559..41a668a4d35 100644 --- a/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h +++ b/src/core/symbology-ng/qgsgeometrygeneratorsymbollayer.h @@ -95,7 +95,7 @@ class CORE_EXPORT QgsGeometryGeneratorSymbolLayer : public QgsSymbolLayer private: QgsGeometryGeneratorSymbolLayer( const QString& expression ); - QScopedPointer mExpression; + std::unique_ptr mExpression; QgsFillSymbol* mFillSymbol; QgsLineSymbol* mLineSymbol; QgsMarkerSymbol* mMarkerSymbol; diff --git a/src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp b/src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp index 70f3d3861a3..8b6455fb19f 100644 --- a/src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp +++ b/src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp @@ -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( 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 symbol( mRanges.at( i ).symbol() ? mRanges.at( i ).symbol()->clone() : nullptr ); + std::unique_ptr 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 symbol( sym->clone() ); + std::unique_ptr 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( symbol.data() )->setSize( + static_cast( symbol.get() )->setSize( static_cast( range.symbol() )->size() ); else if ( symbol->type() == QgsSymbol::Line ) - static_cast( symbol.data() )->setWidth( + static_cast( symbol.get() )->setWidth( static_cast( 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() ); diff --git a/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h b/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h index d0e9c77bfeb..5dc132c39ec 100644 --- a/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h +++ b/src/core/symbology-ng/qgsgraduatedsymbolrenderer.h @@ -66,7 +66,7 @@ class CORE_EXPORT QgsRendererRange protected: double mLowerValue, mUpperValue; - QScopedPointer mSymbol; + std::unique_ptr mSymbol; QString mLabel; bool mRender; @@ -333,11 +333,11 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer QString mAttrName; QgsRangeList mRanges; Mode mMode; - QScopedPointer mSourceSymbol; - QScopedPointer mSourceColorRamp; + std::unique_ptr mSourceSymbol; + std::unique_ptr mSourceColorRamp; QgsRendererRangeLabelFormat mLabelFormat; - QScopedPointer mExpression; + std::unique_ptr mExpression; GraduatedMethod mGraduatedMethod; //! attribute index (derived from attribute name in startRender) int mAttrNum; diff --git a/src/core/symbology-ng/qgsheatmaprenderer.cpp b/src/core/symbology-ng/qgsheatmaprenderer.cpp index 8505daa3744..ff72f913d16 100644 --- a/src/core/symbology-ng/qgsheatmaprenderer.cpp +++ b/src/core/symbology-ng/qgsheatmaprenderer.cpp @@ -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 diff --git a/src/core/symbology-ng/qgsheatmaprenderer.h b/src/core/symbology-ng/qgsheatmaprenderer.h index 4b9486888aa..883cb63a1a1 100644 --- a/src/core/symbology-ng/qgsheatmaprenderer.h +++ b/src/core/symbology-ng/qgsheatmaprenderer.h @@ -177,7 +177,7 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRenderer QString mWeightExpressionString; int mWeightAttrNum; - QScopedPointer mWeightExpression; + std::unique_ptr mWeightExpression; QgsColorRamp* mGradientRamp; diff --git a/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp b/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp index 8fc35943155..f0f1c54a05a 100644 --- a/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp +++ b/src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp @@ -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 ); diff --git a/src/core/symbology-ng/qgsinvertedpolygonrenderer.h b/src/core/symbology-ng/qgsinvertedpolygonrenderer.h index 1e1d3d676aa..dc6b5363ef5 100644 --- a/src/core/symbology-ng/qgsinvertedpolygonrenderer.h +++ b/src/core/symbology-ng/qgsinvertedpolygonrenderer.h @@ -144,7 +144,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRenderer private: //! Embedded renderer - QScopedPointer mSubRenderer; + std::unique_ptr mSubRenderer; //! Structure where the reversed geometry is built during renderFeature struct CombinedFeature diff --git a/src/core/symbology-ng/qgsmarkersymbollayer.cpp b/src/core/symbology-ng/qgsmarkersymbollayer.cpp index adfab66f7f4..7798ec62af5 100644 --- a/src/core/symbology-ng/qgsmarkersymbollayer.cpp +++ b/src/core/symbology-ng/qgsmarkersymbollayer.cpp @@ -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 QgsFilledMarkerSymbolLayer::usedAttributes( const QgsRenderContext& context ) const { QSet attr = QgsSimpleMarkerSymbolLayerBase::usedAttributes( context ); - if ( mFill.data() ) + if ( mFill ) attr.unite( mFill->usedAttributes( context ) ); return attr; } @@ -1640,13 +1640,13 @@ QSet 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 ) diff --git a/src/core/symbology-ng/qgsmarkersymbollayer.h b/src/core/symbology-ng/qgsmarkersymbollayer.h index 48d844b58b8..5f1bc7b2c3a 100644 --- a/src/core/symbology-ng/qgsmarkersymbollayer.h +++ b/src/core/symbology-ng/qgsmarkersymbollayer.h @@ -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; }; ////////// diff --git a/src/core/symbology-ng/qgsnullsymbolrenderer.cpp b/src/core/symbology-ng/qgsnullsymbolrenderer.cpp index 60ac9f65670..d5587ca617e 100644 --- a/src/core/symbology-ng/qgsnullsymbolrenderer.cpp +++ b/src/core/symbology-ng/qgsnullsymbolrenderer.cpp @@ -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 ); } diff --git a/src/core/symbology-ng/qgsnullsymbolrenderer.h b/src/core/symbology-ng/qgsnullsymbolrenderer.h index 02abe45aba3..71eaedc7f1f 100644 --- a/src/core/symbology-ng/qgsnullsymbolrenderer.h +++ b/src/core/symbology-ng/qgsnullsymbolrenderer.h @@ -63,7 +63,7 @@ class CORE_EXPORT QgsNullSymbolRenderer : public QgsFeatureRenderer private: //! Symbol to use for rendering selected features - QScopedPointer mSymbol; + std::unique_ptr mSymbol; }; diff --git a/src/core/symbology-ng/qgspointclusterrenderer.cpp b/src/core/symbology-ng/qgspointclusterrenderer.cpp index 058edc9c8f1..96d1ed87ebe 100644 --- a/src/core/symbology-ng/qgspointclusterrenderer.cpp +++ b/src/core/symbology-ng/qgspointclusterrenderer.cpp @@ -120,7 +120,7 @@ QgsFeatureRenderer* QgsPointClusterRenderer::create( QDomElement& symbologyElem QgsMarkerSymbol* QgsPointClusterRenderer::clusterSymbol() { - return mClusterSymbol.data(); + return mClusterSymbol.get(); } QDomElement QgsPointClusterRenderer::save( QDomDocument& doc ) @@ -139,7 +139,7 @@ QDomElement QgsPointClusterRenderer::save( QDomDocument& doc ) } if ( mClusterSymbol ) { - QDomElement centerSymbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "centerSymbol" ), mClusterSymbol.data(), doc ); + QDomElement centerSymbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "centerSymbol" ), mClusterSymbol.get(), doc ); rendererElement.appendChild( centerSymbolElem ); } diff --git a/src/core/symbology-ng/qgspointclusterrenderer.h b/src/core/symbology-ng/qgspointclusterrenderer.h index fe2a8dd1279..e02f26f57ac 100644 --- a/src/core/symbology-ng/qgspointclusterrenderer.h +++ b/src/core/symbology-ng/qgspointclusterrenderer.h @@ -60,7 +60,7 @@ class CORE_EXPORT QgsPointClusterRenderer: public QgsPointDistanceRenderer private: //! Symbol for point clusters - QScopedPointer< QgsMarkerSymbol > mClusterSymbol; + std::unique_ptr< QgsMarkerSymbol > mClusterSymbol; void drawGroup( QPointF centerPoint, QgsRenderContext& context, const QgsPointDistanceRenderer::ClusteredGroup& group ) override; diff --git a/src/core/symbology-ng/qgspointdisplacementrenderer.cpp b/src/core/symbology-ng/qgspointdisplacementrenderer.cpp index f7ee423ea64..a61a97680ba 100644 --- a/src/core/symbology-ng/qgspointdisplacementrenderer.cpp +++ b/src/core/symbology-ng/qgspointdisplacementrenderer.cpp @@ -169,7 +169,7 @@ QgsFeatureRenderer* QgsPointDisplacementRenderer::create( QDomElement& symbology QgsMarkerSymbol* QgsPointDisplacementRenderer::centerSymbol() { - return mCenterSymbol.data(); + return mCenterSymbol.get(); } QDomElement QgsPointDisplacementRenderer::save( QDomDocument& doc ) @@ -196,7 +196,7 @@ QDomElement QgsPointDisplacementRenderer::save( QDomDocument& doc ) } if ( mCenterSymbol ) { - QDomElement centerSymbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "centerSymbol" ), mCenterSymbol.data(), doc ); + QDomElement centerSymbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "centerSymbol" ), mCenterSymbol.get(), doc ); rendererElement.appendChild( centerSymbolElem ); } diff --git a/src/core/symbology-ng/qgspointdisplacementrenderer.h b/src/core/symbology-ng/qgspointdisplacementrenderer.h index 0d5914c00bb..7dd14dcf216 100644 --- a/src/core/symbology-ng/qgspointdisplacementrenderer.h +++ b/src/core/symbology-ng/qgspointdisplacementrenderer.h @@ -121,7 +121,7 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsPointDistanceRenderer private: //! Center symbol for a displacement group - QScopedPointer< QgsMarkerSymbol > mCenterSymbol; + std::unique_ptr< QgsMarkerSymbol > mCenterSymbol; //! Displacement placement mode Placement mPlacement; diff --git a/src/core/symbology-ng/qgspointdistancerenderer.cpp b/src/core/symbology-ng/qgspointdistancerenderer.cpp index 197e7e2219d..085426a748d 100644 --- a/src/core/symbology-ng/qgspointdistancerenderer.cpp +++ b/src/core/symbology-ng/qgspointdistancerenderer.cpp @@ -161,7 +161,7 @@ void QgsPointDistanceRenderer::setEmbeddedRenderer( QgsFeatureRenderer* r ) const QgsFeatureRenderer*QgsPointDistanceRenderer::embeddedRenderer() const { - return mRenderer.data(); + return mRenderer.get(); } void QgsPointDistanceRenderer::setLegendSymbolItem( const QString& key, QgsSymbol* symbol ) diff --git a/src/core/symbology-ng/qgspointdistancerenderer.h b/src/core/symbology-ng/qgspointdistancerenderer.h index e28c4973147..b890521a8b4 100644 --- a/src/core/symbology-ng/qgspointdistancerenderer.h +++ b/src/core/symbology-ng/qgspointdistancerenderer.h @@ -208,7 +208,7 @@ class CORE_EXPORT QgsPointDistanceRenderer: public QgsFeatureRenderer protected: //! Embedded base renderer. This can be used for rendering individual, isolated points. - QScopedPointer< QgsFeatureRenderer > mRenderer; + std::unique_ptr< QgsFeatureRenderer > mRenderer; //! Attribute name for labeling. An empty string indicates that no labels should be rendered. QString mLabelAttributeName; diff --git a/src/core/symbology-ng/qgssinglesymbolrenderer.cpp b/src/core/symbology-ng/qgssinglesymbolrenderer.cpp index 269aeba10e2..82d40f8da0a 100644 --- a/src/core/symbology-ng/qgssinglesymbolrenderer.cpp +++ b/src/core/symbology-ng/qgssinglesymbolrenderer.cpp @@ -42,19 +42,19 @@ QgsSingleSymbolRenderer::QgsSingleSymbolRenderer( QgsSymbol* symbol ) QgsSymbol* QgsSingleSymbolRenderer::symbolForFeature( QgsFeature&, QgsRenderContext & ) { - return mSymbol.data(); + return mSymbol.get(); } QgsSymbol* QgsSingleSymbolRenderer::originalSymbolForFeature( QgsFeature& feature, QgsRenderContext &context ) { Q_UNUSED( context ); Q_UNUSED( feature ); - return mSymbol.data(); + return mSymbol.get(); } void QgsSingleSymbolRenderer::startRender( QgsRenderContext& context, const QgsFields& fields ) { - if ( !mSymbol.data() ) + if ( !mSymbol ) return; mSymbol->startRender( context, fields ); @@ -62,7 +62,7 @@ void QgsSingleSymbolRenderer::startRender( QgsRenderContext& context, const QgsF void QgsSingleSymbolRenderer::stopRender( QgsRenderContext& context ) { - if ( !mSymbol.data() ) + if ( !mSymbol ) return; mSymbol->stopRender( context ); @@ -71,14 +71,14 @@ void QgsSingleSymbolRenderer::stopRender( QgsRenderContext& context ) QSet QgsSingleSymbolRenderer::usedAttributes( const QgsRenderContext& context ) const { QSet attributes; - if ( mSymbol.data() ) + if ( mSymbol ) attributes.unite( mSymbol->usedAttributes( context ) ); return attributes; } QgsSymbol* QgsSingleSymbolRenderer::symbol() const { - return mSymbol.data(); + return mSymbol.get(); } void QgsSingleSymbolRenderer::setSymbol( QgsSymbol* s ) @@ -89,7 +89,7 @@ void QgsSingleSymbolRenderer::setSymbol( QgsSymbol* s ) QString QgsSingleSymbolRenderer::dump() const { - return mSymbol.data() ? QStringLiteral( "SINGLE: %1" ).arg( mSymbol->dump() ) : QLatin1String( "" ); + return mSymbol ? QStringLiteral( "SINGLE: %1" ).arg( mSymbol->dump() ) : QLatin1String( "" ); } QgsSingleSymbolRenderer* QgsSingleSymbolRenderer::clone() const @@ -113,14 +113,14 @@ void QgsSingleSymbolRenderer::toSld( QDomDocument& doc, QDomElement &element, co QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElem, newProps ); - if ( mSymbol.data() ) mSymbol->toSld( doc, ruleElem, newProps ); + if ( mSymbol ) mSymbol->toSld( doc, ruleElem, newProps ); } QgsSymbolList QgsSingleSymbolRenderer::symbols( QgsRenderContext &context ) { Q_UNUSED( context ); QgsSymbolList lst; - lst.append( mSymbol.data() ); + lst.append( mSymbol.get() ); return lst; } @@ -144,13 +144,13 @@ QgsFeatureRenderer* QgsSingleSymbolRenderer::create( QDomElement& element ) QDomElement rotationElem = element.firstChildElement( QStringLiteral( "rotation" ) ); if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral( "field" ) ).isEmpty() ) { - convertSymbolRotation( r->mSymbol.data(), rotationElem.attribute( QStringLiteral( "field" ) ) ); + convertSymbolRotation( r->mSymbol.get(), rotationElem.attribute( QStringLiteral( "field" ) ) ); } QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral( "sizescale" ) ); if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral( "field" ) ).isEmpty() ) { - convertSymbolSizeScale( r->mSymbol.data(), + convertSymbolSizeScale( r->mSymbol.get(), QgsSymbolLayerUtils::decodeScaleMethod( sizeScaleElem.attribute( QStringLiteral( "scalemethod" ) ) ), sizeScaleElem.attribute( QStringLiteral( "field" ) ) ); } @@ -255,7 +255,7 @@ QDomElement QgsSingleSymbolRenderer::save( QDomDocument& doc ) rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? "1" : "0" ) ); QgsSymbolMap symbols; - symbols[QStringLiteral( "0" )] = mSymbol.data(); + symbols[QStringLiteral( "0" )] = mSymbol.get(); QDomElement symbolsElem = QgsSymbolLayerUtils::saveSymbols( symbols, QStringLiteral( "symbols" ), doc ); rendererElem.appendChild( symbolsElem ); @@ -282,9 +282,9 @@ QDomElement QgsSingleSymbolRenderer::save( QDomDocument& doc ) QgsLegendSymbologyList QgsSingleSymbolRenderer::legendSymbologyItems( QSize iconSize ) { QgsLegendSymbologyList lst; - if ( mSymbol.data() ) + if ( mSymbol ) { - QPixmap pix = QgsSymbolLayerUtils::symbolPreviewPixmap( mSymbol.data(), iconSize ); + QPixmap pix = QgsSymbolLayerUtils::symbolPreviewPixmap( mSymbol.get(), iconSize ); lst << qMakePair( QString(), pix ); } return lst; @@ -295,7 +295,7 @@ QgsLegendSymbolList QgsSingleSymbolRenderer::legendSymbolItems( double scaleDeno Q_UNUSED( scaleDenominator ); Q_UNUSED( rule ); QgsLegendSymbolList lst; - lst << qMakePair( QString(), mSymbol.data() ); + lst << qMakePair( QString(), mSymbol.get() ); return lst; } @@ -304,7 +304,7 @@ QgsLegendSymbolListV2 QgsSingleSymbolRenderer::legendSymbolItemsV2() const QgsLegendSymbolListV2 lst; if ( mSymbol->type() == QgsSymbol::Marker ) { - const QgsMarkerSymbol * symbol = static_cast( mSymbol.data() ); + const QgsMarkerSymbol * symbol = static_cast( mSymbol.get() ); QgsProperty sizeDD( symbol->dataDefinedSize() ); if ( sizeDD && sizeDD.isActive() && sizeDD.propertyType() == QgsProperty::ExpressionBasedProperty ) { @@ -315,7 +315,7 @@ QgsLegendSymbolListV2 QgsSingleSymbolRenderer::legendSymbolItemsV2() const lst << title; Q_FOREACH ( double v, QgsSymbolLayerUtils::prettyBreaks( scaleExp.minValue(), scaleExp.maxValue(), 4 ) ) { - QgsLegendSymbolItem si( mSymbol.data(), QString::number( v ), QString() ); + QgsLegendSymbolItem si( mSymbol.get(), QString::number( v ), QString() ); QgsMarkerSymbol * s = static_cast( si.symbol() ); s->setDataDefinedSize( QgsProperty() ); s->setSize( scaleExp.size( v ) ); @@ -326,7 +326,7 @@ QgsLegendSymbolListV2 QgsSingleSymbolRenderer::legendSymbolItemsV2() const } } - lst << QgsLegendSymbolItem( mSymbol.data(), QString(), QString() ); + lst << QgsLegendSymbolItem( mSymbol.get(), QString(), QString() ); return lst; } diff --git a/src/core/symbology-ng/qgssinglesymbolrenderer.h b/src/core/symbology-ng/qgssinglesymbolrenderer.h index d10e79983fe..d7e09b75bb2 100644 --- a/src/core/symbology-ng/qgssinglesymbolrenderer.h +++ b/src/core/symbology-ng/qgssinglesymbolrenderer.h @@ -65,7 +65,7 @@ class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer static QgsSingleSymbolRenderer* convertFromRenderer( const QgsFeatureRenderer *renderer ); protected: - QScopedPointer mSymbol; + std::unique_ptr mSymbol; }; diff --git a/src/core/symbology-ng/qgsstyle.cpp b/src/core/symbology-ng/qgsstyle.cpp index 455f5155b83..52a8b8f64d0 100644 --- a/src/core/symbology-ng/qgsstyle.cpp +++ b/src/core/symbology-ng/qgsstyle.cpp @@ -1688,8 +1688,8 @@ bool QgsStyle::updateSymbol( StyleEntity type, const QString& name ) return false; } - QScopedPointer< QgsColorRamp > ramp( colorRamp( name ) ); - symEl = QgsSymbolLayerUtils::saveColorRamp( name, ramp.data(), doc ); + std::unique_ptr< QgsColorRamp > ramp( colorRamp( name ) ); + symEl = QgsSymbolLayerUtils::saveColorRamp( name, ramp.get(), doc ); if ( symEl.isNull() ) { QgsDebugMsg( "Couldn't convert color ramp to valid XML!" ); diff --git a/src/gui/qgisgui.cpp b/src/gui/qgisgui.cpp index b63c14adcdf..e3fc2eeda20 100644 --- a/src/gui/qgisgui.cpp +++ b/src/gui/qgisgui.cpp @@ -140,7 +140,7 @@ namespace QgisGui #else //create a file dialog using the filter list generated above - QScopedPointer fileDialog( new QFileDialog( theParent, theMessage, initialPath, QStringList( filterMap.keys() ).join( ";;" ) ) ); + std::unique_ptr fileDialog( new QFileDialog( theParent, theMessage, initialPath, QStringList( filterMap.keys() ).join( ";;" ) ) ); // allow for selection of more than one file fileDialog->setFileMode( QFileDialog::AnyFile ); diff --git a/src/gui/qgsadvanceddigitizingdockwidget.cpp b/src/gui/qgsadvanceddigitizingdockwidget.cpp index 172c3380131..4bd164d76d2 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.cpp +++ b/src/gui/qgsadvanceddigitizingdockwidget.cpp @@ -348,19 +348,19 @@ QgsAdvancedDigitizingDockWidget::CadConstraint* QgsAdvancedDigitizingDockWidget: CadConstraint* constraint = nullptr; if ( obj == mAngleLineEdit || obj == mLockAngleButton ) { - constraint = mAngleConstraint.data(); + constraint = mAngleConstraint.get(); } else if ( obj == mDistanceLineEdit || obj == mLockDistanceButton ) { - constraint = mDistanceConstraint.data(); + constraint = mDistanceConstraint.get(); } else if ( obj == mXLineEdit || obj == mLockXButton ) { - constraint = mXConstraint.data(); + constraint = mXConstraint.get(); } else if ( obj == mYLineEdit || obj == mLockYButton ) { - constraint = mYConstraint.data(); + constraint = mYConstraint.get(); } return constraint; } @@ -440,7 +440,7 @@ void QgsAdvancedDigitizingDockWidget::lockConstraint( bool activate /* default t if ( activate ) { // deactivate perpendicular/parallel if angle has been activated - if ( constraint == mAngleConstraint.data() ) + if ( constraint == mAngleConstraint.get() ) { lockAdditionalConstraint( NoConstraint ); } diff --git a/src/gui/qgsadvanceddigitizingdockwidget.h b/src/gui/qgsadvanceddigitizingdockwidget.h index 9d6fa1673c1..4c76f73c526 100644 --- a/src/gui/qgsadvanceddigitizingdockwidget.h +++ b/src/gui/qgsadvanceddigitizingdockwidget.h @@ -22,7 +22,7 @@ #include #include "qgis_gui.h" - +#include class QgsAdvancedDigitizingCanvasItem; class QgsMapCanvas; @@ -271,13 +271,13 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private //! Additional constraints are used to place perpendicular/parallel segments to snapped segments on the canvas AdditionalConstraint additionalConstraint() const { return mAdditionalConstraint; } //! Constraint on the angle - const CadConstraint* constraintAngle() const { return mAngleConstraint.data(); } + const CadConstraint* constraintAngle() const { return mAngleConstraint.get(); } //! Constraint on the distance - const CadConstraint* constraintDistance() const { return mDistanceConstraint.data(); } + const CadConstraint* constraintDistance() const { return mDistanceConstraint.get(); } //! Constraint on the X coordinate - const CadConstraint* constraintX() const { return mXConstraint.data(); } + const CadConstraint* constraintX() const { return mXConstraint.get(); } //! Constraint on the Y coordinate - const CadConstraint* constraintY() const { return mYConstraint.data(); } + const CadConstraint* constraintY() const { return mYConstraint.get(); } //! Constraint on a common angle bool commonAngleConstraint() const { return mCommonAngleConstraint; } @@ -455,10 +455,10 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private QgsMapMouseEvent::SnappingMode mSnappingMode; // constraints - QScopedPointer< CadConstraint > mAngleConstraint; - QScopedPointer< CadConstraint > mDistanceConstraint; - QScopedPointer< CadConstraint > mXConstraint; - QScopedPointer< CadConstraint > mYConstraint; + std::unique_ptr< CadConstraint > mAngleConstraint; + std::unique_ptr< CadConstraint > mDistanceConstraint; + std::unique_ptr< CadConstraint > mXConstraint; + std::unique_ptr< CadConstraint > mYConstraint; AdditionalConstraint mAdditionalConstraint; int mCommonAngleConstraint; // if 0: do not snap to common angles @@ -470,7 +470,7 @@ class GUI_EXPORT QgsAdvancedDigitizingDockWidget : public QgsDockWidget, private bool mSessionActive; // error message - QScopedPointer mErrorMessage; + std::unique_ptr mErrorMessage; // UI QAction* mEnableAction; diff --git a/src/gui/qgscolorrampbutton.cpp b/src/gui/qgscolorrampbutton.cpp index 1df9890fd7c..39c2972e1e7 100644 --- a/src/gui/qgscolorrampbutton.cpp +++ b/src/gui/qgscolorrampbutton.cpp @@ -87,7 +87,7 @@ void QgsColorRampButton::showColorRampDialog() QgsPanelWidget* panel = QgsPanelWidget::findParentPanel( this ); bool panelMode = panel && panel->dockMode(); - QScopedPointer< QgsColorRamp > currentRamp( colorRamp() ); + std::unique_ptr< QgsColorRamp > currentRamp( colorRamp() ); if ( !currentRamp ) return; @@ -95,7 +95,7 @@ void QgsColorRampButton::showColorRampDialog() if ( currentRamp->type() == QLatin1String( "gradient" ) ) { - QgsGradientColorRamp* gradRamp = static_cast( currentRamp.data() ); + QgsGradientColorRamp* gradRamp = static_cast( currentRamp.get() ); QgsGradientColorRampDialog dlg( *gradRamp, this ); dlg.setWindowTitle( mColorRampDialogTitle ); if ( dlg.exec() ) @@ -105,7 +105,7 @@ void QgsColorRampButton::showColorRampDialog() } else if ( currentRamp->type() == QLatin1String( "random" ) ) { - QgsLimitedRandomColorRamp* randRamp = static_cast( currentRamp.data() ); + QgsLimitedRandomColorRamp* randRamp = static_cast( currentRamp.get() ); if ( panelMode ) { QgsLimitedRandomColorRampWidget* widget = new QgsLimitedRandomColorRampWidget( *randRamp, this ); @@ -124,7 +124,7 @@ void QgsColorRampButton::showColorRampDialog() } else if ( currentRamp->type() == QLatin1String( "preset" ) ) { - QgsPresetSchemeColorRamp* presetRamp = static_cast( currentRamp.data() ); + QgsPresetSchemeColorRamp* presetRamp = static_cast( currentRamp.get() ); if ( panelMode ) { QgsPresetColorRampWidget* widget = new QgsPresetColorRampWidget( *presetRamp, this ); @@ -143,7 +143,7 @@ void QgsColorRampButton::showColorRampDialog() } else if ( currentRamp->type() == QLatin1String( "colorbrewer" ) ) { - QgsColorBrewerColorRamp* brewerRamp = static_cast( currentRamp.data() ); + QgsColorBrewerColorRamp* brewerRamp = static_cast( currentRamp.get() ); if ( panelMode ) { QgsColorBrewerColorRampWidget* widget = new QgsColorBrewerColorRampWidget( *brewerRamp, this ); @@ -162,7 +162,7 @@ void QgsColorRampButton::showColorRampDialog() } else if ( currentRamp->type() == QLatin1String( "cpt-city" ) ) { - QgsCptCityColorRamp* cptCityRamp = static_cast( currentRamp.data() ); + QgsCptCityColorRamp* cptCityRamp = static_cast( currentRamp.get() ); QgsCptCityColorRampDialog dlg( *cptCityRamp, this ); if ( dlg.exec() ) { @@ -276,11 +276,11 @@ void QgsColorRampButton::prepareMenu() rampNames.sort(); for ( QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it ) { - QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( *it ) ); + std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( *it ) ); if ( !mShowGradientOnly || ( ramp->type() == QLatin1String( "gradient" ) || ramp->type() == QLatin1String( "cpt-city" ) ) ) { - QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), QSize( 16, 16 ) ); + QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), QSize( 16, 16 ) ); QAction* ra = new QAction( *it, this ); ra->setIcon( icon ); connect( ra, &QAction::triggered, this, &QgsColorRampButton::loadColorRamp ); @@ -296,11 +296,11 @@ void QgsColorRampButton::prepareMenu() rampNames.sort(); for ( QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it ) { - QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( *it ) ); + std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( *it ) ); if ( !mShowGradientOnly || ( ramp->type() == QLatin1String( "gradient" ) || ramp->type() == QLatin1String( "cpt-city" ) ) ) { - QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), QSize( 16, 16 ) ); + QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), QSize( 16, 16 ) ); QAction* ra = new QAction( *it, this ); ra->setIcon( icon ); connect( ra, &QAction::triggered, this, &QgsColorRampButton::loadColorRamp ); @@ -486,10 +486,10 @@ void QgsColorRampButton::setColorRampFromName( const QString& name ) { if ( !name.isEmpty() ) { - QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( name ) ); + std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( name ) ); if ( ramp ) { - setColorRamp( ramp.data() ); + setColorRamp( ramp.get() ); } } } diff --git a/src/gui/qgscomposerview.cpp b/src/gui/qgscomposerview.cpp index f4ecdb98493..3031ad18053 100644 --- a/src/gui/qgscomposerview.cpp +++ b/src/gui/qgscomposerview.cpp @@ -458,14 +458,14 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e ) case AddPolygon: { - if ( mPolygonItem.isNull() ) + if ( !mPolygonItem ) { mPolygonItem.reset( new QGraphicsPolygonItem() ); - mPolygonItem.data()->setBrush( Qt::NoBrush ); - mPolygonItem.data()->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) ); - mPolygonItem.data()->setZValue( 1000 ); + mPolygonItem->setBrush( Qt::NoBrush ); + mPolygonItem->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) ); + mPolygonItem->setZValue( 1000 ); - scene()->addItem( mPolygonItem.data() ); + scene()->addItem( mPolygonItem.get() ); scene()->update(); } @@ -474,13 +474,13 @@ void QgsComposerView::mousePressEvent( QMouseEvent* e ) case AddPolyline: { - if ( mPolylineItem.isNull() && mPolygonItem.isNull() ) + if ( !mPolylineItem && !mPolygonItem ) { mPolygonItem.reset( new QGraphicsPolygonItem() ); mPolylineItem.reset( new QGraphicsPathItem() ); - mPolylineItem.data()->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) ); - mPolylineItem.data()->setZValue( 1000 ); + mPolylineItem->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) ); + mPolylineItem->setZValue( 1000 ); } break; @@ -796,18 +796,18 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) { case AddPolygon: { - if ( ! mPolygonItem.isNull() ) + if ( mPolygonItem ) { - QPolygonF poly = mPolygonItem.data()->polygon(); + QPolygonF poly = mPolygonItem->polygon(); // last (temporary) point is removed poly.remove( poly.count() - 1 ); if ( poly.size() >= 3 ) { - mPolygonItem.data()->setPolygon( poly ); + mPolygonItem->setPolygon( poly ); // add polygon in composition - QgsComposerPolygon *composerPolygon = new QgsComposerPolygon( mPolygonItem.data()->polygon(), composition() ); + QgsComposerPolygon *composerPolygon = new QgsComposerPolygon( mPolygonItem->polygon(), composition() ); composition()->addComposerPolygon( composerPolygon ); // select the polygon @@ -819,7 +819,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) } // clean - scene()->removeItem( mPolygonItem.data() ); + scene()->removeItem( mPolygonItem.get() ); mPolygonItem.reset(); emit actionFinished(); } @@ -828,19 +828,19 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) case AddPolyline: { - if ( ! mPolygonItem.isNull() && ! mPolylineItem.isNull() ) + if ( mPolygonItem && mPolylineItem ) { // ignore the last point due to release event before doubleClick event - QPolygonF poly = mPolygonItem.data()->polygon(); + QPolygonF poly = mPolygonItem->polygon(); // last (temporary) point is removed poly.remove( poly.count() - 1 ); if ( poly.size() >= 2 ) { - mPolygonItem.data()->setPolygon( poly ); + mPolygonItem->setPolygon( poly ); // add polygon in composition - QgsComposerPolyline *composerPolyline = new QgsComposerPolyline( mPolygonItem.data()->polygon(), composition() ); + QgsComposerPolyline *composerPolyline = new QgsComposerPolyline( mPolygonItem->polygon(), composition() ); composition()->addComposerPolyline( composerPolyline ); // select the polygon @@ -852,7 +852,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) } // clean - scene()->removeItem( mPolylineItem.data() ); + scene()->removeItem( mPolylineItem.get() ); mPolygonItem.reset(); mPolylineItem.reset(); emit actionFinished(); @@ -964,7 +964,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) case AddPolygon: { - if ( ! mPolygonItem.isNull() ) + if ( mPolygonItem ) addPolygonNode( scenePoint ); break; @@ -972,17 +972,17 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent* e ) case AddPolyline: { - if ( ! mPolygonItem.isNull() && ! mPolylineItem.isNull() ) + if ( mPolygonItem && mPolylineItem ) { addPolygonNode( scenePoint ); // rebuild a new qpainter path QPainterPath path; - path.addPolygon( mPolygonItem.data()->polygon() ); - mPolylineItem.data()->setPath( path ); + path.addPolygon( mPolygonItem->polygon() ); + mPolylineItem->setPath( path ); // add it to the scene - scene()->addItem( mPolylineItem.data() ); + scene()->addItem( mPolylineItem.get() ); scene()->update(); } break; @@ -1201,7 +1201,7 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e ) mMouseLastXY = e->pos(); return; } - else if (( e->buttons() == Qt::NoButton ) && ( mPolygonItem.isNull() ) ) + else if (( e->buttons() == Qt::NoButton ) && ( !mPolygonItem ) ) { if ( mCurrentTool == Select ) { @@ -1248,7 +1248,7 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e ) case AddPolygon: { - if ( ! mPolygonItem.isNull() ) + if ( mPolygonItem ) movePolygonNode( scenePoint, shiftModifier ); break; @@ -1256,14 +1256,14 @@ void QgsComposerView::mouseMoveEvent( QMouseEvent* e ) case AddPolyline: { - if ( ! mPolygonItem.isNull() && ! mPolylineItem.isNull() ) + if ( mPolygonItem && mPolylineItem ) { movePolygonNode( scenePoint, shiftModifier ); // rebuild a new qpainter path QPainterPath path; - path.addPolygon( mPolygonItem.data()->polygon() ); - mPolylineItem.data()->setPath( path ); + path.addPolygon( mPolygonItem->polygon() ); + mPolylineItem->setPath( path ); } break; @@ -2251,18 +2251,18 @@ QMainWindow* QgsComposerView::composerWindow() void QgsComposerView::addPolygonNode( QPointF scenePoint ) { - QPolygonF polygon = mPolygonItem.data()->polygon(); + QPolygonF polygon = mPolygonItem->polygon(); polygon.append( QPointF( scenePoint.x(), scenePoint.y() ) ); if ( polygon.size() == 1 ) polygon.append( QPointF( scenePoint.x(), scenePoint.y() ) ); - mPolygonItem.data()->setPolygon( polygon ); + mPolygonItem->setPolygon( polygon ); } void QgsComposerView::movePolygonNode( QPointF scenePoint, bool constrainAngle ) { - QPolygonF polygon = mPolygonItem.data()->polygon(); + QPolygonF polygon = mPolygonItem->polygon(); if ( polygon.isEmpty() ) return; @@ -2279,7 +2279,7 @@ void QgsComposerView::movePolygonNode( QPointF scenePoint, bool constrainAngle ) } polygon.replace( polygon.size() - 1, scenePoint ); - mPolygonItem.data()->setPolygon( polygon ); + mPolygonItem->setPolygon( polygon ); } void QgsComposerView::displayNodes( const bool display ) diff --git a/src/gui/qgscomposerview.h b/src/gui/qgscomposerview.h index bae08042fc2..1dc68e8ebc7 100644 --- a/src/gui/qgscomposerview.h +++ b/src/gui/qgscomposerview.h @@ -21,6 +21,7 @@ #include "qgsprevieweffect.h" // for QgsPreviewEffect::PreviewMode #include #include "qgis_gui.h" +#include class QDomDocument; class QDomElement; @@ -248,8 +249,8 @@ class GUI_EXPORT QgsComposerView: public QGraphicsView float mMoveContentSearchRadius; QgsComposerNodesItem* mNodesItem; int mNodesItemIndex; - QScopedPointer mPolygonItem; - QScopedPointer mPolylineItem; + std::unique_ptr mPolygonItem; + std::unique_ptr mPolylineItem; //! True if user is currently panning by clicking and dragging with the pan tool bool mToolPanning; diff --git a/src/gui/qgsdatadefinedbutton.cpp b/src/gui/qgsdatadefinedbutton.cpp index 273bceb4057..012bbeab9be 100644 --- a/src/gui/qgsdatadefinedbutton.cpp +++ b/src/gui/qgsdatadefinedbutton.cpp @@ -395,7 +395,7 @@ void QgsDataDefinedButton::aboutToShowMenu() mDefineMenu->addAction( mActionPasteExpr ); } - if ( mAssistant.data() ) + if ( mAssistant ) { mDefineMenu->addSeparator(); mDefineMenu->addAction( mActionAssistant ); @@ -488,7 +488,7 @@ void QgsDataDefinedButton::showDescriptionDialog() void QgsDataDefinedButton::showAssistant() { - if ( !mAssistant.data() ) + if ( !mAssistant ) return; if ( mAssistant->exec() == QDialog::Accepted ) @@ -700,12 +700,12 @@ void QgsDataDefinedButton::setAssistant( const QString& title, QgsDataDefinedAss { mActionAssistant->setText( title.isEmpty() ? tr( "Assistant..." ) : title ); mAssistant.reset( assistant ); - mAssistant.data()->setParent( this, Qt::Dialog ); + mAssistant->setParent( this, Qt::Dialog ); } QgsDataDefinedAssistant *QgsDataDefinedButton::assistant() { - return mAssistant.data(); + return mAssistant.get(); } void QgsDataDefinedButton::checkCheckedWidgets( bool check ) diff --git a/src/gui/qgsdatadefinedbutton.h b/src/gui/qgsdatadefinedbutton.h index 650eb304f6c..9316124ce32 100644 --- a/src/gui/qgsdatadefinedbutton.h +++ b/src/gui/qgsdatadefinedbutton.h @@ -380,7 +380,7 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton QString mUsageInfo; QString mCurrentDefinition; - QScopedPointer mAssistant; + std::unique_ptr mAssistant; QIcon mIconDataDefine; QIcon mIconDataDefineOn; diff --git a/src/gui/qgsexpressionlineedit.cpp b/src/gui/qgsexpressionlineedit.cpp index fe6f8ba57fa..cad08bb5647 100644 --- a/src/gui/qgsexpressionlineedit.cpp +++ b/src/gui/qgsexpressionlineedit.cpp @@ -156,7 +156,7 @@ void QgsExpressionLineEdit::editExpression() QgsExpressionContext context = mExpressionContextGenerator ? mExpressionContextGenerator->createExpressionContext() : mExpressionContext; QgsExpressionBuilderDialog dlg( mLayer, currentExpression, this, QStringLiteral( "generic" ), context ); - if ( !mDa.isNull() ) + if ( mDa ) { dlg.setGeomCalculator( *mDa ); } diff --git a/src/gui/qgsexpressionlineedit.h b/src/gui/qgsexpressionlineedit.h index f98ebd8b6f2..fe1f485e71c 100644 --- a/src/gui/qgsexpressionlineedit.h +++ b/src/gui/qgsexpressionlineedit.h @@ -20,6 +20,7 @@ #include "qgsexpressioncontext.h" #include "qgsdistancearea.h" #include "qgis_gui.h" +#include class QgsFilterLineEdit; class QToolButton; @@ -152,7 +153,7 @@ class GUI_EXPORT QgsExpressionLineEdit : public QWidget QgsCodeEditorSQL* mCodeEditor; QToolButton* mButton; QString mExpressionDialogTitle; - QScopedPointer mDa; + std::unique_ptr mDa; QgsExpressionContext mExpressionContext; const QgsExpressionContextGenerator* mExpressionContextGenerator; QgsVectorLayer* mLayer; diff --git a/src/gui/qgsformannotation.h b/src/gui/qgsformannotation.h index 8efac78e34f..4d7f2b0565a 100644 --- a/src/gui/qgsformannotation.h +++ b/src/gui/qgsformannotation.h @@ -71,7 +71,7 @@ class GUI_EXPORT QgsFormAnnotation: public QgsAnnotation private: - QScopedPointer mDesignerWidget; + std::unique_ptr mDesignerWidget; QSize mMinimumSize; //! Path to (and including) the .ui file QString mDesignerForm; diff --git a/src/gui/qgshelp.cpp b/src/gui/qgshelp.cpp index f5e6703c366..547ff6dc1f1 100644 --- a/src/gui/qgshelp.cpp +++ b/src/gui/qgshelp.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "qgis.h" #include "qgsapplication.h" @@ -44,7 +45,7 @@ QUrl QgsHelp::helpUrl( const QString& key ) return helpNotFound; } - QScopedPointer scope( QgsExpressionContextUtils::globalScope() ); + std::unique_ptr scope( QgsExpressionContextUtils::globalScope() ); QUrl helpUrl; QString helpPath, fullPath; diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index 0590c8fd441..749a47324ea 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -1157,8 +1157,8 @@ void QgsMapCanvas::mouseDoubleClickEvent( QMouseEvent* e ) // call handler of current map tool if ( mMapTool ) { - QScopedPointer me( new QgsMapMouseEvent( this, e ) ); - mMapTool->canvasDoubleClickEvent( me.data() ); + std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + mMapTool->canvasDoubleClickEvent( me.get() ); } }// mouseDoubleClickEvent @@ -1228,8 +1228,8 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent* e ) } else { - QScopedPointer me( new QgsMapMouseEvent( this, e ) ); - mMapTool->canvasPressEvent( me.data() ); + std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + mMapTool->canvasPressEvent( me.get() ); } } } @@ -1283,8 +1283,8 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent* e ) } return; } - QScopedPointer me( new QgsMapMouseEvent( this, e ) ); - mMapTool->canvasReleaseEvent( me.data() ); + std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + mMapTool->canvasReleaseEvent( me.get() ); } } @@ -1445,8 +1445,8 @@ void QgsMapCanvas::mouseMoveEvent( QMouseEvent * e ) // call handler of current map tool if ( mMapTool ) { - QScopedPointer me( new QgsMapMouseEvent( this, e ) ); - mMapTool->canvasMoveEvent( me.data() ); + std::unique_ptr me( new QgsMapMouseEvent( this, e ) ); + mMapTool->canvasMoveEvent( me.get() ); } } diff --git a/src/gui/qgsmapcanvas.h b/src/gui/qgsmapcanvas.h index b40f9678b78..47bd5476367 100644 --- a/src/gui/qgsmapcanvas.h +++ b/src/gui/qgsmapcanvas.h @@ -600,7 +600,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView class CanvasProperties; /// Handle pattern for implementation object - QScopedPointer mCanvasProperties; + std::unique_ptr mCanvasProperties; #if 0 @@ -698,7 +698,7 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView bool mZoomDragging; //! Zoom by rectangle rubber band - QScopedPointer< QgsRubberBand > mZoomRubberBand; + std::unique_ptr< QgsRubberBand > mZoomRubberBand; QCursor mZoomCursor; diff --git a/src/gui/qgsmaptoolcapture.cpp b/src/gui/qgsmaptoolcapture.cpp index ac600b2c7ca..3de9c1f809c 100644 --- a/src/gui/qgsmaptoolcapture.cpp +++ b/src/gui/qgsmaptoolcapture.cpp @@ -635,7 +635,7 @@ void QgsMapToolCapture::validateGeometry() delete mGeomErrorMarkers.takeFirst(); } - QScopedPointer g; + std::unique_ptr g; switch ( mCaptureMode ) { @@ -659,10 +659,10 @@ void QgsMapToolCapture::validateGeometry() break; } - if ( !g.data() ) + if ( !g ) return; - mValidator = new QgsGeometryValidator( g.data() ); + mValidator = new QgsGeometryValidator( g.get() ); connect( mValidator, SIGNAL( errorFound( QgsGeometry::Error ) ), this, SLOT( addError( QgsGeometry::Error ) ) ); connect( mValidator, SIGNAL( finished() ), this, SLOT( validationFinished() ) ); mValidator->start(); diff --git a/src/gui/qgsrasterformatsaveoptionswidget.cpp b/src/gui/qgsrasterformatsaveoptionswidget.cpp index aa6749de2d3..b74394606c2 100644 --- a/src/gui/qgsrasterformatsaveoptionswidget.cpp +++ b/src/gui/qgsrasterformatsaveoptionswidget.cpp @@ -261,7 +261,7 @@ void QgsRasterFormatSaveOptionsWidget::helpOptions() if ( mProvider == QLatin1String( "gdal" ) && mFormat != QLatin1String( "" ) && ! mPyramids ) { // get helpCreationOptionsFormat() function ptr for provider - QScopedPointer< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( mProvider ) ); + std::unique_ptr< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( mProvider ) ); if ( library ) { helpCreationOptionsFormat_t * helpCreationOptionsFormat = @@ -357,7 +357,7 @@ QString QgsRasterFormatSaveOptionsWidget::validateOptions( bool gui, bool report else { // get validateCreationOptionsFormat() function ptr for provider - QScopedPointer< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( mProvider ) ); + std::unique_ptr< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( mProvider ) ); if ( library ) { validateCreationOptionsFormat_t * validateCreationOptionsFormat = diff --git a/src/gui/qgsvariableeditorwidget.cpp b/src/gui/qgsvariableeditorwidget.cpp index 6d27c6e6ab5..36130fe0ddc 100644 --- a/src/gui/qgsvariableeditorwidget.cpp +++ b/src/gui/qgsvariableeditorwidget.cpp @@ -108,7 +108,7 @@ void QgsVariableEditorWidget::setContext( QgsExpressionContext* context ) void QgsVariableEditorWidget::reloadContext() { mTreeWidget->resetTree(); - mTreeWidget->setContext( mContext.data() ); + mTreeWidget->setContext( mContext.get() ); mTreeWidget->refreshTree(); } diff --git a/src/gui/qgsvariableeditorwidget.h b/src/gui/qgsvariableeditorwidget.h index a828ea07705..994c1f5e1fa 100644 --- a/src/gui/qgsvariableeditorwidget.h +++ b/src/gui/qgsvariableeditorwidget.h @@ -21,6 +21,7 @@ #include #include #include "qgis_gui.h" +#include class QTableWidget; class QgsExpressionContextScope; @@ -64,7 +65,7 @@ class GUI_EXPORT QgsVariableEditorWidget : public QWidget * are created with an empty context by default. * @see setContext() */ - QgsExpressionContext* context() const { return mContext.data(); } + QgsExpressionContext* context() const { return mContext.get(); } /** Sets the editable scope for the widget. Only variables from the editable scope can * be modified by users. @@ -122,7 +123,7 @@ class GUI_EXPORT QgsVariableEditorWidget : public QWidget private: - QScopedPointer mContext; + std::unique_ptr mContext; int mEditableScopeIndex; QgsVariableEditorTree* mTreeWidget; QPushButton* mAddButton; diff --git a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp index c75001a8e7c..c8642749876 100644 --- a/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp +++ b/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp @@ -337,7 +337,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mDeleteEntryButton_clicked() void QgsSingleBandPseudoColorRendererWidget::classify() { - QScopedPointer< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); + std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); if ( !ramp ) { return; @@ -346,7 +346,7 @@ void QgsSingleBandPseudoColorRendererWidget::classify() QgsSingleBandPseudoColorRenderer *pr = new QgsSingleBandPseudoColorRenderer( mRasterLayer->dataProvider(), mBandComboBox->currentData().toInt(), nullptr ); pr->setClassificationMin( lineEditValue( mMinLineEdit ) ); pr->setClassificationMax( lineEditValue( mMaxLineEdit ) ); - pr->createShader( ramp.data(), static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ), static_cast< QgsColorRampShader::ClassificationMode >( mClassificationModeComboBox->currentData().toInt() ), mNumberOfEntriesSpinBox->value(), mClipCheckBox->isChecked(), minMaxWidget()->extent() ); + pr->createShader( ramp.get(), static_cast< QgsColorRampShader::Type >( mColorInterpolationComboBox->currentData().toInt() ), static_cast< QgsColorRampShader::ClassificationMode >( mClassificationModeComboBox->currentData().toInt() ), mNumberOfEntriesSpinBox->value(), mClipCheckBox->isChecked(), minMaxWidget()->extent() ); const QgsRasterShader* rasterShader = pr->shader(); if ( rasterShader ) @@ -386,7 +386,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassificationModeComboBox_curr void QgsSingleBandPseudoColorRendererWidget::applyColorRamp() { - QScopedPointer< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); + std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); if ( !ramp ) { return; diff --git a/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp b/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp index cb63d60ff3e..458c69ebf1c 100644 --- a/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp +++ b/src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp @@ -735,7 +735,7 @@ void QgsCategorizedSymbolRendererWidget::addCategories() // recreate renderer QgsCategorizedSymbolRenderer *r = new QgsCategorizedSymbolRenderer( attrName, cats ); r->setSourceSymbol( mCategorizedSymbol->clone() ); - QScopedPointer< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); + std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); if ( ramp ) r->setSourceColorRamp( ramp->clone() ); diff --git a/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp b/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp index 3da7b955770..0d0c6f2b176 100644 --- a/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp +++ b/src/gui/symbology-ng/qgsgraduatedsymbolrendererwidget.cpp @@ -778,7 +778,7 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated() int nclasses = spinGraduatedClasses->value(); - QScopedPointer ramp( btnColorRamp->colorRamp() ); + std::unique_ptr ramp( btnColorRamp->colorRamp() ); if ( !ramp ) { QMessageBox::critical( this, tr( "Error" ), tr( "No color ramp defined." ) ); @@ -817,7 +817,7 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated() QMessageBox::critical( this, tr( "Error" ), tr( "No color ramp defined." ) ); return; } - mRenderer->setSourceColorRamp( ramp.take() ); + mRenderer->setSourceColorRamp( ramp.release() ); } else { @@ -839,11 +839,11 @@ void QgsGraduatedSymbolRendererWidget::classifyGraduated() void QgsGraduatedSymbolRendererWidget::reapplyColorRamp() { - QScopedPointer< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); + std::unique_ptr< QgsColorRamp > ramp( btnColorRamp->colorRamp() ); if ( !ramp ) return; - mRenderer->updateColorRamp( ramp.take() ); + mRenderer->updateColorRamp( ramp.release() ); mRenderer->updateSymbols( mGraduatedSymbol ); refreshSymbolView(); } diff --git a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp index b37ef3f7f73..c1f53da52a1 100644 --- a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp +++ b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.cpp @@ -107,7 +107,7 @@ QgsFeatureRenderer* QgsInvertedPolygonRendererWidget::renderer() mRenderer->setEmbeddedRenderer( embeddedRenderer->clone() ); } } - return mRenderer.data(); + return mRenderer.get(); } void QgsInvertedPolygonRendererWidget::setContext( const QgsSymbolWidgetContext& context ) @@ -124,7 +124,7 @@ void QgsInvertedPolygonRendererWidget::on_mRendererComboBox_currentIndexChanged( if ( m ) { mEmbeddedRendererWidget.reset( m->createRendererWidget( mLayer, mStyle, const_cast( mRenderer->embeddedRenderer() )->clone() ) ); - connect( mEmbeddedRendererWidget.data(), SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) ); + connect( mEmbeddedRendererWidget.get(), SIGNAL( widgetChanged() ), this, SIGNAL( widgetChanged() ) ); mEmbeddedRendererWidget->setContext( mContext ); if ( layout()->count() > 2 ) @@ -132,7 +132,7 @@ void QgsInvertedPolygonRendererWidget::on_mRendererComboBox_currentIndexChanged( // remove the current renderer widget layout()->takeAt( 2 ); } - layout()->addWidget( mEmbeddedRendererWidget.data() ); + layout()->addWidget( mEmbeddedRendererWidget.get() ); } } diff --git a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h index d9ac56066fe..a1e57d28f2d 100644 --- a/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h +++ b/src/gui/symbology-ng/qgsinvertedpolygonrendererwidget.h @@ -53,9 +53,9 @@ class GUI_EXPORT QgsInvertedPolygonRendererWidget : public QgsRendererWidget, pr protected: //! The mask renderer - QScopedPointer mRenderer; + std::unique_ptr mRenderer; //! The widget used to represent the mask's embedded renderer - QScopedPointer mEmbeddedRendererWidget; + std::unique_ptr mEmbeddedRendererWidget; private slots: void on_mRendererComboBox_currentIndexChanged( int index ); diff --git a/src/gui/symbology-ng/qgssizescalewidget.cpp b/src/gui/symbology-ng/qgssizescalewidget.cpp index 2fbb22b38a1..fad771920ff 100644 --- a/src/gui/symbology-ng/qgssizescalewidget.cpp +++ b/src/gui/symbology-ng/qgssizescalewidget.cpp @@ -184,7 +184,7 @@ QgsSizeScaleWidget::QgsSizeScaleWidget( const QgsVectorLayer * layer, const QgsS QgsProperty QgsSizeScaleWidget::property() const { - QScopedPointer exp( createExpression() ); + std::unique_ptr exp( createExpression() ); return QgsProperty::fromExpression( exp->expression() ); } @@ -210,7 +210,7 @@ void QgsSizeScaleWidget::updatePreview() if ( !mSymbol || !mLayer ) return; - QScopedPointer expr( createExpression() ); + std::unique_ptr expr( createExpression() ); if ( expr->type() == QgsScaleExpression::Exponential ) exponentSpinBox->show(); @@ -224,29 +224,29 @@ void QgsSizeScaleWidget::updatePreview() int widthMax = 0; for ( int i = 0; i < breaks.length(); i++ ) { - QScopedPointer< QgsSymbolLegendNode > node; + std::unique_ptr< QgsSymbolLegendNode > node; if ( dynamic_cast( mSymbol ) ) { - QScopedPointer< QgsMarkerSymbol > symbol( static_cast( mSymbol->clone() ) ); + std::unique_ptr< QgsMarkerSymbol > symbol( static_cast( mSymbol->clone() ) ); symbol->setDataDefinedSize( QgsProperty() ); symbol->setDataDefinedAngle( QgsProperty() ); // to avoid symbol not being drawn symbol->setSize( expr->size( breaks[i] ) ); - node.reset( new QgsSymbolLegendNode( mLayerTreeLayer, QgsLegendSymbolItem( symbol.data(), QString::number( i ), QString() ) ) ); + node.reset( new QgsSymbolLegendNode( mLayerTreeLayer, QgsLegendSymbolItem( symbol.get(), QString::number( i ), QString() ) ) ); } else if ( dynamic_cast( mSymbol ) ) { - QScopedPointer< QgsLineSymbol > symbol( static_cast( mSymbol->clone() ) ); + std::unique_ptr< QgsLineSymbol > symbol( static_cast( mSymbol->clone() ) ); symbol->setDataDefinedWidth( QgsProperty() ); symbol->setWidth( expr->size( breaks[i] ) ); - node.reset( new QgsSymbolLegendNode( mLayerTreeLayer, QgsLegendSymbolItem( symbol.data(), QString::number( i ), QString() ) ) ); + node.reset( new QgsSymbolLegendNode( mLayerTreeLayer, QgsLegendSymbolItem( symbol.get(), QString::number( i ), QString() ) ) ); } const QSize sz( node->minimumIconSize() ); node->setIconSize( sz ); - QScopedPointer< QStandardItem > item( new QStandardItem( node->data( Qt::DecorationRole ).value(), QString::number( breaks[i] ) ) ); + std::unique_ptr< QStandardItem > item( new QStandardItem( node->data( Qt::DecorationRole ).value(), QString::number( breaks[i] ) ) ); widthMax = qMax( sz.width(), widthMax ); - mPreviewList.appendRow( item.take() ); + mPreviewList.appendRow( item.release() ); } // center icon and align text left by giving icons the same width diff --git a/src/gui/symbology-ng/qgsstyleexportimportdialog.cpp b/src/gui/symbology-ng/qgsstyleexportimportdialog.cpp index 06a44d6bbe8..5ded4d72cc2 100644 --- a/src/gui/symbology-ng/qgsstyleexportimportdialog.cpp +++ b/src/gui/symbology-ng/qgsstyleexportimportdialog.cpp @@ -215,10 +215,10 @@ bool QgsStyleExportImportDialog::populateStyles( QgsStyle* style ) for ( int i = 0; i < styleNames.count(); ++i ) { name = styleNames[i]; - QScopedPointer< QgsColorRamp > ramp( style->colorRamp( name ) ); + std::unique_ptr< QgsColorRamp > ramp( style->colorRamp( name ) ); QStandardItem* item = new QStandardItem( name ); - QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), listItems->iconSize(), 15 ); + QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), listItems->iconSize(), 15 ); item->setIcon( icon ); model->appendRow( item ); } diff --git a/src/gui/symbology-ng/qgsstylemanagerdialog.cpp b/src/gui/symbology-ng/qgsstylemanagerdialog.cpp index bff2538e457..40211749a99 100644 --- a/src/gui/symbology-ng/qgsstylemanagerdialog.cpp +++ b/src/gui/symbology-ng/qgsstylemanagerdialog.cpp @@ -302,10 +302,10 @@ void QgsStyleManagerDialog::populateColorRamps( const QStringList& colorRamps, b for ( int i = 0; i < colorRamps.count(); ++i ) { QString name = colorRamps[i]; - QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( name ) ); + std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( name ) ); QStandardItem* item = new QStandardItem( name ); - QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), listItems->iconSize(), 18 ); + QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.get(), listItems->iconSize(), 18 ); item->setIcon( icon ); item->setData( name ); // used to find out original name when user edited the name item->setCheckable( check ); @@ -478,7 +478,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget* parent, QgsStyle* st QString name = tr( "new ramp" ); - QScopedPointer< QgsColorRamp > ramp; + std::unique_ptr< QgsColorRamp > ramp; if ( rampType == tr( "Gradient" ) ) { QgsGradientColorRampDialog dlg( QgsGradientColorRamp(), parent ); @@ -593,7 +593,7 @@ QString QgsStyleManagerDialog::addColorRampStatic( QWidget* parent, QgsStyle* st } QStringList colorRampTags = saveDlg.tags().split( ',' ); - QgsColorRamp* r = ramp.take(); + QgsColorRamp* r = ramp.release(); // add new symbol to style and re-populate the list style->addColorRamp( name, r ); @@ -671,11 +671,11 @@ bool QgsStyleManagerDialog::editColorRamp() if ( name.isEmpty() ) return false; - QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( name ) ); + std::unique_ptr< QgsColorRamp > ramp( mStyle->colorRamp( name ) ); if ( ramp->type() == QLatin1String( "gradient" ) ) { - QgsGradientColorRamp* gradRamp = static_cast( ramp.data() ); + QgsGradientColorRamp* gradRamp = static_cast( ramp.get() ); QgsGradientColorRampDialog dlg( *gradRamp, this ); if ( !dlg.exec() ) { @@ -685,7 +685,7 @@ bool QgsStyleManagerDialog::editColorRamp() } else if ( ramp->type() == QLatin1String( "random" ) ) { - QgsLimitedRandomColorRamp* randRamp = static_cast( ramp.data() ); + QgsLimitedRandomColorRamp* randRamp = static_cast( ramp.get() ); QgsLimitedRandomColorRampDialog dlg( *randRamp, this ); if ( !dlg.exec() ) { @@ -695,7 +695,7 @@ bool QgsStyleManagerDialog::editColorRamp() } else if ( ramp->type() == QLatin1String( "colorbrewer" ) ) { - QgsColorBrewerColorRamp* brewerRamp = static_cast( ramp.data() ); + QgsColorBrewerColorRamp* brewerRamp = static_cast( ramp.get() ); QgsColorBrewerColorRampDialog dlg( *brewerRamp, this ); if ( !dlg.exec() ) { @@ -705,7 +705,7 @@ bool QgsStyleManagerDialog::editColorRamp() } else if ( ramp->type() == QLatin1String( "preset" ) ) { - QgsPresetSchemeColorRamp* presetRamp = static_cast( ramp.data() ); + QgsPresetSchemeColorRamp* presetRamp = static_cast( ramp.get() ); QgsPresetColorRampDialog dlg( *presetRamp, this ); if ( !dlg.exec() ) { @@ -715,7 +715,7 @@ bool QgsStyleManagerDialog::editColorRamp() } else if ( ramp->type() == QLatin1String( "cpt-city" ) ) { - QgsCptCityColorRamp* cptCityRamp = static_cast( ramp.data() ); + QgsCptCityColorRamp* cptCityRamp = static_cast( ramp.get() ); QgsCptCityColorRampDialog dlg( *cptCityRamp, this ); if ( !dlg.exec() ) { @@ -735,7 +735,7 @@ bool QgsStyleManagerDialog::editColorRamp() Q_ASSERT( 0 && "invalid ramp type" ); } - mStyle->addColorRamp( name, ramp.take(), true ); + mStyle->addColorRamp( name, ramp.release(), true ); mModified = true; return true; } diff --git a/src/gui/symbology-ng/qgssymbolselectordialog.cpp b/src/gui/symbology-ng/qgssymbolselectordialog.cpp index 4dbecdfa0e5..22f67cb8126 100644 --- a/src/gui/symbology-ng/qgssymbolselectordialog.cpp +++ b/src/gui/symbology-ng/qgssymbolselectordialog.cpp @@ -422,7 +422,7 @@ void QgsSymbolSelectorWidget::layerChanged() layerProp->setDockMode( this->dockMode() ); layerProp->setContext( mContext ); setWidget( layerProp ); - connect( layerProp, SIGNAL( changed() ), mDataDefineRestorer.data(), SLOT( restore() ) ); + connect( layerProp, SIGNAL( changed() ), mDataDefineRestorer.get(), SLOT( restore() ) ); connect( layerProp, SIGNAL( changed() ), this, SLOT( updateLayerPreview() ) ); // This connection when layer type is changed connect( layerProp, SIGNAL( changeLayer( QgsSymbolLayer* ) ), this, SLOT( changeLayer( QgsSymbolLayer* ) ) ); diff --git a/src/gui/symbology-ng/qgssymbolselectordialog.h b/src/gui/symbology-ng/qgssymbolselectordialog.h index 5aa185f8f46..befc59963d1 100644 --- a/src/gui/symbology-ng/qgssymbolselectordialog.h +++ b/src/gui/symbology-ng/qgssymbolselectordialog.h @@ -236,7 +236,7 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs QWidget *mPresentWidget; private: - QScopedPointer mDataDefineRestorer; + std::unique_ptr mDataDefineRestorer; QgsSymbolWidgetContext mContext; }; diff --git a/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp b/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp index 2bd7c3ccb1b..b7961e45e98 100644 --- a/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp +++ b/src/gui/symbology-ng/qgssymbolwidgetcontext.cpp @@ -65,7 +65,7 @@ void QgsSymbolWidgetContext::setExpressionContext( QgsExpressionContext* context QgsExpressionContext* QgsSymbolWidgetContext::expressionContext() const { - return mExpressionContext.data(); + return mExpressionContext.get(); } void QgsSymbolWidgetContext::setAdditionalExpressionContextScopes( const QList& scopes ) diff --git a/src/gui/symbology-ng/qgssymbolwidgetcontext.h b/src/gui/symbology-ng/qgssymbolwidgetcontext.h index fe9e260517d..20d111b0ab3 100644 --- a/src/gui/symbology-ng/qgssymbolwidgetcontext.h +++ b/src/gui/symbology-ng/qgssymbolwidgetcontext.h @@ -17,6 +17,7 @@ #include "qgsexpressioncontext.h" #include "qgis_gui.h" +#include class QgsMapCanvas; @@ -89,7 +90,7 @@ class GUI_EXPORT QgsSymbolWidgetContext // clazy:exclude=rule-of-three private: QgsMapCanvas* mMapCanvas; - QScopedPointer< QgsExpressionContext > mExpressionContext; + std::unique_ptr< QgsExpressionContext > mExpressionContext; QList< QgsExpressionContextScope > mAdditionalScopes; }; diff --git a/src/providers/ows/qgsowsdataitems.cpp b/src/providers/ows/qgsowsdataitems.cpp index 4a1a6865b46..ed5b90eb223 100644 --- a/src/providers/ows/qgsowsdataitems.cpp +++ b/src/providers/ows/qgsowsdataitems.cpp @@ -45,7 +45,7 @@ QVector QgsOWSConnectionItem::createChildren() Q_FOREACH ( const QString& key, QStringList() << "wms" << "WFS" << "wcs" ) { QgsDebugMsg( "Add connection for provider " + key ); - QScopedPointer< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( key ) ); + std::unique_ptr< QLibrary > library( QgsProviderRegistry::instance()->providerLibrary( key ) ); if ( !library ) { QgsDebugMsg( "Cannot get provider " + key ); diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index 992c6ca8d60..75c620aeaaa 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -2624,7 +2624,7 @@ void QgsPostgresProvider::appendGeomParam( const QgsGeometry& geom, QStringList QString param; - QScopedPointer convertedGeom( convertToProviderType( geom ) ); + std::unique_ptr convertedGeom( convertToProviderType( geom ) ); QByteArray wkb( convertedGeom ? convertedGeom->exportToWkb() : geom.exportToWkb() ); const unsigned char *buf = reinterpret_cast< const unsigned char * >( wkb.constData() ); int wkbSize = wkb.length(); diff --git a/src/providers/virtual/qgsvirtuallayerfeatureiterator.h b/src/providers/virtual/qgsvirtuallayerfeatureiterator.h index e443e5c48fd..34fdd751abf 100644 --- a/src/providers/virtual/qgsvirtuallayerfeatureiterator.h +++ b/src/providers/virtual/qgsvirtuallayerfeatureiterator.h @@ -20,6 +20,7 @@ email : hugo dot mercier at oslandia dot com #include #include +#include class QgsVirtualLayerFeatureSource : public QgsAbstractFeatureSource { @@ -47,7 +48,7 @@ class QgsVirtualLayerFeatureIterator : public QgsAbstractFeatureIteratorFromSour virtual bool fetchFeature( QgsFeature& feature ) override; - QScopedPointer mQuery; + std::unique_ptr mQuery; QgsFeatureId mFid; diff --git a/src/providers/virtual/qgsvirtuallayersourceselect.cpp b/src/providers/virtual/qgsvirtuallayersourceselect.cpp index 3e1341820c1..89a679ec10c 100644 --- a/src/providers/virtual/qgsvirtuallayersourceselect.cpp +++ b/src/providers/virtual/qgsvirtuallayersourceselect.cpp @@ -229,7 +229,7 @@ void QgsVirtualLayerSourceSelect::onTestQuery() { QgsVirtualLayerDefinition def = getVirtualLayerDef(); - QScopedPointer vl( new QgsVectorLayer( def.toString(), QStringLiteral( "test" ), QStringLiteral( "virtual" ) ) ); + std::unique_ptr vl( new QgsVectorLayer( def.toString(), QStringLiteral( "test" ), QStringLiteral( "virtual" ) ) ); if ( vl->isValid() ) { QMessageBox::information( nullptr, tr( "Virtual layer test" ), tr( "No error" ) ); diff --git a/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp b/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp index 95df6692b28..88261176047 100644 --- a/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp +++ b/src/providers/virtual/qgsvirtuallayersqlitemodule.cpp @@ -341,7 +341,7 @@ int vtableCreateConnect( sqlite3* sql, void* aux, int argc, const char* const* a return SQLITE_ERROR; } - QScopedPointer newVtab; + std::unique_ptr newVtab; int r; if ( argc == 4 ) @@ -410,7 +410,7 @@ int vtableCreateConnect( sqlite3* sql, void* aux, int argc, const char* const* a return r; } - *outVtab = reinterpret_cast< sqlite3_vtab* >( newVtab.take() ); + *outVtab = reinterpret_cast< sqlite3_vtab* >( newVtab.release() ); return SQLITE_OK; #undef RETURN_CSTR_ERROR #undef RETURN_CPPSTR_ERROR diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index cbdcd30703e..db963af17af 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -636,7 +636,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, i double vres = viewExtent.width() / pixelWidth; const QgsWmtsTileMatrix *tm = nullptr; - QScopedPointer tempTm; + std::unique_ptr tempTm; enum QgsTileMode tileMode; if ( mSettings.mTiled ) @@ -662,7 +662,7 @@ QImage *QgsWmsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, i tempTm->matrixWidth = ceil( mLayerExtent.width() / mSettings.mMaxWidth / vres ); tempTm->matrixHeight = ceil( mLayerExtent.height() / mSettings.mMaxHeight / vres ); tempTm->tres = vres; - tm = tempTm.data(); + tm = tempTm.get(); tileMode = WMSC; } @@ -3382,9 +3382,9 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh, const if ( !mLegendGraphicFetcher ) return QImage(); - connect( mLegendGraphicFetcher.data(), SIGNAL( finish( const QImage& ) ), this, SLOT( getLegendGraphicReplyFinished( const QImage& ) ) ); - connect( mLegendGraphicFetcher.data(), SIGNAL( error( const QString& ) ), this, SLOT( getLegendGraphicReplyErrored( const QString& ) ) ); - connect( mLegendGraphicFetcher.data(), SIGNAL( progress( qint64, qint64 ) ), this, SLOT( getLegendGraphicReplyProgress( qint64, qint64 ) ) ); + connect( mLegendGraphicFetcher.get(), SIGNAL( finish( const QImage& ) ), this, SLOT( getLegendGraphicReplyFinished( const QImage& ) ) ); + connect( mLegendGraphicFetcher.get(), SIGNAL( error( const QString& ) ), this, SLOT( getLegendGraphicReplyErrored( const QString& ) ) ); + connect( mLegendGraphicFetcher.get(), SIGNAL( progress( qint64, qint64 ) ), this, SLOT( getLegendGraphicReplyProgress( qint64, qint64 ) ) ); mLegendGraphicFetcher->start(); QEventLoop loop; @@ -3453,7 +3453,7 @@ void QgsWmsProvider::getLegendGraphicReplyFinished( const QImage& img ) #endif } - if ( reply == mLegendGraphicFetcher.data() ) + if ( reply == mLegendGraphicFetcher.get() ) { QEventLoop *loop = qobject_cast< QEventLoop *>( reply->property( "eventLoop" ).value< QObject *>() ); if ( loop ) @@ -3469,7 +3469,7 @@ void QgsWmsProvider::getLegendGraphicReplyErrored( const QString& message ) QObject* reply = sender(); - if ( reply == mLegendGraphicFetcher.data() ) + if ( reply == mLegendGraphicFetcher.get() ) { QEventLoop *loop = qobject_cast< QEventLoop *>( reply->property( "eventLoop" ).value< QObject *>() ); if ( loop ) diff --git a/src/providers/wms/qgswmsprovider.h b/src/providers/wms/qgswmsprovider.h index 9e02686b448..f5cde151d14 100644 --- a/src/providers/wms/qgswmsprovider.h +++ b/src/providers/wms/qgswmsprovider.h @@ -396,7 +396,7 @@ class QgsWmsProvider : public QgsRasterDataProvider QgsRectangle mGetLegendGraphicExtent; - QScopedPointer mLegendGraphicFetcher; + std::unique_ptr mLegendGraphicFetcher; /** * Visibility status of the given active sublayer diff --git a/src/server/qgswmsconfigparser.cpp b/src/server/qgswmsconfigparser.cpp index 95e159f1b1e..7e4093b426b 100644 --- a/src/server/qgswmsconfigparser.cpp +++ b/src/server/qgswmsconfigparser.cpp @@ -329,8 +329,8 @@ QStringList QgsWmsConfigParser::addHighlightLayers( const QMap } QString errorMsg; - QScopedPointer renderer( QgsFeatureRenderer::loadSld( sldDoc.documentElement(), geom.type(), errorMsg ) ); - if ( !renderer.data() ) + std::unique_ptr renderer( QgsFeatureRenderer::loadSld( sldDoc.documentElement(), geom.type(), errorMsg ) ); + if ( !renderer ) { continue; } @@ -342,17 +342,17 @@ QStringList QgsWmsConfigParser::addHighlightLayers( const QMap labelString = labelSplit.at( i ); } - QScopedPointer layer( createHighlightLayer( i, crsString, geom, labelString, labelSizeSplit, labelColorSplit, labelWeightSplit, labelFontSplit, - labelBufferSizeSplit, labelBufferColorSplit ) ); - if ( !layer.data() ) + std::unique_ptr layer( createHighlightLayer( i, crsString, geom, labelString, labelSizeSplit, labelColorSplit, labelWeightSplit, labelFontSplit, + labelBufferSizeSplit, labelBufferColorSplit ) ); + if ( !layer ) { continue; } - layer->setRenderer( renderer.take() ); - layerSet.prepend( layer.data()->id() ); - highlightLayers.append( layer.data()->id() ); - QgsProject::instance()->addMapLayers( QList() << layer.take() ); + layer->setRenderer( renderer.release() ); + layerSet.prepend( layer->id() ); + highlightLayers.append( layer->id() ); + QgsProject::instance()->addMapLayers( QList() << layer.release() ); } return highlightLayers; } diff --git a/src/server/services/wfs/qgswfsgetfeature.cpp b/src/server/services/wfs/qgswfsgetfeature.cpp index 636ddae3354..f1af77f2d5c 100644 --- a/src/server/services/wfs/qgswfsgetfeature.cpp +++ b/src/server/services/wfs/qgswfsgetfeature.cpp @@ -111,7 +111,7 @@ namespace QgsWfs //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - QScopedPointer< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( accessControl ) ); + std::unique_ptr< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( accessControl ) ); if ( doc.setContent( parameters.value( QStringLiteral( "REQUEST_BODY" ) ), true, &errorMsg ) ) { @@ -914,7 +914,7 @@ namespace QgsWfs { QString fcString; - QScopedPointer< QgsRectangle > transformedRect; + std::unique_ptr< QgsRectangle > transformedRect; if ( format == QLatin1String( "GeoJSON" ) ) { @@ -931,7 +931,7 @@ namespace QgsWfs if ( exportGeom.transform( transform ) == 0 ) { transformedRect.reset( new QgsRectangle( exportGeom.boundingBox() ) ); - rect = transformedRect.data(); + rect = transformedRect.get(); } } catch ( QgsException &cse ) diff --git a/src/server/services/wms/qgsmaprendererjobproxy.cpp b/src/server/services/wms/qgsmaprendererjobproxy.cpp index 7e25b3bb2e7..b5d80319a2c 100644 --- a/src/server/services/wms/qgsmaprendererjobproxy.cpp +++ b/src/server/services/wms/qgsmaprendererjobproxy.cpp @@ -63,7 +63,7 @@ namespace QgsWms else { mPainter.reset( new QPainter( image ) ); - QgsMapRendererCustomPainterJob renderJob( mapSettings, mPainter.data() ); + QgsMapRendererCustomPainterJob renderJob( mapSettings, mPainter.get() ); #ifdef HAVE_SERVER_PYTHON_PLUGINS renderJob.setFeatureFilterProvider( mAccessControl ); #endif @@ -73,7 +73,7 @@ namespace QgsWms QPainter* QgsMapRendererJobProxy::takePainter() { - return mPainter.take(); + return mPainter.release(); } } // namespace qgsws diff --git a/src/server/services/wms/qgsmaprendererjobproxy.h b/src/server/services/wms/qgsmaprendererjobproxy.h index 5396471c782..bb577316f31 100644 --- a/src/server/services/wms/qgsmaprendererjobproxy.h +++ b/src/server/services/wms/qgsmaprendererjobproxy.h @@ -56,7 +56,7 @@ namespace QgsWms private: bool mParallelRendering; QgsAccessControl* mAccessControl; - QScopedPointer mPainter; + std::unique_ptr mPainter; }; diff --git a/src/server/services/wms/qgswmsgetlegendgraphics.cpp b/src/server/services/wms/qgswmsgetlegendgraphics.cpp index 766b3cf31a2..a5b7d0b6629 100644 --- a/src/server/services/wms/qgswmsgetlegendgraphics.cpp +++ b/src/server/services/wms/qgswmsgetlegendgraphics.cpp @@ -34,9 +34,9 @@ namespace QgsWms QgsServerRequest::Parameters params = request.parameters(); QgsRenderer renderer( serverIface, project, params, getConfigParser( serverIface ) ); - QScopedPointer result( renderer.getLegendGraphics() ); + std::unique_ptr result( renderer.getLegendGraphics() ); - if ( !result.isNull() ) + if ( result ) { QString format = params.value( QStringLiteral( "FORMAT" ), QStringLiteral( "PNG" ) ); writeImage( response, *result, format, renderer.getImageQuality() ); diff --git a/src/server/services/wms/qgswmsgetmap.cpp b/src/server/services/wms/qgswmsgetmap.cpp index d530c3ad17c..cad1e250194 100644 --- a/src/server/services/wms/qgswmsgetmap.cpp +++ b/src/server/services/wms/qgswmsgetmap.cpp @@ -34,8 +34,8 @@ namespace QgsWms QgsServerRequest::Parameters params = request.parameters(); QgsRenderer renderer( serverIface, project, params, getConfigParser( serverIface ) ); - QScopedPointer result( renderer.getMap() ); - if ( !result.isNull() ) + std::unique_ptr result( renderer.getMap() ); + if ( result ) { QString format = params.value( QStringLiteral( "FORMAT" ), QStringLiteral( "PNG" ) ); writeImage( response, *result, format, renderer.getImageQuality() ); diff --git a/src/server/services/wms/qgswmsgetprint.cpp b/src/server/services/wms/qgswmsgetprint.cpp index f22d74338a2..664566f562c 100644 --- a/src/server/services/wms/qgswmsgetprint.cpp +++ b/src/server/services/wms/qgswmsgetprint.cpp @@ -63,7 +63,7 @@ namespace QgsWms QString( "Output format %1 is not supported by the GetPrint request" ).arg( format ) ); } - QScopedPointer result( renderer.getPrint( format ) ); + std::unique_ptr result( renderer.getPrint( format ) ); response.setHeader( QStringLiteral( "Content-Type" ), contentType ); response.write( *result ); } diff --git a/src/server/services/wms/qgswmsrenderer.cpp b/src/server/services/wms/qgswmsrenderer.cpp index 11d75ad6448..7451e3fac6c 100644 --- a/src/server/services/wms/qgswmsrenderer.cpp +++ b/src/server/services/wms/qgswmsrenderer.cpp @@ -573,7 +573,7 @@ namespace QgsWms //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - QScopedPointer< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( mAccessControl ) ); + std::unique_ptr< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( mAccessControl ) ); applyRequestedLayerFilters( layersList, mapSettings, filterRestorer->originalFilters() ); @@ -734,7 +734,7 @@ namespace QgsWms //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - QScopedPointer< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( mAccessControl ) ); + std::unique_ptr< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( mAccessControl ) ); applyRequestedLayerFilters( layersList, mapSettings, filterRestorer->originalFilters() ); @@ -751,7 +751,7 @@ namespace QgsWms applyOpacities( layersList, bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies ); - QScopedPointer painter; + std::unique_ptr painter; if ( hitTest ) { runHitTest( mapSettings, *hitTest ); @@ -770,7 +770,7 @@ namespace QgsWms if ( mConfigParser ) { //draw configuration format specific overlay items - mConfigParser->drawOverlays( painter.data(), theImage->dotsPerMeterX() / 1000.0 * 25.4, theImage->width(), theImage->height() ); + mConfigParser->drawOverlays( painter.get(), theImage->dotsPerMeterX() / 1000.0 * 25.4, theImage->width(), theImage->height() ); } restoreOpacities( bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies ); @@ -828,9 +828,9 @@ namespace QgsWms initializeSLDParser( layersList, stylesList ); QgsMapSettings mapSettings; - QScopedPointer outputImage( createImage() ); + std::unique_ptr outputImage( createImage() ); - configureMapSettings( outputImage.data(), mapSettings ); + configureMapSettings( outputImage.get(), mapSettings ); QgsMessageLog::logMessage( "mapSettings.extent(): " + mapSettings.extent().toString() ); QgsMessageLog::logMessage( QStringLiteral( "mapSettings width = %1 height = %2" ).arg( mapSettings.outputSize().width() ).arg( mapSettings.outputSize().height() ) ); @@ -892,8 +892,8 @@ namespace QgsWms //Normally, I/J or X/Y are mandatory parameters. //However, in order to make attribute only queries via the FILTER parameter, it is allowed to skip them if the FILTER parameter is there - QScopedPointer featuresRect; - QScopedPointer infoPoint; + std::unique_ptr featuresRect; + std::unique_ptr infoPoint; if ( i == -1 || j == -1 ) { @@ -910,7 +910,7 @@ namespace QgsWms else { infoPoint.reset( new QgsPoint() ); - infoPointToMapCoordinates( i, j, infoPoint.data(), mapSettings ); + infoPointToMapCoordinates( i, j, infoPoint.get(), mapSettings ); } //get the layer registered in QgsMapLayerRegistry and apply possible filters @@ -918,7 +918,7 @@ namespace QgsWms //scoped pointer to restore all original layer filters (subsetStrings) when pointer goes out of scope //there's LOTS of potential exit paths here, so we avoid having to restore the filters manually - QScopedPointer< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( mAccessControl ) ); + std::unique_ptr< QgsOWSServerFilterRestorer > filterRestorer( new QgsOWSServerFilterRestorer( mAccessControl ) ); applyRequestedLayerFilters( layersList, mapSettings, filterRestorer->originalFilters() ); #ifdef HAVE_SERVER_PYTHON_PLUGINS @@ -1037,7 +1037,7 @@ namespace QgsWms if ( vectorLayer ) { - if ( !featureInfoFromVectorLayer( vectorLayer, infoPoint.data(), featureCount, result, layerElement, mapSettings, renderContext, version, infoFormat, featuresRect.data() ) ) + if ( !featureInfoFromVectorLayer( vectorLayer, infoPoint.get(), featureCount, result, layerElement, mapSettings, renderContext, version, infoFormat, featuresRect.get() ) ) { continue; } @@ -1053,11 +1053,11 @@ namespace QgsWms QgsRasterLayer* rasterLayer = qobject_cast( currentLayer ); if ( rasterLayer ) { - if ( !infoPoint.data() ) + if ( !infoPoint ) { continue; } - QgsPoint layerInfoPoint = mapSettings.mapToLayerCoordinates( currentLayer, *( infoPoint.data() ) ); + QgsPoint layerInfoPoint = mapSettings.mapToLayerCoordinates( currentLayer, *( infoPoint.get() ) ); if ( !featureInfoFromRasterLayer( rasterLayer, mapSettings, &layerInfoPoint, result, layerElement, version, infoFormat ) ) { continue; @@ -1080,11 +1080,11 @@ namespace QgsWms int gmlVersion = infoFormat.startsWith( QLatin1String( "application/vnd.ogc.gml/3" ) ) ? 3 : 2; if ( gmlVersion < 3 ) { - boxElem = QgsOgcUtils::rectangleToGMLBox( featuresRect.data(), result, 8 ); + boxElem = QgsOgcUtils::rectangleToGMLBox( featuresRect.get(), result, 8 ); } else { - boxElem = QgsOgcUtils::rectangleToGMLEnvelope( featuresRect.data(), result, 8 ); + boxElem = QgsOgcUtils::rectangleToGMLEnvelope( featuresRect.get(), result, 8 ); } QgsCoordinateReferenceSystem crs = mapSettings.destinationCrs(); @@ -1138,12 +1138,12 @@ namespace QgsWms { throw QgsException( QStringLiteral( "initializeRendering: The project configuration does not allow datasources defined in the request" ) ); } - QScopedPointer gmlDoc( new QDomDocument() ); + std::unique_ptr gmlDoc( new QDomDocument() ); if ( gmlDoc->setContent( gml, true ) ) { QString layerName = gmlDoc->documentElement().attribute( QStringLiteral( "layerName" ) ); QgsMessageLog::logMessage( "Adding entry with key: " + layerName + " to external GML data" ); - mConfigParser->addExternalGMLData( layerName, gmlDoc.take() ); + mConfigParser->addExternalGMLData( layerName, gmlDoc.release() ); } else { @@ -1151,9 +1151,9 @@ namespace QgsWms } } - QScopedPointer theImage( createImage() ); + std::unique_ptr theImage( createImage() ); - configureMapSettings( theImage.data(), mapSettings ); + configureMapSettings( theImage.get(), mapSettings ); //find out the current scale denominater and set it to the SLD parser QgsScaleCalculator scaleCalc(( theImage->logicalDpiX() + theImage->logicalDpiY() ) / 2, mapSettings.destinationCrs().mapUnits() ); @@ -1175,7 +1175,7 @@ namespace QgsWms // load label settings mConfigParser->loadLabelSettings(); - return theImage.take(); + return theImage.release(); } QImage* QgsRenderer::createImage( int width, int height, bool useBbox ) const @@ -1402,7 +1402,7 @@ namespace QgsWms if ( !xml.isEmpty() ) { //ignore LAYERS and STYLES and take those information from the SLD - QScopedPointer theDocument( new QDomDocument( QStringLiteral( "user.sld" ) ) ); + std::unique_ptr theDocument( new QDomDocument( QStringLiteral( "user.sld" ) ) ); QString errorMsg; int errorLine, errorColumn; @@ -1411,7 +1411,7 @@ namespace QgsWms throw QgsException( QStringLiteral( "SLDParser: Could not create DomDocument from SLD: %1" ).arg( errorMsg ) ); } - QgsSLDConfigParser* userSLDParser = new QgsSLDConfigParser( theDocument.take(), mParameters ); + QgsSLDConfigParser* userSLDParser = new QgsSLDConfigParser( theDocument.release(), mParameters ); userSLDParser->setFallbackParser( mConfigParser ); mConfigParser = userSLDParser; mOwnsConfigParser = true; diff --git a/tests/src/app/testqgsattributetable.cpp b/tests/src/app/testqgsattributetable.cpp index b907196b96d..7d9f656195c 100644 --- a/tests/src/app/testqgsattributetable.cpp +++ b/tests/src/app/testqgsattributetable.cpp @@ -75,7 +75,7 @@ void TestQgsAttributeTable::testFieldCalculation() //test field calculation //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -94,9 +94,9 @@ void TestQgsAttributeTable::testFieldCalculation() QgsProject::instance()->setDistanceUnits( QgsUnitTypes::DistanceMeters ); // run length calculation - QScopedPointer< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.data() ) ); + std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); - dlg->runFieldCalculation( tempLayer.data(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); + dlg->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); tempLayer->commitChanges(); // check result QgsFeatureIterator fit = tempLayer->dataProvider()->getFeatures(); @@ -107,9 +107,9 @@ void TestQgsAttributeTable::testFieldCalculation() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( QgsUnitTypes::DistanceFeet ); - QScopedPointer< QgsAttributeTableDialog > dlg2( new QgsAttributeTableDialog( tempLayer.data() ) ); + std::unique_ptr< QgsAttributeTableDialog > dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); - dlg2->runFieldCalculation( tempLayer.data(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); + dlg2->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$length" ) ); tempLayer->commitChanges(); // check result fit = tempLayer->dataProvider()->getFeatures(); @@ -123,7 +123,7 @@ void TestQgsAttributeTable::testFieldCalculationArea() //test $area field calculation //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -145,9 +145,9 @@ void TestQgsAttributeTable::testFieldCalculationArea() QgsProject::instance()->setAreaUnits( QgsUnitTypes::AreaSquareMeters ); // run area calculation - QScopedPointer< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.data() ) ); + std::unique_ptr< QgsAttributeTableDialog > dlg( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); - dlg->runFieldCalculation( tempLayer.data(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); + dlg->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); tempLayer->commitChanges(); // check result QgsFeatureIterator fit = tempLayer->dataProvider()->getFeatures(); @@ -158,9 +158,9 @@ void TestQgsAttributeTable::testFieldCalculationArea() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( QgsUnitTypes::AreaSquareMiles ); - QScopedPointer< QgsAttributeTableDialog > dlg2( new QgsAttributeTableDialog( tempLayer.data() ) ); + std::unique_ptr< QgsAttributeTableDialog > dlg2( new QgsAttributeTableDialog( tempLayer.get() ) ); tempLayer->startEditing(); - dlg2->runFieldCalculation( tempLayer.data(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); + dlg2->runFieldCalculation( tempLayer.get(), QStringLiteral( "col1" ), QStringLiteral( "$area" ) ); tempLayer->commitChanges(); // check result fit = tempLayer->dataProvider()->getFeatures(); diff --git a/tests/src/app/testqgsfieldcalculator.cpp b/tests/src/app/testqgsfieldcalculator.cpp index bb389bd258b..88b6387a7d3 100644 --- a/tests/src/app/testqgsfieldcalculator.cpp +++ b/tests/src/app/testqgsfieldcalculator.cpp @@ -73,7 +73,7 @@ void TestQgsFieldCalculator::testLengthCalculations() //test length calculation respects ellipsoid and project distance units //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -93,7 +93,7 @@ void TestQgsFieldCalculator::testLengthCalculations() // run length calculation tempLayer->startEditing(); - QScopedPointer< QgsFieldCalculator > calc( new QgsFieldCalculator( tempLayer.data() ) ); + std::unique_ptr< QgsFieldCalculator > calc( new QgsFieldCalculator( tempLayer.get() ) ); // this next part is fragile, and may need to be modified if the dialog changes: calc->mUpdateExistingGroupBox->setChecked( true ); @@ -113,7 +113,7 @@ void TestQgsFieldCalculator::testLengthCalculations() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( QgsUnitTypes::DistanceFeet ); tempLayer->startEditing(); - QScopedPointer< QgsFieldCalculator > calc2( new QgsFieldCalculator( tempLayer.data() ) ); + std::unique_ptr< QgsFieldCalculator > calc2( new QgsFieldCalculator( tempLayer.get() ) ); calc2->mUpdateExistingGroupBox->setChecked( true ); calc2->mExistingFieldComboBox->setCurrentIndex( 1 ); calc2->builder->setExpressionText( QStringLiteral( "$length" ) ); @@ -132,7 +132,7 @@ void TestQgsFieldCalculator::testAreaCalculations() //test area calculation respects ellipsoid and project area units //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -155,7 +155,7 @@ void TestQgsFieldCalculator::testAreaCalculations() // run area calculation tempLayer->startEditing(); - QScopedPointer< QgsFieldCalculator > calc( new QgsFieldCalculator( tempLayer.data() ) ); + std::unique_ptr< QgsFieldCalculator > calc( new QgsFieldCalculator( tempLayer.get() ) ); // this next part is fragile, and may need to be modified if the dialog changes: calc->mUpdateExistingGroupBox->setChecked( true ); @@ -175,7 +175,7 @@ void TestQgsFieldCalculator::testAreaCalculations() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( QgsUnitTypes::AreaSquareMiles ); tempLayer->startEditing(); - QScopedPointer< QgsFieldCalculator > calc2( new QgsFieldCalculator( tempLayer.data() ) ); + std::unique_ptr< QgsFieldCalculator > calc2( new QgsFieldCalculator( tempLayer.get() ) ); calc2->mUpdateExistingGroupBox->setChecked( true ); calc2->mExistingFieldComboBox->setCurrentIndex( 1 ); calc2->builder->setExpressionText( QStringLiteral( "$area" ) ); diff --git a/tests/src/app/testqgsmaptoolidentifyaction.cpp b/tests/src/app/testqgsmaptoolidentifyaction.cpp index 84cec1c9743..dab15afd9e2 100644 --- a/tests/src/app/testqgsmaptoolidentifyaction.cpp +++ b/tests/src/app/testqgsmaptoolidentifyaction.cpp @@ -114,7 +114,7 @@ void TestQgsMapToolIdentifyAction::lengthCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -136,8 +136,8 @@ void TestQgsMapToolIdentifyAction::lengthCalculation() QgsPoint mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - QScopedPointer< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedLength = result.at( 0 ).mDerivedAttributes[tr( "Length" )]; double length = derivedLength.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -145,7 +145,7 @@ void TestQgsMapToolIdentifyAction::lengthCalculation() //check that project units are respected QgsProject::instance()->setDistanceUnits( QgsUnitTypes::DistanceFeet ); - result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); derivedLength = result.at( 0 ).mDerivedAttributes[tr( "Length" )]; length = derivedLength.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -153,7 +153,7 @@ void TestQgsMapToolIdentifyAction::lengthCalculation() //test unchecked "keep base units" setting s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), false ); - result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); derivedLength = result.at( 0 ).mDerivedAttributes[tr( "Length" )]; length = derivedLength.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -166,7 +166,7 @@ void TestQgsMapToolIdentifyAction::perimeterCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -190,8 +190,8 @@ void TestQgsMapToolIdentifyAction::perimeterCalculation() QgsPoint mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - QScopedPointer< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedPerimeter = result.at( 0 ).mDerivedAttributes[tr( "Perimeter" )]; double perimeter = derivedPerimeter.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -199,7 +199,7 @@ void TestQgsMapToolIdentifyAction::perimeterCalculation() //check that project units are respected QgsProject::instance()->setDistanceUnits( QgsUnitTypes::DistanceFeet ); - result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); derivedPerimeter = result.at( 0 ).mDerivedAttributes[tr( "Perimeter" )]; perimeter = derivedPerimeter.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -207,7 +207,7 @@ void TestQgsMapToolIdentifyAction::perimeterCalculation() //test unchecked "keep base units" setting s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), false ); - result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); derivedPerimeter = result.at( 0 ).mDerivedAttributes[tr( "Perimeter" )]; perimeter = derivedPerimeter.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -220,7 +220,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation() s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), true ); //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "Polygon?crs=epsg:3111&field=pk:int&field=col1:double" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); QgsFeature f1( tempLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -245,8 +245,8 @@ void TestQgsMapToolIdentifyAction::areaCalculation() QgsPoint mapPoint = canvas->getCoordinateTransform()->transform( 2484588, 2425722 ); - QScopedPointer< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); - QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); QString derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area" )]; double area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -254,7 +254,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation() //check that project units are respected QgsProject::instance()->setAreaUnits( QgsUnitTypes::AreaSquareMiles ); - result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area" )]; area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -263,7 +263,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation() //test unchecked "keep base units" setting s.setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), false ); QgsProject::instance()->setAreaUnits( QgsUnitTypes::AreaSquareFeet ); - result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.data() ); + result = action->identify( mapPoint.x(), mapPoint.y(), QList() << tempLayer.get() ); QCOMPARE( result.length(), 1 ); derivedArea = result.at( 0 ).mDerivedAttributes[tr( "Area" )]; area = derivedArea.remove( ',' ).split( ' ' ).at( 0 ).toDouble(); @@ -273,7 +273,7 @@ void TestQgsMapToolIdentifyAction::areaCalculation() // private QString TestQgsMapToolIdentifyAction::testIdentifyRaster( QgsRasterLayer* layer, double xGeoref, double yGeoref ) { - QScopedPointer< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); QgsPoint mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << layer ); if ( result.length() != 1 ) @@ -285,7 +285,7 @@ QString TestQgsMapToolIdentifyAction::testIdentifyRaster( QgsRasterLayer* layer, QList TestQgsMapToolIdentifyAction::testIdentifyVector( QgsVectorLayer* layer, double xGeoref, double yGeoref ) { - QScopedPointer< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); + std::unique_ptr< QgsMapToolIdentifyAction > action( new QgsMapToolIdentifyAction( canvas ) ); QgsPoint mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); QList result = action->identify( mapPoint.x(), mapPoint.y(), QList() << layer ); return result; @@ -298,62 +298,62 @@ void TestQgsMapToolIdentifyAction::identifyRasterFloat32() // By default the QgsRasterLayer forces AAIGRID_DATATYPE=Float64 CPLSetConfigOption( "AAIGRID_DATATYPE", "Float32" ); - QScopedPointer< QgsRasterLayer> tempLayer( new QgsRasterLayer( raster ) ); + std::unique_ptr< QgsRasterLayer> tempLayer( new QgsRasterLayer( raster ) ); CPLSetConfigOption( "AAIGRID_DATATYPE", nullptr ); QVERIFY( tempLayer->isValid() ); canvas->setExtent( QgsRectangle( 0, 0, 7, 1 ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 0.5, 0.5 ), QString( "-999.9" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 0.5, 0.5 ), QString( "-999.9" ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 1.5, 0.5 ), QString( "-999.987" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 1.5, 0.5 ), QString( "-999.987" ) ); // More than 6 significant digits for corresponding value in .asc: // precision loss in Float32 - QCOMPARE( testIdentifyRaster( tempLayer.data(), 2.5, 0.5 ), QString( "1.234568" ) ); // in .asc file : 1.2345678 + QCOMPARE( testIdentifyRaster( tempLayer.get(), 2.5, 0.5 ), QString( "1.234568" ) ); // in .asc file : 1.2345678 - QCOMPARE( testIdentifyRaster( tempLayer.data(), 3.5, 0.5 ), QString( "123456" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 3.5, 0.5 ), QString( "123456" ) ); // More than 6 significant digits: no precision loss here for that particular value - QCOMPARE( testIdentifyRaster( tempLayer.data(), 4.5, 0.5 ), QString( "1234567" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 4.5, 0.5 ), QString( "1234567" ) ); // More than 6 significant digits: no precision loss here for that particular value - QCOMPARE( testIdentifyRaster( tempLayer.data(), 5.5, 0.5 ), QString( "-999.9876" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 5.5, 0.5 ), QString( "-999.9876" ) ); // More than 6 significant digits for corresponding value in .asc: // precision loss in Float32 - QCOMPARE( testIdentifyRaster( tempLayer.data(), 6.5, 0.5 ), QString( "1.234568" ) ); // in .asc file : 1.2345678901234 + QCOMPARE( testIdentifyRaster( tempLayer.get(), 6.5, 0.5 ), QString( "1.234568" ) ); // in .asc file : 1.2345678901234 } void TestQgsMapToolIdentifyAction::identifyRasterFloat64() { //create a temporary layer QString raster = QStringLiteral( TEST_DATA_DIR ) + "/raster/test.asc"; - QScopedPointer< QgsRasterLayer> tempLayer( new QgsRasterLayer( raster ) ); + std::unique_ptr< QgsRasterLayer> tempLayer( new QgsRasterLayer( raster ) ); QVERIFY( tempLayer->isValid() ); canvas->setExtent( QgsRectangle( 0, 0, 7, 1 ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 0.5, 0.5 ), QString( "-999.9" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 0.5, 0.5 ), QString( "-999.9" ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 1.5, 0.5 ), QString( "-999.987" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 1.5, 0.5 ), QString( "-999.987" ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 2.5, 0.5 ), QString( "1.2345678" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 2.5, 0.5 ), QString( "1.2345678" ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 3.5, 0.5 ), QString( "123456" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 3.5, 0.5 ), QString( "123456" ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 4.5, 0.5 ), QString( "1234567" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 4.5, 0.5 ), QString( "1234567" ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 5.5, 0.5 ), QString( "-999.9876" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 5.5, 0.5 ), QString( "-999.9876" ) ); - QCOMPARE( testIdentifyRaster( tempLayer.data(), 6.5, 0.5 ), QString( "1.2345678901234" ) ); + QCOMPARE( testIdentifyRaster( tempLayer.get(), 6.5, 0.5 ), QString( "1.2345678901234" ) ); } void TestQgsMapToolIdentifyAction::identifyInvalidPolygons() { //create a temporary layer - QScopedPointer< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature f1( memoryLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -369,9 +369,9 @@ void TestQgsMapToolIdentifyAction::identifyInvalidPolygons() canvas->setExtent( QgsRectangle( 0, 0, 10, 10 ) ); QList identified; - identified = testIdentifyVector( memoryLayer.data(), 4, 6 ); + identified = testIdentifyVector( memoryLayer.get(), 4, 6 ); QCOMPARE( identified.length(), 0 ); - identified = testIdentifyVector( memoryLayer.data(), 6, 4 ); + identified = testIdentifyVector( memoryLayer.get(), 6, 4 ); QCOMPARE( identified.length(), 1 ); QCOMPARE( identified[0].mFeature.attribute( "pk" ), QVariant( 1 ) ); diff --git a/tests/src/app/testqgsmaptoolselect.cpp b/tests/src/app/testqgsmaptoolselect.cpp index fa099a14f56..2bc1ba97013 100644 --- a/tests/src/app/testqgsmaptoolselect.cpp +++ b/tests/src/app/testqgsmaptoolselect.cpp @@ -108,20 +108,20 @@ void TestQgsMapToolSelect::cleanup() QgsFeatureList TestQgsMapToolSelect::testSelectVector( QgsVectorLayer* layer, double xGeoref, double yGeoref ) { - QScopedPointer< QgsMapToolSelect > tool( new QgsMapToolSelect( canvas ) ); + std::unique_ptr< QgsMapToolSelect > tool( new QgsMapToolSelect( canvas ) ); QgsPoint mapPoint = canvas->getCoordinateTransform()->transform( xGeoref, yGeoref ); // make given vector layer current canvas->setCurrentLayer( layer ); - QScopedPointer< QgsMapMouseEvent > event( new QgsMapMouseEvent( + std::unique_ptr< QgsMapMouseEvent > event( new QgsMapMouseEvent( canvas, QEvent::MouseButtonRelease, QPoint( mapPoint.x(), mapPoint.y() ) ) ); // trigger mouseRelease handler - tool->canvasReleaseEvent( event.data() ); + tool->canvasReleaseEvent( event.get() ); // return selected features return layer->selectedFeatures(); @@ -130,7 +130,7 @@ TestQgsMapToolSelect::testSelectVector( QgsVectorLayer* layer, double xGeoref, d void TestQgsMapToolSelect::selectInvalidPolygons() { //create a temporary layer - QScopedPointer< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer > memoryLayer( new QgsVectorLayer( QStringLiteral( "Polygon?field=pk:int" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( memoryLayer->isValid() ); QgsFeature f1( memoryLayer->dataProvider()->fields(), 1 ); f1.setAttribute( QStringLiteral( "pk" ), 1 ); @@ -143,9 +143,9 @@ void TestQgsMapToolSelect::selectInvalidPolygons() canvas->setExtent( QgsRectangle( 0, 0, 10, 10 ) ); QgsFeatureList selected; - selected = testSelectVector( memoryLayer.data(), 4, 6 ); + selected = testSelectVector( memoryLayer.get(), 4, 6 ); QCOMPARE( selected.length(), 0 ); - selected = testSelectVector( memoryLayer.data(), 6, 4 ); + selected = testSelectVector( memoryLayer.get(), 6, 4 ); QCOMPARE( selected.length(), 1 ); QCOMPARE( selected[0].attribute( "pk" ), QVariant( 1 ) ); diff --git a/tests/src/app/testqgsmeasuretool.cpp b/tests/src/app/testqgsmeasuretool.cpp index 5348f562ee5..cc1bf5f82f6 100644 --- a/tests/src/app/testqgsmeasuretool.cpp +++ b/tests/src/app/testqgsmeasuretool.cpp @@ -99,8 +99,8 @@ void TestQgsMeasureTool::testLengthCalculation() QgsProject::instance()->setDistanceUnits( QgsUnitTypes::DistanceMeters ); // run length calculation - QScopedPointer< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, false ) ); - QScopedPointer< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.data() ) ); + std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, false ) ); + std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); tool->restart(); tool->addPoint( QgsPoint( 2484588, 2425722 ) ); @@ -116,8 +116,8 @@ void TestQgsMeasureTool::testLengthCalculation() // change project length unit, check calculation respects unit QgsProject::instance()->setDistanceUnits( QgsUnitTypes::DistanceFeet ); - QScopedPointer< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, false ) ); - QScopedPointer< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.data() ) ); + std::unique_ptr< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, false ) ); + std::unique_ptr< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.get() ) ); tool2->restart(); tool2->addPoint( QgsPoint( 2484588, 2425722 ) ); @@ -166,8 +166,8 @@ void TestQgsMeasureTool::testAreaCalculation() QgsProject::instance()->setAreaUnits( QgsUnitTypes::AreaSquareMeters ); // run length calculation - QScopedPointer< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, true ) ); - QScopedPointer< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.data() ) ); + std::unique_ptr< QgsMeasureTool > tool( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr< QgsMeasureDialog > dlg( new QgsMeasureDialog( tool.get() ) ); tool->restart(); tool->addPoint( QgsPoint( 2484588, 2425722 ) ); @@ -185,8 +185,8 @@ void TestQgsMeasureTool::testAreaCalculation() // change project area unit, check calculation respects unit QgsProject::instance()->setAreaUnits( QgsUnitTypes::AreaSquareMiles ); - QScopedPointer< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, true ) ); - QScopedPointer< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.data() ) ); + std::unique_ptr< QgsMeasureTool > tool2( new QgsMeasureTool( mCanvas, true ) ); + std::unique_ptr< QgsMeasureDialog > dlg2( new QgsMeasureDialog( tool2.get() ) ); tool2->restart(); tool2->addPoint( QgsPoint( 2484588, 2425722 ) ); diff --git a/tests/src/app/testqgsvectorlayersaveasdialog.cpp b/tests/src/app/testqgsvectorlayersaveasdialog.cpp index f9ad4417902..cf723c8e1e8 100644 --- a/tests/src/app/testqgsvectorlayersaveasdialog.cpp +++ b/tests/src/app/testqgsvectorlayersaveasdialog.cpp @@ -71,13 +71,13 @@ void TestQgsVectorLayerSaveAsDialog::cleanupTestCase() void TestQgsVectorLayerSaveAsDialog::testAttributesAsDisplayedValues() { //create a temporary layer - QScopedPointer< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr< QgsVectorLayer> tempLayer( new QgsVectorLayer( QStringLiteral( "none?field=code:int&field=regular:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) ) ); QVERIFY( tempLayer->isValid() ); // Set a widget tempLayer->setEditorWidgetSetup( 0, QgsEditorWidgetSetup( QStringLiteral( "ValueRelation" ), QVariantMap() ) ); - QgsVectorLayerSaveAsDialog d( tempLayer.data() ); + QgsVectorLayerSaveAsDialog d( tempLayer.get() ); QPushButton* mDeselectAllAttributes = d.findChild( QStringLiteral( "mDeselectAllAttributes" ) ); QTest::mouseClick( mDeselectAllAttributes, Qt::LeftButton ); diff --git a/tests/src/core/testqgis.cpp b/tests/src/core/testqgis.cpp index 5df0bf6424a..8b3c20ca16a 100644 --- a/tests/src/core/testqgis.cpp +++ b/tests/src/core/testqgis.cpp @@ -17,6 +17,7 @@ #include #include #include +#include //qgis includes... #include @@ -157,9 +158,9 @@ void TestQgis::qgsround() void TestQgis::signalBlocker() { - QScopedPointer< QCheckBox > checkbox( new QCheckBox() ); + std::unique_ptr< QCheckBox > checkbox( new QCheckBox() ); - QSignalSpy spy( checkbox.data(), SIGNAL( toggled( bool ) ) ); + QSignalSpy spy( checkbox.get(), SIGNAL( toggled( bool ) ) ); //first check that signals are not blocked QVERIFY( !checkbox->signalsBlocked() ); @@ -169,7 +170,7 @@ void TestQgis::signalBlocker() //block signals { - QgsSignalBlocker< QCheckBox > blocker( checkbox.data() ); + QgsSignalBlocker< QCheckBox > blocker( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); checkbox->setChecked( false ); @@ -190,7 +191,7 @@ void TestQgis::signalBlocker() // now check that initial blocking state is restored when QgsSignalBlocker goes out of scope checkbox->blockSignals( true ); { - QgsSignalBlocker< QCheckBox > blocker( checkbox.data() ); + QgsSignalBlocker< QCheckBox > blocker( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); } // initial blocked state should be restored @@ -199,10 +200,10 @@ void TestQgis::signalBlocker() // nested signal blockers { - QgsSignalBlocker< QCheckBox > blocker( checkbox.data() ); + QgsSignalBlocker< QCheckBox > blocker( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); { - QgsSignalBlocker< QCheckBox > blocker2( checkbox.data() ); + QgsSignalBlocker< QCheckBox > blocker2( checkbox.get() ); QVERIFY( checkbox->signalsBlocked() ); } QVERIFY( checkbox->signalsBlocked() ); @@ -215,14 +216,14 @@ void TestQgis::signalBlocker() QCOMPARE( spy.last().at( 0 ).toBool(), true ); QVERIFY( !checkbox->signalsBlocked() ); - whileBlocking( checkbox.data() )->setChecked( false ); + whileBlocking( checkbox.get() )->setChecked( false ); // should have been no signals emitted QCOMPARE( spy.count(), 3 ); // check that initial state of blocked signals was restored correctly QVERIFY( !checkbox->signalsBlocked() ); checkbox->blockSignals( true ); QVERIFY( checkbox->signalsBlocked() ); - whileBlocking( checkbox.data() )->setChecked( true ); + whileBlocking( checkbox.get() )->setChecked( true ); QVERIFY( checkbox->signalsBlocked() ); } diff --git a/tests/src/core/testqgsdatadefined.cpp b/tests/src/core/testqgsdatadefined.cpp index 6a7c39d7749..0678a2ee2b6 100644 --- a/tests/src/core/testqgsdatadefined.cpp +++ b/tests/src/core/testqgsdatadefined.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "qgsdatadefined.h" #include "qgsapplication.h" @@ -78,19 +78,19 @@ void TestQgsDataDefined::create() QCOMPARE( dd->field(), QString( "field" ) ); //test with string constructor - QScopedPointer stringConstructorField( new QgsDataDefined( QStringLiteral( "\"col1\"" ) ) ); + std::unique_ptr stringConstructorField( new QgsDataDefined( QStringLiteral( "\"col1\"" ) ) ); QVERIFY( stringConstructorField->isActive() ); QVERIFY( ! stringConstructorField->useExpression() ); QVERIFY( stringConstructorField->expressionString().isEmpty() ); QCOMPARE( stringConstructorField->field(), QString( "col1" ) ); - QScopedPointer stringConstructorExp( new QgsDataDefined( QStringLiteral( "1 + 2" ) ) ); + std::unique_ptr stringConstructorExp( new QgsDataDefined( QStringLiteral( "1 + 2" ) ) ); QVERIFY( stringConstructorExp->isActive() ); QVERIFY( stringConstructorExp->useExpression() ); QCOMPARE( stringConstructorExp->expressionString(), QString( "1 + 2" ) ); QVERIFY( stringConstructorExp->field().isEmpty() ); - QScopedPointer stringConstructorEmpty( new QgsDataDefined( QString() ) ); + std::unique_ptr stringConstructorEmpty( new QgsDataDefined( QString() ) ); QVERIFY( ! stringConstructorEmpty->isActive() ); } diff --git a/tests/src/core/testqgsexpressioncontext.cpp b/tests/src/core/testqgsexpressioncontext.cpp index 014b0ec4101..913e24e2d4a 100644 --- a/tests/src/core/testqgsexpressioncontext.cpp +++ b/tests/src/core/testqgsexpressioncontext.cpp @@ -606,10 +606,10 @@ void TestQgsExpressionContext::layerScope() layerScope = 0; //create a map layer - QScopedPointer vectorLayer( new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer&field=col2:integer&field=col3:integer" ), QStringLiteral( "test layer" ), QStringLiteral( "memory" ) ) ); + std::unique_ptr vectorLayer( new QgsVectorLayer( QStringLiteral( "Point?field=col1:integer&field=col2:integer&field=col3:integer" ), QStringLiteral( "test layer" ), QStringLiteral( "memory" ) ) ); QgsExpressionContext context; - context << QgsExpressionContextUtils::layerScope( vectorLayer.data() ); + context << QgsExpressionContextUtils::layerScope( vectorLayer.get() ); QCOMPARE( context.variable( "layer_name" ).toString(), vectorLayer->name() ); QCOMPARE( context.variable( "layer_id" ).toString(), vectorLayer->id() ); @@ -622,17 +622,17 @@ void TestQgsExpressionContext::layerScope() QCOMPARE( fromVar, vectorLayer->fields() ); //test setting layer variables - QgsExpressionContextUtils::setLayerVariable( vectorLayer.data(), QStringLiteral( "testvar" ), "testval" ); + QgsExpressionContextUtils::setLayerVariable( vectorLayer.get(), QStringLiteral( "testvar" ), "testval" ); delete layerScope; - layerScope = QgsExpressionContextUtils::layerScope( vectorLayer.data() ); + layerScope = QgsExpressionContextUtils::layerScope( vectorLayer.get() ); QCOMPARE( layerScope->variable( "testvar" ).toString(), QString( "testval" ) ); QVariantMap variables; variables.insert( QStringLiteral( "var1" ), QStringLiteral( "val1" ) ); variables.insert( QStringLiteral( "var2" ), QStringLiteral( "val2" ) ); - QgsExpressionContextUtils::setLayerVariables( vectorLayer.data(), variables ); + QgsExpressionContextUtils::setLayerVariables( vectorLayer.get(), variables ); delete layerScope; - layerScope = QgsExpressionContextUtils::layerScope( vectorLayer.data() ); + layerScope = QgsExpressionContextUtils::layerScope( vectorLayer.get() ); QCOMPARE( layerScope->variable( "testvar" ), QVariant() ); QCOMPARE( layerScope->variable( "var1" ).toString(), QString( "val1" ) ); QCOMPARE( layerScope->variable( "var2" ).toString(), QString( "val2" ) ); diff --git a/tests/src/core/testqgsfield.cpp b/tests/src/core/testqgsfield.cpp index b2936aecf03..94a05683fd0 100644 --- a/tests/src/core/testqgsfield.cpp +++ b/tests/src/core/testqgsfield.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "qgsfield.h" #include "qgsapplication.h" @@ -74,7 +75,7 @@ void TestQgsField::cleanup() void TestQgsField::create() { - QScopedPointer field( new QgsField( QStringLiteral( "name" ), QVariant::Double, QStringLiteral( "double" ), 5, 2, QStringLiteral( "comment" ) ) ); + std::unique_ptr field( new QgsField( QStringLiteral( "name" ), QVariant::Double, QStringLiteral( "double" ), 5, 2, QStringLiteral( "comment" ) ) ); QCOMPARE( field->name(), QString( "name" ) ); QCOMPARE( field->type(), QVariant::Double ); QCOMPARE( field->typeName(), QString( "double" ) ); diff --git a/tests/src/core/testqgsgeometry.cpp b/tests/src/core/testqgsgeometry.cpp index a2471db669c..66322e1a1a1 100644 --- a/tests/src/core/testqgsgeometry.cpp +++ b/tests/src/core/testqgsgeometry.cpp @@ -528,7 +528,7 @@ void TestQgsGeometry::point() QCOMPARE( p10.dimension(), 0 ); //clone - QScopedPointer< QgsPointV2 >clone( p10.clone() ); + std::unique_ptr< QgsPointV2 >clone( p10.clone() ); QVERIFY( p10 == *clone ); //assignment @@ -728,7 +728,7 @@ void TestQgsGeometry::point() QCOMPARE( p20.area(), 0.0 ); QCOMPARE( p20.centroid(), p20 ); QVERIFY( !p20.hasCurvedSegments() ); - QScopedPointer< QgsPointV2 >segmented( static_cast< QgsPointV2*>( p20.segmentize() ) ); + std::unique_ptr< QgsPointV2 >segmented( static_cast< QgsPointV2*>( p20.segmentize() ) ); QCOMPARE( *segmented, p20 ); //addZValue @@ -1156,11 +1156,11 @@ void TestQgsGeometry::lineString() QVERIFY( l10.isEmpty() ); QCOMPARE( l10.numPoints(), 0 ); - QScopedPointer toAppend( new QgsLineString() ); + std::unique_ptr toAppend( new QgsLineString() ); toAppend->setPoints( QgsPointSequence() << QgsPointV2( 1, 2 ) << QgsPointV2( 11, 12 ) << QgsPointV2( 21, 22 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QVERIFY( !l10.is3D() ); QVERIFY( !l10.isMeasure() ); QCOMPARE( l10.numPoints(), 3 ); @@ -1178,7 +1178,7 @@ void TestQgsGeometry::lineString() toAppend->setPoints( QgsPointSequence() << QgsPointV2( 31, 32 ) << QgsPointV2( 41, 42 ) << QgsPointV2( 51, 52 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QCOMPARE( l10.numPoints(), 6 ); QCOMPARE( l10.vertexCount(), 6 ); QCOMPARE( l10.nCoordinates(), 6 ); @@ -1194,7 +1194,7 @@ void TestQgsGeometry::lineString() toAppend->setPoints( QgsPointSequence() << QgsPointV2( QgsWkbTypes::PointZM, 31, 32, 33, 34 ) << QgsPointV2( QgsWkbTypes::PointZM, 41, 42, 43 , 44 ) << QgsPointV2( QgsWkbTypes::PointZM, 51, 52, 53, 54 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QVERIFY( l10.is3D() ); QVERIFY( l10.isMeasure() ); QCOMPARE( l10.numPoints(), 3 ); @@ -1214,7 +1214,7 @@ void TestQgsGeometry::lineString() toAppend->setPoints( QgsPointSequence() << QgsPointV2( QgsWkbTypes::PointZM, 31, 32, 33, 34 ) << QgsPointV2( QgsWkbTypes::PointZM, 41, 42, 43 , 44 ) << QgsPointV2( QgsWkbTypes::PointZM, 51, 52, 53, 54 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QCOMPARE( l10.wkbType(), QgsWkbTypes::LineString ); QCOMPARE( l10.pointN( 0 ), QgsPointV2( 1, 2 ) ); QCOMPARE( l10.pointN( 1 ), QgsPointV2( 31, 32 ) ); @@ -1231,7 +1231,7 @@ void TestQgsGeometry::lineString() toAppend->setPoints( QgsPointSequence() << QgsPointV2( 31, 32 ) << QgsPointV2( 41, 42 ) << QgsPointV2( 51, 52 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QCOMPARE( l10.wkbType(), QgsWkbTypes::LineStringZM ); QCOMPARE( l10.pointN( 0 ), QgsPointV2( QgsWkbTypes::PointZM, 1, 2, 3, 4 ) ); QCOMPARE( l10.pointN( 1 ), QgsPointV2( QgsWkbTypes::PointZM, 31, 32 ) ); @@ -1243,7 +1243,7 @@ void TestQgsGeometry::lineString() toAppend.reset( new QgsLineString() ); toAppend->setPoints( QgsPointSequence() << QgsPointV2( QgsWkbTypes::Point25D, 31, 32, 33 ) << QgsPointV2( QgsWkbTypes::Point25D, 41, 42, 43 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QVERIFY( l10.is3D() ); QVERIFY( !l10.isMeasure() ); QCOMPARE( l10.wkbType(), QgsWkbTypes::LineString25D ); @@ -1252,7 +1252,7 @@ void TestQgsGeometry::lineString() l10.clear(); l10.setPoints( QgsPointSequence() << QgsPointV2( QgsWkbTypes::Point25D, 11, 12, 33 ) ); QCOMPARE( l10.wkbType(), QgsWkbTypes::LineString25D ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QVERIFY( l10.is3D() ); QVERIFY( !l10.isMeasure() ); QCOMPARE( l10.wkbType(), QgsWkbTypes::LineString25D ); @@ -1268,14 +1268,14 @@ void TestQgsGeometry::lineString() << QgsPointV2( 1, 1 ) << QgsPointV2( 5, 5 ) << QgsPointV2( 10, 1 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QCOMPARE( l10.numPoints(), 3 ); QCOMPARE( l10.vertexCount(), 3 ); toAppend.reset( new QgsLineString() ); toAppend->setPoints( QgsPointSequence() << QgsPointV2( 10, 1 ) << QgsPointV2( 1, 1 ) ); - l10.append( toAppend.data() ); + l10.append( toAppend.get() ); QVERIFY( l10.isClosed() ); QCOMPARE( l10.numPoints(), 4 ); @@ -1391,7 +1391,7 @@ void TestQgsGeometry::lineString() << QgsPointV2( 11, 2 ) << QgsPointV2( 11, 22 ) << QgsPointV2( 1, 22 ) ); - QScopedPointer cloned( l14.clone() ); + std::unique_ptr cloned( l14.clone() ); QCOMPARE( cloned->numPoints(), 4 ); QCOMPARE( cloned->vertexCount(), 4 ); QCOMPARE( cloned->ringCount(), 1 ); @@ -1403,7 +1403,7 @@ void TestQgsGeometry::lineString() QCOMPARE( cloned->pointN( 1 ), l14.pointN( 1 ) ); QCOMPARE( cloned->pointN( 2 ), l14.pointN( 2 ) ); QCOMPARE( cloned->pointN( 3 ), l14.pointN( 3 ) ); - QScopedPointer< QgsLineString > segmentized( static_cast< QgsLineString* >( l14.segmentize() ) ); + std::unique_ptr< QgsLineString > segmentized( static_cast< QgsLineString* >( l14.segmentize() ) ); QCOMPARE( segmentized->numPoints(), 4 ); QCOMPARE( segmentized->wkbType(), QgsWkbTypes::LineString ); QVERIFY( !segmentized->is3D() ); @@ -1798,7 +1798,7 @@ void TestQgsGeometry::lineString() //reversed QgsLineString l27; - QScopedPointer< QgsLineString > reversed( l27.reversed() ); + std::unique_ptr< QgsLineString > reversed( l27.reversed() ); QVERIFY( reversed->isEmpty() ); l27.setPoints( QgsPointSequence() << QgsPointV2( QgsWkbTypes::PointZM, 1, 2, 2, 3 ) << QgsPointV2( QgsWkbTypes::PointZM, 11, 12, 4, 5 ) @@ -2205,7 +2205,7 @@ void TestQgsGeometry::lineString() //append toAppend.reset( new QgsLineString() ); toAppend->setPoints( QgsPointSequence() << QgsPointV2( 1, 2 ) << QgsPointV2( 4, 0 ) ); - l37.append( toAppend.data() ); + l37.append( toAppend.get() ); QCOMPARE( l37.boundingBox(), QgsRectangle( -6, -15, 4, 2 ) ); l37.addVertex( QgsPointV2( 6, 3 ) ); QCOMPARE( l37.boundingBox(), QgsRectangle( -6, -15, 6, 3 ) ); @@ -2807,7 +2807,7 @@ void TestQgsGeometry::polygon() //clone QgsPolygonV2 p11; - QScopedPointer< QgsPolygonV2 >cloned( p11.clone() ); + std::unique_ptr< QgsPolygonV2 >cloned( p11.clone() ); QCOMPARE( p11, *cloned ); ext = new QgsLineString(); ext->setPoints( QgsPointSequence() << QgsPointV2( QgsWkbTypes::PointZM, 0, 0, 1, 5 ) @@ -2847,7 +2847,7 @@ void TestQgsGeometry::polygon() QCOMPARE( p12, p15 ); //surfaceToPolygon - should be identical given polygon has no curves - QScopedPointer< QgsPolygonV2 > surface( p12.surfaceToPolygon() ); + std::unique_ptr< QgsPolygonV2 > surface( p12.surfaceToPolygon() ); QCOMPARE( *surface, p12 ); //to/fromWKB @@ -3833,11 +3833,11 @@ void TestQgsGeometry::dataStream() QCOMPARE( geom.geometry()->asWkt(), resultGeometry.geometry()->asWkt() ); //also test with geometry without data - QScopedPointer emptyGeom( new QgsGeometry() ); + std::unique_ptr emptyGeom( new QgsGeometry() ); QByteArray ba2; QDataStream ds2( &ba2, QIODevice::ReadWrite ); - ds2 << emptyGeom; + ds2 << emptyGeom.get(); ds2.device()->seek( 0 ); ds2 >> resultGeometry; diff --git a/tests/src/core/testqgsproperty.cpp b/tests/src/core/testqgsproperty.cpp index ad6da2d1258..bf93b3bd656 100644 --- a/tests/src/core/testqgsproperty.cpp +++ b/tests/src/core/testqgsproperty.cpp @@ -674,7 +674,7 @@ void TestQgsProperty::sizeScaleTransformer() QCOMPARE( r1.type(), QgsSizeScaleTransformer::Exponential ); // test cloning - QScopedPointer< QgsSizeScaleTransformer > r2( t1.clone() ); + std::unique_ptr< QgsSizeScaleTransformer > r2( t1.clone() ); QCOMPARE( r2->minValue(), 15.0 ); QCOMPARE( r2->maxValue(), 25.0 ); QCOMPARE( r2->minSize(), 150.0 ); @@ -795,7 +795,7 @@ void TestQgsProperty::colorRampTransformer() QCOMPARE( static_cast< QgsGradientColorRamp* >( r1.colorRamp() )->color2(), QColor( 200, 190, 180 ) ); // test cloning - QScopedPointer< QgsColorRampTransformer > r2( t1.clone() ); + std::unique_ptr< QgsColorRampTransformer > r2( t1.clone() ); QCOMPARE( r2->minValue(), 15.0 ); QCOMPARE( r2->maxValue(), 25.0 ); QCOMPARE( r2->nullColor(), QColor( 100, 150, 200 ) ); diff --git a/tests/src/core/testqgsrasterfilewriter.cpp b/tests/src/core/testqgsrasterfilewriter.cpp index 812ff3972af..0d1b12e1fee 100644 --- a/tests/src/core/testqgsrasterfilewriter.cpp +++ b/tests/src/core/testqgsrasterfilewriter.cpp @@ -111,7 +111,7 @@ bool TestQgsRasterFileWriter::writeTest( const QString& theRasterName ) qDebug() << myFileName; QFileInfo myRasterFileInfo( myFileName ); - QScopedPointer mpRasterLayer( new QgsRasterLayer( myRasterFileInfo.filePath(), + std::unique_ptr mpRasterLayer( new QgsRasterLayer( myRasterFileInfo.filePath(), myRasterFileInfo.completeBaseName() ) ); qDebug() << theRasterName << " metadata: " << mpRasterLayer->dataProvider()->metadata(); diff --git a/tests/src/core/testqgstaskmanager.cpp b/tests/src/core/testqgstaskmanager.cpp index 3c0937db7c1..f59f941d7de 100644 --- a/tests/src/core/testqgstaskmanager.cpp +++ b/tests/src/core/testqgstaskmanager.cpp @@ -235,15 +235,15 @@ void TestQgsTaskManager::cleanup() void TestQgsTaskManager::task() { - QScopedPointer< TestTask > task( new TestTask( "desc" ) ); + std::unique_ptr< TestTask > task( new TestTask( "desc" ) ); QCOMPARE( task->status(), QgsTask::Queued ); QCOMPARE( task->description(), QString( "desc" ) ); QVERIFY( !task->isActive() ); QVERIFY( task->canCancel() ); QVERIFY( task->flags() & QgsTask::CanCancel ); - QSignalSpy startedSpy( task.data(), &QgsTask::begun ); - QSignalSpy statusSpy( task.data(), &QgsTask::statusChanged ); + QSignalSpy startedSpy( task.get(), &QgsTask::begun ); + QSignalSpy statusSpy( task.get(), &QgsTask::statusChanged ); task->start(); QVERIFY( task->runCalled ); @@ -253,9 +253,9 @@ void TestQgsTaskManager::task() QCOMPARE( static_cast< QgsTask::TaskStatus >( statusSpy.at( 1 ).at( 0 ).toInt() ), QgsTask::Complete ); //test that calling stopped sets correct state - QScopedPointer< FailTask > failTask( new FailTask() ); - QSignalSpy stoppedSpy( failTask.data(), &QgsTask::taskTerminated ); - QSignalSpy statusSpy2( failTask.data(), &QgsTask::statusChanged ); + std::unique_ptr< FailTask > failTask( new FailTask() ); + QSignalSpy stoppedSpy( failTask.get(), &QgsTask::taskTerminated ); + QSignalSpy statusSpy2( failTask.get(), &QgsTask::statusChanged ); failTask->start(); QCOMPARE( failTask->status(), QgsTask::Terminated ); QVERIFY( !failTask->isActive() ); @@ -265,8 +265,8 @@ void TestQgsTaskManager::task() //test that calling completed sets correct state task.reset( new TestTask() ); - QSignalSpy completeSpy( task.data(), &QgsTask::taskCompleted ); - QSignalSpy statusSpy3( task.data(), &QgsTask::statusChanged ); + QSignalSpy completeSpy( task.get(), &QgsTask::taskCompleted ); + QSignalSpy statusSpy3( task.get(), &QgsTask::statusChanged ); task->start(); QCOMPARE( task->status(), QgsTask::Complete ); QVERIFY( !task->isActive() ); @@ -294,9 +294,9 @@ void TestQgsTaskManager::task() void TestQgsTaskManager::taskResult() { - QScopedPointer< QgsTask > task( new SuccessTask() ); + std::unique_ptr< QgsTask > task( new SuccessTask() ); QCOMPARE( task->status(), QgsTask::Queued ); - QSignalSpy statusSpy( task.data(), &QgsTask::statusChanged ); + QSignalSpy statusSpy( task.get(), &QgsTask::statusChanged ); task->start(); QCOMPARE( statusSpy.count(), 2 ); @@ -306,7 +306,7 @@ void TestQgsTaskManager::taskResult() task.reset( new FailTask() ); QCOMPARE( task->status(), QgsTask::Queued ); - QSignalSpy statusSpy2( task.data(), &QgsTask::statusChanged ); + QSignalSpy statusSpy2( task.get(), &QgsTask::statusChanged ); task->start(); QCOMPARE( statusSpy2.count(), 2 ); diff --git a/tests/src/gui/testqgsfieldexpressionwidget.cpp b/tests/src/gui/testqgsfieldexpressionwidget.cpp index a0f5f1852b8..4645ff5372a 100644 --- a/tests/src/gui/testqgsfieldexpressionwidget.cpp +++ b/tests/src/gui/testqgsfieldexpressionwidget.cpp @@ -140,7 +140,7 @@ void TestQgsFieldExpressionWidget::asExpression() QgsVectorLayer* layer = new QgsVectorLayer( QStringLiteral( "point?field=fld:int&field=fld2:int&field=fld3:int" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - QScopedPointer< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); + std::unique_ptr< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); widget->setLayer( layer ); // check with field set @@ -167,11 +167,11 @@ void TestQgsFieldExpressionWidget::testIsValid() QgsVectorLayer* layer = new QgsVectorLayer( QStringLiteral( "point?field=fld:int&field=name%20with%20space:string" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - QScopedPointer< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); + std::unique_ptr< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); widget->setLayer( layer ); // also check the fieldChanged signal to ensure that the emitted bool isValid value is correct - QSignalSpy spy( widget.data(), SIGNAL( fieldChanged( QString, bool ) ) ); + QSignalSpy spy( widget.get(), SIGNAL( fieldChanged( QString, bool ) ) ); // check with simple field name set bool isExpression = false; @@ -224,7 +224,7 @@ void TestQgsFieldExpressionWidget::testFilters() QgsVectorLayer* layer = new QgsVectorLayer( QStringLiteral( "point?field=intfld:int&field=stringfld:string&field=string2fld:string&field=longfld:long&field=doublefld:double&field=datefld:date&field=timefld:time&field=datetimefld:datetime" ), QStringLiteral( "x" ), QStringLiteral( "memory" ) ); QgsProject::instance()->addMapLayer( layer ); - QScopedPointer< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); + std::unique_ptr< QgsFieldExpressionWidget > widget( new QgsFieldExpressionWidget() ); widget->setLayer( layer ); QCOMPARE( widget->mCombo->count(), 8 );