From 157709129eb7b4852ffb0e301e9b7e4a34f947cf Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Mon, 24 Apr 2017 15:52:13 +0200 Subject: [PATCH] sipify layer tree classes --- python/auto_sip.blacklist | 6 - python/core/layertree/qgslayertree.sip | 179 ++++++- python/core/layertree/qgslayertreemodel.sip | 480 +++++++++++------- .../layertree/qgslayertreemodellegendnode.sip | 360 ++++++++----- python/core/layertree/qgslayertreenode.sip | 364 ++++++++----- .../layertree/qgslayertreeregistrybridge.sip | 85 +++- python/core/layertree/qgslayertreeutils.sip | 135 +++-- scripts/sipify_all.sh | 5 + src/core/layertree/qgslayertree.h | 15 +- src/core/layertree/qgslayertreemodel.h | 20 +- .../layertree/qgslayertreemodellegendnode.h | 17 +- src/core/layertree/qgslayertreenode.h | 28 +- .../layertree/qgslayertreeregistrybridge.h | 3 +- 13 files changed, 1140 insertions(+), 557 deletions(-) diff --git a/python/auto_sip.blacklist b/python/auto_sip.blacklist index 75fc4b1cc99..e8a681f92ed 100644 --- a/python/auto_sip.blacklist +++ b/python/auto_sip.blacklist @@ -200,12 +200,6 @@ core/fieldformatter/qgslistfieldformatter.sip core/fieldformatter/qgsrelationreferencefieldformatter.sip core/fieldformatter/qgsvaluemapfieldformatter.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/qgsbrightnesscontrastfilter.sip core/raster/qgscliptominmaxenhancement.sip diff --git a/python/core/layertree/qgslayertree.sip b/python/core/layertree/qgslayertree.sip index 839591dbfe7..aad5cae1650 100644 --- a/python/core/layertree/qgslayertree.sip +++ b/python/core/layertree/qgslayertree.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 { -%TypeHeaderCode -#include +%Docstring + 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 +%TypeHeaderCode +#include "qgslayertree.h" +%End public: + 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 ); +%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. - // PYTHON: automatic cast - //inline QgsLayerTreeGroup* toGroup( QgsLayerTreeNode* node ); +.. versionadded:: 2.4 + :rtype: bool +%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 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 &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/; +%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 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; +%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 ); +%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 ); +%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 ); +%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 QgsLayerTree *clone() const; - - - - - void clear(); +%Docstring + Clear any information from this layer tree. + +.. versionadded:: 3.0 +%End signals: - - - - void customLayerOrderChanged(); +%Docstring + Emitted when the custom layer order has changed. - - - - +.. versionadded:: 3.0 +%End void layerOrderChanged(); +%Docstring + Emitted when the layer order has changed. + +.. versionadded:: 3.0 +%End + 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 * + ************************************************************************/ diff --git a/python/core/layertree/qgslayertreemodel.sip b/python/core/layertree/qgslayertreemodel.sip index e6c5fc90204..7402cdb1fe6 100644 --- a/python/core/layertree/qgslayertreemodel.sip +++ b/python/core/layertree/qgslayertreemodel.sip @@ -1,201 +1,277 @@ -/** - * 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 - * @note added in 2.4 - */ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/layertree/qgslayertreemodel.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + + 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 -#include +#include "qgslayertreemodel.h" %End %ConvertToSubClassCode - if (sipCpp->inherits("QgsLayerTreeModel")) - sipType = sipType_QgsLayerTreeModel; - else - sipType = 0; + if ( sipCpp->inherits( "QgsLayerTreeModel" ) ) + sipType = sipType_QgsLayerTreeModel; + else + sipType = 0; +%End + public: + explicit QgsLayerTreeModel( QgsLayerTree *rootNode, QObject *parent /TransferThis/ = 0 ); +%Docstring +The root node is not transferred by the model. %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(); - // Implementation of virtual functions from QAbstractItemModel - 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; - QModelIndex parent( const QModelIndex &child ) const; - QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; - Qt::ItemFlags flags( const QModelIndex &index ) const; - bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ); - Qt::DropActions supportedDropActions() const; - QStringList mimeTypes() const; - QMimeData* mimeData( const QModelIndexList& indexes ) const; - bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ); - bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() ); + virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; + +%Docstring +Implementation of virtual functions from QAbstractItemModel + :rtype: int +%End + virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; + + virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const; + + virtual QModelIndex parent( const QModelIndex &child ) const; + + 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 { - // display flags - ShowLegend, //!< Add legend nodes for layer nodes - ShowRasterPreviewIcon, //!< Will use real preview of raster layer as icon (may be slow) - ShowLegendAsTree, //!< For legends that support it, will show them in a tree instead of a list (needs also ShowLegend). Added in 2.8 - DeferredLegendInvalidation, //!< defer legend model invalidation + // display + ShowLegend, + ShowRasterPreviewIcon, + ShowLegendAsTree, + DeferredLegendInvalidation, + UseEmbeddedWidgets, - // behavioral flags - AllowNodeReorder, //!< Allow reordering with drag'n'drop - AllowNodeRename, //!< Allow renaming of groups and layers - AllowNodeChangeVisibility, //!< Allow user to set node visibility with a check box - AllowLegendChangeState, //!< Allow check boxes for legend nodes (if supported by layer's legend) - ActionHierarchical, //!< Check/uncheck action has consequences on children (or parents for leaf node) + // behavioral + AllowNodeReorder, + AllowNodeRename, + AllowNodeChangeVisibility, + AllowLegendChangeState, + ActionHierarchical, }; typedef QFlags Flags; - //! Set OR-ed combination of model flags - void setFlags( Flags f ); - //! Enable or disable a model flag + + void setFlags( QgsLayerTreeModel::Flags f ); +%Docstring +Set OR-ed combination of model flags +%End 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; - //! Check whether a flag is enabled +%Docstring +Return OR-ed combination of model flags + :rtype: Flags +%End 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. - //! Returns null pointer if index does not refer to a layer tree node (e.g. it is a legend node) - QgsLayerTreeNode* index2node( const QModelIndex& index ) const; - //! Return index for a given node. If the node does not belong to the layer tree, the result is undefined - QModelIndex node2index( QgsLayerTreeNode* node ) const; - //! Convert a list of indexes to a list of layer tree nodes. - //! Indices that do not represent layer tree nodes are skipped. - //! @arg skipInternal If true, a node is included in the output list only if no parent node is in the list - QList indexes2nodes( const QModelIndexList& list, bool skipInternal = false ) const; + QgsLayerTreeNode *index2node( const QModelIndex &index ) const; +%Docstring +Returns null pointer if index does not refer to a layer tree node (e.g. it is a legend node) + :rtype: QgsLayerTreeNode +%End + QModelIndex node2index( QgsLayerTreeNode *node ) const; +%Docstring +Return index for a given node. If the node does not belong to the layer tree, the result is undefined + :rtype: QModelIndex +%End + QList 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 - //! @note added in 2.6 - static QgsLayerTreeModelLegendNode* index2legendNode( const QModelIndex& index ); - //! Return index for a given legend node. If the legend node does not belong to the layer tree, the result is undefined. - //! If the legend node is belongs to the tree but it is filtered out, invalid model index is returned. - //! @note added in 2.6 - QModelIndex legendNode2index( QgsLayerTreeModelLegendNode* legendNode ); + static QgsLayerTreeModelLegendNode *index2legendNode( const QModelIndex &index ); +%Docstring +.. versionadded:: 2.6 + :rtype: QgsLayerTreeModelLegendNode +%End + QModelIndex legendNode2index( QgsLayerTreeModelLegendNode *legendNode ); +%Docstring +.. versionadded:: 2.6 + :rtype: QModelIndex +%End - //! Return filtered list of active legend nodes attached to a particular layer node - //! (by default it returns also legend node embedded in parent layer node (if any) unless skipNodeEmbeddedInParent is true) - //! @note added in 2.6 - //! @note skipNodeEmbeddedInParent added in 2.18 - //! @see layerOriginalLegendNodes() - QList layerLegendNodes( QgsLayerTreeLayer* nodeLayer, bool skipNodeEmbeddedInParent = false ); + QList layerLegendNodes( QgsLayerTreeLayer *nodeLayer, bool skipNodeEmbeddedInParent = false ); +%Docstring +\see layerOriginalLegendNodes() + :rtype: list of QgsLayerTreeModelLegendNode +%End - //! Return original (unfiltered) list of legend nodes attached to a particular layer node - //! @note added in 2.14 - //! @see layerLegendNodes() - QList layerOriginalLegendNodes( QgsLayerTreeLayer* nodeLayer ); + QList layerOriginalLegendNodes( QgsLayerTreeLayer *nodeLayer ); +%Docstring +\see layerLegendNodes() + :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). - //! @note added in 2.18 - QgsLayerTreeModelLegendNode* legendNodeEmbeddedInParent( QgsLayerTreeLayer* nodeLayer ) const; + QgsLayerTreeModelLegendNode *legendNodeEmbeddedInParent( QgsLayerTreeLayer *nodeLayer ) const; +%Docstring +.. versionadded:: 2.18 + :rtype: QgsLayerTreeModelLegendNode +%End - /** Searches through the layer tree to find a legend node with a matching layer ID - * and rule key. - * @param layerId map layer ID - * @param ruleKey legend node rule key - * @returns QgsLayerTreeModelLegendNode if found - * @note added in QGIS 2.14 - */ - QgsLayerTreeModelLegendNode* findLegendNode( const QString& layerId, const QString& ruleKey ) const; + QgsLayerTreeModelLegendNode *findLegendNode( const QString &layerId, const QString &ruleKey ) const; +%Docstring + Searches through the layer tree to find a legend node with a matching layer ID + and rule key. + \param layerId map layer ID + \param ruleKey legend node rule key + :return: QgsLayerTreeModelLegendNode if found +.. versionadded:: 2.14 + :rtype: QgsLayerTreeModelLegendNode +%End - //! Return pointer to the root node of the layer tree. Always a non-null pointer. - QgsLayerTree* rootGroup() const; - //! Reset the model and use a new root group node - //! @note added in 2.6 - void setRootGroup( QgsLayerTree* newRootGroup ); + QgsLayerTree *rootGroup() const; +%Docstring +Return pointer to the root node of the layer tree. Always a non-null pointer. + :rtype: QgsLayerTree +%End + void setRootGroup( QgsLayerTree *newRootGroup ); +%Docstring +.. versionadded:: 2.6 +%End - //! Force a refresh of legend nodes of a layer node. - //! Not necessary to call when layer's renderer is changed as the model listens to these events. - void refreshLayerLegend( QgsLayerTreeLayer* nodeLayer ); + void refreshLayerLegend( QgsLayerTreeLayer *nodeLayer ); +%Docstring +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; - //! Set index of the current item. May be used by view. Item marked as current is underlined. - void setCurrentIndex( const QModelIndex& currentIndex ); +%Docstring +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 ); - //! Get font for a particular type of layer tree node. nodeType should come from QgsLayerTreeNode::NodeType enumeration + void setLayerTreeNodeFont( int nodeType, const QFont &font ); +%Docstring +Set font for a particular type of layer tree node. nodeType should come from QgsLayerTreeNode.NodeType enumeration +%End 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 ); - //! 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; +%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 ); +%Docstring +.. versionadded:: 2.6 +%End double legendFilterByScale() const; +%Docstring + :rtype: float +%End - //! Force only display of legend nodes which are valid for given map settings. - //! Setting null pointer or invalid map settings will disable the functionality. - //! Ownership of map settings pointer does not change. - //! @note added in 2.6 - void setLegendFilterByMap( const QgsMapSettings* settings ); + void setLegendFilterByMap( const QgsMapSettings *settings ); +%Docstring +.. versionadded:: 2.6 +%End - //! Filter display of legend nodes for given map settings - //! @param settings Map settings. Setting a null pointer or invalid settings will disable any filter. Ownership is not changed, a copy is made - //! @param useExtent Whether to use the extent of the map settings as a first spatial filter on legend nodes - //! @param polygon If not empty, this polygon will be used instead of the map extent to filter legend nodes - //! @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 ); + void setLegendFilter( const QgsMapSettings *settings, bool useExtent = true, const QgsGeometry &polygon = QgsGeometry(), bool useExpressions = true ); +%Docstring +.. versionadded:: 2.14 +%End - //! Returns the current map settings used for the current legend filter (or null if none is enabled) - //! @note added in 2.14 - const QgsMapSettings* legendFilterMapSettings() const; + const QgsMapSettings *legendFilterMapSettings() const; +%Docstring +.. 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 ); - //! 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. - //! @note added in 2.6 - void legendMapViewData( double *mapUnitsPerPixel /Out/, int *dpi /Out/, double *scale /Out/ ) const; +%Docstring +.. versionadded:: 2.6 +%End + 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 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 - //! @note added in 2.10 - void setLayerStyleOverrides( const QMap& overrides ); - - signals: +%Docstring +.. versionadded:: 2.10 + :rtype: QMap +%End + void setLayerStyleOverrides( const QMap &overrides ); +%Docstring +.. versionadded:: 2.10 +%End protected slots: - void nodeWillAddChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo ); - void nodeAddedChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo ); - void nodeWillRemoveChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo ); + void nodeWillAddChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo ); + void nodeAddedChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo ); + void nodeWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo ); void nodeRemovedChildren(); - void nodeVisibilityChanged( QgsLayerTreeNode* node ); - //! Updates model when node's name has changed - //! @note added in 3.0 - void nodeNameChanged( QgsLayerTreeNode* node, const QString& name ); + void nodeVisibilityChanged( QgsLayerTreeNode *node ); + void nodeNameChanged( QgsLayerTreeNode *node, const QString &name ); +%Docstring +.. versionadded:: 3.0 +%End - void nodeCustomPropertyChanged( QgsLayerTreeNode* node, const QString& key ); + void nodeCustomPropertyChanged( QgsLayerTreeNode *node, const QString &key ); void nodeLayerLoaded(); void nodeLayerWillBeUnloaded(); @@ -208,43 +284,105 @@ class QgsLayerTreeModel : QAbstractItemModel void invalidateLegendMapBasedData(); protected: - void removeLegendFromLayer( QgsLayerTreeLayer* nodeLayer ); - void addLegendToLayer( QgsLayerTreeLayer* nodeL ); + void removeLegendFromLayer( QgsLayerTreeLayer *nodeLayer ); + void addLegendToLayer( QgsLayerTreeLayer *nodeL ); - void connectToLayer( QgsLayerTreeLayer* nodeLayer ); - void disconnectFromLayer( QgsLayerTreeLayer* nodeLayer ); + void connectToLayer( QgsLayerTreeLayer *nodeLayer ); + void disconnectFromLayer( QgsLayerTreeLayer *nodeLayer ); - void connectToLayers( QgsLayerTreeGroup* parentGroup ); - void disconnectFromLayers( QgsLayerTreeGroup* parentGroup ); + void connectToLayers( QgsLayerTreeGroup *parentGroup ); + void disconnectFromLayers( QgsLayerTreeGroup *parentGroup ); void connectToRootNode(); 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. - * Emits dataChanged() for all scale dependent layers. - * @note added in QGIS 2.16 - */ - void refreshScaleBasedLayers( const QModelIndex& index = QModelIndex() ); + void refreshScaleBasedLayers( const QModelIndex &index = QModelIndex() ); +%Docstring + Updates layer data for scale dependent layers, should be called when map scale changes. + Emits dataChanged() for all scale dependent layers. +.. versionadded:: 2.16 +%End static QIcon iconGroup(); +%Docstring + :rtype: QIcon +%End - //! Filter nodes from QgsMapLayerLegend according to the current filtering rules - QList filterLegendNodes( const QList& nodes ); + QList filterLegendNodes( const QList &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 legendNodeRowCount( QgsLayerTreeModelLegendNode* node ) const; - QModelIndex legendRootIndex( int row, int column, QgsLayerTreeLayer* nL ) const; - QModelIndex legendNodeIndex( int row, int column, QgsLayerTreeModelLegendNode* node ) const; - QModelIndex legendParent( QgsLayerTreeModelLegendNode* legendNode ) const; - QVariant legendNodeData( QgsLayerTreeModelLegendNode* node, int role ) const; - Qt::ItemFlags legendNodeFlags( QgsLayerTreeModelLegendNode* node ) const; - bool legendEmbeddedInParent( QgsLayerTreeLayer* nodeLayer ) const; - QIcon legendIconEmbeddedInParent( QgsLayerTreeLayer* nodeLayer ) const; + int legendRootRowCount( QgsLayerTreeLayer *nL ) const; +%Docstring + :rtype: int +%End + int legendNodeRowCount( QgsLayerTreeModelLegendNode *node ) const; +%Docstring + :rtype: int +%End + 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 legendInvalidateMapBasedData(); + protected: + + + + + + + + + + + }; + +QFlags operator|(QgsLayerTreeModel::Flag f1, QFlags 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 * + ************************************************************************/ diff --git a/python/core/layertree/qgslayertreemodellegendnode.sip b/python/core/layertree/qgslayertreemodellegendnode.sip index 0e3c867e29d..6da04540a59 100644 --- a/python/core/layertree/qgslayertreemodellegendnode.sip +++ b/python/core/layertree/qgslayertreemodellegendnode.sip @@ -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 { -%TypeHeaderCode -#include +%Docstring + 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 +%TypeHeaderCode +#include "qgslayertreemodellegendnode.h" +%End public: - ~QgsLayerTreeModelLegendNode(); enum LegendNodeRoles { - RuleKeyRole, //!< rule key of the node (QString) - ParentRuleKeyRole //!< rule key of the parent legend node - for legends with tree hierarchy (QString). Added in 2.8 + RuleKeyRole + 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; +%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; +%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; +%Docstring + :rtype: bool +%End virtual void setEmbeddedInParent( bool embedded ); 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; +%Docstring + :rtype: bool +%End - /** Notification from model that information from associated map view has changed. - * Default implementation does nothing. */ virtual void invalidateMapBasedData(); +%Docstring + Notification from model that information from associated map view has changed. + Default implementation does nothing. * +%End struct ItemContext { - //! Painter - QPainter* painter; - //! Top-left corner of the legend item + QPainter *painter; +%Docstring +Painter +%End QPointF point; - //! offset from the left side where label should start +%Docstring +Top-left corner of the legend item +%End double labelXOffset; +%Docstring +offset from the left side where label should start +%End }; struct ItemMetrics @@ -66,204 +108,240 @@ class QgsLayerTreeModelLegendNode : QObject QSizeF labelSize; }; - /** Entry point called from QgsLegendRenderer to do the rendering. - * Default implementation calls drawSymbol() and drawSymbolText() methods. - * - * If ctx is null, this is just first stage when preparing layout - without actual rendering. - */ - virtual ItemMetrics draw( const QgsLegendSettings& settings, ItemContext* ctx ); + virtual ItemMetrics draw( const QgsLegendSettings &settings, ItemContext *ctx ); +%Docstring + Entry point called from QgsLegendRenderer to do the rendering. + Default implementation calls drawSymbol() and drawSymbolText() methods. - /** - * Draws symbol on the left 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 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; + If ctx is null, this is just first stage when preparing layout - without actual rendering. + :rtype: ItemMetrics +%End - /** - * 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) - */ - virtual QSizeF drawSymbolText( const QgsLegendSettings& settings, ItemContext* ctx, QSizeF symbolSize ) const; + virtual QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const; +%Docstring + Draws symbol on the left 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 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) + :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: - //! Emitted on internal data change so the layer tree model can forward the signal to views void dataChanged(); +%Docstring +Emitted on internal data change so the layer tree model can forward the signal to views +%End 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: - QgsLayerTreeModelLegendNode(const QgsLayerTreeModelLegendNode &); + protected: }; - -/** - * 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 { +%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 -#include +#include "qgslayertreemodellegendnode.h" %End public: - QgsSymbolLegendNode( QgsLayerTreeLayer* nodeLayer, const QgsLegendSymbolItem& item, QObject* parent /TransferThis/ = 0 ); - ~QgsSymbolLegendNode(); + QgsSymbolLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent /TransferThis/ = 0 ); virtual Qt::ItemFlags flags() 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 ); - void setUserLabel( const QString& userLabel ); + virtual void setUserLabel( const QString &userLabel ); virtual bool isScaleOK( double scale ) const; virtual void invalidateMapBasedData(); - //! Set the icon size - //! @note added in 2.10 void setIconSize( QSize sz ); - //! @note added in 2.10 +%Docstring +.. versionadded:: 2.10 +%End 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; +%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 - /** - * 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 call this method instead of minimumIconSize(). - * @note added in QGIS 2.18 - */ - QSize minimumIconSize( QgsRenderContext* context ) const; + QSize minimumIconSize( QgsRenderContext *context ) 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 call this method instead of minimumIconSize(). +.. versionadded:: 2.18 + :rtype: QSize +%End - /** Returns the symbol used by the legend node. - * @see setSymbol() - * @note added in QGIS 2.14 - */ - const QgsSymbol* symbol() const; + const QgsSymbol *symbol() const; +%Docstring + Returns the symbol used by the legend node. + \see setSymbol() +.. versionadded:: 2.14 + :rtype: QgsSymbol +%End - /** Sets the symbol to be used by the legend node. The symbol change is also propagated - * to the associated vector layer's renderer. - * @param symbol new symbol for node. Ownership is transferred. - * @see symbol() - * @note added in QGIS 2.14 - */ - void setSymbol( QgsSymbol* symbol /Transfer/ ); + void setSymbol( QgsSymbol *symbol ); +%Docstring + Sets the symbol to be used by the legend node. The symbol change is also propagated + to the associated vector layer's renderer. + \param symbol new symbol for node. Ownership is transferred. + \see symbol() +.. versionadded:: 2.14 +%End public slots: - /** Checks all items belonging to the same layer as this node. - * @note added in QGIS 2.14 - * @see uncheckAllItems() - */ 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(); +%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 { +%Docstring + Implementation of legend node interface for displaying arbitrary label with icon. + +.. versionadded:: 2.6 +%End + %TypeHeaderCode -#include +#include "qgslayertreemodellegendnode.h" %End 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; + }; -/** - * Implementation of legend node interface for displaying arbitrary raster image - * - * @note added in 2.6 - */ class QgsImageLegendNode : QgsLayerTreeModelLegendNode { +%Docstring + Implementation of legend node interface for displaying arbitrary raster image + +.. versionadded:: 2.6 +%End + %TypeHeaderCode -#include +#include "qgslayertreemodellegendnode.h" %End 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; - 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 { +%Docstring + Implementation of legend node interface for displaying raster legend entries + +.. versionadded:: 2.6 +%End + %TypeHeaderCode -#include +#include "qgslayertreemodellegendnode.h" %End 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; - 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 { +%Docstring + Implementation of legend node interface for displaying WMS legend entries + +.. versionadded:: 2.8 +%End + %TypeHeaderCode -#include +#include "qgslayertreemodellegendnode.h" %End public: - /** Constructor for QgsWmsLegendNode. - * @param nodeLayer layer node - * @param parent parent object - */ - QgsWmsLegendNode( QgsLayerTreeLayer* nodeLayer, QObject* parent /TransferThis/ = nullptr ); + QgsWmsLegendNode( QgsLayerTreeLayer *nodeLayer, QObject *parent /TransferThis/ = 0 ); +%Docstring + Constructor for QgsWmsLegendNode. + \param nodeLayer layer node + \param parent parent object +%End 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(); }; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/layertree/qgslayertreemodellegendnode.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/python/core/layertree/qgslayertreenode.sip b/python/core/layertree/qgslayertreenode.sip index 077d69b0565..456883729f7 100644 --- a/python/core/layertree/qgslayertreenode.sip +++ b/python/core/layertree/qgslayertreenode.sip @@ -1,194 +1,306 @@ -/** - * 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 - * @note added in 2.4 - */ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/layertree/qgslayertreenode.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + + + 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 -#include +#include "qgslayertreenode.h" %End %ConvertToSubClassCode - if (sipCpp->inherits("QgsLayerTreeNode")) - { - sipType = sipType_QgsLayerTreeNode; - QgsLayerTreeNode* node = qobject_cast(sipCpp); - if (QgsLayerTree::isLayer(node)) - sipType = sipType_QgsLayerTreeLayer; - else if (qobject_cast(sipCpp)) - sipType = sipType_QgsLayerTree; - else if (QgsLayerTree::isGroup(node)) - sipType = sipType_QgsLayerTreeGroup; - } - else - sipType = 0; + if ( sipCpp->inherits( "QgsLayerTreeNode" ) ) + { + sipType = sipType_QgsLayerTreeNode; + QgsLayerTreeNode *node = qobject_cast( sipCpp ); + if ( QgsLayerTree::isLayer( node ) ) + sipType = sipType_QgsLayerTreeLayer; + else if ( qobject_cast( sipCpp ) ) + sipType = sipType_QgsLayerTree; + else if ( QgsLayerTree::isGroup( node ) ) + sipType = sipType_QgsLayerTreeGroup; + } + else + sipType = 0; %End - public: - //! Enumeration of possible tree node types enum NodeType { - NodeGroup, //!< container of other groups and layers - NodeLayer //!< leaf node pointing to a layer + NodeGroup, + NodeLayer }; ~QgsLayerTreeNode(); - //! Find out about type of the node. It is usually shorter to use convenience functions from QgsLayerTree namespace for that 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(); - //! Get list of children of the node. Children are owned by the parent - QList children(); +%Docstring +Get pointer to the parent. If parent is a null pointer, the node is a root node + :rtype: QgsLayerTreeNode +%End + QList 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; - //! Set name of the node. Emits nameChanged signal. - //! @note added in 3.0 - virtual void setName( const QString& name ) = 0; +%Docstring +.. versionadded:: 3.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/; - //! Read layer tree from XML. Returns new instance. - //! Also resolves textual references to layers from the project (calls resolveReferences() internally). - //! @note added in 3.0 - static QgsLayerTreeNode* readXml( QDomElement& element, const QgsProject* project ) /Factory/; +%Docstring +Does not resolve textual references to layers. Call resolveReferences() afterwards to do it. + :rtype: QgsLayerTreeNode +%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; +%Docstring +Write layer tree to XML +%End - //! Return string with layer tree structure. For debug purposes only 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/; +%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; +%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; +%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; +%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 ); +%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 ); +%Docstring +.. versionadded:: 3.0 +%End - //! Check or uncheck a node and all its parents - //! @note added in 3.0 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; +%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; - QList< QgsMapLayer * > checkedLayers() const; - bool isExpanded() const; - //! Set whether the node should be shown as expanded or collapsed in GUI - void setExpanded( bool expanded ); +%Docstring +.. versionadded:: 3.0 + :rtype: bool +%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 ); - /** 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; - /** 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 ); - /** 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; - /** Remove a child from a node */ +%Docstring +Return list of keys stored in custom properties + :rtype: list of str +%End bool takeChild( QgsLayerTreeNode *node ); +%Docstring +Remove a child from a node + :rtype: bool +%End signals: - //! Emitted when one or more nodes will be added to a node within the tree 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 ); - //! 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 ); - //! 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 ); - //! 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 ); - //! Emitted when a custom property of a node within the tree has been changed or removed - void customPropertyChanged( QgsLayerTreeNode *node, const QString& key ); - //! Emitted when the collapsed/expanded state of a node within the tree has been changed +%Docstring +Emitted when check 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 ); - //! Emitted when the name of the node is changed - //! @note added in 3.0 - void nameChanged( QgsLayerTreeNode* node, QString name ); +%Docstring +Emitted when the collapsed/expanded state of a node within the tree has been changed +%End + void nameChanged( QgsLayerTreeNode *node, QString name ); +%Docstring +.. versionadded:: 3.0 +%End protected: - QgsLayerTreeNode( NodeType t ); + QgsLayerTreeNode( NodeType t, bool checked = true ); +%Docstring +Constructor +%End + QgsLayerTreeNode( const QgsLayerTreeNode &other ); + void readCommonXml( QDomElement &element ); +%Docstring +Read common XML elements. +%End 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 nodes ); - //! Low-level removal of children from the node. + void insertChildrenPrivate( int index, QList nodes ); +%Docstring +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 ); +%Docstring +Low-level removal of children from the node. +%End - private: - QgsLayerTreeNode( const QgsLayerTreeNode& other ); - + protected: }; + + + + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/layertree/qgslayertreenode.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/python/core/layertree/qgslayertreeregistrybridge.sip b/python/core/layertree/qgslayertreeregistrybridge.sip index 47d2d4878e6..3acc4fd15bd 100644 --- a/python/core/layertree/qgslayertreeregistrybridge.sip +++ b/python/core/layertree/qgslayertreeregistrybridge.sip @@ -1,47 +1,80 @@ -/** - * 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. - * - * @note added in 2.4 - */ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/layertree/qgslayertreeregistrybridge.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + + + class QgsLayerTreeRegistryBridge : QObject { -%TypeHeaderCode -#include +%Docstring + 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 +%TypeHeaderCode +#include "qgslayertreeregistrybridge.h" +%End 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 ); bool isEnabled() const; +%Docstring + :rtype: bool +%End void setNewLayersVisible( bool enabled ); bool newLayersVisible() const; +%Docstring + :rtype: bool +%End - //! Set where the new layers should be inserted - can be used to follow current selection. - //! By default it is root group with zero index. - void setLayerInsertionPoint( QgsLayerTreeGroup* parentGroup, int index ); + void setLayerInsertionPoint( QgsLayerTreeGroup *parentGroup, int index ); +%Docstring +By default it is root group with zero index. +%End signals: - //! Tell others we have just added layers to the tree (used in QGIS to auto-select first newly added layer) - //! @note added in 2.6 - void addedLayersToLayerTree( const QList& layers ); + void addedLayersToLayerTree( const QList &layers ); +%Docstring +.. versionadded:: 2.6 +%End protected slots: - void layersAdded( const QList& layers ); - void layersWillBeRemoved( const QStringList& layerIds ); + void layersAdded( const QList &layers ); + void layersWillBeRemoved( const QStringList &layerIds ); - void groupWillRemoveChildren( QgsLayerTreeNode* node, int indexFrom, int indexTo ); + void groupWillRemoveChildren( QgsLayerTreeNode *node, int indexFrom, int indexTo ); 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 * + ************************************************************************/ diff --git a/python/core/layertree/qgslayertreeutils.sip b/python/core/layertree/qgslayertreeutils.sip index 00e5c81ef47..eef75dcfb66 100644 --- a/python/core/layertree/qgslayertreeutils.sip +++ b/python/core/layertree/qgslayertreeutils.sip @@ -1,54 +1,115 @@ -/** - * Assorted functions for dealing with layer trees. - * - * @note added in 2.4 - */ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/layertree/qgslayertreeutils.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + + class QgsLayerTreeUtils { -%TypeHeaderCode -#include +%Docstring + Assorted functions for dealing with layer trees. + +.. versionadded:: 2.4 %End +%TypeHeaderCode +#include "qgslayertreeutils.h" +%End public: - //! Try to load layer tree from \verbatim \endverbatim tag from project files from QGIS 2.2 and below - static bool readOldLegend( QgsLayerTreeGroup* root, const QDomElement& legendElem ); - //! Try to load custom layer order from \verbatim \endverbatim tag from project files from QGIS 2.2 and below - static bool readOldLegendLayerOrder( const QDomElement& legendElem, bool& hasCustomOrder, QStringList& order ); - //! Return \verbatim \endverbatim tag used in QGIS 2.2 and below - static QDomElement writeOldLegend( QDomDocument& doc, QgsLayerTreeGroup* root, bool hasCustomOrder, const QList &order ); + static bool readOldLegend( QgsLayerTreeGroup *root, const QDomElement &legendElem ); +%Docstring +Try to load layer tree from \verbatim \endverbatim tag from project files from QGIS 2.2 and below + :rtype: bool +%End + static bool readOldLegendLayerOrder( const QDomElement &legendElem, bool &hasCustomOrder, QStringList &order ); +%Docstring +Try to load custom layer order from \verbatim \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 &order ); +%Docstring +Return \verbatim \endverbatim tag used in QGIS 2.2 and below + :rtype: QDomElement +%End - //! Convert Qt::CheckState to QString static QString checkStateToXml( Qt::CheckState state ); - //! Convert QString to Qt::CheckState - static Qt::CheckState checkStateFromXml( const QString& txt ); +%Docstring +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& layerNodes ); - //! Return true if any of the layers is modified - static bool layersModified( const QList& layerNodes ); + static bool layersEditable( const QList &layerNodes ); +%Docstring +Return true if any of the layers is editable + :rtype: bool +%End + static bool layersModified( const QList &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 ); +%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 ); - //! Return the expression filter of a legend layer - static QString legendFilterByExpression( const QgsLayerTreeLayer& layer, bool* enabled = 0 ); - //! Test if one of the layers in a group has an expression filter - static bool hasLegendFilterExpression( const QgsLayerTreeGroup& group ); + static void setLegendFilterByExpression( QgsLayerTreeLayer &layer, const QString &expr, bool enabled = true ); +%Docstring +Set the expression filter of a legend layer +%End + static QString legendFilterByExpression( const QgsLayerTreeLayer &layer, bool *enabled = 0 ); +%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 - //! @param group the tree group where layers are (can be the root group) - //! @param refLayer the reference layer - //! @param layerToInsert the new layer to insert just below the reference layer - //! @returns the new tree layer - static QgsLayerTreeLayer* insertLayerBelow( QgsLayerTreeGroup* group, const QgsMapLayer* refLayer, QgsMapLayer* layerToInsert ); + static QgsLayerTreeLayer *insertLayerBelow( QgsLayerTreeGroup *group, const QgsMapLayer *refLayer, QgsMapLayer *layerToInsert ); +%Docstring +:return: the new tree layer + :rtype: QgsLayerTreeLayer +%End }; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/layertree/qgslayertreeutils.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/scripts/sipify_all.sh b/scripts/sipify_all.sh index fbb2d70ee39..aa3ae1089de 100755 --- a/scripts/sipify_all.sh +++ b/scripts/sipify_all.sh @@ -25,6 +25,8 @@ fi pushd ${DIR} > /dev/null +count=0 + while read -r sipfile; do if ! grep -Fxq "$sipfile" python/auto_sip.blacklist; then echo "$sipfile" @@ -34,6 +36,7 @@ while read -r sipfile; do else ./scripts/sipify.pl $header > python/$sipfile fi + count=$((count+1)) fi done < <( ${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 ) +echo " => $count files sipified!" + popd > /dev/null diff --git a/src/core/layertree/qgslayertree.h b/src/core/layertree/qgslayertree.h index adb082ef6dd..5696d4378d1 100644 --- a/src/core/layertree/qgslayertree.h +++ b/src/core/layertree/qgslayertree.h @@ -60,7 +60,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup * \since QGIS 2.4 * \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( node ); } @@ -71,7 +71,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup * \since QGIS 2.4 * \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( node ); } @@ -82,7 +82,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup * \since QGIS 2.4 * \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 ); } @@ -92,11 +92,6 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup */ QgsLayerTree(); - /** - * Copy constructor - */ - QgsLayerTree( const QgsLayerTree &other ); - /** * The order in which layers will be rendered on the canvas. * Will only be used if the property hasCustomLayerOrder is true. @@ -134,7 +129,7 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup * * \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. @@ -227,6 +222,8 @@ class CORE_EXPORT QgsLayerTree : public QgsLayerTreeGroup void nodeRemovedChildren(); private: + //! Copy constructor \see clone() + QgsLayerTree( const QgsLayerTree &other ); void addMissingLayers(); QgsWeakMapLayerPointerList mCustomLayerOrder; bool mHasCustomLayerOrder = false; diff --git a/src/core/layertree/qgslayertreemodel.h b/src/core/layertree/qgslayertreemodel.h index 5100c795296..073348a3a23 100644 --- a/src/core/layertree/qgslayertreemodel.h +++ b/src/core/layertree/qgslayertreemodel.h @@ -53,11 +53,21 @@ class QgsLayerTree; */ 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 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 = nullptr ); + explicit QgsLayerTreeModel( QgsLayerTree *rootNode, QObject *parent SIP_TRANSFERTHIS = nullptr ); ~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. //! If there are no valid map view data (from previous call to setLegendMapViewData()), returned values are zeros. //! \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 //! \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) //! The tree structure (parents and children of each node) is extracted by analyzing nodes' parent rules. //! \note not available in Python bindings +#ifndef SIP_RUN struct LayerLegendTree { //! 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. QMap > children; }; +#endif //! Structure that stores all data associated with one map layer //! \note not available in Python bindings +#ifndef SIP_RUN struct LayerLegendData { LayerLegendData() @@ -323,9 +336,10 @@ class CORE_EXPORT QgsLayerTreeModel : public QAbstractItemModel //! Optional pointer to a tree structure - see LayerLegendTree for details LayerLegendTree *tree = nullptr; }; +#endif //! \note not available in Python bindings - LayerLegendTree *tryBuildLegendTree( const QList &nodes ); + LayerLegendTree *tryBuildLegendTree( const QList &nodes ) SIP_SKIP; //! 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 diff --git a/src/core/layertree/qgslayertreemodellegendnode.h b/src/core/layertree/qgslayertreemodellegendnode.h index 17d17b6594c..4f1eac457cd 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.h +++ b/src/core/layertree/qgslayertreemodellegendnode.h @@ -19,10 +19,13 @@ #ifndef QGSLAYERTREEMODELLEGENDNODE_H #define QGSLAYERTREEMODELLEGENDNODE_H -#include "qgis_core.h" #include #include + +#include "qgis_core.h" +#include "qgis.h" + #include "qgsrasterdataprovider.h" // for QgsImageFetcher dtor visibility class QgsLayerTreeLayer; @@ -126,7 +129,7 @@ class CORE_EXPORT QgsLayerTreeModelLegendNode : public QObject protected: //! 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: QgsLayerTreeLayer *mLayerNode = nullptr; @@ -147,7 +150,7 @@ class CORE_EXPORT QgsSymbolLegendNode : public QgsLayerTreeModelLegendNode Q_OBJECT 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 QVariant data( int role ) const override; @@ -247,7 +250,7 @@ class CORE_EXPORT QgsSimpleLegendNode : public QgsLayerTreeModelLegendNode Q_OBJECT 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; @@ -269,7 +272,7 @@ class CORE_EXPORT QgsImageLegendNode : public QgsLayerTreeModelLegendNode Q_OBJECT 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; @@ -289,7 +292,7 @@ class CORE_EXPORT QgsRasterSymbolLegendNode : public QgsLayerTreeModelLegendNode Q_OBJECT 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; @@ -317,7 +320,7 @@ class CORE_EXPORT QgsWmsLegendNode : public QgsLayerTreeModelLegendNode * \param nodeLayer layer node * \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; diff --git a/src/core/layertree/qgslayertreenode.h b/src/core/layertree/qgslayertreenode.h index 73249dac7a1..48cd69b653a 100644 --- a/src/core/layertree/qgslayertreenode.h +++ b/src/core/layertree/qgslayertreenode.h @@ -20,6 +20,7 @@ #include #include "qgsobjectcustomproperties.h" +#include "qgis.h" class QDomElement; @@ -69,6 +70,25 @@ class QgsMapLayer; class CORE_EXPORT QgsLayerTreeNode : public QObject { Q_OBJECT + +#ifdef SIP_RUN + SIP_CONVERT_TO_SUBCLASS_CODE + if ( sipCpp->inherits( "QgsLayerTreeNode" ) ) + { + sipType = sipType_QgsLayerTreeNode; + QgsLayerTreeNode *node = qobject_cast( sipCpp ); + if ( QgsLayerTree::isLayer( node ) ) + sipType = sipType_QgsLayerTreeLayer; + else if ( qobject_cast( sipCpp ) ) + sipType = sipType_QgsLayerTree; + else if ( QgsLayerTree::isGroup( node ) ) + sipType = sipType_QgsLayerTreeGroup; + } + else + sipType = 0; + SIP_END +#endif + public: //! 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 QList children() { return mChildren; } //! Get list of children of the node. Children are owned by the parent - QList children() const { return mChildren; } + QList children() const { return mChildren; } SIP_SKIP //! Return name of the node //! \since QGIS 3.0 @@ -98,11 +118,11 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject //! 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 ); + static QgsLayerTreeNode *readXml( QDomElement &element ) SIP_FACTORY; //! Read layer tree from XML. Returns new instance. //! Also resolves textual references to layers from the project (calls resolveReferences() internally). //! \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 virtual void writeXml( QDomElement &parentElement ) = 0; @@ -111,7 +131,7 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject virtual QString dump() const = 0; //! 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. diff --git a/src/core/layertree/qgslayertreeregistrybridge.h b/src/core/layertree/qgslayertreeregistrybridge.h index ae2809566e7..41e0ce3d5ef 100644 --- a/src/core/layertree/qgslayertreeregistrybridge.h +++ b/src/core/layertree/qgslayertreeregistrybridge.h @@ -20,6 +20,7 @@ #include #include "qgis_core.h" +#include "qgis.h" class QgsLayerTreeGroup; class QgsLayerTreeNode; @@ -44,7 +45,7 @@ class CORE_EXPORT QgsLayerTreeRegistryBridge : public QObject Q_OBJECT public: //! 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; } bool isEnabled() const { return mEnabled; }