Skip to content

Commit

Permalink
[Geometry checker] Prevent output layer from being set as current inp…
Browse files Browse the repository at this point in the history
…ut layer when dialog is visible
  • Loading branch information
manisandro committed Jan 19, 2016
1 parent 4827cbc commit 20ca316
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp
Expand Up @@ -81,21 +81,25 @@ void QgsGeometryCheckerSetupTab::updateLayers()
ui.comboBoxInputLayer->clear();

// Collect layers
QgsMapLayer* currentLayer = mIface->mapCanvas()->currentLayer();
// Don't switch current layer if dialog is visible to avoid confusing the user
QgsMapLayer* currentLayer = isVisible() ? 0 : mIface->mapCanvas()->currentLayer();
int currIdx = -1;
int idx = 0;
Q_FOREACH( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() )
{
QgsDebugMsg( QString( "Adding layer, have %1 in list" ).arg( ui.comboBoxInputLayer->count() ) );
if ( qobject_cast<QgsVectorLayer*>( layer ) )
{
ui.comboBoxInputLayer->addItem( layer->name(), layer->id() );
if ( layer->name() == prevLayer )
{
currIdx = ui.comboBoxInputLayer->count() - 1;
currIdx = idx;
}
else if ( currIdx == -1 && layer == currentLayer )
{
currIdx = ui.comboBoxInputLayer->count() - 1;
currIdx = idx;
}
++idx;
}
}
ui.comboBoxInputLayer->setCurrentIndex( qMax( 0, currIdx ) );
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/geometry_snapper/qgsgeometrysnapperdialog.cpp
Expand Up @@ -69,9 +69,11 @@ void QgsGeometrySnapperDialog::updateLayers()
comboBoxReferenceLayer->clear();

// Collect layers
QgsMapLayer* currentLayer = mIface->mapCanvas()->currentLayer();
// Don't switch current layer if dialog is visible to avoid confusing the user
QgsMapLayer* currentLayer = isVisible() ? 0 : mIface->mapCanvas()->currentLayer();
int curInputIdx = -1;
int curReferenceIdx = -1;
int idx = 0;
Q_FOREACH( QgsMapLayer* layer, QgsMapLayerRegistry::instance()->mapLayers() )
{
if ( qobject_cast<QgsVectorLayer*>( layer ) )
Expand All @@ -83,17 +85,18 @@ void QgsGeometrySnapperDialog::updateLayers()
comboBoxReferenceLayer->addItem( layer->name(), layer->id() );
if ( layer->name() == curInput )
{
curInputIdx = comboBoxInputLayer->count() - 1;
curInputIdx = idx;
}
else if ( curInputIdx == -1 && layer == currentLayer )
{
curInputIdx = comboBoxInputLayer->count() - 1;
curInputIdx = idx;
}

if ( layer->name() == curReference )
{
curReferenceIdx = comboBoxReferenceLayer->count() - 1;
curReferenceIdx = idx;
}
++idx;
}
}
}
Expand Down

0 comments on commit 20ca316

Please sign in to comment.