QGIS API Documentation 4.1.0-Master (d6fb7a379fb)
Loading...
Searching...
No Matches
qgslayertreeviewdefaultactions.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayertreeviewdefaultactions.cpp
3 --------------------------------------
4 Date : May 2014
5 Copyright : (C) 2014 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgsapplication.h"
19#include "qgsguiutils.h"
20#include "qgslayertree.h"
21#include "qgslayertreemodel.h"
22#include "qgslayertreeview.h"
23#include "qgsmapcanvas.h"
24#include "qgsproject.h"
25#include "qgsvectorlayer.h"
26
27#include <QAction>
28#include <QString>
29
30#include "moc_qgslayertreeviewdefaultactions.cpp"
31
32using namespace Qt::StringLiterals;
33
38
40{
41 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionAddGroup.svg"_s ), tr( "&Add Group" ), parent );
42 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::addGroup );
43 return a;
44}
45
47{
48 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionRemoveLayer.svg"_s ), tr( "&Remove" ), parent );
49 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::removeGroupOrLayer );
50 return a;
51}
52
54{
55 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionRemoveLayer.svg"_s ), tr( "&Remove Group" ), parent );
56 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::removeGroupPromoteLayers );
57 return a;
58}
59
61{
62 QgsLayerTreeNode *node = mView->currentNode();
63 if ( !node )
64 return nullptr;
65
66 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionInOverview.svg"_s ), tr( "Show in &Overview" ), parent );
67 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::showInOverview );
68 a->setCheckable( true );
69 a->setChecked( node->customProperty( u"overview"_s, 0 ).toInt() );
70 return a;
71}
72
74{
75 QgsLayerTreeNode *node = mView->currentNode();
76 if ( !node )
77 return nullptr;
78
79 QString text;
80 if ( QgsLayerTree::isGroup( node ) )
81 text = tr( "Re&name Group" );
82 else
83 text = tr( "Re&name Layer" );
84
85 QAction *a = new QAction( text, parent );
86 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::renameGroupOrLayer );
87 return a;
88}
89
91{
92 QgsLayerTreeNode *node = mView->currentNode();
93 if ( !node )
94 return nullptr;
95
96 QAction *a = new QAction( tr( "Show Feature &Count" ), parent );
97 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::showFeatureCount );
98 a->setCheckable( true );
99 a->setChecked( node->customProperty( u"showFeatureCount"_s, 0 ).toInt() );
100 return a;
101}
102
104{
105 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionZoomToLayer.svg"_s ), tr( "&Zoom to Layer" ), parent );
106 a->setData( QVariant::fromValue( reinterpret_cast<void *>( canvas ) ) );
108 connect( a, &QAction::triggered, this, static_cast<void ( QgsLayerTreeViewDefaultActions::* )()>( &QgsLayerTreeViewDefaultActions::zoomToLayer ) );
110 return a;
111}
112
114{
115 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionZoomToLayer.svg"_s ), tr( "&Zoom to Layer(s)" ), parent );
116 a->setData( QVariant::fromValue( canvas ) );
117 connect( a, &QAction::triggered, this, static_cast<void ( QgsLayerTreeViewDefaultActions::* )()>( &QgsLayerTreeViewDefaultActions::zoomToLayers ) );
118 return a;
119}
120
122{
123 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionZoomToSelected.svg"_s ), tr( "Zoom to &Selection" ), parent );
124 a->setData( QVariant::fromValue( reinterpret_cast<void *>( canvas ) ) );
125 connect( a, &QAction::triggered, this, static_cast<void ( QgsLayerTreeViewDefaultActions::* )()>( &QgsLayerTreeViewDefaultActions::zoomToSelection ) );
126 return a;
127}
128
130{
131 QAction *a = new QAction( QgsApplication::getThemeIcon( u"/mActionZoomToLayer.svg"_s ), tr( "&Zoom to Group" ), parent );
132 a->setData( QVariant::fromValue( reinterpret_cast<void *>( canvas ) ) );
133 connect( a, &QAction::triggered, this, static_cast<void ( QgsLayerTreeViewDefaultActions::* )()>( &QgsLayerTreeViewDefaultActions::zoomToGroup ) );
134 return a;
135}
136
138{
139 QAction *a = new QAction( tr( "&Move to Top-level" ), parent );
141 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::makeTopLevel );
143 return a;
144}
145
147{
148 QAction *a = new QAction( tr( "Move O&ut of Group" ), parent );
149 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::moveOutOfGroup );
150 return a;
151}
152
154{
155 QAction *a = new QAction( tr( "Move to &Top" ), parent );
156 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::moveToTop );
157 return a;
158}
159
161{
162 QAction *a = new QAction( tr( "Move to &Bottom" ), parent );
163 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::moveToBottom );
164 return a;
165}
166
168{
169 QAction *a = new QAction( tr( "&Group Selected" ), parent );
170 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::groupSelected );
171 return a;
172}
173
175{
176 QgsLayerTreeNode *node = mView->currentNode();
177 if ( !node || !QgsLayerTree::isGroup( node ) )
178 return nullptr;
179
180 QAction *a = new QAction( tr( "&Mutually Exclusive Group" ), parent );
181 a->setCheckable( true );
182 a->setChecked( QgsLayerTree::toGroup( node )->isMutuallyExclusive() );
183 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::mutuallyExclusiveGroup );
184 return a;
185}
186
188{
189 QgsLayerTreeNode *node = mView->currentNode();
190 if ( !node || !QgsLayerTree::isGroup( node ) || node->isItemVisibilityCheckedRecursive() )
191 return nullptr;
192#ifdef Q_OS_MACOS
193 QAction *a = new QAction( tr( "Check and All its Children (⌘-click)" ), parent );
194#else
195 QAction *a = new QAction( tr( "Check and All its Children (Ctrl-click)" ), parent );
196#endif
197 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::checkAndAllChildren );
198 return a;
199}
200
202{
203 QgsLayerTreeNode *node = mView->currentNode();
204 if ( !node || !QgsLayerTree::isGroup( node ) || node->isItemVisibilityUncheckedRecursive() )
205 return nullptr;
206#ifdef Q_OS_MACOS
207 QAction *a = new QAction( tr( "Uncheck and All its Children (⌘-click)" ), parent );
208#else
209 QAction *a = new QAction( tr( "Uncheck and All its Children (Ctrl-click)" ), parent );
210#endif
211 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::uncheckAndAllChildren );
212 return a;
213}
214
216{
217 QgsLayerTreeNode *node = mView->currentNode();
218 if ( !node || !QgsLayerTree::isLayer( node ) || node->isVisible() )
219 return nullptr;
220 QAction *a = new QAction( tr( "Chec&k and All its Parents" ), parent );
221 connect( a, &QAction::triggered, this, &QgsLayerTreeViewDefaultActions::checkAndAllParents );
222 return a;
223}
224
225void QgsLayerTreeViewDefaultActions::checkAndAllChildren()
226{
228 if ( !node )
229 return;
231}
232
233void QgsLayerTreeViewDefaultActions::uncheckAndAllChildren()
234{
235 QgsLayerTreeNode *node = mView->currentNode();
236 if ( !node )
237 return;
239}
240
241void QgsLayerTreeViewDefaultActions::checkAndAllParents()
242{
243 QgsLayerTreeNode *node = mView->currentNode();
244 if ( !node )
245 return;
247}
248
250{
251 int nodeCount = mView->selectedNodes( true ).count();
252 if ( nodeCount > 1 || ( nodeCount == 1 && mView->currentLayer() ) )
253 {
255 return;
256 }
257 QgsLayerTreeGroup *group = mView->currentGroupNode();
258 if ( !group )
259 group = mView->layerTreeModel()->rootGroup();
260
261 QgsLayerTreeGroup *newGroup = group->addGroup( uniqueGroupName( group ) );
262 mView->edit( mView->node2index( newGroup ) );
263}
264
266{
267 const auto constSelectedNodes = mView->selectedNodes( true );
268 for ( QgsLayerTreeNode *node : constSelectedNodes )
269 {
270 // could be more efficient if working directly with ranges instead of individual nodes
271 qobject_cast<QgsLayerTreeGroup *>( node->parent() )->removeChildNode( node );
272 }
273}
274
276{
277 QgsLayerTreeGroup *group = mView->currentGroupNode();
278
279 // can't remove the root group!
280 if ( !group || group == mView->layerTreeModel()->rootGroup() )
281 return;
282
283 QgsLayerTreeGroup *newParentGroup = qobject_cast<QgsLayerTreeGroup *>( group->parent() );
284 if ( !newParentGroup )
285 return;
286
287 const int existingNodePosition = newParentGroup->children().indexOf( group );
288
289 const QList< QgsLayerTreeNode * > childrenToPromote = group->children();
290 if ( !childrenToPromote.isEmpty() )
291 {
292 for ( auto it = childrenToPromote.rbegin(); it != childrenToPromote.rend(); ++it )
293 {
294 newParentGroup->insertChildNode( existingNodePosition, ( *it )->clone() );
295 group->removeChildNode( *it );
296 }
297 }
298
299 newParentGroup->removeChildNode( group );
300}
301
303{
304 mView->edit( mView->currentIndex() );
305}
306
308{
309 QgsLayerTreeNode *node = mView->currentNode();
310 if ( !node )
311 return;
312 int newValue = node->customProperty( u"overview"_s, 0 ).toInt();
313 const auto constSelectedLayerNodes = mView->selectedLayerNodes();
314 for ( QgsLayerTreeLayer *l : constSelectedLayerNodes )
315 l->setCustomProperty( u"overview"_s, newValue ? 0 : 1 );
316}
317
319{
320 QgsLayerTreeNode *node = mView->currentNode();
321 if ( !QgsLayerTree::isLayer( node ) )
322 return;
323
324 int newValue = node->customProperty( u"showFeatureCount"_s, 0 ).toInt();
325 const auto constSelectedLayerNodes = mView->selectedLayerNodes();
326 for ( QgsLayerTreeLayer *l : constSelectedLayerNodes )
327 l->setCustomProperty( u"showFeatureCount"_s, newValue ? 0 : 1 );
328}
329
331{
332 QgsMapLayer *layer = mView->currentLayer();
333 if ( !layer )
334 return;
335
336 const QList<QgsMapLayer *> layers { layer };
337 zoomToLayers( canvas, layers );
338}
339
341{
342 const QList<QgsMapLayer *> layers = mView->selectedLayers();
343
344 zoomToLayers( canvas, layers );
345}
346
348{
349 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mView->currentLayer() );
350
351 const QList<QgsMapLayer *> layers = mView->selectedLayers();
352
353 if ( layers.size() > 1 )
354 canvas->zoomToSelected( layers );
355 else if ( layers.size() <= 1 && layer )
356 canvas->zoomToSelected( layer );
357}
358
360{
361 QgsLayerTreeGroup *groupNode = mView->currentGroupNode();
362 if ( !groupNode )
363 return;
364
365 QList<QgsMapLayer *> layers;
366 const QStringList findLayerIds = groupNode->findLayerIds();
367 for ( const QString &layerId : findLayerIds )
368 layers << QgsProject::instance()->mapLayer( layerId );
369
370 zoomToLayers( canvas, layers );
371}
372
374{
376 QAction *s = qobject_cast<QAction *>( sender() );
377 QgsMapCanvas *canvas = reinterpret_cast<QgsMapCanvas *>( s->data().value<void *>() );
378
379 zoomToLayer( canvas );
381}
382
384{
385 QAction *s = qobject_cast<QAction *>( sender() );
386 QgsMapCanvas *canvas = s->data().value<QgsMapCanvas *>();
387 zoomToLayers( canvas );
388}
389
391{
392 QAction *s = qobject_cast<QAction *>( sender() );
393 QgsMapCanvas *canvas = reinterpret_cast<QgsMapCanvas *>( s->data().value<void *>() );
394 zoomToSelection( canvas );
395}
396
398{
399 QAction *s = qobject_cast<QAction *>( sender() );
400 QgsMapCanvas *canvas = reinterpret_cast<QgsMapCanvas *>( s->data().value<void *>() );
401 zoomToGroup( canvas );
402}
403
404void QgsLayerTreeViewDefaultActions::zoomToLayers( QgsMapCanvas *canvas, const QList<QgsMapLayer *> &layers )
405{
406 QgsTemporaryCursorOverride cursorOverride( Qt::WaitCursor );
407
408 QgsRectangle extent;
409 extent.setNull();
410
411 if ( !layers.empty() )
412 {
413 canvas->zoomToLayers( layers );
414 }
415 // If no layer is selected, use current layer
416 else if ( mView->currentLayer() )
417 {
418 const QList<QgsMapLayer *> layers { mView->currentLayer() };
419 canvas->zoomToLayers( layers );
420 }
421}
422
423
425{
426 QString prefix = parentGroup == mView->layerTreeModel()->rootGroup() ? "group" : "sub-group";
427 QString newName = prefix + '1';
428 for ( int i = 2; parentGroup->findGroup( newName ); ++i )
429 newName = prefix + QString::number( i );
430 return newName;
431}
432
433
435{
436 const auto constSelectedLayerNodes = mView->selectedLayerNodes();
437 for ( QgsLayerTreeLayer *l : constSelectedLayerNodes )
438 {
439 QgsLayerTreeGroup *rootGroup = mView->layerTreeModel()->rootGroup();
440 QgsLayerTreeGroup *parentGroup = qobject_cast<QgsLayerTreeGroup *>( l->parent() );
441 if ( !parentGroup || parentGroup == rootGroup )
442 continue;
443 QgsLayerTreeLayer *clonedLayer = l->clone();
444 rootGroup->addChildNode( clonedLayer );
445 parentGroup->removeChildNode( l );
446 }
447}
448
449
451{
452 const QList<QgsLayerTreeLayer *> selectedLayerNodes = mView->selectedLayerNodes();
453 for ( QgsLayerTreeLayer *l : selectedLayerNodes )
454 {
455 QgsLayerTreeGroup *rootGroup = mView->layerTreeModel()->rootGroup();
456 QgsLayerTreeGroup *parentGroup = qobject_cast<QgsLayerTreeGroup *>( l->parent() );
457 if ( !parentGroup || parentGroup == rootGroup )
458 continue;
459 QgsLayerTreeGroup *tempGroup = parentGroup;
460 while ( tempGroup->parent() != rootGroup )
461 {
462 tempGroup = qobject_cast<QgsLayerTreeGroup *>( tempGroup->parent() );
463 }
464 QgsLayerTreeLayer *clonedLayer = l->clone();
465 int insertIdx = rootGroup->children().indexOf( tempGroup );
466 rootGroup->insertChildNode( insertIdx, clonedLayer );
467 parentGroup->removeChildNode( l );
468 }
469}
470
471
473{
474 QList<QgsLayerTreeNode *> selectedNodes = mView->selectedNodes();
475 std::reverse( selectedNodes.begin(), selectedNodes.end() );
476 // sort the nodes by depth first to avoid moving a group before its contents
477 std::stable_sort( selectedNodes.begin(), selectedNodes.end(), []( const QgsLayerTreeNode *a, const QgsLayerTreeNode *b ) { return a->depth() > b->depth(); } );
478 for ( QgsLayerTreeNode *n : std::as_const( selectedNodes ) )
479 {
480 QgsLayerTreeGroup *parentGroup = qobject_cast<QgsLayerTreeGroup *>( n->parent() );
481 QgsLayerTreeNode *clonedNode = n->clone();
482 parentGroup->insertChildNode( 0, clonedNode );
483 parentGroup->removeChildNode( n );
484 }
485}
486
487
489{
490 QList<QgsLayerTreeNode *> selectedNodes = mView->selectedNodes();
491 // sort the nodes by depth first to avoid moving a group before its contents
492 std::stable_sort( selectedNodes.begin(), selectedNodes.end(), []( const QgsLayerTreeNode *a, const QgsLayerTreeNode *b ) { return a->depth() > b->depth(); } );
493 for ( QgsLayerTreeNode *n : std::as_const( selectedNodes ) )
494 {
495 QgsLayerTreeGroup *parentGroup = qobject_cast<QgsLayerTreeGroup *>( n->parent() );
496 QgsLayerTreeNode *clonedNode = n->clone();
497 parentGroup->insertChildNode( -1, clonedNode );
498 parentGroup->removeChildNode( n );
499 }
500}
501
502
504{
505 const QList<QgsLayerTreeNode *> nodes = mView->selectedNodes( true );
506 if ( nodes.empty() || !QgsLayerTree::isGroup( nodes[0]->parent() ) )
507 return;
508
509 QgsLayerTreeGroup *parentGroup = QgsLayerTree::toGroup( nodes[0]->parent() );
510 int insertIdx = parentGroup->children().indexOf( nodes[0] );
511
512 QgsLayerTreeGroup *newGroup = new QgsLayerTreeGroup( uniqueGroupName( parentGroup ) );
513 for ( QgsLayerTreeNode *node : nodes )
514 newGroup->addChildNode( node->clone() );
515
516 parentGroup->insertChildNode( insertIdx, newGroup );
517
518 for ( QgsLayerTreeNode *node : nodes )
519 {
520 QgsLayerTreeGroup *group = qobject_cast<QgsLayerTreeGroup *>( node->parent() );
521 if ( group )
522 group->removeChildNode( node );
523 }
524
525 mView->setCurrentIndex( mView->node2index( newGroup ) );
526 mView->edit( mView->node2index( newGroup ) );
527}
528
530{
531 QgsLayerTreeNode *node = mView->currentNode();
532 if ( !node || !QgsLayerTree::isGroup( node ) )
533 return;
534
535 QgsLayerTree::toGroup( node )->setIsMutuallyExclusive( !QgsLayerTree::toGroup( node )->isMutuallyExclusive() );
536}
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Layer tree group node serves as a container for layers and further groups.
void insertChildNode(int index, QgsLayerTreeNode *node)
Insert existing node at specified position.
QgsLayerTreeGroup * findGroup(const QString &name)
Find group node with specified name.
void removeChildNode(QgsLayerTreeNode *node)
Remove a child node from this group.
QStringList findLayerIds() const
Find layer IDs used in all layer nodes.
void addChildNode(QgsLayerTreeNode *node)
Append an existing node.
void setIsMutuallyExclusive(bool enabled, int initialChildIndex=-1)
Set whether the group is mutually exclusive (only one child can be checked at a time).
QgsLayerTreeGroup * addGroup(const QString &name)
Append a new group node with given name.
Layer tree node points to a map layer.
QgsLayerTreeLayer * clone() const override
Create a copy of the node. Returns new instance.
Base class for nodes in a layer tree.
bool isVisible() const
Returns whether a node is really visible (ie checked and all its ancestors checked as well).
bool isItemVisibilityUncheckedRecursive() const
Returns whether this node is unchecked and all its children.
QList< QgsLayerTreeNode * > children()
Gets list of children of the node. Children are owned by the parent.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer. Properties are stored in a map and saved in project file.
QgsLayerTreeNode * parent()
Gets pointer to the parent. If parent is nullptr, the node is a root node.
virtual void setItemVisibilityCheckedRecursive(bool checked)
Check or uncheck a node and all its children (taking into account exclusion rules).
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
bool isItemVisibilityCheckedRecursive() const
Returns whether this node is checked and all its children.
void setItemVisibilityCheckedParentRecursive(bool checked)
Check or uncheck a node and all its parents.
Base class for QTreeView widgets which display a layer tree.
QgsLayerTreeNode * currentNode() const
Returns the current node.
QAction * actionRemoveGroupOrLayer(QObject *parent=nullptr)
Returns a new action which removes either a group or layer, depending on the selected node.
void zoomToLayers()
Zooms to the combined extent of all the selected layer(s) in the layer tree.
void removeGroupPromoteLayers()
Removes the selected group node, promoting all child nodes up into the removed group's parent node.
void zoomToLayers(QgsMapCanvas *canvas)
Zooms a map canvas to all the selected layer(s) in the layer tree.
QAction * actionZoomToLayers(QgsMapCanvas *canvas, QObject *parent=nullptr)
Action to zoom to all the selected layer(s) in the layer tree.
void moveToTop()
Moves selected layer(s) and/or group(s) to the top of the layer panel or the top of the group if the ...
QAction * actionMoveToTop(QObject *parent=nullptr)
QAction * actionShowInOverview(QObject *parent=nullptr)
Returns a new action for toggling whether a layer is shown in the map overview.
QAction * actionRenameGroupOrLayer(QObject *parent=nullptr)
Returns a new action for renaming a group or layer, depending on the selected node.
QAction * actionCheckAndAllChildren(QObject *parent=nullptr)
Action to check a group and all its children.
QAction * actionCheckAndAllParents(QObject *parent=nullptr)
Action to check a group and all its parents.
void moveToBottom()
Moves selected layer(s) and/or group(s) to the bottom of the layer panel or the bottom of the group i...
QAction * actionRemoveGroupPromoteLayers(QObject *parent=nullptr)
Returns a new action which removes a group.
Q_DECL_DEPRECATED QAction * actionZoomToLayer(QgsMapCanvas *canvas, QObject *parent=nullptr)
Action to zoom to the active layer from the layer tree.
QAction * actionAddGroup(QObject *parent=nullptr)
Returns a new action which adds a group.
QAction * actionGroupSelected(QObject *parent=nullptr)
QgsLayerTreeViewDefaultActions(QgsLayerTreeViewBase *view)
Constructor for QgsLayerTreeViewDefaultActions, creating actions for a view.
QAction * actionMoveToBottom(QObject *parent=nullptr)
QAction * actionShowFeatureCount(QObject *parent=nullptr)
Returns a new action for toggling whether the feature count is shown for a layer.
Q_DECL_DEPRECATED void zoomToLayer(QgsMapCanvas *canvas)
Zooms a map canvas to the extent of the active layer in the layer tree.
QAction * actionMutuallyExclusiveGroup(QObject *parent=nullptr)
Action to enable/disable mutually exclusive flag of a group (only one child node may be checked).
Q_DECL_DEPRECATED QAction * actionMakeTopLevel(QObject *parent=nullptr)
QString uniqueGroupName(QgsLayerTreeGroup *parentGroup)
QAction * actionUncheckAndAllChildren(QObject *parent=nullptr)
Action to uncheck a group and all its children.
void mutuallyExclusiveGroup()
Slot to enable/disable mutually exclusive group flag.
void zoomToSelection()
Zooms to the bounding box of all selected features of a vector layer.
void moveOutOfGroup()
Moves selected layer(s) out of the group(s) and places this/these above the group(s).
QAction * actionZoomToSelection(QgsMapCanvas *canvas, QObject *parent=nullptr)
Action to zoom to selected features of a vector layer.
QAction * actionMoveOutOfGroup(QObject *parent=nullptr)
QAction * actionZoomToGroup(QgsMapCanvas *canvas, QObject *parent=nullptr)
Q_DECL_DEPRECATED void zoomToLayer()
Zooms to the extent of the active layer in the layer tree.
static bool isLayer(const QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
static bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
static QgsLayerTreeGroup * toGroup(QgsLayerTreeNode *node)
Cast node to a group.
Map canvas is a class for displaying all GIS data types on a canvas.
void zoomToSelected(QgsMapLayer *layer=nullptr)
Zoom to the extent of the selected features of provided map layer.
void zoomToLayers(const QList< QgsMapLayer * > &layers)
Zoom to the combined extent of a set of layers.
Base class for all map layer types.
Definition qgsmaplayer.h:83
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
A rectangle specified with double values.
void setNull()
Mark a rectangle as being null (holding no spatial information).
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Represents a vector layer which manages a vector based dataset.
#define Q_NOWARN_DEPRECATED_POP
Definition qgis.h:7766
#define Q_NOWARN_DEPRECATED_PUSH
Definition qgis.h:7765