16#ifndef QGSLAYERTREELAYER_H
17#define QGSLAYERTREELAYER_H
56 explicit QgsLayerTreeLayer(
const QString &layerId,
const QString &name = QString(),
const QString &source = QString(),
const QString &provider = QString() );
59 SIP_PYOBJECT __repr__();
61 QString
str = QStringLiteral(
"<QgsLayerTreeLayer: %1>" ).arg( sipCpp->name() );
62 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
71 QString
layerId()
const {
return mRef.layerId; }
91 QString
name()
const override;
100 void setName(
const QString &n )
override;
107 void setUseLayerName(
bool use =
true );
113 bool useLayerName()
const;
130 QString
dump()
const override;
138 void resolveReferences( const
QgsProject *project,
bool looseMatching = false ) override;
145 void setLabelExpression( const QString &expression );
152 QString labelExpression()
const {
return mLabelExpression; }
238 void attachToLayer();
248 bool mUseLayerName =
true;
256 void layerNameChanged();
262 void layerWillBeDeleted();
Layer tree node points to a map layer.
QString layerId() const
Returns the ID for the map layer associated with this node.
QString mLabelExpression
Expression to evaluate in the legend.
void setPatchSize(QSizeF size)
Sets the user (overridden) size for the legend node.
QgsMapLayerRef mRef
Weak reference to the layer (or just it's ID if the reference is not resolved yet)
void layerWillBeUnloaded()
Emitted when a previously available layer got unloaded (from layer registry).
LegendNodesSplitBehavior
Legend node column split behavior.
@ AllowSplittingLegendNodesOverMultipleColumns
Allow splitting node's legend nodes across multiple columns.
@ PreventSplittingLegendNodesOverMultipleColumns
Prevent splitting node's legend nodes across multiple columns.
@ UseDefaultLegendSetting
Inherit default legend column splitting setting.
void layerLoaded()
Emitted when a previously unavailable layer got loaded.
void setLegendSplitBehavior(LegendNodesSplitBehavior behavior)
Sets the column split behavior for the node.
LegendNodesSplitBehavior legendSplitBehavior() const
Returns the column split behavior for the node.
QgsMapLayer * layer() const
Returns the map layer associated with this node.
QString mLayerName
Layer name - only used if layer does not exist or if mUseLayerName is false.
QSizeF patchSize() const
Returns the user (overridden) size for the legend node.
This class is a base class for nodes in a layer tree.
virtual void setName(const QString &name)=0
Set name of the node.
virtual QString dump() const =0
Returns string with layer tree structure. For debug purposes only.
virtual void writeXml(QDomElement &parentElement, const QgsReadWriteContext &context)=0
Write layer tree to XML.
static QgsLayerTreeNode * readXml(QDomElement &element, const QgsReadWriteContext &context)
Read layer tree from XML.
virtual QString name() const =0
Returns name of the node.
virtual QgsLayerTreeNode * clone() const =0
Create a copy of the node. Returns new instance.
Represents a patch shape for use in map legends.
Base class for all map layer types.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
The class is used as a container of context for various read/write operations on other objects.