2017-06-08 15:37:13 +02:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/gui/layertree/qgslayertreeview.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-22 01:09:14 +07:00
|
|
|
class QgsLayerTreeView : QTreeView
|
|
|
|
{
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
The QgsLayerTreeView class extends QTreeView and provides some additional functionality
|
|
|
|
when working with a layer tree.
|
2017-06-08 15:37:13 +02:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
The view updates expanded state of layer tree nodes and also listens to changes
|
|
|
|
to expanded states in the layer tree.
|
2017-06-08 15:37:13 +02:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
The view keeps track of the current layer and emits a signal when the current layer has changed.
|
2017-06-08 15:37:13 +02:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
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.
|
2017-06-08 15:37:13 +02:00
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:class:`QgsLayerTreeModel`
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
.. versionadded:: 2.4
|
|
|
|
%End
|
|
|
|
|
2014-05-22 01:09:14 +07:00
|
|
|
%TypeHeaderCode
|
2017-06-08 15:37:13 +02:00
|
|
|
#include "qgslayertreeview.h"
|
2014-05-22 01:09:14 +07:00
|
|
|
%End
|
2014-06-13 18:19:15 +07:00
|
|
|
%ConvertToSubClassCode
|
2017-06-08 15:37:13 +02:00
|
|
|
if ( sipCpp->inherits( "QgsLayerTreeView" ) )
|
|
|
|
sipType = sipType_QgsLayerTreeView;
|
|
|
|
else
|
|
|
|
sipType = 0;
|
2014-06-13 18:19:15 +07:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
public:
|
2017-12-12 11:44:10 +10:00
|
|
|
|
2014-06-03 17:45:56 +07:00
|
|
|
explicit QgsLayerTreeView( QWidget *parent /TransferThis/ = 0 );
|
2017-12-12 11:44:10 +10:00
|
|
|
%Docstring
|
|
|
|
Constructor for QgsLayerTreeView
|
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
~QgsLayerTreeView();
|
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
virtual void setModel( QAbstractItemModel *model );
|
2017-12-15 08:57:22 +10:00
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
|
|
|
Overridden setModel() from base class. Only QgsLayerTreeModel is an acceptable model.
|
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsLayerTreeModel *layerTreeModel() const;
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2018-05-26 18:44:30 +10:00
|
|
|
Gets access to the model casted to :py:class:`QgsLayerTreeModel`
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsLayerTreeViewDefaultActions *defaultActions();
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2018-05-26 18:44:30 +10:00
|
|
|
Gets access to the default actions that may be used with the tree view
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void setMenuProvider( QgsLayerTreeViewMenuProvider *menuProvider /Transfer/ );
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Sets provider for context menu. Takes ownership of the instance
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsLayerTreeViewMenuProvider *menuProvider() const;
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2019-03-21 12:44:16 +10:00
|
|
|
Returns pointer to the context menu provider. May be ``None``
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsMapLayer *currentLayer() const;
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2019-02-26 21:19:42 +10:00
|
|
|
Returns the currently selected layer, or ``None`` if no layers is selected.
|
2019-02-26 09:11:18 +10:00
|
|
|
|
|
|
|
.. seealso:: :py:func:`setCurrentLayer`
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2019-02-26 09:11:18 +10:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void setCurrentLayer( QgsMapLayer *layer );
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2019-02-26 09:11:18 +10:00
|
|
|
Sets the currently selected ``layer``.
|
|
|
|
|
2019-02-26 21:19:42 +10:00
|
|
|
If ``layer`` is ``None`` then all layers will be deselected.
|
2019-02-26 09:11:18 +10:00
|
|
|
|
|
|
|
.. seealso:: :py:func:`currentLayer`
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsLayerTreeNode *currentNode() const;
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2019-03-21 12:44:16 +10:00
|
|
|
Gets current node. May be ``None``
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsLayerTreeGroup *currentGroupNode() const;
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2019-03-21 12:44:16 +10:00
|
|
|
Gets current group node. If a layer is current node, the function will return parent group. May be ``None``.
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsLayerTreeModelLegendNode *currentLegendNode() const;
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2019-02-26 21:19:42 +10:00
|
|
|
Gets current legend node. May be ``None`` if current node is not a legend node.
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
.. versionadded:: 2.14
|
|
|
|
%End
|
2015-12-09 16:07:39 +11:00
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
QList<QgsLayerTreeNode *> selectedNodes( bool skipInternal = false ) const;
|
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Returns list of selected nodes
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2019-02-26 19:54:09 +10:00
|
|
|
:param skipInternal: If ``True``, will ignore nodes which have an ancestor in the selection
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
|
|
|
QList<QgsLayerTreeLayer *> selectedLayerNodes() const;
|
|
|
|
%Docstring
|
2018-05-25 13:54:27 +10:00
|
|
|
Returns list of selected nodes filtered to just layer nodes
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
QList<QgsMapLayer *> selectedLayers() const;
|
|
|
|
%Docstring
|
2018-05-26 18:44:30 +10:00
|
|
|
Gets list of selected layers
|
2018-09-25 12:04:30 +02:00
|
|
|
%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 selectedLayers() returns an empty list.
|
|
|
|
|
|
|
|
.. versionadded:: 3.4
|
2018-01-13 18:53:05 +01:00
|
|
|
%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.
|
2018-01-17 13:08:52 +01:00
|
|
|
|
|
|
|
.. seealso:: :py:func:`removeIndicator`
|
|
|
|
|
|
|
|
.. seealso:: :py:func:`indicators`
|
2018-01-13 18:53:05 +01:00
|
|
|
|
|
|
|
.. 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.
|
2018-01-17 13:08:52 +01:00
|
|
|
|
|
|
|
.. seealso:: :py:func:`addIndicator`
|
|
|
|
|
|
|
|
.. seealso:: :py:func:`indicators`
|
2018-01-13 18:53:05 +01:00
|
|
|
|
|
|
|
.. versionadded:: 3.2
|
|
|
|
%End
|
|
|
|
|
|
|
|
QList<QgsLayerTreeViewIndicator *> indicators( QgsLayerTreeNode *node ) const;
|
|
|
|
%Docstring
|
|
|
|
Returns list of indicators associated with a particular layer tree node.
|
2018-01-17 13:08:52 +01:00
|
|
|
|
|
|
|
.. seealso:: :py:func:`addIndicator`
|
|
|
|
|
|
|
|
.. seealso:: :py:func:`removeIndicator`
|
2018-01-13 18:53:05 +01:00
|
|
|
|
|
|
|
.. versionadded:: 3.2
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2018-03-10 12:25:55 +10:00
|
|
|
|
|
|
|
|
2014-06-03 17:45:56 +07:00
|
|
|
public slots:
|
2017-05-01 18:13:15 +02:00
|
|
|
void refreshLayerSymbology( const QString &layerId );
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
|
|
|
Force refresh of layer symbology. Normally not needed as the changes of layer's renderer are monitored by the model
|
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2016-10-14 11:17:36 +08:00
|
|
|
void expandAllNodes();
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Enhancement of QTreeView.expandAll() that also records expanded state in layer tree nodes
|
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
.. versionadded:: 2.18
|
|
|
|
%End
|
2016-10-14 11:17:36 +08:00
|
|
|
|
|
|
|
void collapseAllNodes();
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Enhancement of QTreeView.collapseAll() that also records expanded state in layer tree nodes
|
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
.. versionadded:: 2.18
|
|
|
|
%End
|
2016-10-14 11:17:36 +08:00
|
|
|
|
2014-06-03 17:45:56 +07:00
|
|
|
signals:
|
2017-05-01 18:13:15 +02:00
|
|
|
void currentLayerChanged( QgsMapLayer *layer );
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
|
|
|
Emitted when a current layer is changed
|
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
|
2015-02-03 02:21:52 +01:00
|
|
|
protected:
|
2017-06-08 15:37:13 +02:00
|
|
|
virtual void contextMenuEvent( QContextMenuEvent *event );
|
|
|
|
|
2015-02-03 02:21:52 +01:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void updateExpandedStateFromNode( QgsLayerTreeNode *node );
|
2015-02-03 02:21:52 +01:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
QgsMapLayer *layerForIndex( const QModelIndex &index ) const;
|
2017-06-08 15:37:13 +02:00
|
|
|
|
|
|
|
virtual void mouseReleaseEvent( QMouseEvent *event );
|
|
|
|
|
|
|
|
virtual void keyPressEvent( QKeyEvent *event );
|
|
|
|
|
2016-01-04 22:51:18 +11:00
|
|
|
|
2017-07-07 08:54:00 +10:00
|
|
|
virtual void dropEvent( QDropEvent *event );
|
|
|
|
|
|
|
|
|
2016-01-04 22:51:18 +11:00
|
|
|
protected slots:
|
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void modelRowsInserted( const QModelIndex &index, int start, int end );
|
2016-01-04 22:51:18 +11:00
|
|
|
void modelRowsRemoved();
|
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void updateExpandedStateToNode( const QModelIndex &index );
|
2016-01-04 22:51:18 +11:00
|
|
|
|
|
|
|
void onCurrentChanged();
|
2017-05-01 18:13:15 +02:00
|
|
|
void onExpandedChanged( QgsLayerTreeNode *node, bool expanded );
|
2016-01-04 22:51:18 +11:00
|
|
|
void onModelReset();
|
2017-06-08 15:37:13 +02:00
|
|
|
|
|
|
|
protected:
|
2018-01-13 18:53:05 +01:00
|
|
|
|
2014-06-03 17:45:56 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class QgsLayerTreeViewMenuProvider
|
|
|
|
{
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Implementation of this interface can be implemented to allow QgsLayerTreeView
|
|
|
|
instance to provide custom context menus (opened upon right-click).
|
2017-06-08 15:37:13 +02:00
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:class:`QgsLayerTreeView`
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
.. versionadded:: 2.4
|
2014-06-03 17:45:56 +07:00
|
|
|
%End
|
|
|
|
|
2017-06-08 15:37:13 +02:00
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgslayertreeview.h"
|
|
|
|
%End
|
2014-06-03 17:45:56 +07:00
|
|
|
public:
|
|
|
|
virtual ~QgsLayerTreeViewMenuProvider();
|
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
virtual QMenu *createContextMenu() = 0 /Factory/;
|
2017-06-08 15:37:13 +02:00
|
|
|
%Docstring
|
2019-03-20 07:28:32 +10:00
|
|
|
Returns a newly created menu instance (or ``None`` on error)
|
2017-06-08 15:37:13 +02:00
|
|
|
%End
|
2014-05-22 01:09:14 +07:00
|
|
|
};
|
2017-06-08 15:37:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/gui/layertree/qgslayertreeview.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|