QGIS/python/PyQt6/gui/auto_generated/layertree/qgslayertreeview.sip.in
2025-08-25 12:17:32 +10:00

549 lines
14 KiB
Plaintext

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/layertree/qgslayertreeview.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsLayerTreeProxyModel : QSortFilterProxyModel
{
%Docstring(signature="appended")
A proxy model for :py:class:`QgsLayerTreeModel`, supporting private
layers and text filtering.
.. versionadded:: 3.18
%End
%TypeHeaderCode
#include "qgslayertreeview.h"
%End
%ConvertToSubClassCode
if ( qobject_cast<QgsLayerTreeProxyModel *>( sipCpp ) != nullptr )
sipType = sipType_QgsLayerTreeProxyModel;
else
sipType = nullptr;
%End
public:
QgsLayerTreeProxyModel( QgsLayerTreeModel *treeModel, QObject *parent );
%Docstring
Constructs QgsLayerTreeProxyModel with source model ``treeModel`` and a
``parent``
%End
void setFilterText( const QString &filterText = QString() );
%Docstring
Sets filter to ``filterText``.
%End
bool showPrivateLayers() const;
%Docstring
Returns if private layers are shown.
%End
void setShowPrivateLayers( bool showPrivate );
%Docstring
Determines if private layers are shown.
%End
bool hideValidLayers() const;
%Docstring
Returns if valid layers should be hidden (i.e. only invalid layers are
shown).
.. seealso:: :py:func:`setHideValidLayers`
.. versionadded:: 3.38
%End
void setHideValidLayers( bool hideValid );
%Docstring
Sets whether valid layers should be hidden (i.e. only invalid layers are
shown).
.. seealso:: :py:func:`setHideValidLayers`
.. versionadded:: 3.38
%End
protected:
virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;
};
class QgsLayerTreeView : QTreeView
{
%Docstring(signature="appended")
Extends QTreeView and provides additional functionality when working
with a layer tree.
The view updates expanded state of layer tree nodes and also listens to
changes to expanded states in the layer tree.
The view keeps track of the current layer and emits a signal when the
current layer has changed.
Allows the client to specify a context menu provider with custom
actions. Also it comes with a set of default actions that can be used
when building context menu.
.. seealso:: :py:class:`QgsLayerTreeModel`
%End
%TypeHeaderCode
#include "qgslayertreeview.h"
%End
%ConvertToSubClassCode
if ( sipCpp->inherits( "QgsLayerTreeView" ) )
sipType = sipType_QgsLayerTreeView;
else
sipType = 0;
%End
public:
explicit QgsLayerTreeView( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsLayerTreeView
%End
~QgsLayerTreeView();
virtual void setModel( QAbstractItemModel *model );
%Docstring
Overridden :py:func:`~QgsLayerTreeView.setModel` from base class. Only
:py:class:`QgsLayerTreeModel` is an acceptable model.
%End
QgsLayerTreeModel *layerTreeModel() const;
%Docstring
Gets access to the model casted to :py:class:`QgsLayerTreeModel`
%End
QgsLayerTreeProxyModel *proxyModel() const;
%Docstring
Returns the proxy model used by the view.
This can be used to set filters controlling which layers are shown in
the view.
.. versionadded:: 3.18
%End
QgsLayerTreeNode *index2node( const QModelIndex &index ) const;
%Docstring
Returns layer tree node for given proxy model tree ``index``. Returns
root node for invalid index. Returns ``None`` if index does not refer to
a layer tree node (e.g. it is a legend node)
Unlike :py:func:`QgsLayerTreeModel.index2Node()`, calling this method
correctly accounts for mapping the view indexes through the view's proxy
model to the source model.
.. versionadded:: 3.18
%End
QModelIndex node2index( QgsLayerTreeNode *node ) const;
%Docstring
Returns proxy model index for a given node. If the node does not belong
to the layer tree, the result is undefined
Unlike :py:func:`QgsLayerTreeModel.node2index()`, calling this method
correctly accounts for mapping the view indexes through the view's proxy
model to the source model.
.. versionadded:: 3.18
%End
QModelIndex node2sourceIndex( QgsLayerTreeNode *node ) const;
%Docstring
Returns source model index for a given node. If the node does not belong
to the layer tree, the result is undefined
.. versionadded:: 3.18
%End
QgsLayerTreeModelLegendNode *index2legendNode( const QModelIndex &index ) const;
%Docstring
Returns legend node for given proxy model tree ``index``. Returns
``None`` for invalid index
Unlike :py:func:`QgsLayerTreeModel.index2legendNode()`, calling this
method correctly accounts for mapping the view indexes through the
view's proxy model to the source model.
.. versionadded:: 3.18
%End
QModelIndex legendNode2index( QgsLayerTreeModelLegendNode *legendNode );
%Docstring
Returns proxy model 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.
Unlike :py:func:`QgsLayerTreeModel.legendNode2index()`, calling this
method correctly accounts for mapping the view indexes through the
view's proxy model to the source model.
.. versionadded:: 3.18
%End
QModelIndex legendNode2sourceIndex( QgsLayerTreeModelLegendNode *legendNode );
%Docstring
Returns 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.
.. versionadded:: 3.18
%End
QgsLayerTreeViewDefaultActions *defaultActions();
%Docstring
Gets access to the default actions that may be used with the tree view
%End
void setMenuProvider( QgsLayerTreeViewMenuProvider *menuProvider /Transfer/ );
%Docstring
Sets provider for context menu. Takes ownership of the instance
%End
QgsLayerTreeViewMenuProvider *menuProvider() const;
%Docstring
Returns pointer to the context menu provider. May be ``None``
%End
QgsMapLayer *currentLayer() const;
%Docstring
Returns the currently selected layer, or ``None`` if no layers is
selected.
.. seealso:: :py:func:`setCurrentLayer`
%End
void setLayerVisible( QgsMapLayer *layer, bool visible );
%Docstring
Convenience methods which sets the visible state of the specified map
``layer``.
.. seealso:: :py:func:`QgsLayerTreeNode.setItemVisibilityChecked`
.. versionadded:: 3.10
%End
void setCurrentNode( QgsLayerTreeNode *node );
%Docstring
Sets the currently selected ``node``.
If ``node`` is ``None`` then all nodes will be deselected.
.. seealso:: :py:func:`currentNode`
.. versionadded:: 3.40
%End
void setCurrentLayer( QgsMapLayer *layer );
%Docstring
Sets the currently selected ``layer``.
If ``layer`` is ``None`` then all layers will be deselected.
.. seealso:: :py:func:`currentLayer`
%End
QgsLayerTreeNode *currentNode() const;
%Docstring
Gets current node. May be ``None``
%End
QgsLayerTreeGroup *currentGroupNode() const;
%Docstring
Gets current group node. If a layer is current node, the function will
return parent group. May be ``None``.
%End
QgsLayerTreeModelLegendNode *currentLegendNode() const;
%Docstring
Gets current legend node. May be ``None`` if current node is not a
legend node.
%End
QList<QgsLayerTreeNode *> selectedNodes( bool skipInternal = false ) const;
%Docstring
Returns the list of selected layer tree nodes.
:param skipInternal: If ``True``, will ignore nodes which have an
ancestor in the selection
.. seealso:: :py:func:`selectedLayerNodes`
.. seealso:: :py:func:`selectedLegendNodes`
.. seealso:: :py:func:`selectedLayers`
%End
QList<QgsLayerTreeLayer *> selectedLayerNodes() const;
%Docstring
Returns the list of selected nodes filtered to just layer nodes
(:py:class:`QgsLayerTreeLayer`).
.. seealso:: :py:func:`selectedNodes`
.. seealso:: :py:func:`selectedLayers`
.. seealso:: :py:func:`selectedLegendNodes`
%End
QList<QgsMapLayer *> selectedLayers() const;
%Docstring
Returns the list of selected layers.
.. seealso:: :py:func:`selectedNodes`
.. seealso:: :py:func:`selectedLayerNodes`
.. seealso:: :py:func:`selectedLegendNodes`
%End
QList<QgsLayerTreeModelLegendNode *> selectedLegendNodes() const;
%Docstring
Returns the list of selected legend nodes.
.. seealso:: :py:func:`selectedNodes`
.. seealso:: :py:func:`selectedLayerNodes`
.. versionadded:: 3.32
%End
QList<QgsMapLayer *> selectedLayersRecursive() const;
%Docstring
Gets list of selected layers, including those that are not directly
selected, but their ancestor groups is selected. If we have a group with
two layers L1, L2 and just the group node is selected, this method
returns L1 and L2, while :py:func:`~QgsLayerTreeView.selectedLayers`
returns an empty list.
.. versionadded:: 3.4
%End
void addIndicator( QgsLayerTreeNode *node, QgsLayerTreeViewIndicator *indicator );
%Docstring
Adds an indicator to the given layer tree node. Indicators are icons
shown next to layer/group names in the layer tree view. They can be used
to show extra information with tree nodes and they allow user
interaction.
Does not take ownership of the indicator. One indicator object may be
used for multiple layer tree nodes.
.. seealso:: :py:func:`removeIndicator`
.. seealso:: :py:func:`indicators`
.. versionadded:: 3.2
%End
void removeIndicator( QgsLayerTreeNode *node, QgsLayerTreeViewIndicator *indicator );
%Docstring
Removes a previously added indicator to a layer tree node. Does not
delete the indicator.
.. seealso:: :py:func:`addIndicator`
.. seealso:: :py:func:`indicators`
.. versionadded:: 3.2
%End
QList<QgsLayerTreeViewIndicator *> indicators( QgsLayerTreeNode *node ) const;
%Docstring
Returns list of indicators associated with a particular layer tree node.
.. seealso:: :py:func:`addIndicator`
.. seealso:: :py:func:`removeIndicator`
.. versionadded:: 3.2
%End
int layerMarkWidth() const;
%Docstring
Returns width of contextual menu mark, at right of layer node items.
.. seealso:: :py:func:`setLayerMarkWidth`
.. versionadded:: 3.8
%End
bool showPrivateLayers() const;
%Docstring
Returns the show private layers status
.. versionadded:: 3.18
%End
bool hideValidLayers() const;
%Docstring
Returns if valid layers should be hidden (i.e. only invalid layers are
shown).
.. seealso:: :py:func:`setHideValidLayers`
.. versionadded:: 3.38
%End
public slots:
void refreshLayerSymbology( const QString &layerId );
%Docstring
Force refresh of layer symbology. Normally not needed as the changes of
layer's renderer are monitored by the model
%End
void expandAllNodes();
%Docstring
Enhancement of QTreeView.expandAll() that also records expanded state in
layer tree nodes
%End
void collapseAllNodes();
%Docstring
Enhancement of QTreeView.collapseAll() that also records expanded state
in layer tree nodes
%End
void setLayerMarkWidth( int width );
%Docstring
Set width of contextual menu mark, at right of layer node items.
.. seealso:: :py:func:`layerMarkWidth`
.. versionadded:: 3.8
%End
void setMessageBar( QgsMessageBar *messageBar );
%Docstring
Set the message bar to display messages from the layer tree
.. versionadded:: 3.14
%End
void setShowPrivateLayers( bool showPrivate );
%Docstring
Set the show private layers to ``showPrivate``
.. versionadded:: 3.18
%End
void setHideValidLayers( bool hideValid );
%Docstring
Sets whether valid layers should be hidden (i.e. only invalid layers are
shown).
.. seealso:: :py:func:`setHideValidLayers`
.. versionadded:: 3.38
%End
signals:
void currentLayerChanged( QgsMapLayer *layer );
%Docstring
Emitted when a current layer is changed
%End
void datasetsDropped( QDropEvent *event );
%Docstring
Emitted when datasets are dropped onto the layer tree view
%End
void contextMenuAboutToShow( QMenu *menu );
%Docstring
Emitted when the context menu is about to show.
Allows customization of the menu.
.. versionadded:: 3.32
%End
protected:
virtual void contextMenuEvent( QContextMenuEvent *event );
void updateExpandedStateFromNode( QgsLayerTreeNode *node );
QgsMapLayer *layerForIndex( const QModelIndex &index ) const;
virtual void mouseDoubleClickEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );
virtual void keyPressEvent( QKeyEvent *event );
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dragMoveEvent( QDragMoveEvent *event );
virtual void dropEvent( QDropEvent *event );
virtual void resizeEvent( QResizeEvent *event );
protected slots:
void modelRowsInserted( const QModelIndex &index, int start, int end );
void modelRowsRemoved();
void updateExpandedStateToNode( const QModelIndex &index );
void onCurrentChanged();
void onExpandedChanged( QgsLayerTreeNode *node, bool expanded );
void onModelReset();
protected:
};
class QgsLayerTreeViewMenuProvider
{
%Docstring(signature="appended")
Implementation of this interface can be implemented to allow
:py:class:`QgsLayerTreeView` instance to provide custom context menus
(opened upon right-click).
.. seealso:: :py:class:`QgsLayerTreeView`
%End
%TypeHeaderCode
#include "qgslayertreeview.h"
%End
public:
virtual ~QgsLayerTreeViewMenuProvider();
virtual QMenu *createContextMenu() = 0 /Factory/;
%Docstring
Returns a newly created menu instance (or ``None`` on error)
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/layertree/qgslayertreeview.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/