Skip to content
Permalink
Browse files

Return a vector instead of a list and deprecate rasterEntries

  • Loading branch information
elpaso committed Nov 29, 2018
1 parent 80c12b5 commit 49da1c3be972b8f7d92c5f1f0cc33265f1b472b9
@@ -23,7 +23,7 @@ Represents an individual raster layer/band number entry within a raster calculat
%End
public:

static QList<QgsRasterCalculatorEntry> rasterEntries();
static QVector<QgsRasterCalculatorEntry> rasterEntries();
%Docstring
Creates a list of raster entries from the current project.

@@ -351,9 +351,9 @@ QString QgsRasterCalculator::lastError() const
return mLastError;
}

QList<QgsRasterCalculatorEntry> QgsRasterCalculatorEntry::rasterEntries()
QVector<QgsRasterCalculatorEntry> QgsRasterCalculatorEntry::rasterEntries()
{
QList<QgsRasterCalculatorEntry> availableEntries;
QVector<QgsRasterCalculatorEntry> availableEntries;
const QMap<QString, QgsMapLayer *> &layers = QgsProject::instance()->mapLayers();

auto uniqueRasterBandIdentifier = [ & ]( QgsRasterCalculatorEntry & entry ) -> bool
@@ -50,7 +50,7 @@ class ANALYSIS_EXPORT QgsRasterCalculatorEntry
* \return the list of raster entries form the current project
* \since QGIS 3.6
*/
static QList<QgsRasterCalculatorEntry> rasterEntries();
static QVector<QgsRasterCalculatorEntry> rasterEntries();

/**
* Name of entry.
@@ -5681,7 +5681,7 @@ void QgisApp::showRasterCalculator()
if ( d.exec() == QDialog::Accepted )
{
//invoke analysis library
QgsRasterCalculator rc( d.formulaString(), d.outputFile(), d.outputFormat(), d.outputRectangle(), d.outputCrs(), d.numberOfColumns(), d.numberOfRows(), d.rasterEntries() );
QgsRasterCalculator rc( d.formulaString(), d.outputFile(), d.outputFormat(), d.outputRectangle(), d.outputCrs(), d.numberOfColumns(), d.numberOfRows(), QgsRasterCalculatorEntry::rasterEntries() );

QProgressDialog p( tr( "Calculating raster expression…" ), tr( "Abort" ), 0, 0 );
p.setWindowModality( Qt::WindowModal );
@@ -167,7 +167,7 @@ void QgsRasterCalcDialog::setExtentSize( int width, int height, QgsRectangle bbo

void QgsRasterCalcDialog::insertAvailableRasterBands()
{
mAvailableRasterBands = QgsRasterCalculatorEntry::rasterEntries();
mAvailableRasterBands = QgsRasterCalculatorEntry::rasterEntries().toList();
for ( const auto &entry : qgis::as_const( mAvailableRasterBands ) )
{
QgsRasterLayer *rlayer = entry.raster;
@@ -53,8 +53,9 @@ class APP_EXPORT QgsRasterCalcDialog: public QDialog, private Ui::QgsRasterCalcD
/**
* Extract raster layer information from the current project
* \return a vector of raster entries from the current project
* \deprecated since QGIS 3.6 use QgsRasterCalculatorEntry::rasterEntries() instead
*/
QVector<QgsRasterCalculatorEntry> rasterEntries() const;
Q_DECL_DEPRECATED QVector<QgsRasterCalculatorEntry> rasterEntries() const;

private slots:
void mRasterBandsListWidget_itemDoubleClicked( QListWidgetItem *item );
@@ -575,7 +575,7 @@ void TestQgsRasterCalculator::testRasterEntries()
rlayer = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/analysis/slope.tif", QStringLiteral( "slope2" ) );
layers << rlayer ;
QgsProject::instance()->addMapLayers( layers );
QList<QgsRasterCalculatorEntry> availableRasterBands = QgsRasterCalculatorEntry::rasterEntries();
QVector<QgsRasterCalculatorEntry> availableRasterBands = QgsRasterCalculatorEntry::rasterEntries();
QMap<QString, QgsRasterCalculatorEntry> entryMap;
for ( const auto &rb : qgis::as_const( availableRasterBands ) )
{

0 comments on commit 49da1c3

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