Skip to content
Permalink
Browse files
Fix #9918 (enable add symbol layer also when selection is not on symbol)
  • Loading branch information
wonder-sk committed Mar 28, 2014
1 parent 748ff8b commit 530b5fd5ce2e0fe41b9ca35c46fc39684651422e
Showing with 8 additions and 7 deletions.
  1. +8 −7 src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
@@ -256,7 +256,6 @@ void QgsSymbolV2SelectorDialog::updateUi()
btnDown->setEnabled( false );
btnRemoveLayer->setEnabled( false );
btnLock->setEnabled( false );
btnAddLayer->setEnabled( true );
return;
}

@@ -267,7 +266,6 @@ void QgsSymbolV2SelectorDialog::updateUi()
btnDown->setEnabled( currentRow < rowCount - 1 );
btnRemoveLayer->setEnabled( rowCount > 1 );
btnLock->setEnabled( true );
btnAddLayer->setEnabled( false );
}

void QgsSymbolV2SelectorDialog::updatePreview()
@@ -398,19 +396,22 @@ void QgsSymbolV2SelectorDialog::addLayer()
if ( !idx.isValid() )
return;

int insertIdx = -1;
SymbolLayerItem *item = static_cast<SymbolLayerItem*>( model->itemFromIndex( idx ) );
if ( item->isLayer() )
{
QMessageBox::critical( this, tr( "Invalid Selection!" ), tr( "Kindly select a symbol to add layer." ) );
return;
insertIdx = item->row();
item = static_cast<SymbolLayerItem*>( item->parent() );
}

QgsSymbolV2* parentSymbol = item->symbol();
QgsSymbolLayerV2* newLayer = QgsSymbolLayerV2Registry::instance()->defaultSymbolLayer( parentSymbol->type() );
parentSymbol->appendSymbolLayer( newLayer );
// XXX Insane behaviour of the appendSymbolLayer, it actually "pushes" into the list
if ( insertIdx == -1 )
parentSymbol->appendSymbolLayer( newLayer );
else
parentSymbol->insertSymbolLayer( item->rowCount() - insertIdx, newLayer );
SymbolLayerItem *newLayerItem = new SymbolLayerItem( newLayer );
item->insertRow( 0, newLayerItem );
item->insertRow( insertIdx == -1 ? 0 : insertIdx, newLayerItem );
item->updatePreview();

layersTree->setCurrentIndex( model->indexFromItem( newLayerItem ) );

0 comments on commit 530b5fd

Please sign in to comment.