diff --git a/python/core/auto_generated/raster/qgsrasterdataprovider.sip.in b/python/core/auto_generated/raster/qgsrasterdataprovider.sip.in index c5ceff3d063..e7cc9894b13 100644 --- a/python/core/auto_generated/raster/qgsrasterdataprovider.sip.in +++ b/python/core/auto_generated/raster/qgsrasterdataprovider.sip.in @@ -236,23 +236,55 @@ Returns a new image downloader for the raster legend. const QStringList &configOptions = QStringList(), QgsRasterBlockFeedback *feedback = 0 ); %Docstring -Create pyramid overviews +Creates pyramid overviews. + +:param pyramidList: a list of :py:class:`QgsRasterPryamids` to create overviews for. The :py:func:`QgsRasterPryamid.setBuild()` flag + should be set to ``True`` for every layer where pyramids are desired. +:param resamplingMethod: resampling method to use when creating the pyramids. The :py:func:`~QgsRasterDataProvider.pyramidResamplingMethods` method + can be used to retrieve a list of valid resampling methods available for specific raster data providers. +:param format: raster pyramid format. +:param configOptions: optional configuration options which are passed to the specific data provider + for use during pyramid creation. +:param feedback: optional feedback argument for progress reports and cancelation support. + +.. seealso:: :py:func:`buildPyramidList` + +.. seealso:: :py:func:`hasPyramids` + +.. seealso:: :py:func:`pyramidResamplingMethods` %End - virtual QList buildPyramidList( QList overviewList = QList() ); + virtual QList buildPyramidList( const QList &overviewList = QList() ); %Docstring Returns the raster layers pyramid list. +This method returns a list of pyramid layers which are valid for the data provider. The returned list +is a complete list of all possible layers, and includes both pyramids layers which currently exist and +layers which have not yet been constructed. To know which of the pyramid layers +ACTUALLY exists you need to look at the :py:func:`QgsRasterPyramid.getExists()` member for each value in the +list. + +The returned list is suitable for passing to the :py:func:`~QgsRasterDataProvider.buildPyramids` method. First, modify the returned list +by calling `QgsRasterPryamid.setBuild( ``True`` )` for every layer you want to create pyramids for, and then +pass the modified list to :py:func:`~QgsRasterDataProvider.buildPryamids`. + :param overviewList: used to construct the pyramid list (optional), when empty the list is defined by the provider. - A pyramid list defines the - POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers - ACTUALLY exists you need to look at the existsFlag member in each struct stored in the - list. + +.. seealso:: :py:func:`buildPyramids` + +.. seealso:: :py:func:`hasPyramids` %End bool hasPyramids(); %Docstring -Returns ``True`` if raster has at least one populated histogram. +Returns ``True`` if raster has at least one existing pyramid. + +The :py:func:`~QgsRasterDataProvider.buildPyramidList` method can be used to retrieve additional details about potential and existing +pryamid layers. + +.. seealso:: :py:func:`buildPyramidList` + +.. seealso:: :py:func:`buildPyramids` %End virtual QString htmlMetadata() = 0; diff --git a/python/core/auto_generated/raster/qgsrasterpyramid.sip.in b/python/core/auto_generated/raster/qgsrasterpyramid.sip.in index 3bc22c42e0b..5820fbb62a8 100644 --- a/python/core/auto_generated/raster/qgsrasterpyramid.sip.in +++ b/python/core/auto_generated/raster/qgsrasterpyramid.sip.in @@ -18,13 +18,100 @@ This struct is used to store pyramid info for the raster layer. #include "qgsrasterpyramid.h" %End public: - int level; - int xDim; - int yDim; - bool exists; - bool build; - QgsRasterPyramid(); + + int getLevel() const; +%Docstring +Returns the pyramid level. + +Pyramid levels are as defined by GDAL, eg +level 2 is half the original raster size. + +.. versionadded:: 3.20 +%End + + void setLevel( int level ); +%Docstring +Sets the pyramid ``level``. + +Pyramid levels are as defined by GDAL, eg +level 2 is half the original raster size. + +.. versionadded:: 3.20 +%End + +%Property( name = level, get = getLevel, set = setLevel ) + + void setXDim( int dimension ); +%Docstring +Sets the x ``dimension`` for this pyramid layer. + +.. versionadded:: 3.20 +%End + + int getXDim() const; +%Docstring +Returns the x dimension for this pyramid layer. + +.. versionadded:: 3.20 +%End + +%Property( name = xDim, get = getXDim, set = setXDim ) + + void setYDim( int dimension ); +%Docstring +Sets the y ``dimension`` for this pyramid layer. + +.. versionadded:: 3.20 +%End + + int getYDim() const; +%Docstring +Returns the y dimension for this pyramid layer. + +.. versionadded:: 3.20 +%End + +%Property( name = yDim, get = getYDim, set = setYDim ) + + bool getExists() const; +%Docstring +Returns ``True`` if the pyramid layer currently exists. + +.. versionadded:: 3.20 +%End + + void setExists( bool exists ); +%Docstring +Sets whether the pyramid layer currently exists. + +.. versionadded:: 3.20 +%End + +%Property( name = exists, get = getExists, set = setExists ) + + bool getBuild() const; +%Docstring +Returns ``True`` if the pyramid layer will be built. + +When used with :py:func:`QgsRasterDataProvider.buildPyramids()` this flag controls +whether pyramids will be built for the layer. + +.. versionadded:: 3.20 +%End + + void setBuild( bool build ); +%Docstring +Sets whether the pyramid layer will be built. + +When used with :py:func:`QgsRasterDataProvider.buildPyramids()` this flag controls +whether pyramids will be built for the layer. Set to ``True`` to build +the pyramids. + +.. versionadded:: 3.20 +%End + +%Property( name = build, get = getBuild, set = setBuild ) }; /************************************************************************ diff --git a/src/core/providers/gdal/qgsgdalprovider.cpp b/src/core/providers/gdal/qgsgdalprovider.cpp index 74385ad7659..c5800f04651 100644 --- a/src/core/providers/gdal/qgsgdalprovider.cpp +++ b/src/core/providers/gdal/qgsgdalprovider.cpp @@ -2038,16 +2038,16 @@ QString QgsGdalProvider::buildPyramids( const QList &rasterPyr ++myRasterPyramidIterator ) { #ifdef QGISDEBUG - QgsDebugMsgLevel( QStringLiteral( "Build pyramids:: Level %1" ).arg( myRasterPyramidIterator->level ), 2 ); - QgsDebugMsgLevel( QStringLiteral( "x:%1" ).arg( myRasterPyramidIterator->xDim ), 2 ); - QgsDebugMsgLevel( QStringLiteral( "y:%1" ).arg( myRasterPyramidIterator->yDim ), 2 ); - QgsDebugMsgLevel( QStringLiteral( "exists : %1" ).arg( myRasterPyramidIterator->exists ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Build pyramids:: Level %1" ).arg( myRasterPyramidIterator->getLevel() ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "x:%1" ).arg( myRasterPyramidIterator->getXDim() ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "y:%1" ).arg( myRasterPyramidIterator->getYDim() ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "exists : %1" ).arg( myRasterPyramidIterator->getExists() ), 2 ); #endif - if ( myRasterPyramidIterator->build ) + if ( myRasterPyramidIterator->getBuild() ) { QgsDebugMsgLevel( QStringLiteral( "adding overview at level %1 to list" - ).arg( myRasterPyramidIterator->level ), 2 ); - myOverviewLevelsVector.append( myRasterPyramidIterator->level ); + ).arg( myRasterPyramidIterator->getLevel() ), 2 ); + myOverviewLevelsVector.append( myRasterPyramidIterator->getLevel() ); } } /* From : http://www.gdal.org/classGDALDataset.html#a2aa6f88b3bbc840a5696236af11dde15 @@ -2226,8 +2226,9 @@ QList QgsGdalProvider::buildPyramidList() } #endif -QList QgsGdalProvider::buildPyramidList( QList overviewList ) +QList QgsGdalProvider::buildPyramidList( const QList &list ) { + QList< int > overviewList = list; QMutexLocker locker( mpMutex ); int myWidth = mWidth; @@ -2260,12 +2261,12 @@ QList QgsGdalProvider::buildPyramidList( QList overviewLi // QgsRasterPyramid myRasterPyramid; - myRasterPyramid.level = myDivisor; - myRasterPyramid.xDim = ( int )( 0.5 + ( myWidth / static_cast( myDivisor ) ) ); // NOLINT - myRasterPyramid.yDim = ( int )( 0.5 + ( myHeight / static_cast( myDivisor ) ) ); // NOLINT - myRasterPyramid.exists = false; + myRasterPyramid.setLevel( myDivisor ); + myRasterPyramid.setXDim( ( int )( 0.5 + ( myWidth / static_cast( myDivisor ) ) ) ); // NOLINT + myRasterPyramid.setYDim( ( int )( 0.5 + ( myHeight / static_cast( myDivisor ) ) ) ); // NOLINT + myRasterPyramid.setExists( false ); - QgsDebugMsgLevel( QStringLiteral( "Pyramid %1 xDim %2 yDim %3" ).arg( myRasterPyramid.level ).arg( myRasterPyramid.xDim ).arg( myRasterPyramid.yDim ), 2 ); + QgsDebugMsgLevel( QStringLiteral( "Pyramid %1 xDim %2 yDim %3" ).arg( myRasterPyramid.getLevel() ).arg( myRasterPyramid.getXDim() ).arg( myRasterPyramid.getYDim() ), 2 ); // // Now we check if it actually exists in the raster layer @@ -2288,20 +2289,20 @@ QList QgsGdalProvider::buildPyramidList( QList overviewLi // here is where we check if its a near match: // we will see if its within 5 cells either side of // - QgsDebugMsgLevel( "Checking whether " + QString::number( myRasterPyramid.xDim ) + " x " + - QString::number( myRasterPyramid.yDim ) + " matches " + + QgsDebugMsgLevel( "Checking whether " + QString::number( myRasterPyramid.getXDim() ) + " x " + + QString::number( myRasterPyramid.getYDim() ) + " matches " + QString::number( myOverviewXDim ) + " x " + QString::number( myOverviewYDim ), 2 ); - if ( ( myOverviewXDim <= ( myRasterPyramid.xDim + myNearMatchLimit ) ) && - ( myOverviewXDim >= ( myRasterPyramid.xDim - myNearMatchLimit ) ) && - ( myOverviewYDim <= ( myRasterPyramid.yDim + myNearMatchLimit ) ) && - ( myOverviewYDim >= ( myRasterPyramid.yDim - myNearMatchLimit ) ) ) + if ( ( myOverviewXDim <= ( myRasterPyramid.getXDim() + myNearMatchLimit ) ) && + ( myOverviewXDim >= ( myRasterPyramid.getXDim() - myNearMatchLimit ) ) && + ( myOverviewYDim <= ( myRasterPyramid.getYDim() + myNearMatchLimit ) ) && + ( myOverviewYDim >= ( myRasterPyramid.getYDim() - myNearMatchLimit ) ) ) { //right we have a match so adjust the a / y before they get added to the list - myRasterPyramid.xDim = myOverviewXDim; - myRasterPyramid.yDim = myOverviewYDim; - myRasterPyramid.exists = true; + myRasterPyramid.setXDim( myOverviewXDim ); + myRasterPyramid.setYDim( myOverviewYDim ); + myRasterPyramid.setExists( true ); QgsDebugMsgLevel( QStringLiteral( ".....YES!" ), 2 ); } else diff --git a/src/core/providers/gdal/qgsgdalprovider.h b/src/core/providers/gdal/qgsgdalprovider.h index 3dce1000e58..5f8f453e51f 100644 --- a/src/core/providers/gdal/qgsgdalprovider.h +++ b/src/core/providers/gdal/qgsgdalprovider.h @@ -189,7 +189,7 @@ class QgsGdalProvider final: public QgsRasterDataProvider, QgsGdalProviderBase QgsRaster::RasterPyramidsFormat format = QgsRaster::PyramidsGTiff, const QStringList &createOptions = QStringList(), QgsRasterBlockFeedback *feedback = nullptr ) override; - QList buildPyramidList( QList overviewList = QList() ) override; + QList buildPyramidList( const QList &overviewList = QList() ) override; static QMap supportedMimes(); diff --git a/src/core/raster/qgsrasterdataprovider.cpp b/src/core/raster/qgsrasterdataprovider.cpp index c3b6cfac161..387a0eb02bf 100644 --- a/src/core/raster/qgsrasterdataprovider.cpp +++ b/src/core/raster/qgsrasterdataprovider.cpp @@ -374,22 +374,8 @@ QList > QgsRasterDataProvider::pyramidResamplingMethods( bool QgsRasterDataProvider::hasPyramids() { - QList myPyramidList = buildPyramidList(); - - if ( myPyramidList.isEmpty() ) - return false; - - QList::iterator myRasterPyramidIterator; - for ( myRasterPyramidIterator = myPyramidList.begin(); - myRasterPyramidIterator != myPyramidList.end(); - ++myRasterPyramidIterator ) - { - if ( myRasterPyramidIterator->exists ) - { - return true; - } - } - return false; + const QList pyramidList = buildPyramidList(); + return std::any_of( pyramidList.constBegin(), pyramidList.constEnd(), []( QgsRasterPyramid pyramid ) { return pyramid.getExists(); } ); } void QgsRasterDataProvider::setUserNoDataValue( int bandNo, const QgsRasterRangeList &noData ) diff --git a/src/core/raster/qgsrasterdataprovider.h b/src/core/raster/qgsrasterdataprovider.h index e70d092daf7..4140d7e0ea7 100644 --- a/src/core/raster/qgsrasterdataprovider.h +++ b/src/core/raster/qgsrasterdataprovider.h @@ -309,7 +309,22 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast return nullptr; } - //! \brief Create pyramid overviews + /** + * Creates pyramid overviews. + * + * \param pyramidList a list of QgsRasterPryamids to create overviews for. The QgsRasterPryamid::setBuild() flag + * should be set to TRUE for every layer where pyramids are desired. + * \param resamplingMethod resampling method to use when creating the pyramids. The pyramidResamplingMethods() method + * can be used to retrieve a list of valid resampling methods available for specific raster data providers. + * \param format raster pyramid format. + * \param configOptions optional configuration options which are passed to the specific data provider + * for use during pyramid creation. + * \param feedback optional feedback argument for progress reports and cancelation support. + * + * \see buildPyramidList() + * \see hasPyramids() + * \see pyramidResamplingMethods() + */ virtual QString buildPyramids( const QList &pyramidList, const QString &resamplingMethod = "NEAREST", QgsRaster::RasterPyramidsFormat format = QgsRaster::PyramidsGTiff, @@ -326,16 +341,34 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast /** * Returns the raster layers pyramid list. - * \param overviewList used to construct the pyramid list (optional), when empty the list is defined by the provider. - * A pyramid list defines the - * POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers - * ACTUALLY exists you need to look at the existsFlag member in each struct stored in the + * + * This method returns a list of pyramid layers which are valid for the data provider. The returned list + * is a complete list of all possible layers, and includes both pyramids layers which currently exist and + * layers which have not yet been constructed. To know which of the pyramid layers + * ACTUALLY exists you need to look at the QgsRasterPyramid::getExists() member for each value in the * list. + * + * The returned list is suitable for passing to the buildPyramids() method. First, modify the returned list + * by calling `QgsRasterPryamid::setBuild( TRUE )` for every layer you want to create pyramids for, and then + * pass the modified list to buildPryamids(). + * + * \param overviewList used to construct the pyramid list (optional), when empty the list is defined by the provider. + * + * \see buildPyramids() + * \see hasPyramids() */ - virtual QList buildPyramidList( QList overviewList = QList() ) // clazy:exclude=function-args-by-ref + virtual QList buildPyramidList( const QList &overviewList = QList() ) { Q_UNUSED( overviewList ) return QList(); } - //! \brief Returns TRUE if raster has at least one populated histogram. + /** + * Returns TRUE if raster has at least one existing pyramid. + * + * The buildPyramidList() method can be used to retrieve additional details about potential and existing + * pryamid layers. + * + * \see buildPyramidList() + * \see buildPyramids() + */ bool hasPyramids(); /** diff --git a/src/core/raster/qgsrasterfilewriter.cpp b/src/core/raster/qgsrasterfilewriter.cpp index 6ab657ff4ab..dfbe4bf8cdb 100644 --- a/src/core/raster/qgsrasterfilewriter.cpp +++ b/src/core/raster/qgsrasterfilewriter.cpp @@ -818,7 +818,7 @@ void QgsRasterFileWriter::buildPyramids( const QString &filename, QgsRasterDataP myPyramidList = destProvider->buildPyramidList( mPyramidsList ); for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ ) { - myPyramidList[myCounterInt].build = true; + myPyramidList[myCounterInt].setBuild( true ); } QgsDebugMsgLevel( QStringLiteral( "building pyramids : %1 pyramids, %2 resampling, %3 format, %4 options" ).arg( myPyramidList.count() ).arg( mPyramidsResampling ).arg( mPyramidsFormat ).arg( mPyramidsConfigOptions.count() ), 4 ); diff --git a/src/core/raster/qgsrasterpyramid.h b/src/core/raster/qgsrasterpyramid.h index db4f0dc1cf4..5ae6143df29 100644 --- a/src/core/raster/qgsrasterpyramid.h +++ b/src/core/raster/qgsrasterpyramid.h @@ -19,6 +19,7 @@ #define QGSRASTERPYRAMID #include "qgis_core.h" +#include "qgis_sip.h" /** * \ingroup core @@ -27,25 +28,125 @@ class CORE_EXPORT QgsRasterPyramid { public: - //! \brief The pyramid level as implemented in gdal (level 2 is half original raster size etc) - int level; - //! \brief XDimension for this pyramid layer - int xDim; - //! \brief YDimension for this pyramid layer - int yDim; - //! \brief Whether the pyramid layer has been built yet - bool exists; - //! \brief Whether the pyramid should be built - bool build; - QgsRasterPyramid() - { - level = 0; - xDim = 0; - yDim = 0; - exists = false; - build = false; - } + //TODO QGIS 4.0 - rename get* to remove get prefix, and remove + //temporary SIP_PROPERTY definitions + + /** + * Returns the pyramid level. + * + * Pyramid levels are as defined by GDAL, eg + * level 2 is half the original raster size. + * + * \since QGIS 3.20 + */ + int getLevel() const { return mLevel; } + + /** + * Sets the pyramid \a level. + * + * Pyramid levels are as defined by GDAL, eg + * level 2 is half the original raster size. + * + * \since QGIS 3.20 + */ + void setLevel( int level ) { mLevel = level; } + +#ifdef SIP_RUN + SIP_PROPERTY( name = level, get = getLevel, set = setLevel ) +#endif + + /** + * Sets the x \a dimension for this pyramid layer. + * + * \since QGIS 3.20 + */ + void setXDim( int dimension ) { mXDim = dimension; } + + /** + * Returns the x dimension for this pyramid layer. + * + * \since QGIS 3.20 + */ + int getXDim() const { return mXDim; } + +#ifdef SIP_RUN + SIP_PROPERTY( name = xDim, get = getXDim, set = setXDim ) +#endif + + /** + * Sets the y \a dimension for this pyramid layer. + * + * \since QGIS 3.20 + */ + void setYDim( int dimension ) { mYDim = dimension; } + + /** + * Returns the y dimension for this pyramid layer. + * + * \since QGIS 3.20 + */ + int getYDim() const { return mYDim; } + +#ifdef SIP_RUN + SIP_PROPERTY( name = yDim, get = getYDim, set = setYDim ) +#endif + + /** + * Returns TRUE if the pyramid layer currently exists. + * + * \since QGIS 3.20 + */ + bool getExists() const { return mExists; } + + /** + * Sets whether the pyramid layer currently exists. + * + * \since QGIS 3.20 + */ + void setExists( bool exists ) { mExists = exists; } + +#ifdef SIP_RUN + SIP_PROPERTY( name = exists, get = getExists, set = setExists ) +#endif + + /** + * Returns TRUE if the pyramid layer will be built. + * + * When used with QgsRasterDataProvider::buildPyramids() this flag controls + * whether pyramids will be built for the layer. + * + * \since QGIS 3.20 + */ + bool getBuild() const { return mBuild; } + + /** + * Sets whether the pyramid layer will be built. + * + * When used with QgsRasterDataProvider::buildPyramids() this flag controls + * whether pyramids will be built for the layer. Set to TRUE to build + * the pyramids. + * + * \since QGIS 3.20 + */ + void setBuild( bool build ) { mBuild = build; } + +#ifdef SIP_RUN + SIP_PROPERTY( name = build, get = getBuild, set = setBuild ) +#endif + + private: + + //! \brief The pyramid level as implemented in gdal (level 2 is half original raster size etc) + int mLevel = 0; + //! \brief XDimension for this pyramid layer + int mXDim = 0; + //! \brief YDimension for this pyramid layer + int mYDim = 0; + //! \brief Whether the pyramid layer has been built yet + bool mExists = false; + //! \brief Whether the pyramid should be built + bool mBuild = false; }; #endif diff --git a/src/gui/qgsrasterlayersaveasdialog.cpp b/src/gui/qgsrasterlayersaveasdialog.cpp index 9bf50031bec..1b857c5b439 100644 --- a/src/gui/qgsrasterlayersaveasdialog.cpp +++ b/src/gui/qgsrasterlayersaveasdialog.cpp @@ -824,15 +824,12 @@ void QgsRasterLayerSaveAsDialog::populatePyramidsLevels() if ( ! mPyramidsOptionsWidget->overviewList().isEmpty() ) myPyramidList = mDataProvider->buildPyramidList( mPyramidsOptionsWidget->overviewList() ); } - QList::iterator myRasterPyramidIterator; - for ( myRasterPyramidIterator = myPyramidList.begin(); - myRasterPyramidIterator != myPyramidList.end(); - ++myRasterPyramidIterator ) + for ( const QgsRasterPyramid &pyramid : std::as_const( myPyramidList ) ) { - if ( ! mPyramidsUseExistingCheckBox->isChecked() || myRasterPyramidIterator->exists ) + if ( ! mPyramidsUseExistingCheckBox->isChecked() || pyramid.getExists() ) { - text += QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( "x" ) + - QString::number( myRasterPyramidIterator->yDim ) + ' '; + text += QString::number( pyramid.getXDim() ) + QStringLiteral( "x" ) + + QString::number( pyramid.getYDim() ) + ' '; } } } diff --git a/src/gui/raster/qgsrasterlayerproperties.cpp b/src/gui/raster/qgsrasterlayerproperties.cpp index d26755756e9..0200655e127 100644 --- a/src/gui/raster/qgsrasterlayerproperties.cpp +++ b/src/gui/raster/qgsrasterlayerproperties.cpp @@ -245,24 +245,21 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv // build pyramid list - QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList(); - QList< QgsRasterPyramid >::iterator myRasterPyramidIterator; + const QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList(); - for ( myRasterPyramidIterator = myPyramidList.begin(); - myRasterPyramidIterator != myPyramidList.end(); - ++myRasterPyramidIterator ) + for ( const QgsRasterPyramid &pyramid : myPyramidList ) { - if ( myRasterPyramidIterator->exists ) + if ( pyramid.getExists() ) { lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap, - QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) + - QString::number( myRasterPyramidIterator->yDim ) ) ); + QString::number( pyramid.getXDim() ) + QStringLiteral( " x " ) + + QString::number( pyramid.getYDim() ) ) ); } else { lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap, - QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) + - QString::number( myRasterPyramidIterator->yDim ) ) ); + QString::number( pyramid.getXDim() ) + QStringLiteral( " x " ) + + QString::number( pyramid.getYDim() ) ) ); } } } @@ -1149,7 +1146,7 @@ void QgsRasterLayerProperties::buttonBuildPyramids_clicked() { QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt ); //mark to be pyramided - myPyramidList[myCounterInt].build = myItem->isSelected() || myPyramidList[myCounterInt].exists; + myPyramidList[myCounterInt].setBuild( myItem->isSelected() || myPyramidList[myCounterInt].getExists() ); } // keep it in sync with qgsrasterpyramidsoptionwidget.cpp @@ -1218,21 +1215,19 @@ void QgsRasterLayerProperties::buttonBuildPyramids_clicked() QIcon myNoPyramidPixmap( QgsApplication::getThemeIcon( "/mIconNoPyramid.svg" ) ); QList< QgsRasterPyramid >::iterator myRasterPyramidIterator; - for ( myRasterPyramidIterator = myPyramidList.begin(); - myRasterPyramidIterator != myPyramidList.end(); - ++myRasterPyramidIterator ) + for ( const QgsRasterPyramid &pyramid : std::as_const( myPyramidList ) ) { - if ( myRasterPyramidIterator->exists ) + if ( pyramid.getExists() ) { lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap, - QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) + - QString::number( myRasterPyramidIterator->yDim ) ) ); + QString::number( pyramid.getXDim() ) + QStringLiteral( " x " ) + + QString::number( pyramid.getYDim() ) ) ); } else { lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap, - QString::number( myRasterPyramidIterator->xDim ) + QStringLiteral( " x " ) + - QString::number( myRasterPyramidIterator->yDim ) ) ); + QString::number( pyramid.getXDim() ) + QStringLiteral( " x " ) + + QString::number( pyramid.getYDim() ) ) ); } } //update the legend pixmap diff --git a/tests/src/core/testqgsrasterlayer.cpp b/tests/src/core/testqgsrasterlayer.cpp index 2c476f143ce..5fdaf735b25 100644 --- a/tests/src/core/testqgsrasterlayer.cpp +++ b/tests/src/core/testqgsrasterlayer.cpp @@ -547,7 +547,7 @@ void TestQgsRasterLayer::buildExternalOverviews() for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ ) { //mark to be pyramided - myPyramidList[myCounterInt].build = true; + myPyramidList[myCounterInt].setBuild( true ); } //now actually make the pyramids QString myResult = @@ -561,7 +561,7 @@ void TestQgsRasterLayer::buildExternalOverviews() for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ ) { //mark to be pyramided - QVERIFY( myPyramidList.at( myCounterInt ).exists ); + QVERIFY( myPyramidList.at( myCounterInt ).getExists() ); } // @@ -579,7 +579,7 @@ void TestQgsRasterLayer::buildExternalOverviews() for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ ) { //mark to be pyramided - myPyramidList[myCounterInt].build = true; + myPyramidList[myCounterInt].setBuild( true ); } // Test with options