Skip to content

Commit

Permalink
[FEATURE] optionally add new layers to the selected group
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13071 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 18, 2010
1 parent 80f1e54 commit 116dfc8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app/legend/qgslegend.cpp
Expand Up @@ -520,7 +520,18 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
}
blockSignals( false );

insertTopLevelItem( 0, llayer );
QgsLegendGroup *lg = dynamic_cast<QgsLegendGroup *>( currentItem() );
QSettings settings;
if ( lg && settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() )
{
lg->insertChild( 0, llayer );
}
else
{
insertTopLevelItem( 0, llayer );
setCurrentItem( llayer );
}

setItemExpanded( llayer, true );

refreshLayerSymbology( layer->getLayerID() );
Expand All @@ -533,7 +544,6 @@ void QgsLegend::addLayer( QgsMapLayer * layer )
mMapCanvas->zoomToFullExtent();
mMapCanvas->clearExtentHistory();
}
setCurrentItem( llayer );
//make the QTreeWidget item up-to-date
doItemsLayout();
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -206,6 +206,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
cbxAttributeTableDocked->setChecked( settings.value( "/qgis/dockAttributeTable", false ).toBool() );
cbxIdentifyResultsDocked->setChecked( settings.value( "/qgis/dockIdentifyResults", false ).toBool() );
cbxAddPostgisDC->setChecked( settings.value( "/qgis/addPostgisDC", false ).toBool() );
cbxAddNewLayersToCurrentGroup->setChecked( settings.value( "/qgis/addNewLayersToCurrentGroup", false ).toBool() );

//set the color for selections
int myRed = settings.value( "/qgis/default_selection_color_red", 255 ).toInt();
Expand Down Expand Up @@ -454,6 +455,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/dockAttributeTable", cbxAttributeTableDocked->isChecked() );
settings.setValue( "/qgis/dockIdentifyResults", cbxIdentifyResultsDocked->isChecked() );
settings.setValue( "/qgis/addPostgisDC", cbxAddPostgisDC->isChecked() );
settings.setValue( "/qgis/addNewLayersToCurrentGroup", cbxAddNewLayersToCurrentGroup->isChecked() );
settings.setValue( "/qgis/new_layers_visible", chkAddedVisibility->isChecked() );
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
Expand Down
7 changes: 7 additions & 0 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -362,6 +362,13 @@
</item>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="cbxAddNewLayersToCurrentGroup">
<property name="text">
<string>Add new layers to selected group</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 116dfc8

Please sign in to comment.