Merge pull request #47087 from landryb/fix/28858

Update wms layer title each time a new layer is selected
This commit is contained in:
Loïc Bartoletti 2022-03-23 11:59:11 +01:00 committed by GitHub
commit 99dd9699fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 22 deletions

View File

@ -986,32 +986,27 @@ void QgsWMSSourceSelect::updateButtons()
}
}
if ( leLayerName->text().isEmpty() || leLayerName->text() == mLastLayerName )
if ( addButton()->isEnabled() )
{
if ( addButton()->isEnabled() )
if ( !lstTilesets->selectedItems().isEmpty() )
{
if ( !lstTilesets->selectedItems().isEmpty() )
{
QTableWidgetItem *item = lstTilesets->selectedItems().first();
mLastLayerName = item->data( Qt::UserRole + 5 ).toString();
if ( mLastLayerName.isEmpty() )
mLastLayerName = item->data( Qt::UserRole + 0 ).toString();
leLayerName->setText( mLastLayerName );
}
else
{
QStringList layers, styles, titles;
collectSelectedLayers( layers, styles, titles );
mLastLayerName = titles.join( QLatin1Char( '/' ) );
leLayerName->setText( mLastLayerName );
}
QTableWidgetItem *item = lstTilesets->selectedItems().first();
QString tileLayerName = item->data( Qt::UserRole + 5 ).toString();
if ( tileLayerName.isEmpty() )
tileLayerName = item->data( Qt::UserRole + 0 ).toString();
leLayerName->setText( tileLayerName );
}
else
{
mLastLayerName.clear();
leLayerName->setText( mLastLayerName );
QStringList layers, styles, titles;
collectSelectedLayers( layers, styles, titles );
leLayerName->setText( titles.join( QLatin1Char( '/' ) ) );
}
}
else
{
leLayerName->setText( "" );
}
}

View File

@ -160,9 +160,6 @@ class QgsWMSSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsWM
//! URI for selected connection
QgsDataSourceUri mUri;
//! layer name derived from latest layer selection (updated as long it's not edited manually)
QString mLastLayerName;
//! The widget that controls the image format radio buttons
QButtonGroup *mImageFormatGroup = nullptr;