Skip to content
Permalink
Browse files
sipify QgsLayerTreeLayer
  • Loading branch information
nyalldawson committed Apr 18, 2017
1 parent 468c784 commit 023ad46525c9db196d55288f098c9bfbed4b570d
Showing with 154 additions and 67 deletions.
  1. +0 −1 python/auto_sip.blacklist
  2. +95 −41 python/core/layertree/qgslayertreelayer.sip
  3. +59 −25 src/core/layertree/qgslayertreelayer.h
@@ -218,7 +218,6 @@ core/fieldformatter/qgsrelationreferencefieldformatter.sip
core/fieldformatter/qgsvaluemapfieldformatter.sip
core/fieldformatter/qgsvaluerelationfieldformatter.sip
core/layertree/qgslayertree.sip
core/layertree/qgslayertreelayer.sip
core/layertree/qgslayertreemodel.sip
core/layertree/qgslayertreemodellegendnode.sip
core/layertree/qgslayertreenode.sip
@@ -1,69 +1,123 @@
/**
* Layer tree node points to a map layer.
*
* 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, resolveReferences() method can be called
* once the layer is loaded.
*
* 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
*/
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layertree/qgslayertreelayer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class QgsLayerTreeLayer : QgsLayerTreeNode
{
%TypeHeaderCode
#include <qgslayertreelayer.h>
%Docstring
Layer tree node points to a map layer.

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, resolveReferences() method can be called
once the layer is loaded.

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.

.. versionadded:: 2.4
%End

%TypeHeaderCode
#include "qgslayertreelayer.h"
%End
public:
explicit QgsLayerTreeLayer( QgsMapLayer* layer );
explicit QgsLayerTreeLayer( QgsMapLayer *layer );

explicit QgsLayerTreeLayer( const QString& layerId, const QString& name = QString() );

explicit QgsLayerTreeLayer( const QString &layerId, const QString &name = QString(), const QString &source = QString(), const QString &provider = QString() );

QString layerId() const;
%Docstring
:rtype: str
%End

QgsMapLayer* layer() const;
QgsMapLayer *layer() const;
%Docstring
:rtype: QgsMapLayer
%End

//! 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 );
%Docstring
Returns the layer's name.
.. versionadded:: 3.0
:rtype: str
%End

void setName( const QString &n );
%Docstring
Sets the layer's name.
.. versionadded:: 3.0
%End

//! Read layer node from XML. Returns new instance.
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
static QgsLayerTreeLayer* readXml( QDomElement& element ) /Factory/;
//! Read layer node from XML. Returns new instance.
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
//! @note added in 3.0
static QgsLayerTreeLayer* readXml( QDomElement& element, const QgsProject* project ) /Factory/;
static QgsLayerTreeLayer *readXml( QDomElement &element ) /Factory/;
%Docstring
Read layer node from XML. Returns new instance.
Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
:rtype: QgsLayerTreeLayer
%End

static QgsLayerTreeLayer *readXml( QDomElement &element, const QgsProject *project ) /Factory/;
%Docstring
Read layer node from XML. Returns new instance.
Also resolves textual references to layers from the project (calls resolveReferences() internally).
.. versionadded:: 3.0
:rtype: QgsLayerTreeLayer
%End

virtual void writeXml( QDomElement& parentElement );
virtual void writeXml( QDomElement &parentElement );

virtual QString dump() const;
%Docstring
:rtype: str
%End

virtual QgsLayerTreeLayer* clone() const /Factory/;
virtual QgsLayerTreeLayer *clone() const /Factory/;
%Docstring
:rtype: QgsLayerTreeLayer
%End

//! Resolves reference to layer from stored layer ID (if it has not been resolved already)
//! \since QGIS 3.0
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false );

%Docstring
Resolves reference to layer from stored layer ID (if it has not been resolved already)
.. versionadded:: 3.0
%End

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
%Docstring
Emitted when a previously unavailable layer got loaded.
%End

void layerWillBeUnloaded();
%Docstring
Emitted when a previously available layer got unloaded (from layer registry).
.. versionadded:: 2.6
%End

protected:
void attachToLayer();

private:
QgsLayerTreeLayer( const QgsLayerTreeLayer& other );

private:
QgsLayerTreeLayer( const QgsLayerTreeLayer &other );
};



/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layertree/qgslayertreelayer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -17,6 +17,7 @@
#define QGSLAYERTREELAYER_H

#include "qgis_core.h"
#include "qgis.h"
#include "qgslayertreenode.h"
#include "qgsmaplayerref.h"

@@ -41,52 +42,65 @@ class CORE_EXPORT QgsLayerTreeLayer : public QgsLayerTreeNode
Q_OBJECT
public:
explicit QgsLayerTreeLayer( QgsMapLayer *layer );

#ifndef SIP_RUN
QgsLayerTreeLayer( const QgsLayerTreeLayer &other );
#endif

explicit QgsLayerTreeLayer( const QString &layerId, const QString &name = QString(), const QString &source = QString(), const QString &provider = QString() );

QString layerId() const { return mRef.layerId; }

QgsMapLayer *layer() const { return mRef.layer.data(); }

//! Get layer's name
//! \since QGIS 3.0
/**
* Returns the layer's name.
* \since QGIS 3.0
*/
QString name() const override;
//! Set layer's name
//! \since QGIS 3.0

/**
* Sets the layer's name.
* \since QGIS 3.0
*/
void setName( const QString &n ) override;

//! Read layer node from XML. Returns new instance.
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
static QgsLayerTreeLayer *readXml( QDomElement &element );
//! Read layer node from XML. Returns new instance.
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
//! \since QGIS 3.0
static QgsLayerTreeLayer *readXml( QDomElement &element, const QgsProject *project );
/**
* Read layer node from XML. Returns new instance.
* Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
*/
static QgsLayerTreeLayer *readXml( QDomElement &element ) SIP_FACTORY;

/**
* Read layer node from XML. Returns new instance.
* Also resolves textual references to layers from the project (calls resolveReferences() internally).
* \since QGIS 3.0
*/
static QgsLayerTreeLayer *readXml( QDomElement &element, const QgsProject *project ) SIP_FACTORY;

virtual void writeXml( QDomElement &parentElement ) override;

virtual QString dump() const override;

virtual QgsLayerTreeLayer *clone() const override;
virtual QgsLayerTreeLayer *clone() const override SIP_FACTORY;

//! Resolves reference to layer from stored layer ID (if it has not been resolved already)
//! \since QGIS 3.0
/**
* Resolves reference to layer from stored layer ID (if it has not been resolved already)
* \since QGIS 3.0
*/
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false ) override;

private slots:
//! Emits a nameChanged() signal if layer's name has changed
//! \since QGIS 3.0
void layerNameChanged();
//! Handles the event of deletion of the referenced layer
//! \since QGIS 3.0
void layerWillBeDeleted();

signals:
//! emitted when a previously unavailable layer got loaded

/**
* Emitted when a previously unavailable layer got loaded.
*/
void layerLoaded();
//! emitted when a previously available layer got unloaded (from layer registry)
//! \since QGIS 2.6

/**
* Emitted when a previously available layer got unloaded (from layer registry).
* \since QGIS 2.6
*/
void layerWillBeUnloaded();

protected:
@@ -96,6 +110,26 @@ class CORE_EXPORT QgsLayerTreeLayer : public QgsLayerTreeNode
QgsMapLayerRef mRef;
//! Layer name - only used if layer does not exist
QString mLayerName;

private slots:

/**
* Emits a nameChanged() signal if layer's name has changed
* \since QGIS 3.0
*/
void layerNameChanged();

/**
* Handles the event of deletion of the referenced layer
* \since QGIS 3.0
*/
void layerWillBeDeleted();

private:

#ifdef SIP_RUN
QgsLayerTreeLayer( const QgsLayerTreeLayer &other );
#endif
};


0 comments on commit 023ad46

Please sign in to comment.