mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
sipify layer tree classes
This commit is contained in:
parent
6b260ffee6
commit
157709129e
@ -200,12 +200,6 @@ core/fieldformatter/qgslistfieldformatter.sip
|
|||||||
core/fieldformatter/qgsrelationreferencefieldformatter.sip
|
core/fieldformatter/qgsrelationreferencefieldformatter.sip
|
||||||
core/fieldformatter/qgsvaluemapfieldformatter.sip
|
core/fieldformatter/qgsvaluemapfieldformatter.sip
|
||||||
core/fieldformatter/qgsvaluerelationfieldformatter.sip
|
core/fieldformatter/qgsvaluerelationfieldformatter.sip
|
||||||
core/layertree/qgslayertree.sip
|
|
||||||
core/layertree/qgslayertreemodel.sip
|
|
||||||
core/layertree/qgslayertreemodellegendnode.sip
|
|
||||||
core/layertree/qgslayertreenode.sip
|
|
||||||
core/layertree/qgslayertreeregistrybridge.sip
|
|
||||||
core/layertree/qgslayertreeutils.sip
|
|
||||||
core/raster/qgsbilinearrasterresampler.sip
|
core/raster/qgsbilinearrasterresampler.sip
|
||||||
core/raster/qgsbrightnesscontrastfilter.sip
|
core/raster/qgsbrightnesscontrastfilter.sip
|
||||||
core/raster/qgscliptominmaxenhancement.sip
|
core/raster/qgscliptominmaxenhancement.sip
|
||||||
|
@ -1,61 +1,188 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertree.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsLayerTree : QgsLayerTreeGroup
|
class QgsLayerTree : QgsLayerTreeGroup
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%Docstring
|
||||||
#include <qgslayertree.h>
|
Namespace with helper functions for layer tree operations.
|
||||||
|
|
||||||
|
Only generally useful routines should be here. Miscellaneous utility functions for work
|
||||||
|
with the layer tree are in QgsLayerTreeUtils class.
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include "qgslayertree.h"
|
||||||
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static bool isGroup( QgsLayerTreeNode *node );
|
static bool isGroup( QgsLayerTreeNode *node );
|
||||||
|
%Docstring
|
||||||
|
Check whether the node is a valid group node
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
static bool isLayer( const QgsLayerTreeNode *node );
|
static bool isLayer( const QgsLayerTreeNode *node );
|
||||||
|
%Docstring
|
||||||
|
Check whether the node is a valid layer node
|
||||||
|
|
||||||
//! Cast node to a group. No type checking is done - use isGroup() to find out whether this operation is legal.
|
.. versionadded:: 2.4
|
||||||
// PYTHON: automatic cast
|
:rtype: bool
|
||||||
//inline QgsLayerTreeGroup* toGroup( QgsLayerTreeNode* node );
|
%End
|
||||||
|
|
||||||
//! Cast node to a layer. No type checking is done - use isLayer() to find out whether this operation is legal.
|
|
||||||
// PYTHON: automatic cast
|
|
||||||
//inline QgsLayerTreeLayer* toLayer( QgsLayerTreeNode* node );
|
|
||||||
|
QgsLayerTree();
|
||||||
|
%Docstring
|
||||||
|
Create a new empty layer tree
|
||||||
|
%End
|
||||||
|
|
||||||
QList<QgsMapLayer *> customLayerOrder() const;
|
QList<QgsMapLayer *> customLayerOrder() const;
|
||||||
|
%Docstring
|
||||||
|
The order in which layers will be rendered on the canvas.
|
||||||
|
Will only be used if the property hasCustomLayerOrder is true.
|
||||||
|
If you need the current layer order that is active, prefer using layerOrder().
|
||||||
|
|
||||||
|
\see setCustomLayerOrder
|
||||||
|
\see layerOrder
|
||||||
|
\see hasCustomLayerOrder
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: list of QgsMapLayer
|
||||||
|
%End
|
||||||
|
|
||||||
void setCustomLayerOrder( const QList<QgsMapLayer *> &customLayerOrder );
|
void setCustomLayerOrder( const QList<QgsMapLayer *> &customLayerOrder );
|
||||||
|
%Docstring
|
||||||
|
The order in which layers will be rendered on the canvas.
|
||||||
|
Will only be used if the property hasCustomLayerOrder is true.
|
||||||
|
If you need the current layer order that is active, prefer using layerOrder().
|
||||||
|
|
||||||
|
\see customLayerOrder
|
||||||
|
\see layerOrder
|
||||||
|
\see hasCustomLayerOrder
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
void setCustomLayerOrder( const QStringList &customLayerOrder ) /PyName=setCustomLayerOrderByIds/;
|
void setCustomLayerOrder( const QStringList &customLayerOrder ) /PyName=setCustomLayerOrderByIds/;
|
||||||
|
%Docstring
|
||||||
|
The order in which layers will be rendered on the canvas.
|
||||||
|
Will only be used if the property hasCustomLayerOrder is true.
|
||||||
|
If you need the current layer order that is active, prefer using layerOrder().
|
||||||
|
|
||||||
|
\see customLayerOrder
|
||||||
|
\see layerOrder
|
||||||
|
\see hasCustomLayerOrder
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
QList<QgsMapLayer *> layerOrder() const;
|
QList<QgsMapLayer *> layerOrder() const;
|
||||||
|
%Docstring
|
||||||
|
The order in which layers will be rendered on the canvas.
|
||||||
|
Depending on hasCustomLayerOrder, this will return either the override
|
||||||
|
customLayerOrder or the layer order derived from the tree.
|
||||||
|
This property is read only.
|
||||||
|
|
||||||
|
\see customLayerOrder
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: list of QgsMapLayer
|
||||||
|
%End
|
||||||
|
|
||||||
bool hasCustomLayerOrder() const;
|
bool hasCustomLayerOrder() const;
|
||||||
|
%Docstring
|
||||||
|
Determines if the layer order should be derived from the layer tree
|
||||||
|
or if a custom override order shall be used instead.
|
||||||
|
|
||||||
|
\see customLayerOrder
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
void setHasCustomLayerOrder( bool hasCustomLayerOrder );
|
void setHasCustomLayerOrder( bool hasCustomLayerOrder );
|
||||||
|
%Docstring
|
||||||
|
Determines if the layer order should be derived from the layer tree
|
||||||
|
or if a custom override order shall be used instead.
|
||||||
|
|
||||||
|
\see setCustomLayerOrder
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
static QgsLayerTree *readXml( QDomElement &element );
|
static QgsLayerTree *readXml( QDomElement &element );
|
||||||
|
%Docstring
|
||||||
|
Load the layer tree from an XML element.
|
||||||
|
It is not required that layers are loaded at this point.
|
||||||
|
resolveReferences() needs to be called after loading the layers and
|
||||||
|
before using the tree.
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: QgsLayerTree
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void readLayerOrderFromXml( const QDomElement &doc );
|
void readLayerOrderFromXml( const QDomElement &doc );
|
||||||
|
%Docstring
|
||||||
|
Load the layer order from an XML element.
|
||||||
|
Make sure that this is only called after the layers are loaded.
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
virtual void writeXml( QDomElement &parentElement );
|
virtual void writeXml( QDomElement &parentElement );
|
||||||
|
|
||||||
virtual QgsLayerTree *clone() const;
|
virtual QgsLayerTree *clone() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
%Docstring
|
||||||
|
Clear any information from this layer tree.
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void customLayerOrderChanged();
|
void customLayerOrderChanged();
|
||||||
|
%Docstring
|
||||||
|
Emitted when the custom layer order has changed.
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void layerOrderChanged();
|
void layerOrderChanged();
|
||||||
|
%Docstring
|
||||||
|
Emitted when the layer order has changed.
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
void hasCustomLayerOrderChanged( bool hasCustomLayerOrder );
|
void hasCustomLayerOrderChanged( bool hasCustomLayerOrder );
|
||||||
|
%Docstring
|
||||||
|
Emitted when the hasCustomLayerOrder flag changes.
|
||||||
|
|
||||||
|
\see hasCustomLayerOrder
|
||||||
|
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertree.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
@ -1,201 +1,277 @@
|
|||||||
/**
|
/************************************************************************
|
||||||
* The QgsLayerTreeModel class is model implementation for Qt item views framework.
|
* This file has been generated automatically from *
|
||||||
* The model can be used in any QTreeView, it is however recommended to use it
|
* *
|
||||||
* with QgsLayerTreeView which brings additional functionality specific to layer tree handling.
|
* src/core/layertree/qgslayertreemodel.h *
|
||||||
*
|
* *
|
||||||
* The model listens to the changes in the layer tree and signals the changes as appropriate,
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
* so that any view that uses the model is updated accordingly.
|
************************************************************************/
|
||||||
*
|
|
||||||
* Behavior of the model can be customized with flags. For example, whether to show legend or
|
|
||||||
* whether to allow changes to the layer tree.
|
|
||||||
*
|
|
||||||
* @see QgsLayerTreeView
|
|
||||||
* @note added in 2.4
|
|
||||||
*/
|
|
||||||
class QgsLayerTreeModel : QAbstractItemModel
|
class QgsLayerTreeModel : QAbstractItemModel
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
The QgsLayerTreeModel class is model implementation for Qt item views framework.
|
||||||
|
The model can be used in any QTreeView, it is however recommended to use it
|
||||||
|
with QgsLayerTreeView which brings additional functionality specific to layer tree handling.
|
||||||
|
|
||||||
|
The model listens to the changes in the layer tree and signals the changes as appropriate,
|
||||||
|
so that any view that uses the model is updated accordingly.
|
||||||
|
|
||||||
|
Behavior of the model can be customized with flags. For example, whether to show legend or
|
||||||
|
whether to allow changes to the layer tree.
|
||||||
|
|
||||||
|
\see QgsLayerTreeView
|
||||||
|
.. versionadded:: 2.4
|
||||||
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgslayertreemodel.h>
|
#include "qgslayertreemodel.h"
|
||||||
%End
|
%End
|
||||||
|
|
||||||
%ConvertToSubClassCode
|
%ConvertToSubClassCode
|
||||||
if (sipCpp->inherits("QgsLayerTreeModel"))
|
if ( sipCpp->inherits( "QgsLayerTreeModel" ) )
|
||||||
sipType = sipType_QgsLayerTreeModel;
|
sipType = sipType_QgsLayerTreeModel;
|
||||||
else
|
else
|
||||||
sipType = 0;
|
sipType = 0;
|
||||||
|
%End
|
||||||
|
public:
|
||||||
|
explicit QgsLayerTreeModel( QgsLayerTree *rootNode, QObject *parent /TransferThis/ = 0 );
|
||||||
|
%Docstring
|
||||||
|
The root node is not transferred by the model.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
public:
|
|
||||||
//! Construct a new tree model with given layer tree (root node must not be null pointer).
|
|
||||||
//! The root node is not transferred by the model.
|
|
||||||
explicit QgsLayerTreeModel( QgsLayerTree* rootNode, QObject *parent /TransferThis/ = 0 );
|
|
||||||
~QgsLayerTreeModel();
|
~QgsLayerTreeModel();
|
||||||
|
|
||||||
// Implementation of virtual functions from QAbstractItemModel
|
|
||||||
|
|
||||||
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
|
virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
|
||||||
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
|
|
||||||
QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
|
%Docstring
|
||||||
QModelIndex parent( const QModelIndex &child ) const;
|
Implementation of virtual functions from QAbstractItemModel
|
||||||
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
|
:rtype: int
|
||||||
Qt::ItemFlags flags( const QModelIndex &index ) const;
|
%End
|
||||||
bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
|
virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
|
||||||
Qt::DropActions supportedDropActions() const;
|
|
||||||
QStringList mimeTypes() const;
|
virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
|
||||||
QMimeData* mimeData( const QModelIndexList& indexes ) const;
|
|
||||||
bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
virtual QModelIndex parent( const QModelIndex &child ) const;
|
||||||
bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() );
|
|
||||||
|
virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
|
||||||
|
|
||||||
|
virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
|
||||||
|
|
||||||
|
virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
|
||||||
|
|
||||||
|
virtual Qt::DropActions supportedDropActions() const;
|
||||||
|
|
||||||
|
virtual QStringList mimeTypes() const;
|
||||||
|
|
||||||
|
virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
|
||||||
|
|
||||||
|
virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
|
||||||
|
|
||||||
|
virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
|
||||||
|
|
||||||
|
|
||||||
// New stuff
|
|
||||||
|
|
||||||
enum Flag
|
enum Flag
|
||||||
{
|
{
|
||||||
// display flags
|
// display
|
||||||
ShowLegend, //!< Add legend nodes for layer nodes
|
ShowLegend,
|
||||||
ShowRasterPreviewIcon, //!< Will use real preview of raster layer as icon (may be slow)
|
ShowRasterPreviewIcon,
|
||||||
ShowLegendAsTree, //!< For legends that support it, will show them in a tree instead of a list (needs also ShowLegend). Added in 2.8
|
ShowLegendAsTree,
|
||||||
DeferredLegendInvalidation, //!< defer legend model invalidation
|
DeferredLegendInvalidation,
|
||||||
|
UseEmbeddedWidgets,
|
||||||
|
|
||||||
// behavioral flags
|
// behavioral
|
||||||
AllowNodeReorder, //!< Allow reordering with drag'n'drop
|
AllowNodeReorder,
|
||||||
AllowNodeRename, //!< Allow renaming of groups and layers
|
AllowNodeRename,
|
||||||
AllowNodeChangeVisibility, //!< Allow user to set node visibility with a check box
|
AllowNodeChangeVisibility,
|
||||||
AllowLegendChangeState, //!< Allow check boxes for legend nodes (if supported by layer's legend)
|
AllowLegendChangeState,
|
||||||
ActionHierarchical, //!< Check/uncheck action has consequences on children (or parents for leaf node)
|
ActionHierarchical,
|
||||||
};
|
};
|
||||||
typedef QFlags<QgsLayerTreeModel::Flag> Flags;
|
typedef QFlags<QgsLayerTreeModel::Flag> Flags;
|
||||||
|
|
||||||
//! Set OR-ed combination of model flags
|
|
||||||
void setFlags( Flags f );
|
void setFlags( QgsLayerTreeModel::Flags f );
|
||||||
//! Enable or disable a model flag
|
%Docstring
|
||||||
|
Set OR-ed combination of model flags
|
||||||
|
%End
|
||||||
void setFlag( Flag f, bool on = true );
|
void setFlag( Flag f, bool on = true );
|
||||||
//! Return OR-ed combination of model flags
|
%Docstring
|
||||||
|
Enable or disable a model flag
|
||||||
|
%End
|
||||||
Flags flags() const;
|
Flags flags() const;
|
||||||
//! Check whether a flag is enabled
|
%Docstring
|
||||||
|
Return OR-ed combination of model flags
|
||||||
|
:rtype: Flags
|
||||||
|
%End
|
||||||
bool testFlag( Flag f ) const;
|
bool testFlag( Flag f ) const;
|
||||||
|
%Docstring
|
||||||
|
Check whether a flag is enabled
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return layer tree node for given index. Returns root node for invalid index.
|
QgsLayerTreeNode *index2node( const QModelIndex &index ) const;
|
||||||
//! Returns null pointer if index does not refer to a layer tree node (e.g. it is a legend node)
|
%Docstring
|
||||||
QgsLayerTreeNode* index2node( const QModelIndex& index ) const;
|
Returns null pointer if index does not refer to a layer tree node (e.g. it is a legend node)
|
||||||
//! Return index for a given node. If the node does not belong to the layer tree, the result is undefined
|
:rtype: QgsLayerTreeNode
|
||||||
QModelIndex node2index( QgsLayerTreeNode* node ) const;
|
%End
|
||||||
//! Convert a list of indexes to a list of layer tree nodes.
|
QModelIndex node2index( QgsLayerTreeNode *node ) const;
|
||||||
//! Indices that do not represent layer tree nodes are skipped.
|
%Docstring
|
||||||
//! @arg skipInternal If true, a node is included in the output list only if no parent node is in the list
|
Return index for a given node. If the node does not belong to the layer tree, the result is undefined
|
||||||
QList<QgsLayerTreeNode*> indexes2nodes( const QModelIndexList& list, bool skipInternal = false ) const;
|
:rtype: QModelIndex
|
||||||
|
%End
|
||||||
|
QList<QgsLayerTreeNode *> indexes2nodes( const QModelIndexList &list, bool skipInternal = false ) const;
|
||||||
|
%Docstring
|
||||||
|
@arg skipInternal If true, a node is included in the output list only if no parent node is in the list
|
||||||
|
:rtype: list of QgsLayerTreeNode
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return legend node for given index. Returns null for invalid index
|
static QgsLayerTreeModelLegendNode *index2legendNode( const QModelIndex &index );
|
||||||
//! @note added in 2.6
|
%Docstring
|
||||||
static QgsLayerTreeModelLegendNode* index2legendNode( const QModelIndex& index );
|
.. versionadded:: 2.6
|
||||||
//! Return index for a given legend node. If the legend node does not belong to the layer tree, the result is undefined.
|
:rtype: QgsLayerTreeModelLegendNode
|
||||||
//! If the legend node is belongs to the tree but it is filtered out, invalid model index is returned.
|
%End
|
||||||
//! @note added in 2.6
|
QModelIndex legendNode2index( QgsLayerTreeModelLegendNode *legendNode );
|
||||||
QModelIndex legendNode2index( QgsLayerTreeModelLegendNode* legendNode );
|
%Docstring
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
:rtype: QModelIndex
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return filtered list of active legend nodes attached to a particular layer node
|
QList<QgsLayerTreeModelLegendNode *> layerLegendNodes( QgsLayerTreeLayer *nodeLayer, bool skipNodeEmbeddedInParent = false );
|
||||||
//! (by default it returns also legend node embedded in parent layer node (if any) unless skipNodeEmbeddedInParent is true)
|
%Docstring
|
||||||
//! @note added in 2.6
|
\see layerOriginalLegendNodes()
|
||||||
//! @note skipNodeEmbeddedInParent added in 2.18
|
:rtype: list of QgsLayerTreeModelLegendNode
|
||||||
//! @see layerOriginalLegendNodes()
|
%End
|
||||||
QList<QgsLayerTreeModelLegendNode*> layerLegendNodes( QgsLayerTreeLayer* nodeLayer, bool skipNodeEmbeddedInParent = false );
|
|
||||||
|
|
||||||
//! Return original (unfiltered) list of legend nodes attached to a particular layer node
|
QList<QgsLayerTreeModelLegendNode *> layerOriginalLegendNodes( QgsLayerTreeLayer *nodeLayer );
|
||||||
//! @note added in 2.14
|
%Docstring
|
||||||
//! @see layerLegendNodes()
|
\see layerLegendNodes()
|
||||||
QList<QgsLayerTreeModelLegendNode*> layerOriginalLegendNodes( QgsLayerTreeLayer* nodeLayer );
|
:rtype: list of QgsLayerTreeModelLegendNode
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return legend node that may be embedded in parent (i.e. its icon will be used for layer's icon).
|
QgsLayerTreeModelLegendNode *legendNodeEmbeddedInParent( QgsLayerTreeLayer *nodeLayer ) const;
|
||||||
//! @note added in 2.18
|
%Docstring
|
||||||
QgsLayerTreeModelLegendNode* legendNodeEmbeddedInParent( QgsLayerTreeLayer* nodeLayer ) const;
|
.. versionadded:: 2.18
|
||||||
|
:rtype: QgsLayerTreeModelLegendNode
|
||||||
|
%End
|
||||||
|
|
||||||
/** Searches through the layer tree to find a legend node with a matching layer ID
|
QgsLayerTreeModelLegendNode *findLegendNode( const QString &layerId, const QString &ruleKey ) const;
|
||||||
* and rule key.
|
%Docstring
|
||||||
* @param layerId map layer ID
|
Searches through the layer tree to find a legend node with a matching layer ID
|
||||||
* @param ruleKey legend node rule key
|
and rule key.
|
||||||
* @returns QgsLayerTreeModelLegendNode if found
|
\param layerId map layer ID
|
||||||
* @note added in QGIS 2.14
|
\param ruleKey legend node rule key
|
||||||
*/
|
:return: QgsLayerTreeModelLegendNode if found
|
||||||
QgsLayerTreeModelLegendNode* findLegendNode( const QString& layerId, const QString& ruleKey ) const;
|
.. versionadded:: 2.14
|
||||||
|
:rtype: QgsLayerTreeModelLegendNode
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return pointer to the root node of the layer tree. Always a non-null pointer.
|
QgsLayerTree *rootGroup() const;
|
||||||
QgsLayerTree* rootGroup() const;
|
%Docstring
|
||||||
//! Reset the model and use a new root group node
|
Return pointer to the root node of the layer tree. Always a non-null pointer.
|
||||||
//! @note added in 2.6
|
:rtype: QgsLayerTree
|
||||||
void setRootGroup( QgsLayerTree* newRootGroup );
|
%End
|
||||||
|
void setRootGroup( QgsLayerTree *newRootGroup );
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
|
|
||||||
//! Force a refresh of legend nodes of a layer node.
|
void refreshLayerLegend( QgsLayerTreeLayer *nodeLayer );
|
||||||
//! Not necessary to call when layer's renderer is changed as the model listens to these events.
|
%Docstring
|
||||||
void refreshLayerLegend( QgsLayerTreeLayer* nodeLayer );
|
Not necessary to call when layer's renderer is changed as the model listens to these events.
|
||||||
|
%End
|
||||||
|
|
||||||
//! Get index of the item marked as current. Item marked as current is underlined.
|
|
||||||
QModelIndex currentIndex() const;
|
QModelIndex currentIndex() const;
|
||||||
//! Set index of the current item. May be used by view. Item marked as current is underlined.
|
%Docstring
|
||||||
void setCurrentIndex( const QModelIndex& currentIndex );
|
Get index of the item marked as current. Item marked as current is underlined.
|
||||||
|
:rtype: QModelIndex
|
||||||
|
%End
|
||||||
|
void setCurrentIndex( const QModelIndex ¤tIndex );
|
||||||
|
%Docstring
|
||||||
|
Set index of the current item. May be used by view. Item marked as current is underlined.
|
||||||
|
%End
|
||||||
|
|
||||||
//! Set font for a particular type of layer tree node. nodeType should come from QgsLayerTreeNode::NodeType enumeration
|
void setLayerTreeNodeFont( int nodeType, const QFont &font );
|
||||||
void setLayerTreeNodeFont( int nodeType, const QFont& font );
|
%Docstring
|
||||||
//! Get font for a particular type of layer tree node. nodeType should come from QgsLayerTreeNode::NodeType enumeration
|
Set font for a particular type of layer tree node. nodeType should come from QgsLayerTreeNode.NodeType enumeration
|
||||||
|
%End
|
||||||
QFont layerTreeNodeFont( int nodeType ) const;
|
QFont layerTreeNodeFont( int nodeType ) const;
|
||||||
|
%Docstring
|
||||||
|
Get font for a particular type of layer tree node. nodeType should come from QgsLayerTreeNode.NodeType enumeration
|
||||||
|
:rtype: QFont
|
||||||
|
%End
|
||||||
|
|
||||||
//! Set at what number of legend nodes the layer node should be collapsed. Setting -1 disables the auto-collapse (default).
|
|
||||||
void setAutoCollapseLegendNodes( int nodeCount );
|
void setAutoCollapseLegendNodes( int nodeCount );
|
||||||
//! Return at what number of legend nodes the layer node should be collapsed. -1 means no auto-collapse (default).
|
%Docstring
|
||||||
|
Set at what number of legend nodes the layer node should be collapsed. Setting -1 disables the auto-collapse (default).
|
||||||
|
%End
|
||||||
int autoCollapseLegendNodes() const;
|
int autoCollapseLegendNodes() const;
|
||||||
|
%Docstring
|
||||||
|
Return at what number of legend nodes the layer node should be collapsed. -1 means no auto-collapse (default).
|
||||||
|
:rtype: int
|
||||||
|
%End
|
||||||
|
|
||||||
//! Force only display of legend nodes which are valid for given scale denominator.
|
|
||||||
//! Setting value <= 0 will disable the functionality
|
|
||||||
//! @note added in 2.6
|
|
||||||
void setLegendFilterByScale( double scaleDenominator );
|
void setLegendFilterByScale( double scaleDenominator );
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
double legendFilterByScale() const;
|
double legendFilterByScale() const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: float
|
||||||
|
%End
|
||||||
|
|
||||||
//! Force only display of legend nodes which are valid for given map settings.
|
void setLegendFilterByMap( const QgsMapSettings *settings );
|
||||||
//! Setting null pointer or invalid map settings will disable the functionality.
|
%Docstring
|
||||||
//! Ownership of map settings pointer does not change.
|
.. versionadded:: 2.6
|
||||||
//! @note added in 2.6
|
%End
|
||||||
void setLegendFilterByMap( const QgsMapSettings* settings );
|
|
||||||
|
|
||||||
//! Filter display of legend nodes for given map settings
|
void setLegendFilter( const QgsMapSettings *settings, bool useExtent = true, const QgsGeometry &polygon = QgsGeometry(), bool useExpressions = true );
|
||||||
//! @param settings Map settings. Setting a null pointer or invalid settings will disable any filter. Ownership is not changed, a copy is made
|
%Docstring
|
||||||
//! @param useExtent Whether to use the extent of the map settings as a first spatial filter on legend nodes
|
.. versionadded:: 2.14
|
||||||
//! @param polygon If not empty, this polygon will be used instead of the map extent to filter legend nodes
|
%End
|
||||||
//! @param useExpressions Whether to use legend node filter expressions
|
|
||||||
//! @note added in 2.14
|
|
||||||
void setLegendFilter( const QgsMapSettings* settings, bool useExtent = true, const QgsGeometry& polygon = QgsGeometry(), bool useExpressions = true );
|
|
||||||
|
|
||||||
//! Returns the current map settings used for the current legend filter (or null if none is enabled)
|
const QgsMapSettings *legendFilterMapSettings() const;
|
||||||
//! @note added in 2.14
|
%Docstring
|
||||||
const QgsMapSettings* legendFilterMapSettings() const;
|
.. versionadded:: 2.14
|
||||||
|
:rtype: QgsMapSettings
|
||||||
|
%End
|
||||||
|
|
||||||
//! Give the layer tree model hints about the currently associated map view
|
|
||||||
//! so that legend nodes that use map units can be scaled currectly
|
|
||||||
//! @note added in 2.6
|
|
||||||
void setLegendMapViewData( double mapUnitsPerPixel, int dpi, double scale );
|
void setLegendMapViewData( double mapUnitsPerPixel, int dpi, double scale );
|
||||||
//! Get hints about map view - to be used in legend nodes. Arguments that are not null will receive values.
|
%Docstring
|
||||||
//! If there are no valid map view data (from previous call to setLegendMapViewData()), returned values are zeros.
|
.. versionadded:: 2.6
|
||||||
//! @note added in 2.6
|
%End
|
||||||
void legendMapViewData( double *mapUnitsPerPixel /Out/, int *dpi /Out/, double *scale /Out/ ) const;
|
void legendMapViewData( double *mapUnitsPerPixel /Out/, int *dpi /Out/, double *scale /Out/ ) const;
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
|
|
||||||
//! Get map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
|
|
||||||
//! @note added in 2.10
|
|
||||||
QMap<QString, QString> layerStyleOverrides() const;
|
QMap<QString, QString> layerStyleOverrides() const;
|
||||||
//! Set map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
|
%Docstring
|
||||||
//! @note added in 2.10
|
.. versionadded:: 2.10
|
||||||
void setLayerStyleOverrides( const QMap<QString, QString>& overrides );
|
:rtype: QMap<str, QString>
|
||||||
|
%End
|
||||||
signals:
|
void setLayerStyleOverrides( const QMap<QString, QString> &overrides );
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 2.10
|
||||||
|
%End
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void nodeWillAddChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
|
void nodeWillAddChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
void nodeAddedChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
|
void nodeAddedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
void nodeWillRemoveChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
|
void nodeWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
void nodeRemovedChildren();
|
void nodeRemovedChildren();
|
||||||
|
|
||||||
void nodeVisibilityChanged( QgsLayerTreeNode* node );
|
void nodeVisibilityChanged( QgsLayerTreeNode *node );
|
||||||
//! Updates model when node's name has changed
|
void nodeNameChanged( QgsLayerTreeNode *node, const QString &name );
|
||||||
//! @note added in 3.0
|
%Docstring
|
||||||
void nodeNameChanged( QgsLayerTreeNode* node, const QString& name );
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
void nodeCustomPropertyChanged( QgsLayerTreeNode* node, const QString& key );
|
void nodeCustomPropertyChanged( QgsLayerTreeNode *node, const QString &key );
|
||||||
|
|
||||||
void nodeLayerLoaded();
|
void nodeLayerLoaded();
|
||||||
void nodeLayerWillBeUnloaded();
|
void nodeLayerWillBeUnloaded();
|
||||||
@ -208,43 +284,105 @@ class QgsLayerTreeModel : QAbstractItemModel
|
|||||||
void invalidateLegendMapBasedData();
|
void invalidateLegendMapBasedData();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void removeLegendFromLayer( QgsLayerTreeLayer* nodeLayer );
|
void removeLegendFromLayer( QgsLayerTreeLayer *nodeLayer );
|
||||||
void addLegendToLayer( QgsLayerTreeLayer* nodeL );
|
void addLegendToLayer( QgsLayerTreeLayer *nodeL );
|
||||||
|
|
||||||
void connectToLayer( QgsLayerTreeLayer* nodeLayer );
|
void connectToLayer( QgsLayerTreeLayer *nodeLayer );
|
||||||
void disconnectFromLayer( QgsLayerTreeLayer* nodeLayer );
|
void disconnectFromLayer( QgsLayerTreeLayer *nodeLayer );
|
||||||
|
|
||||||
void connectToLayers( QgsLayerTreeGroup* parentGroup );
|
void connectToLayers( QgsLayerTreeGroup *parentGroup );
|
||||||
void disconnectFromLayers( QgsLayerTreeGroup* parentGroup );
|
void disconnectFromLayers( QgsLayerTreeGroup *parentGroup );
|
||||||
void connectToRootNode();
|
void connectToRootNode();
|
||||||
void disconnectFromRootNode();
|
void disconnectFromRootNode();
|
||||||
|
|
||||||
//! emit dataChanged() for layer tree node items
|
void recursivelyEmitDataChanged( const QModelIndex &index = QModelIndex() );
|
||||||
void recursivelyEmitDataChanged( const QModelIndex& index = QModelIndex() );
|
%Docstring
|
||||||
|
emit dataChanged() for layer tree node items
|
||||||
|
%End
|
||||||
|
|
||||||
/** Updates layer data for scale dependent layers, should be called when map scale changes.
|
void refreshScaleBasedLayers( const QModelIndex &index = QModelIndex() );
|
||||||
* Emits dataChanged() for all scale dependent layers.
|
%Docstring
|
||||||
* @note added in QGIS 2.16
|
Updates layer data for scale dependent layers, should be called when map scale changes.
|
||||||
*/
|
Emits dataChanged() for all scale dependent layers.
|
||||||
void refreshScaleBasedLayers( const QModelIndex& index = QModelIndex() );
|
.. versionadded:: 2.16
|
||||||
|
%End
|
||||||
|
|
||||||
static QIcon iconGroup();
|
static QIcon iconGroup();
|
||||||
|
%Docstring
|
||||||
|
:rtype: QIcon
|
||||||
|
%End
|
||||||
|
|
||||||
//! Filter nodes from QgsMapLayerLegend according to the current filtering rules
|
QList<QgsLayerTreeModelLegendNode *> filterLegendNodes( const QList<QgsLayerTreeModelLegendNode *> &nodes );
|
||||||
QList<QgsLayerTreeModelLegendNode*> filterLegendNodes( const QList<QgsLayerTreeModelLegendNode*>& nodes );
|
%Docstring
|
||||||
|
Filter nodes from QgsMapLayerLegend according to the current filtering rules
|
||||||
|
:rtype: list of QgsLayerTreeModelLegendNode
|
||||||
|
%End
|
||||||
|
|
||||||
QModelIndex indexOfParentLayerTreeNode( QgsLayerTreeNode* parentNode ) const;
|
QModelIndex indexOfParentLayerTreeNode( QgsLayerTreeNode *parentNode ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: QModelIndex
|
||||||
|
%End
|
||||||
|
|
||||||
int legendRootRowCount( QgsLayerTreeLayer* nL ) const;
|
int legendRootRowCount( QgsLayerTreeLayer *nL ) const;
|
||||||
int legendNodeRowCount( QgsLayerTreeModelLegendNode* node ) const;
|
%Docstring
|
||||||
QModelIndex legendRootIndex( int row, int column, QgsLayerTreeLayer* nL ) const;
|
:rtype: int
|
||||||
QModelIndex legendNodeIndex( int row, int column, QgsLayerTreeModelLegendNode* node ) const;
|
%End
|
||||||
QModelIndex legendParent( QgsLayerTreeModelLegendNode* legendNode ) const;
|
int legendNodeRowCount( QgsLayerTreeModelLegendNode *node ) const;
|
||||||
QVariant legendNodeData( QgsLayerTreeModelLegendNode* node, int role ) const;
|
%Docstring
|
||||||
Qt::ItemFlags legendNodeFlags( QgsLayerTreeModelLegendNode* node ) const;
|
:rtype: int
|
||||||
bool legendEmbeddedInParent( QgsLayerTreeLayer* nodeLayer ) const;
|
%End
|
||||||
QIcon legendIconEmbeddedInParent( QgsLayerTreeLayer* nodeLayer ) const;
|
QModelIndex legendRootIndex( int row, int column, QgsLayerTreeLayer *nL ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: QModelIndex
|
||||||
|
%End
|
||||||
|
QModelIndex legendNodeIndex( int row, int column, QgsLayerTreeModelLegendNode *node ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: QModelIndex
|
||||||
|
%End
|
||||||
|
QModelIndex legendParent( QgsLayerTreeModelLegendNode *legendNode ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: QModelIndex
|
||||||
|
%End
|
||||||
|
QVariant legendNodeData( QgsLayerTreeModelLegendNode *node, int role ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: QVariant
|
||||||
|
%End
|
||||||
|
Qt::ItemFlags legendNodeFlags( QgsLayerTreeModelLegendNode *node ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: Qt.ItemFlags
|
||||||
|
%End
|
||||||
|
bool legendEmbeddedInParent( QgsLayerTreeLayer *nodeLayer ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
QIcon legendIconEmbeddedInParent( QgsLayerTreeLayer *nodeLayer ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: QIcon
|
||||||
|
%End
|
||||||
void legendCleanup();
|
void legendCleanup();
|
||||||
void legendInvalidateMapBasedData();
|
void legendInvalidateMapBasedData();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QFlags<QgsLayerTreeModel::Flag> operator|(QgsLayerTreeModel::Flag f1, QFlags<QgsLayerTreeModel::Flag> f2);
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertreemodel.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
@ -1,63 +1,105 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertreemodellegendnode.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The QgsLegendRendererItem class is abstract interface for legend items
|
|
||||||
* returned from QgsMapLayerLegend implementation.
|
|
||||||
*
|
|
||||||
* The objects are used in QgsLayerTreeModel. Custom implementations may offer additional interactivity
|
|
||||||
* and customized look.
|
|
||||||
*
|
|
||||||
* @note added in 2.6
|
|
||||||
*/
|
|
||||||
class QgsLayerTreeModelLegendNode : QObject
|
class QgsLayerTreeModelLegendNode : QObject
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%Docstring
|
||||||
#include <qgslayertreemodellegendnode.h>
|
The QgsLegendRendererItem class is abstract interface for legend items
|
||||||
|
returned from QgsMapLayerLegend implementation.
|
||||||
|
|
||||||
|
The objects are used in QgsLayerTreeModel. Custom implementations may offer additional interactivity
|
||||||
|
and customized look.
|
||||||
|
|
||||||
|
.. versionadded:: 2.6
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include "qgslayertreemodellegendnode.h"
|
||||||
|
%End
|
||||||
public:
|
public:
|
||||||
~QgsLayerTreeModelLegendNode();
|
|
||||||
|
|
||||||
enum LegendNodeRoles
|
enum LegendNodeRoles
|
||||||
{
|
{
|
||||||
RuleKeyRole, //!< rule key of the node (QString)
|
RuleKeyRole
|
||||||
ParentRuleKeyRole //!< rule key of the parent legend node - for legends with tree hierarchy (QString). Added in 2.8
|
ParentRuleKeyRole
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Return pointer to the parent layer node */
|
QgsLayerTreeLayer *layerNode() const;
|
||||||
QgsLayerTreeLayer* layerNode() const;
|
%Docstring
|
||||||
|
Return pointer to the parent layer node
|
||||||
|
:rtype: QgsLayerTreeLayer
|
||||||
|
%End
|
||||||
|
|
||||||
/** Return pointer to model owning this legend node */
|
QgsLayerTreeModel *model() const;
|
||||||
QgsLayerTreeModel* model() const;
|
%Docstring
|
||||||
|
Return pointer to model owning this legend node
|
||||||
|
:rtype: QgsLayerTreeModel
|
||||||
|
%End
|
||||||
|
|
||||||
/** Return item flags associated with the item. Default implementation returns Qt::ItemIsEnabled. */
|
|
||||||
virtual Qt::ItemFlags flags() const;
|
virtual Qt::ItemFlags flags() const;
|
||||||
|
%Docstring
|
||||||
|
Return item flags associated with the item. Default implementation returns Qt.ItemIsEnabled.
|
||||||
|
:rtype: Qt.ItemFlags
|
||||||
|
%End
|
||||||
|
|
||||||
/** Return data associated with the item. Must be implemented in derived class. */
|
|
||||||
virtual QVariant data( int role ) const = 0;
|
virtual QVariant data( int role ) const = 0;
|
||||||
|
%Docstring
|
||||||
|
Return data associated with the item. Must be implemented in derived class.
|
||||||
|
:rtype: QVariant
|
||||||
|
%End
|
||||||
|
|
||||||
/** Set some data associated with the item. Default implementation does nothing and returns false. */
|
virtual bool setData( const QVariant &value, int role );
|
||||||
virtual bool setData( const QVariant& value, int role );
|
%Docstring
|
||||||
|
Set some data associated with the item. Default implementation does nothing and returns false.
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
virtual bool isEmbeddedInParent() const;
|
virtual bool isEmbeddedInParent() const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
virtual void setEmbeddedInParent( bool embedded );
|
virtual void setEmbeddedInParent( bool embedded );
|
||||||
|
|
||||||
virtual QString userLabel() const;
|
virtual QString userLabel() const;
|
||||||
virtual void setUserLabel( const QString& userLabel );
|
%Docstring
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
virtual void setUserLabel( const QString &userLabel );
|
||||||
|
|
||||||
virtual bool isScaleOK( double scale ) const;
|
virtual bool isScaleOK( double scale ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
/** Notification from model that information from associated map view has changed.
|
|
||||||
* Default implementation does nothing. */
|
|
||||||
virtual void invalidateMapBasedData();
|
virtual void invalidateMapBasedData();
|
||||||
|
%Docstring
|
||||||
|
Notification from model that information from associated map view has changed.
|
||||||
|
Default implementation does nothing. *
|
||||||
|
%End
|
||||||
|
|
||||||
struct ItemContext
|
struct ItemContext
|
||||||
{
|
{
|
||||||
//! Painter
|
QPainter *painter;
|
||||||
QPainter* painter;
|
%Docstring
|
||||||
//! Top-left corner of the legend item
|
Painter
|
||||||
|
%End
|
||||||
QPointF point;
|
QPointF point;
|
||||||
//! offset from the left side where label should start
|
%Docstring
|
||||||
|
Top-left corner of the legend item
|
||||||
|
%End
|
||||||
double labelXOffset;
|
double labelXOffset;
|
||||||
|
%Docstring
|
||||||
|
offset from the left side where label should start
|
||||||
|
%End
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ItemMetrics
|
struct ItemMetrics
|
||||||
@ -66,204 +108,240 @@ class QgsLayerTreeModelLegendNode : QObject
|
|||||||
QSizeF labelSize;
|
QSizeF labelSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Entry point called from QgsLegendRenderer to do the rendering.
|
virtual ItemMetrics draw( const QgsLegendSettings &settings, ItemContext *ctx );
|
||||||
* Default implementation calls drawSymbol() and drawSymbolText() methods.
|
%Docstring
|
||||||
*
|
Entry point called from QgsLegendRenderer to do the rendering.
|
||||||
* If ctx is null, this is just first stage when preparing layout - without actual rendering.
|
Default implementation calls drawSymbol() and drawSymbolText() methods.
|
||||||
*/
|
|
||||||
virtual ItemMetrics draw( const QgsLegendSettings& settings, ItemContext* ctx );
|
|
||||||
|
|
||||||
/**
|
If ctx is null, this is just first stage when preparing layout - without actual rendering.
|
||||||
* Draws symbol on the left side of the item
|
:rtype: ItemMetrics
|
||||||
* @param settings Legend layout configuration
|
%End
|
||||||
* @param ctx Context for rendering - may be null if only doing layout without actual rendering
|
|
||||||
* @param itemHeight Minimal height of the legend item - used for correct positioning when rendering
|
|
||||||
* @return Real size of the symbol (may be bigger than "normal" symbol size from settings)
|
|
||||||
*/
|
|
||||||
virtual QSizeF drawSymbol( const QgsLegendSettings& settings, ItemContext* ctx, double itemHeight ) const;
|
|
||||||
|
|
||||||
/**
|
virtual QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const;
|
||||||
* Draws label on the right side of the item
|
%Docstring
|
||||||
* @param settings Legend layout configuration
|
Draws symbol on the left side of the item
|
||||||
* @param ctx Context for rendering - may be null if only doing layout without actual rendering
|
\param settings Legend layout configuration
|
||||||
* @param symbolSize Real size of the associated symbol - used for correct positioning when rendering
|
\param ctx Context for rendering - may be null if only doing layout without actual rendering
|
||||||
* @return Size of the label (may span multiple lines)
|
\param itemHeight Minimal height of the legend item - used for correct positioning when rendering
|
||||||
*/
|
:return: Real size of the symbol (may be bigger than "normal" symbol size from settings)
|
||||||
virtual QSizeF drawSymbolText( const QgsLegendSettings& settings, ItemContext* ctx, QSizeF symbolSize ) const;
|
:rtype: QSizeF
|
||||||
|
%End
|
||||||
|
|
||||||
|
virtual QSizeF drawSymbolText( const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize ) const;
|
||||||
|
%Docstring
|
||||||
|
Draws label on the right side of the item
|
||||||
|
\param settings Legend layout configuration
|
||||||
|
\param ctx Context for rendering - may be null if only doing layout without actual rendering
|
||||||
|
\param symbolSize Real size of the associated symbol - used for correct positioning when rendering
|
||||||
|
:return: Size of the label (may span multiple lines)
|
||||||
|
:rtype: QSizeF
|
||||||
|
%End
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Emitted on internal data change so the layer tree model can forward the signal to views
|
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
%Docstring
|
||||||
|
Emitted on internal data change so the layer tree model can forward the signal to views
|
||||||
|
%End
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Construct the node with pointer to its parent layer node */
|
explicit QgsLayerTreeModelLegendNode( QgsLayerTreeLayer *nodeL, QObject *parent /TransferThis/ = 0 );
|
||||||
explicit QgsLayerTreeModelLegendNode( QgsLayerTreeLayer* nodeL, QObject* parent /TransferThis/ = 0 );
|
%Docstring
|
||||||
|
Construct the node with pointer to its parent layer node
|
||||||
|
%End
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QgsLayerTreeModelLegendNode(const QgsLayerTreeModelLegendNode &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of legend node interface for displaying preview of vector symbols and their labels
|
|
||||||
* and allowing interaction with the symbol / renderer.
|
|
||||||
*
|
|
||||||
* @note added in 2.6
|
|
||||||
*/
|
|
||||||
class QgsSymbolLegendNode : QgsLayerTreeModelLegendNode
|
class QgsSymbolLegendNode : QgsLayerTreeModelLegendNode
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
Implementation of legend node interface for displaying preview of vector symbols and their labels
|
||||||
|
and allowing interaction with the symbol / renderer.
|
||||||
|
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgslayertreemodellegendnode.h>
|
#include "qgslayertreemodellegendnode.h"
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
QgsSymbolLegendNode( QgsLayerTreeLayer* nodeLayer, const QgsLegendSymbolItem& item, QObject* parent /TransferThis/ = 0 );
|
QgsSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent /TransferThis/ = 0 );
|
||||||
~QgsSymbolLegendNode();
|
|
||||||
|
|
||||||
virtual Qt::ItemFlags flags() const;
|
virtual Qt::ItemFlags flags() const;
|
||||||
virtual QVariant data( int role ) const;
|
virtual QVariant data( int role ) const;
|
||||||
virtual bool setData( const QVariant& value, int role );
|
virtual bool setData( const QVariant &value, int role );
|
||||||
|
|
||||||
|
virtual QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const;
|
||||||
|
|
||||||
QSizeF drawSymbol( const QgsLegendSettings& settings, ItemContext* ctx, double itemHeight ) const;
|
|
||||||
|
|
||||||
virtual void setEmbeddedInParent( bool embedded );
|
virtual void setEmbeddedInParent( bool embedded );
|
||||||
|
|
||||||
void setUserLabel( const QString& userLabel );
|
virtual void setUserLabel( const QString &userLabel );
|
||||||
|
|
||||||
virtual bool isScaleOK( double scale ) const;
|
virtual bool isScaleOK( double scale ) const;
|
||||||
|
|
||||||
virtual void invalidateMapBasedData();
|
virtual void invalidateMapBasedData();
|
||||||
|
|
||||||
//! Set the icon size
|
|
||||||
//! @note added in 2.10
|
|
||||||
void setIconSize( QSize sz );
|
void setIconSize( QSize sz );
|
||||||
//! @note added in 2.10
|
%Docstring
|
||||||
|
.. versionadded:: 2.10
|
||||||
|
%End
|
||||||
QSize iconSize() const;
|
QSize iconSize() const;
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 2.10
|
||||||
|
:rtype: QSize
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the minimum icon size to prevent cropping. When evaluating
|
|
||||||
* the size for multiple icons it is more efficient to create a single
|
|
||||||
* render context in advance and use the variant which accepts a QgsRenderContext
|
|
||||||
* argument.
|
|
||||||
* @note added in 2.10
|
|
||||||
*/
|
|
||||||
QSize minimumIconSize() const;
|
QSize minimumIconSize() const;
|
||||||
|
%Docstring
|
||||||
|
Calculates the minimum icon size to prevent cropping. When evaluating
|
||||||
|
the size for multiple icons it is more efficient to create a single
|
||||||
|
render context in advance and use the variant which accepts a QgsRenderContext
|
||||||
|
argument.
|
||||||
|
.. versionadded:: 2.10
|
||||||
|
:rtype: QSize
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
QSize minimumIconSize( QgsRenderContext *context ) const;
|
||||||
* Calculates the minimum icon size to prevent cropping. When evaluating
|
%Docstring
|
||||||
* the size for multiple icons it is more efficient to create a single
|
Calculates the minimum icon size to prevent cropping. When evaluating
|
||||||
* render context in advance and call this method instead of minimumIconSize().
|
the size for multiple icons it is more efficient to create a single
|
||||||
* @note added in QGIS 2.18
|
render context in advance and call this method instead of minimumIconSize().
|
||||||
*/
|
.. versionadded:: 2.18
|
||||||
QSize minimumIconSize( QgsRenderContext* context ) const;
|
:rtype: QSize
|
||||||
|
%End
|
||||||
|
|
||||||
/** Returns the symbol used by the legend node.
|
const QgsSymbol *symbol() const;
|
||||||
* @see setSymbol()
|
%Docstring
|
||||||
* @note added in QGIS 2.14
|
Returns the symbol used by the legend node.
|
||||||
*/
|
\see setSymbol()
|
||||||
const QgsSymbol* symbol() const;
|
.. versionadded:: 2.14
|
||||||
|
:rtype: QgsSymbol
|
||||||
|
%End
|
||||||
|
|
||||||
/** Sets the symbol to be used by the legend node. The symbol change is also propagated
|
void setSymbol( QgsSymbol *symbol );
|
||||||
* to the associated vector layer's renderer.
|
%Docstring
|
||||||
* @param symbol new symbol for node. Ownership is transferred.
|
Sets the symbol to be used by the legend node. The symbol change is also propagated
|
||||||
* @see symbol()
|
to the associated vector layer's renderer.
|
||||||
* @note added in QGIS 2.14
|
\param symbol new symbol for node. Ownership is transferred.
|
||||||
*/
|
\see symbol()
|
||||||
void setSymbol( QgsSymbol* symbol /Transfer/ );
|
.. versionadded:: 2.14
|
||||||
|
%End
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/** Checks all items belonging to the same layer as this node.
|
|
||||||
* @note added in QGIS 2.14
|
|
||||||
* @see uncheckAllItems()
|
|
||||||
*/
|
|
||||||
void checkAllItems();
|
void checkAllItems();
|
||||||
|
%Docstring
|
||||||
|
Checks all items belonging to the same layer as this node.
|
||||||
|
.. versionadded:: 2.14
|
||||||
|
\see uncheckAllItems()
|
||||||
|
%End
|
||||||
|
|
||||||
/** Unchecks all items belonging to the same layer as this node.
|
|
||||||
* @note added in QGIS 2.14
|
|
||||||
* @see checkAllItems()
|
|
||||||
*/
|
|
||||||
void uncheckAllItems();
|
void uncheckAllItems();
|
||||||
|
%Docstring
|
||||||
|
Unchecks all items belonging to the same layer as this node.
|
||||||
|
.. versionadded:: 2.14
|
||||||
|
\see checkAllItems()
|
||||||
|
%End
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of legend node interface for displaying arbitrary label with icon.
|
|
||||||
*
|
|
||||||
* @note added in 2.6
|
|
||||||
*/
|
|
||||||
class QgsSimpleLegendNode : QgsLayerTreeModelLegendNode
|
class QgsSimpleLegendNode : QgsLayerTreeModelLegendNode
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
Implementation of legend node interface for displaying arbitrary label with icon.
|
||||||
|
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgslayertreemodellegendnode.h>
|
#include "qgslayertreemodellegendnode.h"
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
QgsSimpleLegendNode( QgsLayerTreeLayer* nodeLayer, const QString& label, const QIcon& icon = QIcon(), QObject* parent /TransferThis/ = 0, const QString& key = QString() );
|
QgsSimpleLegendNode( QgsLayerTreeLayer *nodeLayer, const QString &label, const QIcon &icon = QIcon(), QObject *parent /TransferThis/ = 0, const QString &key = QString() );
|
||||||
|
|
||||||
virtual QVariant data( int role ) const;
|
virtual QVariant data( int role ) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of legend node interface for displaying arbitrary raster image
|
|
||||||
*
|
|
||||||
* @note added in 2.6
|
|
||||||
*/
|
|
||||||
class QgsImageLegendNode : QgsLayerTreeModelLegendNode
|
class QgsImageLegendNode : QgsLayerTreeModelLegendNode
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
Implementation of legend node interface for displaying arbitrary raster image
|
||||||
|
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgslayertreemodellegendnode.h>
|
#include "qgslayertreemodellegendnode.h"
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
QgsImageLegendNode( QgsLayerTreeLayer* nodeLayer, const QImage& img, QObject* parent /TransferThis/ = 0 );
|
QgsImageLegendNode( QgsLayerTreeLayer *nodeLayer, const QImage &img, QObject *parent /TransferThis/ = 0 );
|
||||||
|
|
||||||
virtual QVariant data( int role ) const;
|
virtual QVariant data( int role ) const;
|
||||||
|
|
||||||
QSizeF drawSymbol( const QgsLegendSettings& settings, ItemContext* ctx, double itemHeight ) const;
|
virtual QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of legend node interface for displaying raster legend entries
|
|
||||||
*
|
|
||||||
* @note added in 2.6
|
|
||||||
*/
|
|
||||||
class QgsRasterSymbolLegendNode : QgsLayerTreeModelLegendNode
|
class QgsRasterSymbolLegendNode : QgsLayerTreeModelLegendNode
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
Implementation of legend node interface for displaying raster legend entries
|
||||||
|
|
||||||
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgslayertreemodellegendnode.h>
|
#include "qgslayertreemodellegendnode.h"
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
QgsRasterSymbolLegendNode( QgsLayerTreeLayer* nodeLayer, const QColor& color, const QString& label, QObject* parent /TransferThis/ = 0 );
|
QgsRasterSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const QColor &color, const QString &label, QObject *parent /TransferThis/ = 0 );
|
||||||
|
|
||||||
virtual QVariant data( int role ) const;
|
virtual QVariant data( int role ) const;
|
||||||
|
|
||||||
QSizeF drawSymbol( const QgsLegendSettings& settings, ItemContext* ctx, double itemHeight ) const;
|
virtual QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of legend node interface for displaying WMS legend entries
|
|
||||||
*
|
|
||||||
* @note added in 2.8
|
|
||||||
*/
|
|
||||||
class QgsWmsLegendNode : QgsLayerTreeModelLegendNode
|
class QgsWmsLegendNode : QgsLayerTreeModelLegendNode
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
Implementation of legend node interface for displaying WMS legend entries
|
||||||
|
|
||||||
|
.. versionadded:: 2.8
|
||||||
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgslayertreemodellegendnode.h>
|
#include "qgslayertreemodellegendnode.h"
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Constructor for QgsWmsLegendNode.
|
QgsWmsLegendNode( QgsLayerTreeLayer *nodeLayer, QObject *parent /TransferThis/ = 0 );
|
||||||
* @param nodeLayer layer node
|
%Docstring
|
||||||
* @param parent parent object
|
Constructor for QgsWmsLegendNode.
|
||||||
*/
|
\param nodeLayer layer node
|
||||||
QgsWmsLegendNode( QgsLayerTreeLayer* nodeLayer, QObject* parent /TransferThis/ = nullptr );
|
\param parent parent object
|
||||||
|
%End
|
||||||
|
|
||||||
virtual QVariant data( int role ) const;
|
virtual QVariant data( int role ) const;
|
||||||
|
|
||||||
virtual QSizeF drawSymbol( const QgsLegendSettings& settings, ItemContext* ctx, double itemHeight ) const;
|
virtual QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const;
|
||||||
|
|
||||||
virtual void invalidateMapBasedData();
|
virtual void invalidateMapBasedData();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertreemodellegendnode.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
@ -1,194 +1,306 @@
|
|||||||
/**
|
/************************************************************************
|
||||||
* This class is a base class for nodes in a layer tree.
|
* This file has been generated automatically from *
|
||||||
* Layer tree is a hierarchical structure consisting of group and layer nodes:
|
* *
|
||||||
* - group nodes are containers and may contain children (layer and group nodes)
|
* src/core/layertree/qgslayertreenode.h *
|
||||||
* - layer nodes point to map layers, they do not contain further children
|
* *
|
||||||
*
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
* Layer trees may be used for organization of layers, typically a layer tree
|
************************************************************************/
|
||||||
* is exposed to the user using QgsLayerTreeView widget which shows the tree
|
|
||||||
* and allows manipulation with the tree.
|
|
||||||
*
|
|
||||||
* Ownership of nodes: every node is owned by its parent. Therefore once node
|
|
||||||
* is added to a layer tree, it is the responsibility of the parent to delete it
|
|
||||||
* when the node is not needed anymore. Deletion of root node of a tree will
|
|
||||||
* delete all nodes of the tree.
|
|
||||||
*
|
|
||||||
* Signals: signals are propagated from children to parent. That means it is
|
|
||||||
* sufficient to connect to root node in order to get signals about updates
|
|
||||||
* in the whole layer tree. When adding or removing a node that contains further
|
|
||||||
* children (i.e. a whole subtree), the addition/removal signals are emitted
|
|
||||||
* only for the root node of the subtree that is being added or removed.
|
|
||||||
*
|
|
||||||
* Custom properties: Every node may have some custom properties assigned to it.
|
|
||||||
* This mechanism allows third parties store additional data with the nodes.
|
|
||||||
* The properties are used within QGIS code (whether to show layer in overview,
|
|
||||||
* whether the node is embedded from another project etc), but may be also
|
|
||||||
* used by third party plugins. Custom properties are stored also in the project
|
|
||||||
* file. The storage is not efficient for large amount of data.
|
|
||||||
*
|
|
||||||
* Custom properties that have already been used within QGIS:
|
|
||||||
* - "loading" - whether the project is being currently loaded (root node only)
|
|
||||||
* - "overview" - whether to show a layer in overview
|
|
||||||
* - "showFeatureCount" - whether to show feature counts in layer tree (vector only)
|
|
||||||
* - "embedded" - whether the node comes from an external project
|
|
||||||
* - "embedded_project" - path to the external project (embedded root node only)
|
|
||||||
* - "legend/..." - properties for legend appearance customization
|
|
||||||
* - "expandedLegendNodes" - list of layer's legend nodes' rules in expanded state
|
|
||||||
*
|
|
||||||
* @see also QgsLayerTree, QgsLayerTreeLayer, QgsLayerTreeGroup
|
|
||||||
* @note added in 2.4
|
|
||||||
*/
|
|
||||||
class QgsLayerTreeNode : QObject
|
class QgsLayerTreeNode : QObject
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
This class is a base class for nodes in a layer tree.
|
||||||
|
Layer tree is a hierarchical structure consisting of group and layer nodes:
|
||||||
|
- group nodes are containers and may contain children (layer and group nodes)
|
||||||
|
- layer nodes point to map layers, they do not contain further children
|
||||||
|
|
||||||
|
Layer trees may be used for organization of layers, typically a layer tree
|
||||||
|
is exposed to the user using QgsLayerTreeView widget which shows the tree
|
||||||
|
and allows manipulation with the tree.
|
||||||
|
|
||||||
|
Ownership of nodes: every node is owned by its parent. Therefore once node
|
||||||
|
is added to a layer tree, it is the responsibility of the parent to delete it
|
||||||
|
when the node is not needed anymore. Deletion of root node of a tree will
|
||||||
|
delete all nodes of the tree.
|
||||||
|
|
||||||
|
Signals: signals are propagated from children to parent. That means it is
|
||||||
|
sufficient to connect to root node in order to get signals about updates
|
||||||
|
in the whole layer tree. When adding or removing a node that contains further
|
||||||
|
children (i.e. a whole subtree), the addition/removal signals are emitted
|
||||||
|
only for the root node of the subtree that is being added or removed.
|
||||||
|
|
||||||
|
Custom properties: Every node may have some custom properties assigned to it.
|
||||||
|
This mechanism allows third parties store additional data with the nodes.
|
||||||
|
The properties are used within QGIS code (whether to show layer in overview,
|
||||||
|
whether the node is embedded from another project etc), but may be also
|
||||||
|
used by third party plugins. Custom properties are stored also in the project
|
||||||
|
file. The storage is not efficient for large amount of data.
|
||||||
|
|
||||||
|
Custom properties that have already been used within QGIS:
|
||||||
|
- "loading" - whether the project is being currently loaded (root node only)
|
||||||
|
- "overview" - whether to show a layer in overview
|
||||||
|
- "showFeatureCount" - whether to show feature counts in layer tree (vector only)
|
||||||
|
- "embedded" - whether the node comes from an external project
|
||||||
|
- "embedded_project" - path to the external project (embedded root node only)
|
||||||
|
- "legend/..." - properties for legend appearance customization
|
||||||
|
- "expandedLegendNodes" - list of layer's legend nodes' rules in expanded state
|
||||||
|
|
||||||
|
\see also QgsLayerTree, QgsLayerTreeLayer, QgsLayerTreeGroup
|
||||||
|
.. versionadded:: 2.4
|
||||||
|
%End
|
||||||
|
|
||||||
%TypeHeaderCode
|
%TypeHeaderCode
|
||||||
#include <qgslayertree.h>
|
#include "qgslayertreenode.h"
|
||||||
%End
|
%End
|
||||||
|
|
||||||
%ConvertToSubClassCode
|
%ConvertToSubClassCode
|
||||||
if (sipCpp->inherits("QgsLayerTreeNode"))
|
if ( sipCpp->inherits( "QgsLayerTreeNode" ) )
|
||||||
{
|
{
|
||||||
sipType = sipType_QgsLayerTreeNode;
|
sipType = sipType_QgsLayerTreeNode;
|
||||||
QgsLayerTreeNode* node = qobject_cast<QgsLayerTreeNode*>(sipCpp);
|
QgsLayerTreeNode *node = qobject_cast<QgsLayerTreeNode *>( sipCpp );
|
||||||
if (QgsLayerTree::isLayer(node))
|
if ( QgsLayerTree::isLayer( node ) )
|
||||||
sipType = sipType_QgsLayerTreeLayer;
|
sipType = sipType_QgsLayerTreeLayer;
|
||||||
else if (qobject_cast<QgsLayerTree*>(sipCpp))
|
else if ( qobject_cast<QgsLayerTree *>( sipCpp ) )
|
||||||
sipType = sipType_QgsLayerTree;
|
sipType = sipType_QgsLayerTree;
|
||||||
else if (QgsLayerTree::isGroup(node))
|
else if ( QgsLayerTree::isGroup( node ) )
|
||||||
sipType = sipType_QgsLayerTreeGroup;
|
sipType = sipType_QgsLayerTreeGroup;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sipType = 0;
|
sipType = 0;
|
||||||
%End
|
%End
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Enumeration of possible tree node types
|
|
||||||
enum NodeType
|
enum NodeType
|
||||||
{
|
{
|
||||||
NodeGroup, //!< container of other groups and layers
|
NodeGroup,
|
||||||
NodeLayer //!< leaf node pointing to a layer
|
NodeLayer
|
||||||
};
|
};
|
||||||
|
|
||||||
~QgsLayerTreeNode();
|
~QgsLayerTreeNode();
|
||||||
|
|
||||||
//! Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree namespace for that
|
|
||||||
NodeType nodeType() const;
|
NodeType nodeType() const;
|
||||||
//! Get pointer to the parent. If parent is a null pointer, the node is a root node
|
%Docstring
|
||||||
|
Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree namespace for that
|
||||||
|
:rtype: NodeType
|
||||||
|
%End
|
||||||
QgsLayerTreeNode *parent();
|
QgsLayerTreeNode *parent();
|
||||||
//! Get list of children of the node. Children are owned by the parent
|
%Docstring
|
||||||
QList<QgsLayerTreeNode*> children();
|
Get pointer to the parent. If parent is a null pointer, the node is a root node
|
||||||
|
:rtype: QgsLayerTreeNode
|
||||||
|
%End
|
||||||
|
QList<QgsLayerTreeNode *> children();
|
||||||
|
%Docstring
|
||||||
|
Get list of children of the node. Children are owned by the parent
|
||||||
|
:rtype: list of QgsLayerTreeNode
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return name of the node
|
|
||||||
//! @note added in 3.0
|
|
||||||
virtual QString name() const = 0;
|
virtual QString name() const = 0;
|
||||||
//! Set name of the node. Emits nameChanged signal.
|
%Docstring
|
||||||
//! @note added in 3.0
|
.. versionadded:: 3.0
|
||||||
virtual void setName( const QString& name ) = 0;
|
:rtype: str
|
||||||
|
%End
|
||||||
|
virtual void setName( const QString &name ) = 0;
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
//! Read layer tree from XML. Returns new instance.
|
|
||||||
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
|
|
||||||
static QgsLayerTreeNode *readXml( QDomElement &element ) /Factory/;
|
static QgsLayerTreeNode *readXml( QDomElement &element ) /Factory/;
|
||||||
//! Read layer tree from XML. Returns new instance.
|
%Docstring
|
||||||
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
|
Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
|
||||||
//! @note added in 3.0
|
:rtype: QgsLayerTreeNode
|
||||||
static QgsLayerTreeNode* readXml( QDomElement& element, const QgsProject* project ) /Factory/;
|
%End
|
||||||
|
static QgsLayerTreeNode *readXml( QDomElement &element, const QgsProject *project ) /Factory/;
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: QgsLayerTreeNode
|
||||||
|
%End
|
||||||
|
|
||||||
//! Write layer tree to XML
|
|
||||||
virtual void writeXml( QDomElement &parentElement ) = 0;
|
virtual void writeXml( QDomElement &parentElement ) = 0;
|
||||||
|
%Docstring
|
||||||
|
Write layer tree to XML
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return string with layer tree structure. For debug purposes only
|
|
||||||
virtual QString dump() const = 0;
|
virtual QString dump() const = 0;
|
||||||
|
%Docstring
|
||||||
|
Return string with layer tree structure. For debug purposes only
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
//! Create a copy of the node. Returns new instance
|
|
||||||
virtual QgsLayerTreeNode *clone() const = 0 /Factory/;
|
virtual QgsLayerTreeNode *clone() const = 0 /Factory/;
|
||||||
|
%Docstring
|
||||||
|
Create a copy of the node. Returns new instance
|
||||||
|
:rtype: QgsLayerTreeNode
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Turn textual references to layers into map layer object from project.
|
|
||||||
* This method should be called after readXml()
|
|
||||||
* If \a looseMatching is true then a looser match will be used, where a layer
|
|
||||||
* will match if the name, public source, and data provider match. This can be
|
|
||||||
* used to match legend customisation from different projects where layers
|
|
||||||
* will have different layer IDs.
|
|
||||||
* \since QGIS 3.0
|
|
||||||
*/
|
|
||||||
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false ) = 0;
|
virtual void resolveReferences( const QgsProject *project, bool looseMatching = false ) = 0;
|
||||||
|
%Docstring
|
||||||
|
Turn textual references to layers into map layer object from project.
|
||||||
|
This method should be called after readXml()
|
||||||
|
If ``looseMatching`` is true then a looser match will be used, where a layer
|
||||||
|
will match if the name, public source, and data provider match. This can be
|
||||||
|
used to match legend customisation from different projects where layers
|
||||||
|
will have different layer IDs.
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
//! Returns whether a node is really visible (ie checked and all its ancestors checked as well)
|
|
||||||
//! @note added in 3.0
|
|
||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
//! Returns whether a node is checked (independently of its ancestors or children)
|
|
||||||
//! @note added in 3.0
|
|
||||||
bool itemVisibilityChecked() const;
|
bool itemVisibilityChecked() const;
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
//! Check or uncheck a node (independently of its ancestors or children)
|
|
||||||
//! @note added in 3.0
|
|
||||||
void setItemVisibilityChecked( bool checked );
|
void setItemVisibilityChecked( bool checked );
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
//! Check or uncheck a node and all its children (taking into account exclusion rules)
|
|
||||||
//! @note added in 3.0
|
|
||||||
virtual void setItemVisibilityCheckedRecursive( bool checked );
|
virtual void setItemVisibilityCheckedRecursive( bool checked );
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
//! Check or uncheck a node and all its parents
|
|
||||||
//! @note added in 3.0
|
|
||||||
void setItemVisibilityCheckedParentRecursive( bool checked );
|
void setItemVisibilityCheckedParentRecursive( bool checked );
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return whether this node is checked and all its children.
|
|
||||||
//! @note added in 3.0
|
|
||||||
bool isItemVisibilityCheckedRecursive() const;
|
bool isItemVisibilityCheckedRecursive() const;
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return whether this node is unchecked and all its children.
|
|
||||||
//! @note added in 3.0
|
|
||||||
bool isItemVisibilityUncheckedRecursive() const;
|
bool isItemVisibilityUncheckedRecursive() const;
|
||||||
QList< QgsMapLayer * > checkedLayers() const;
|
%Docstring
|
||||||
bool isExpanded() const;
|
.. versionadded:: 3.0
|
||||||
//! Set whether the node should be shown as expanded or collapsed in GUI
|
:rtype: bool
|
||||||
void setExpanded( bool expanded );
|
%End
|
||||||
|
|
||||||
|
QList< QgsMapLayer * > checkedLayers() const;
|
||||||
|
%Docstring
|
||||||
|
Returns a list of any checked layers which belong to this node or its
|
||||||
|
children.
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: list of QgsMapLayer
|
||||||
|
%End
|
||||||
|
|
||||||
|
bool isExpanded() const;
|
||||||
|
%Docstring
|
||||||
|
Return whether the node should be shown as expanded or collapsed in GUI
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
void setExpanded( bool expanded );
|
||||||
|
%Docstring
|
||||||
|
Set whether the node should be shown as expanded or collapsed in GUI
|
||||||
|
%End
|
||||||
|
|
||||||
/** Set a custom property for the node. Properties are stored in a map and saved in project file. */
|
|
||||||
void setCustomProperty( const QString &key, const QVariant &value );
|
void setCustomProperty( const QString &key, const QVariant &value );
|
||||||
/** Read a custom property from layer. Properties are stored in a map and saved in project file. */
|
%Docstring
|
||||||
|
Set a custom property for the node. Properties are stored in a map and saved in project file.
|
||||||
|
%End
|
||||||
QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
|
QVariant customProperty( const QString &key, const QVariant &defaultValue = QVariant() ) const;
|
||||||
/** Remove a custom property from layer. Properties are stored in a map and saved in project file. */
|
%Docstring
|
||||||
|
Read a custom property from layer. Properties are stored in a map and saved in project file.
|
||||||
|
:rtype: QVariant
|
||||||
|
%End
|
||||||
void removeCustomProperty( const QString &key );
|
void removeCustomProperty( const QString &key );
|
||||||
/** Return list of keys stored in custom properties */
|
%Docstring
|
||||||
|
Remove a custom property from layer. Properties are stored in a map and saved in project file.
|
||||||
|
%End
|
||||||
QStringList customProperties() const;
|
QStringList customProperties() const;
|
||||||
/** Remove a child from a node */
|
%Docstring
|
||||||
|
Return list of keys stored in custom properties
|
||||||
|
:rtype: list of str
|
||||||
|
%End
|
||||||
bool takeChild( QgsLayerTreeNode *node );
|
bool takeChild( QgsLayerTreeNode *node );
|
||||||
|
%Docstring
|
||||||
|
Remove a child from a node
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
//! Emitted when one or more nodes will be added to a node within the tree
|
|
||||||
void willAddChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
void willAddChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
//! Emitted when one or more nodes have been added to a node within the tree
|
%Docstring
|
||||||
|
Emitted when one or more nodes will be added to a node within the tree
|
||||||
|
%End
|
||||||
void addedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
void addedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
//! Emitted when one or more nodes will be removed from a node within the tree
|
%Docstring
|
||||||
|
Emitted when one or more nodes have been added to a node within the tree
|
||||||
|
%End
|
||||||
void willRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
void willRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
//! Emitted when one or more nodes has been removed from a node within the tree
|
%Docstring
|
||||||
|
Emitted when one or more nodes will be removed from a node within the tree
|
||||||
|
%End
|
||||||
void removedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
void removedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
//! Emitted when check state of a node within the tree has been changed
|
%Docstring
|
||||||
|
Emitted when one or more nodes has been removed from a node within the tree
|
||||||
|
%End
|
||||||
void visibilityChanged( QgsLayerTreeNode *node );
|
void visibilityChanged( QgsLayerTreeNode *node );
|
||||||
//! Emitted when a custom property of a node within the tree has been changed or removed
|
%Docstring
|
||||||
void customPropertyChanged( QgsLayerTreeNode *node, const QString& key );
|
Emitted when check state of a node within the tree has been changed
|
||||||
//! Emitted when the collapsed/expanded state of a node within the tree has been changed
|
%End
|
||||||
|
void customPropertyChanged( QgsLayerTreeNode *node, const QString &key );
|
||||||
|
%Docstring
|
||||||
|
Emitted when a custom property of a node within the tree has been changed or removed
|
||||||
|
%End
|
||||||
void expandedChanged( QgsLayerTreeNode *node, bool expanded );
|
void expandedChanged( QgsLayerTreeNode *node, bool expanded );
|
||||||
//! Emitted when the name of the node is changed
|
%Docstring
|
||||||
//! @note added in 3.0
|
Emitted when the collapsed/expanded state of a node within the tree has been changed
|
||||||
void nameChanged( QgsLayerTreeNode* node, QString name );
|
%End
|
||||||
|
void nameChanged( QgsLayerTreeNode *node, QString name );
|
||||||
|
%Docstring
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
QgsLayerTreeNode( NodeType t );
|
QgsLayerTreeNode( NodeType t, bool checked = true );
|
||||||
|
%Docstring
|
||||||
|
Constructor
|
||||||
|
%End
|
||||||
|
QgsLayerTreeNode( const QgsLayerTreeNode &other );
|
||||||
|
|
||||||
|
|
||||||
void readCommonXml( QDomElement &element );
|
void readCommonXml( QDomElement &element );
|
||||||
|
%Docstring
|
||||||
|
Read common XML elements.
|
||||||
|
%End
|
||||||
void writeCommonXml( QDomElement &element );
|
void writeCommonXml( QDomElement &element );
|
||||||
|
%Docstring
|
||||||
|
Write common XML elements.
|
||||||
|
%End
|
||||||
|
|
||||||
//! Low-level insertion of children to the node. The children must not have any parent yet!
|
void insertChildrenPrivate( int index, QList<QgsLayerTreeNode *> nodes );
|
||||||
void insertChildrenPrivate( int index, QList<QgsLayerTreeNode*> nodes );
|
%Docstring
|
||||||
//! Low-level removal of children from the node.
|
Low-level insertion of children to the node. The children must not have any parent yet!
|
||||||
|
%End
|
||||||
void removeChildrenPrivate( int from, int count, bool destroy = true );
|
void removeChildrenPrivate( int from, int count, bool destroy = true );
|
||||||
|
%Docstring
|
||||||
|
Low-level removal of children from the node.
|
||||||
|
%End
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QgsLayerTreeNode( const QgsLayerTreeNode& other );
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertreenode.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
@ -1,47 +1,80 @@
|
|||||||
/**
|
/************************************************************************
|
||||||
* Listens to the updates in map layer registry and does changes in layer tree.
|
* This file has been generated automatically from *
|
||||||
*
|
* *
|
||||||
* When connected to a layer tree, any layers added to the map layer registry
|
* src/core/layertree/qgslayertreeregistrybridge.h *
|
||||||
* will be also added to the layer tree. Similarly, map layers that are removed
|
* *
|
||||||
* from registry will be removed from the layer tree.
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
*
|
************************************************************************/
|
||||||
* If a layer is completely removed from the layer tree, it will be also removed
|
|
||||||
* from the map layer registry.
|
|
||||||
*
|
|
||||||
* @note added in 2.4
|
|
||||||
*/
|
|
||||||
|
|
||||||
class QgsLayerTreeRegistryBridge : QObject
|
class QgsLayerTreeRegistryBridge : QObject
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%Docstring
|
||||||
#include <qgslayertreeregistrybridge.h>
|
Listens to the updates in map layer registry and does changes in layer tree.
|
||||||
|
|
||||||
|
When connected to a layer tree, any layers added to the map layer registry
|
||||||
|
will be also added to the layer tree. Similarly, map layers that are removed
|
||||||
|
from registry will be removed from the layer tree.
|
||||||
|
|
||||||
|
If a layer is completely removed from the layer tree, it will be also removed
|
||||||
|
from the map layer registry.
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include "qgslayertreeregistrybridge.h"
|
||||||
|
%End
|
||||||
public:
|
public:
|
||||||
//! Create the instance that synchronizes given project with a layer tree root
|
explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QgsProject *project, QObject *parent /TransferThis/ = 0 );
|
||||||
explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup* root, QgsProject* project, QObject *parent /TransferThis/ = 0 );
|
%Docstring
|
||||||
|
Create the instance that synchronizes given project with a layer tree root
|
||||||
|
%End
|
||||||
|
|
||||||
void setEnabled( bool enabled );
|
void setEnabled( bool enabled );
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
void setNewLayersVisible( bool enabled );
|
void setNewLayersVisible( bool enabled );
|
||||||
bool newLayersVisible() const;
|
bool newLayersVisible() const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
//! Set where the new layers should be inserted - can be used to follow current selection.
|
void setLayerInsertionPoint( QgsLayerTreeGroup *parentGroup, int index );
|
||||||
//! By default it is root group with zero index.
|
%Docstring
|
||||||
void setLayerInsertionPoint( QgsLayerTreeGroup* parentGroup, int index );
|
By default it is root group with zero index.
|
||||||
|
%End
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer)
|
void addedLayersToLayerTree( const QList<QgsMapLayer *> &layers );
|
||||||
//! @note added in 2.6
|
%Docstring
|
||||||
void addedLayersToLayerTree( const QList<QgsMapLayer*>& layers );
|
.. versionadded:: 2.6
|
||||||
|
%End
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void layersAdded( const QList<QgsMapLayer*>& layers );
|
void layersAdded( const QList<QgsMapLayer *> &layers );
|
||||||
void layersWillBeRemoved( const QStringList& layerIds );
|
void layersWillBeRemoved( const QStringList &layerIds );
|
||||||
|
|
||||||
void groupWillRemoveChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo );
|
void groupWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo );
|
||||||
void groupRemovedChildren();
|
void groupRemovedChildren();
|
||||||
|
|
||||||
void removeLayersFromRegistry( const QStringList& layerIds );
|
void removeLayersFromRegistry( const QStringList &layerIds );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertreeregistrybridge.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
@ -1,54 +1,115 @@
|
|||||||
/**
|
/************************************************************************
|
||||||
* Assorted functions for dealing with layer trees.
|
* This file has been generated automatically from *
|
||||||
*
|
* *
|
||||||
* @note added in 2.4
|
* src/core/layertree/qgslayertreeutils.h *
|
||||||
*/
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsLayerTreeUtils
|
class QgsLayerTreeUtils
|
||||||
{
|
{
|
||||||
%TypeHeaderCode
|
%Docstring
|
||||||
#include <qgslayertreeutils.h>
|
Assorted functions for dealing with layer trees.
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include "qgslayertreeutils.h"
|
||||||
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Try to load layer tree from \verbatim <legend> \endverbatim tag from project files from QGIS 2.2 and below
|
static bool readOldLegend( QgsLayerTreeGroup *root, const QDomElement &legendElem );
|
||||||
static bool readOldLegend( QgsLayerTreeGroup* root, const QDomElement& legendElem );
|
%Docstring
|
||||||
//! Try to load custom layer order from \verbatim <legend> \endverbatim tag from project files from QGIS 2.2 and below
|
Try to load layer tree from \verbatim <legend> \endverbatim tag from project files from QGIS 2.2 and below
|
||||||
static bool readOldLegendLayerOrder( const QDomElement& legendElem, bool& hasCustomOrder, QStringList& order );
|
:rtype: bool
|
||||||
//! Return \verbatim <legend> \endverbatim tag used in QGIS 2.2 and below
|
%End
|
||||||
static QDomElement writeOldLegend( QDomDocument& doc, QgsLayerTreeGroup* root, bool hasCustomOrder, const QList<QgsMapLayer *> &order );
|
static bool readOldLegendLayerOrder( const QDomElement &legendElem, bool &hasCustomOrder, QStringList &order );
|
||||||
|
%Docstring
|
||||||
|
Try to load custom layer order from \verbatim <legend> \endverbatim tag from project files from QGIS 2.2 and below
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
static QDomElement writeOldLegend( QDomDocument &doc, QgsLayerTreeGroup *root, bool hasCustomOrder, const QList<QgsMapLayer *> &order );
|
||||||
|
%Docstring
|
||||||
|
Return \verbatim <legend> \endverbatim tag used in QGIS 2.2 and below
|
||||||
|
:rtype: QDomElement
|
||||||
|
%End
|
||||||
|
|
||||||
//! Convert Qt::CheckState to QString
|
|
||||||
static QString checkStateToXml( Qt::CheckState state );
|
static QString checkStateToXml( Qt::CheckState state );
|
||||||
//! Convert QString to Qt::CheckState
|
%Docstring
|
||||||
static Qt::CheckState checkStateFromXml( const QString& txt );
|
Convert Qt.CheckState to QString
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
static Qt::CheckState checkStateFromXml( const QString &txt );
|
||||||
|
%Docstring
|
||||||
|
Convert QString to Qt.CheckState
|
||||||
|
:rtype: Qt.CheckState
|
||||||
|
%End
|
||||||
|
|
||||||
//! Return true if any of the layers is editable
|
static bool layersEditable( const QList<QgsLayerTreeLayer *> &layerNodes );
|
||||||
static bool layersEditable( const QList<QgsLayerTreeLayer*>& layerNodes );
|
%Docstring
|
||||||
//! Return true if any of the layers is modified
|
Return true if any of the layers is editable
|
||||||
static bool layersModified( const QList<QgsLayerTreeLayer*>& layerNodes );
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
static bool layersModified( const QList<QgsLayerTreeLayer *> &layerNodes );
|
||||||
|
%Docstring
|
||||||
|
Return true if any of the layers is modified
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
//! Remove layer nodes that refer to invalid layers
|
static void removeInvalidLayers( QgsLayerTreeGroup *group );
|
||||||
static void removeInvalidLayers( QgsLayerTreeGroup* group );
|
%Docstring
|
||||||
|
Remove layer nodes that refer to invalid layers
|
||||||
|
%End
|
||||||
|
|
||||||
//! Remove subtree of embedded groups and replaces it with a custom property embedded-visible-layers
|
static void replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup *group );
|
||||||
static void replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup* group );
|
%Docstring
|
||||||
|
Remove subtree of embedded groups and replaces it with a custom property embedded-visible-layers
|
||||||
|
%End
|
||||||
|
|
||||||
|
static void updateEmbeddedGroupsProjectPath( QgsLayerTreeGroup *group, const QgsProject *project );
|
||||||
|
%Docstring
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
not available in Python bindings
|
||||||
|
%End
|
||||||
|
|
||||||
//! get invisible layers
|
|
||||||
static QStringList invisibleLayerList( QgsLayerTreeNode *node );
|
static QStringList invisibleLayerList( QgsLayerTreeNode *node );
|
||||||
|
%Docstring
|
||||||
|
get invisible layers
|
||||||
|
:rtype: list of str
|
||||||
|
%End
|
||||||
|
|
||||||
//! Set the expression filter of a legend layer
|
static void setLegendFilterByExpression( QgsLayerTreeLayer &layer, const QString &expr, bool enabled = true );
|
||||||
static void setLegendFilterByExpression( QgsLayerTreeLayer& layer, const QString& expr, bool enabled = true );
|
%Docstring
|
||||||
//! Return the expression filter of a legend layer
|
Set the expression filter of a legend layer
|
||||||
static QString legendFilterByExpression( const QgsLayerTreeLayer& layer, bool* enabled = 0 );
|
%End
|
||||||
//! Test if one of the layers in a group has an expression filter
|
static QString legendFilterByExpression( const QgsLayerTreeLayer &layer, bool *enabled = 0 );
|
||||||
static bool hasLegendFilterExpression( const QgsLayerTreeGroup& group );
|
%Docstring
|
||||||
|
Return the expression filter of a legend layer
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
static bool hasLegendFilterExpression( const QgsLayerTreeGroup &group );
|
||||||
|
%Docstring
|
||||||
|
Test if one of the layers in a group has an expression filter
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
//! Insert a QgsMapLayer just below another one
|
static QgsLayerTreeLayer *insertLayerBelow( QgsLayerTreeGroup *group, const QgsMapLayer *refLayer, QgsMapLayer *layerToInsert );
|
||||||
//! @param group the tree group where layers are (can be the root group)
|
%Docstring
|
||||||
//! @param refLayer the reference layer
|
:return: the new tree layer
|
||||||
//! @param layerToInsert the new layer to insert just below the reference layer
|
:rtype: QgsLayerTreeLayer
|
||||||
//! @returns the new tree layer
|
%End
|
||||||
static QgsLayerTreeLayer* insertLayerBelow( QgsLayerTreeGroup* group, const QgsMapLayer* refLayer, QgsMapLayer* layerToInsert );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/layertree/qgslayertreeutils.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
@ -25,6 +25,8 @@ fi
|
|||||||
|
|
||||||
pushd ${DIR} > /dev/null
|
pushd ${DIR} > /dev/null
|
||||||
|
|
||||||
|
count=0
|
||||||
|
|
||||||
while read -r sipfile; do
|
while read -r sipfile; do
|
||||||
if ! grep -Fxq "$sipfile" python/auto_sip.blacklist; then
|
if ! grep -Fxq "$sipfile" python/auto_sip.blacklist; then
|
||||||
echo "$sipfile"
|
echo "$sipfile"
|
||||||
@ -34,6 +36,7 @@ while read -r sipfile; do
|
|||||||
else
|
else
|
||||||
./scripts/sipify.pl $header > python/$sipfile
|
./scripts/sipify.pl $header > python/$sipfile
|
||||||
fi
|
fi
|
||||||
|
count=$((count+1))
|
||||||
fi
|
fi
|
||||||
done < <(
|
done < <(
|
||||||
${GP}sed -n -r 's/^%Include (.*\.sip)/core\/\1/p' python/core/core.sip
|
${GP}sed -n -r 's/^%Include (.*\.sip)/core\/\1/p' python/core/core.sip
|
||||||
@ -41,4 +44,6 @@ ${GP}sed -n -r 's/^%Include (.*\.sip)/gui\/\1/p' python/gui/gui.sip
|
|||||||
${GP}sed -n -r 's/^%Include (.*\.sip)/analysis\/\1/p' python/analysis/analysis.sip
|
${GP}sed -n -r 's/^%Include (.*\.sip)/analysis\/\1/p' python/analysis/analysis.sip
|
||||||
)
|
)
|
||||||
|
|
||||||
|
echo " => $count files sipified!"
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
@ -60,7 +60,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup
|
|||||||
* \since QGIS 2.4
|
* \since QGIS 2.4
|
||||||
* \note Not available in Python bindings, because cast is automatic.
|
* \note Not available in Python bindings, because cast is automatic.
|
||||||
*/
|
*/
|
||||||
static inline QgsLayerTreeGroup *toGroup( QgsLayerTreeNode *node )
|
static inline QgsLayerTreeGroup *toGroup( QgsLayerTreeNode *node ) SIP_SKIP
|
||||||
{
|
{
|
||||||
return static_cast<QgsLayerTreeGroup *>( node );
|
return static_cast<QgsLayerTreeGroup *>( node );
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup
|
|||||||
* \since QGIS 2.4
|
* \since QGIS 2.4
|
||||||
* \note Not available in Python bindings, because cast is automatic.
|
* \note Not available in Python bindings, because cast is automatic.
|
||||||
*/
|
*/
|
||||||
static inline QgsLayerTreeLayer *toLayer( QgsLayerTreeNode *node )
|
static inline QgsLayerTreeLayer *toLayer( QgsLayerTreeNode *node ) SIP_SKIP
|
||||||
{
|
{
|
||||||
return static_cast<QgsLayerTreeLayer *>( node );
|
return static_cast<QgsLayerTreeLayer *>( node );
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup
|
|||||||
* \since QGIS 2.4
|
* \since QGIS 2.4
|
||||||
* \note Not available in Python bindings, because cast is automatic.
|
* \note Not available in Python bindings, because cast is automatic.
|
||||||
*/
|
*/
|
||||||
static inline const QgsLayerTreeLayer *toLayer( const QgsLayerTreeNode *node )
|
static inline const QgsLayerTreeLayer *toLayer( const QgsLayerTreeNode *node ) SIP_SKIP
|
||||||
{
|
{
|
||||||
return static_cast< const QgsLayerTreeLayer *>( node );
|
return static_cast< const QgsLayerTreeLayer *>( node );
|
||||||
}
|
}
|
||||||
@ -92,11 +92,6 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup
|
|||||||
*/
|
*/
|
||||||
QgsLayerTree();
|
QgsLayerTree();
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy constructor
|
|
||||||
*/
|
|
||||||
QgsLayerTree( const QgsLayerTree &other );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The order in which layers will be rendered on the canvas.
|
* The order in which layers will be rendered on the canvas.
|
||||||
* Will only be used if the property hasCustomLayerOrder is true.
|
* Will only be used if the property hasCustomLayerOrder is true.
|
||||||
@ -134,7 +129,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup
|
|||||||
*
|
*
|
||||||
* \since QGIS 3.0
|
* \since QGIS 3.0
|
||||||
*/
|
*/
|
||||||
void setCustomLayerOrder( const QStringList &customLayerOrder );
|
void setCustomLayerOrder( const QStringList &customLayerOrder ) SIP_PYNAME( setCustomLayerOrderByIds );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The order in which layers will be rendered on the canvas.
|
* The order in which layers will be rendered on the canvas.
|
||||||
@ -227,6 +222,8 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup
|
|||||||
void nodeRemovedChildren();
|
void nodeRemovedChildren();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Copy constructor \see clone()
|
||||||
|
QgsLayerTree( const QgsLayerTree &other );
|
||||||
void addMissingLayers();
|
void addMissingLayers();
|
||||||
QgsWeakMapLayerPointerList mCustomLayerOrder;
|
QgsWeakMapLayerPointerList mCustomLayerOrder;
|
||||||
bool mHasCustomLayerOrder = false;
|
bool mHasCustomLayerOrder = false;
|
||||||
|
@ -53,11 +53,21 @@ class QgsLayerTree;
|
|||||||
*/
|
*/
|
||||||
class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
|
class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef SIP_RUN
|
||||||
|
SIP_CONVERT_TO_SUBCLASS_CODE
|
||||||
|
if ( sipCpp->inherits( "QgsLayerTreeModel" ) )
|
||||||
|
sipType = sipType_QgsLayerTreeModel;
|
||||||
|
else
|
||||||
|
sipType = 0;
|
||||||
|
SIP_END
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Construct a new tree model with given layer tree (root node must not be null pointer).
|
//! Construct a new tree model with given layer tree (root node must not be null pointer).
|
||||||
//! The root node is not transferred by the model.
|
//! The root node is not transferred by the model.
|
||||||
explicit QgsLayerTreeModel( QgsLayerTree *rootNode, QObject *parent = nullptr );
|
explicit QgsLayerTreeModel( QgsLayerTree *rootNode, QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||||
|
|
||||||
~QgsLayerTreeModel();
|
~QgsLayerTreeModel();
|
||||||
|
|
||||||
@ -204,7 +214,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
|
|||||||
//! Get hints about map view - to be used in legend nodes. Arguments that are not null will receive values.
|
//! Get hints about map view - to be used in legend nodes. Arguments that are not null will receive values.
|
||||||
//! If there are no valid map view data (from previous call to setLegendMapViewData()), returned values are zeros.
|
//! If there are no valid map view data (from previous call to setLegendMapViewData()), returned values are zeros.
|
||||||
//! \since QGIS 2.6
|
//! \since QGIS 2.6
|
||||||
void legendMapViewData( double *mapUnitsPerPixel, int *dpi, double *scale ) const;
|
void legendMapViewData( double *mapUnitsPerPixel SIP_OUT, int *dpi SIP_OUT, double *scale SIP_OUT ) const;
|
||||||
|
|
||||||
//! Get map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
|
//! Get map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
|
||||||
//! \since QGIS 2.10
|
//! \since QGIS 2.10
|
||||||
@ -292,6 +302,7 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
|
|||||||
//! 2. some legend nodes have non-null parent rule key (accessible via data(ParentRuleKeyRole) method)
|
//! 2. some legend nodes have non-null parent rule key (accessible via data(ParentRuleKeyRole) method)
|
||||||
//! The tree structure (parents and children of each node) is extracted by analyzing nodes' parent rules.
|
//! The tree structure (parents and children of each node) is extracted by analyzing nodes' parent rules.
|
||||||
//! \note not available in Python bindings
|
//! \note not available in Python bindings
|
||||||
|
#ifndef SIP_RUN
|
||||||
struct LayerLegendTree
|
struct LayerLegendTree
|
||||||
{
|
{
|
||||||
//! Pointer to parent for each active node. Top-level nodes have null parent. Pointers are not owned.
|
//! Pointer to parent for each active node. Top-level nodes have null parent. Pointers are not owned.
|
||||||
@ -299,9 +310,11 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
|
|||||||
//! List of children for each active node. Top-level nodes are under null pointer key. Pointers are not owned.
|
//! List of children for each active node. Top-level nodes are under null pointer key. Pointers are not owned.
|
||||||
QMap<QgsLayerTreeModelLegendNode *, QList<QgsLayerTreeModelLegendNode *> > children;
|
QMap<QgsLayerTreeModelLegendNode *, QList<QgsLayerTreeModelLegendNode *> > children;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
//! Structure that stores all data associated with one map layer
|
//! Structure that stores all data associated with one map layer
|
||||||
//! \note not available in Python bindings
|
//! \note not available in Python bindings
|
||||||
|
#ifndef SIP_RUN
|
||||||
struct LayerLegendData
|
struct LayerLegendData
|
||||||
{
|
{
|
||||||
LayerLegendData()
|
LayerLegendData()
|
||||||
@ -323,9 +336,10 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel
|
|||||||
//! Optional pointer to a tree structure - see LayerLegendTree for details
|
//! Optional pointer to a tree structure - see LayerLegendTree for details
|
||||||
LayerLegendTree *tree = nullptr;
|
LayerLegendTree *tree = nullptr;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
//! \note not available in Python bindings
|
//! \note not available in Python bindings
|
||||||
LayerLegendTree *tryBuildLegendTree( const QList<QgsLayerTreeModelLegendNode *> &nodes );
|
LayerLegendTree *tryBuildLegendTree( const QList<QgsLayerTreeModelLegendNode *> &nodes ) SIP_SKIP;
|
||||||
|
|
||||||
//! Overrides of map layers' styles: key = layer ID, value = style XML.
|
//! Overrides of map layers' styles: key = layer ID, value = style XML.
|
||||||
//! This allows to show legend that is different from the current style of layers
|
//! This allows to show legend that is different from the current style of layers
|
||||||
|
@ -19,10 +19,13 @@
|
|||||||
#ifndef QGSLAYERTREEMODELLEGENDNODE_H
|
#ifndef QGSLAYERTREEMODELLEGENDNODE_H
|
||||||
#define QGSLAYERTREEMODELLEGENDNODE_H
|
#define QGSLAYERTREEMODELLEGENDNODE_H
|
||||||
|
|
||||||
#include "qgis_core.h"
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
#include "qgis_core.h"
|
||||||
|
#include "qgis.h"
|
||||||
|
|
||||||
#include "qgsrasterdataprovider.h" // for QgsImageFetcher dtor visibility
|
#include "qgsrasterdataprovider.h" // for QgsImageFetcher dtor visibility
|
||||||
|
|
||||||
class QgsLayerTreeLayer;
|
class QgsLayerTreeLayer;
|
||||||
@ -126,7 +129,7 @@ class CORE_EXPORT QgsLayerTreeModelLegendNode : public QObject
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Construct the node with pointer to its parent layer node
|
//! Construct the node with pointer to its parent layer node
|
||||||
explicit QgsLayerTreeModelLegendNode( QgsLayerTreeLayer *nodeL, QObject *parent = nullptr );
|
explicit QgsLayerTreeModelLegendNode( QgsLayerTreeLayer *nodeL, QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QgsLayerTreeLayer *mLayerNode = nullptr;
|
QgsLayerTreeLayer *mLayerNode = nullptr;
|
||||||
@ -147,7 +150,7 @@ class CORE_EXPORT QgsSymbolLegendNode : public QgsLayerTreeModelLegendNode
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QgsSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent = nullptr );
|
QgsSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||||
|
|
||||||
virtual Qt::ItemFlags flags() const override;
|
virtual Qt::ItemFlags flags() const override;
|
||||||
virtual QVariant data( int role ) const override;
|
virtual QVariant data( int role ) const override;
|
||||||
@ -247,7 +250,7 @@ class CORE_EXPORT QgsSimpleLegendNode : public QgsLayerTreeModelLegendNode
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QgsSimpleLegendNode( QgsLayerTreeLayer *nodeLayer, const QString &label, const QIcon &icon = QIcon(), QObject *parent = nullptr, const QString &key = QString() );
|
QgsSimpleLegendNode( QgsLayerTreeLayer *nodeLayer, const QString &label, const QIcon &icon = QIcon(), QObject *parent SIP_TRANSFERTHIS = nullptr, const QString &key = QString() );
|
||||||
|
|
||||||
virtual QVariant data( int role ) const override;
|
virtual QVariant data( int role ) const override;
|
||||||
|
|
||||||
@ -269,7 +272,7 @@ class CORE_EXPORT QgsImageLegendNode : public QgsLayerTreeModelLegendNode
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QgsImageLegendNode( QgsLayerTreeLayer *nodeLayer, const QImage &img, QObject *parent = nullptr );
|
QgsImageLegendNode( QgsLayerTreeLayer *nodeLayer, const QImage &img, QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||||
|
|
||||||
virtual QVariant data( int role ) const override;
|
virtual QVariant data( int role ) const override;
|
||||||
|
|
||||||
@ -289,7 +292,7 @@ class CORE_EXPORT QgsRasterSymbolLegendNode : public QgsLayerTreeModelLegendNode
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QgsRasterSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const QColor &color, const QString &label, QObject *parent = nullptr );
|
QgsRasterSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const QColor &color, const QString &label, QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||||
|
|
||||||
virtual QVariant data( int role ) const override;
|
virtual QVariant data( int role ) const override;
|
||||||
|
|
||||||
@ -317,7 +320,7 @@ class CORE_EXPORT QgsWmsLegendNode : public QgsLayerTreeModelLegendNode
|
|||||||
* \param nodeLayer layer node
|
* \param nodeLayer layer node
|
||||||
* \param parent parent object
|
* \param parent parent object
|
||||||
*/
|
*/
|
||||||
QgsWmsLegendNode( QgsLayerTreeLayer *nodeLayer, QObject *parent = nullptr );
|
QgsWmsLegendNode( QgsLayerTreeLayer *nodeLayer, QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||||
|
|
||||||
virtual QVariant data( int role ) const override;
|
virtual QVariant data( int role ) const override;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "qgsobjectcustomproperties.h"
|
#include "qgsobjectcustomproperties.h"
|
||||||
|
#include "qgis.h"
|
||||||
|
|
||||||
class QDomElement;
|
class QDomElement;
|
||||||
|
|
||||||
@ -69,6 +70,25 @@ class QgsMapLayer;
|
|||||||
class CORE_EXPORT QgsLayerTreeNode : public QObject
|
class CORE_EXPORT QgsLayerTreeNode : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
#ifdef SIP_RUN
|
||||||
|
SIP_CONVERT_TO_SUBCLASS_CODE
|
||||||
|
if ( sipCpp->inherits( "QgsLayerTreeNode" ) )
|
||||||
|
{
|
||||||
|
sipType = sipType_QgsLayerTreeNode;
|
||||||
|
QgsLayerTreeNode *node = qobject_cast<QgsLayerTreeNode *>( sipCpp );
|
||||||
|
if ( QgsLayerTree::isLayer( node ) )
|
||||||
|
sipType = sipType_QgsLayerTreeLayer;
|
||||||
|
else if ( qobject_cast<QgsLayerTree *>( sipCpp ) )
|
||||||
|
sipType = sipType_QgsLayerTree;
|
||||||
|
else if ( QgsLayerTree::isGroup( node ) )
|
||||||
|
sipType = sipType_QgsLayerTreeGroup;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sipType = 0;
|
||||||
|
SIP_END
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Enumeration of possible tree node types
|
//! Enumeration of possible tree node types
|
||||||
@ -87,7 +107,7 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject
|
|||||||
//! Get list of children of the node. Children are owned by the parent
|
//! Get list of children of the node. Children are owned by the parent
|
||||||
QList<QgsLayerTreeNode *> children() { return mChildren; }
|
QList<QgsLayerTreeNode *> children() { return mChildren; }
|
||||||
//! Get list of children of the node. Children are owned by the parent
|
//! Get list of children of the node. Children are owned by the parent
|
||||||
QList<QgsLayerTreeNode *> children() const { return mChildren; }
|
QList<QgsLayerTreeNode *> children() const { return mChildren; } SIP_SKIP
|
||||||
|
|
||||||
//! Return name of the node
|
//! Return name of the node
|
||||||
//! \since QGIS 3.0
|
//! \since QGIS 3.0
|
||||||
@ -98,11 +118,11 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject
|
|||||||
|
|
||||||
//! Read layer tree from XML. Returns new instance.
|
//! Read layer tree from XML. Returns new instance.
|
||||||
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
|
//! Does not resolve textual references to layers. Call resolveReferences() afterwards to do it.
|
||||||
static QgsLayerTreeNode *readXml( QDomElement &element );
|
static QgsLayerTreeNode *readXml( QDomElement &element ) SIP_FACTORY;
|
||||||
//! Read layer tree from XML. Returns new instance.
|
//! Read layer tree from XML. Returns new instance.
|
||||||
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
|
//! Also resolves textual references to layers from the project (calls resolveReferences() internally).
|
||||||
//! \since QGIS 3.0
|
//! \since QGIS 3.0
|
||||||
static QgsLayerTreeNode *readXml( QDomElement &element, const QgsProject *project );
|
static QgsLayerTreeNode *readXml( QDomElement &element, const QgsProject *project ) SIP_FACTORY;
|
||||||
|
|
||||||
//! Write layer tree to XML
|
//! Write layer tree to XML
|
||||||
virtual void writeXml( QDomElement &parentElement ) = 0;
|
virtual void writeXml( QDomElement &parentElement ) = 0;
|
||||||
@ -111,7 +131,7 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject
|
|||||||
virtual QString dump() const = 0;
|
virtual QString dump() const = 0;
|
||||||
|
|
||||||
//! Create a copy of the node. Returns new instance
|
//! Create a copy of the node. Returns new instance
|
||||||
virtual QgsLayerTreeNode *clone() const = 0;
|
virtual QgsLayerTreeNode *clone() const = 0 SIP_FACTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn textual references to layers into map layer object from project.
|
* Turn textual references to layers into map layer object from project.
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "qgis_core.h"
|
#include "qgis_core.h"
|
||||||
|
#include "qgis.h"
|
||||||
|
|
||||||
class QgsLayerTreeGroup;
|
class QgsLayerTreeGroup;
|
||||||
class QgsLayerTreeNode;
|
class QgsLayerTreeNode;
|
||||||
@ -44,7 +45,7 @@ class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
//! Create the instance that synchronizes given project with a layer tree root
|
//! Create the instance that synchronizes given project with a layer tree root
|
||||||
explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QgsProject *project, QObject *parent = nullptr );
|
explicit QgsLayerTreeRegistryBridge( QgsLayerTreeGroup *root, QgsProject *project, QObject *parent SIP_TRANSFERTHIS = nullptr );
|
||||||
|
|
||||||
void setEnabled( bool enabled ) { mEnabled = enabled; }
|
void setEnabled( bool enabled ) { mEnabled = enabled; }
|
||||||
bool isEnabled() const { return mEnabled; }
|
bool isEnabled() const { return mEnabled; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user