84 tr(
"&Zoom to Layer" ), parent );
93 tr(
"&Zoom to Group" ), parent );
216 for (
int i = 0; i < layers.
size(); ++i )
230 layerExtent = vLayer->
extent();
234 if ( layerExtent.
isNull() )
248 extent.
scale( 1.05 );
259 QString newName = prefix +
'1';
260 for (
int i = 2; parentGroup->
findGroup( newName ); ++i )
272 if ( !parentGroup || parentGroup == rootGroup )
Layer tree group node serves as a container for layers and further groups.
QgsLayerTreeModel * layerTreeModel() const
Get access to the model casted to QgsLayerTreeModel.
A rectangle specified with double values.
Base class for all map layer types.
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
bool isEmpty() const
test if rectangle is empty.
QgsLayerTreeGroup * addGroup(const QString &name)
Append a new group node with given name. Newly created node is owned by this group.
QgsMapLayer * currentLayer() const
Get currently selected layer. May be null.
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
void setIsMutuallyExclusive(bool enabled, int initialChildIndex=-1)
Set whether the group is mutually exclusive (only one child can be checked at a time).
void setCurrentIndex(const QModelIndex &index)
QgsLayerTreeGroup * rootGroup() const
Return pointer to the root node of the layer tree. Always a non-null pointer.
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QAction * actionZoomToGroup(QgsMapCanvas *canvas, QObject *parent=nullptr)
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
QgsLayerTreeViewDefaultActions(QgsLayerTreeView *view)
QAction * actionAddGroup(QObject *parent=nullptr)
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
void setExtent(const QgsRectangle &r)
Set the extent of the map canvas.
const T & at(int i) const
void scale(double scaleFactor, const QgsPoint *c=nullptr)
Scale the rectangle around its center point.
void renameGroupOrLayer()
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
bool hasCrsTransformEnabled()
A simple helper method to find out if on the fly projections are enabled or not.
QAction * actionGroupSelected(QObject *parent=nullptr)
QgsLayerTreeNode * currentNode() const
Get current node. May be null.
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
QgsRectangle layerExtentToOutputExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
QAction * actionRemoveGroupOrLayer(QObject *parent=nullptr)
void refresh()
Repaints the canvas map.
void removeChildNode(QgsLayerTreeNode *node)
Remove a child node from this group. The node will be deleted.
QString tr(const char *sourceText, const char *disambiguation, int n)
QList< QgsLayerTreeNode * > selectedNodes(bool skipInternal=false) const
Return list of selected nodes.
Map canvas is a class for displaying all GIS data types on a canvas.
QgsLayerTreeGroup * toGroup(QgsLayerTreeNode *node)
Cast node to a group. No type checking is done - use isGroup() to find out whether this operation is ...
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
virtual void updateExtents()
Update the extents for the layer.
int indexOf(const T &value, int from) const
QString number(int n, int base)
int count(const T &value) const
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
QgsRectangle extent() override
Return the extent of the layer.
int toInt(bool *ok) const
void removeGroupOrLayer()
QAction * actionMakeTopLevel(QObject *parent=nullptr)
void mutuallyExclusiveGroup()
Slot to enable/disable mutually exclusive group flag.
QgsLayerTreeGroup * currentGroupNode() const
Get current group node. If a layer is current node, the function will return parent group...
QgsLayerTreeNode * parent()
Get pointer to the parent. If parent is a null pointer, the node is a root node.
This class is a base class for nodes in a layer tree.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
QList< QgsLayerTreeNode * > children()
Get list of children of the node. Children are owned by the parent.
bool isLayer(QgsLayerTreeNode *node)
Check whether the node is a valid layer node.
void setData(const QVariant &userData)
QList< QgsLayerTreeLayer * > selectedLayerNodes() const
Return list of selected nodes filtered to just layer nodes.
QVariant fromValue(const T &value)
QAction * actionZoomToLayer(QgsMapCanvas *canvas, QObject *parent=nullptr)
QModelIndex node2index(QgsLayerTreeNode *node) const
Return index for a given node. If the node does not belong to the layer tree, the result is undefined...
QAction * actionMutuallyExclusiveGroup(QObject *parent=nullptr)
Action to enable/disable mutually exclusive flag of a group (only one child node may be checked) ...
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
void insertChildNode(int index, QgsLayerTreeNode *node)
Insert existing node at specified position. The node must not have a parent yet. The node will be own...
QStringList findLayerIds() const
Find layer IDs used in all layer nodes. Searches recursively the whole sub-tree.
QgsLayerTreeGroup * findGroup(const QString &name)
Find group node with specified name. Searches recursively the whole sub-tree.
QString uniqueGroupName(QgsLayerTreeGroup *parentGroup)
void zoomToLayers(QgsMapCanvas *canvas, const QList< QgsMapLayer * > &layers)
void addChildNode(QgsLayerTreeNode *node)
Append an existing node. The node must not have a parent yet. The node will be owned by this group...
void edit(const QModelIndex &index)
QAction * actionShowFeatureCount(QObject *parent=nullptr)
QAction * actionRenameGroupOrLayer(QObject *parent=nullptr)
QModelIndex currentIndex() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
virtual QgsRectangle extent()
Return the extent of the layer.
Represents a vector layer which manages a vector based data sets.
bool isGroup(QgsLayerTreeNode *node)
Check whether the node is a valid group node.
virtual QgsLayerTreeLayer * clone() const override
Create a copy of the node. Returns new instance.
QAction * actionShowInOverview(QObject *parent=nullptr)
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the node.
Layer tree node points to a map layer.