Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
If we know for certain a spatial index already exists on a vector layer,
adjust the "Create Spatial Index" button in the vector layer properties
dialog to reflect this.
  • Loading branch information
nyalldawson authored and nirvn committed Nov 17, 2019
1 parent 6eb5987 commit 8ced952
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -236,13 +236,19 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(

syncToLayer();

if ( mLayer->dataProvider() )//enable spatial index button group if supported by provider
if ( mLayer->dataProvider() )
{
//enable spatial index button group if supported by provider, or if one already exists
QgsVectorDataProvider::Capabilities capabilities = mLayer->dataProvider()->capabilities();
if ( !( capabilities & QgsVectorDataProvider::CreateSpatialIndex ) )
{
pbnIndex->setEnabled( false );
}
if ( mLayer->dataProvider()->hasSpatialIndex() == QgsFeatureSource::SpatialIndexPresent )
{
pbnIndex->setEnabled( false );
pbnIndex->setText( tr( "Spatial Index Exists" ) );
}

if ( capabilities & QgsVectorDataProvider::SelectEncoding )
{
Expand Down Expand Up @@ -966,12 +972,13 @@ void QgsVectorLayerProperties::pbnIndex_clicked()
setCursor( Qt::ArrowCursor );
if ( errval )
{
pbnIndex->setEnabled( false );
pbnIndex->setText( tr( "Spatial Index Exists" ) );
QMessageBox::information( this, tr( "Spatial Index" ), tr( "Creation of spatial index successful" ) );
}
else
{
// TODO: Remind the user to use OGR >= 1.2.6 and Shapefile
QMessageBox::information( this, tr( "Spatial Index" ), tr( "Creation of spatial index failed" ) );
QMessageBox::warning( this, tr( "Spatial Index" ), tr( "Creation of spatial index failed" ) );
}
}
}
Expand Down

0 comments on commit 8ced952

Please sign in to comment.