mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-21 00:05:53 -04:00
See https://github.com/qgis/QGIS-Enhancement-Proposals/issues/86 - Checking/unchecking a group doesn't change the check state of its children. A node is visible if and only if it is checked and all its parents too. - There is no more a semi-checked state for a group - Ctrl-clic on a unchecked group will check the group and all its descendants. - Ctrl-clic on a unchecked layer will check the lager and all its parents. - Ctrl-clic on a checked group will uncheck the group and all its descendants. - Ctrl-clic on a checked layer will uncheck the layer and all its parents. - Those actions are available in contextual menu items in the tree view. - Invisible layers because they or their parent(s) is unchecked are greyed out.
69 lines
2.0 KiB
Plaintext
69 lines
2.0 KiB
Plaintext
/**
|
|
* Layer tree node points to a map layer.
|
|
*
|
|
* When using with existing QgsMapLayer instance, it is expected that the layer
|
|
* has been registered in QgsProject earlier.
|
|
*
|
|
* The node can exist also without a valid instance of a layer (just ID). That
|
|
* means the referenced layer does not need to be loaded in order to use it
|
|
* in layer tree. In such case, the node will start listening to map layer
|
|
* registry updates in expectation that the layer (identified by its ID) will
|
|
* be loaded later.
|
|
*
|
|
* A map layer is supposed to be present in one layer tree just once. It is
|
|
* however possible that temporarily a layer exists in one tree more than just
|
|
* once, e.g. while reordering items with drag and drop.
|
|
*
|
|
* @note added in 2.4
|
|
*/
|
|
class QgsLayerTreeLayer : QgsLayerTreeNode
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgslayertreelayer.h>
|
|
%End
|
|
|
|
public:
|
|
explicit QgsLayerTreeLayer( QgsMapLayer* layer );
|
|
|
|
explicit QgsLayerTreeLayer( const QString& layerId, const QString& name = QString() );
|
|
|
|
QString layerId() const;
|
|
|
|
QgsMapLayer* layer() const;
|
|
|
|
//! Get layer's name
|
|
//! @note added in 3.0
|
|
QString name() const;
|
|
//! Set layer's name
|
|
//! @note added in 3.0
|
|
void setName( const QString& n );
|
|
|
|
static QgsLayerTreeLayer* readXml( QDomElement& element ) /Factory/;
|
|
virtual void writeXml( QDomElement& parentElement );
|
|
|
|
virtual QString dump() const;
|
|
|
|
virtual QgsLayerTreeLayer* clone() const /Factory/;
|
|
|
|
protected slots:
|
|
void registryLayersAdded( const QList<QgsMapLayer*>& layers );
|
|
void registryLayersWillBeRemoved( const QStringList& layerIds );
|
|
//! Emits a nameChanged() signal if layer's name has changed
|
|
//! @note added in 3.0
|
|
void layerNameChanged();
|
|
|
|
signals:
|
|
//! emitted when a previously unavailable layer got loaded
|
|
void layerLoaded();
|
|
//! emitted when a previously available layer got unloaded (from layer registry)
|
|
//! @note added in 2.6
|
|
void layerWillBeUnloaded();
|
|
|
|
protected:
|
|
void attachToLayer();
|
|
|
|
private:
|
|
QgsLayerTreeLayer( const QgsLayerTreeLayer& other );
|
|
|
|
};
|