File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,13 @@ QgsLayerTreeGroup* QgsLayerTreeView::currentGroupNode() const
224
224
if ( QgsLayerTree::isGroup ( parent ) )
225
225
return QgsLayerTree::toGroup ( node );
226
226
}
227
- // TODO: also handle if symbology is selected?
227
+
228
+ if ( QgsLayerTreeModelLegendNode* legendNode = layerTreeModel ()->index2legendNode ( selectionModel ()->currentIndex () ) )
229
+ {
230
+ QgsLayerTreeLayer* parent = legendNode->parent ();
231
+ if ( QgsLayerTree::isGroup ( parent->parent () ) )
232
+ return QgsLayerTree::toGroup ( parent->parent () );
233
+ }
228
234
229
235
return 0 ;
230
236
}
Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ QAction* QgsLayerTreeViewDefaultActions::actionGroupSelected( QObject* parent )
113
113
void QgsLayerTreeViewDefaultActions::addGroup ()
114
114
{
115
115
QgsLayerTreeGroup* group = mView ->currentGroupNode ();
116
+ if ( !group )
117
+ group = mView ->layerTreeModel ()->rootGroup ();
116
118
117
119
QgsLayerTreeGroup* newGroup = group->addGroup ( uniqueGroupName ( group ) );
118
120
mView ->edit ( mView ->layerTreeModel ()->node2index ( newGroup ) );
@@ -165,8 +167,12 @@ void QgsLayerTreeViewDefaultActions::zoomToLayer( QgsMapCanvas* canvas )
165
167
166
168
void QgsLayerTreeViewDefaultActions::zoomToGroup ( QgsMapCanvas* canvas )
167
169
{
170
+ QgsLayerTreeGroup* groupNode = mView ->currentGroupNode ();
171
+ if ( !groupNode )
172
+ return ;
173
+
168
174
QList<QgsMapLayer*> layers;
169
- foreach ( QString layerId, mView -> currentGroupNode () ->findLayerIds () )
175
+ foreach ( QString layerId, groupNode ->findLayerIds () )
170
176
layers << QgsMapLayerRegistry::instance ()->mapLayer ( layerId );
171
177
172
178
zoomToLayers ( canvas, layers );
You can’t perform that action at this time.
0 commit comments