Skip to content
Permalink
Browse files

add QgsLayerTreeFilterProxyModel to easily use a layer tree

  • Loading branch information
3nids committed Jun 5, 2020
1 parent 37bd3ae commit 3322d2bb6451c627409ae89e352b0c57d14f3f39
@@ -0,0 +1,109 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layertree/qgslayertreefilterproxymodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsLayerTreeFilterProxyModel : QSortFilterProxyModel
{
%Docstring
QgsLayerTreeFilterProxyModel is a sort filter proxy model to easily reproduce the legend/layer tree in a tree view.
Layers are checkable by default.
Symbology nodes will not be shown.

This model can be re-implemented to add more columns.

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgslayertreefilterproxymodel.h"
%End
public:
QgsLayerTreeFilterProxyModel( QObject *parent = 0 );

void setCheckedLayers( const QList<QgsMapLayer *> layers );
%Docstring
Initialize the list of checked layers.

.. note::

If the model is re-implemented, this method might become useless
%End

QList<QgsMapLayer *> checkedLayers() const;
%Docstring
Returns the checked layers
%End

QgsMapLayer *mapLayer( const QModelIndex &idx ) const;
%Docstring
Returns the map layer at a given index
%End

QgsLayerTreeModel *layerTreeModel() const;
%Docstring
Rerturns the layer tree model
%End
void setLayerTreeModel( QgsLayerTreeModel *layerTreeModel );
%Docstring
Sets the layer tree model
%End

void resetLayerTreeModel();
%Docstring
This will refresh the model
%End

void setMapLayerTypeFilter( const QList<QgsMapLayerType> &types = QList<QgsMapLayerType>() );
%Docstring
Defines the type layers (vector, raster, etc) shown in the tree
If the list is empty, all types are shown.
%End

virtual int columnCount( const QModelIndex &parent ) const;
virtual Qt::ItemFlags flags( const QModelIndex &idx ) const;
virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;

virtual QModelIndex parent( const QModelIndex &child ) const;

virtual QModelIndex sibling( int row, int column, const QModelIndex &idx ) const;

virtual QVariant data( const QModelIndex &index, int role ) const;
virtual bool setData( const QModelIndex &index, const QVariant &value, int role );

public slots:
virtual void setFilterText( const QString &filterText = QString() );
%Docstring
Sets the filter text to search for a layer in the tree
%End

protected:
virtual bool isLayerChecked( QgsMapLayer *layer ) const;
%Docstring
Returns if the layer is checked or not
%End

virtual void setLayerChecked( QgsMapLayer *layer, bool checked );
%Docstring
This will set if the layer is checked or not
%End

virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;


};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/layertree/qgslayertreefilterproxymodel.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -348,6 +348,7 @@
%Include auto_generated/layertree/qgslayertreemodellegendnode.sip
%Include auto_generated/layertree/qgslayertreenode.sip
%Include auto_generated/layertree/qgslayertreeregistrybridge.sip
%Include auto_generated/layertree/qgslayertreefilterproxymodel.sip
%Include auto_generated/layertree/qgslayertreeutils.sip
%Include auto_generated/layertree/qgslegendpatchshape.sip
%Include auto_generated/layout/qgsabstractlayoutiterator.sip
@@ -96,6 +96,7 @@ SET(QGIS_CORE_SRCS
layertree/qgslayertreemodellegendnode.cpp
layertree/qgslayertreenode.cpp
layertree/qgslayertreeregistrybridge.cpp
layertree/qgslayertreefilterproxymodel.cpp
layertree/qgslayertreeutils.cpp
layertree/qgslayertree.cpp
layertree/qgslegendpatchshape.cpp
@@ -1152,6 +1153,7 @@ SET(QGIS_CORE_HDRS
layertree/qgslayertreemodellegendnode.h
layertree/qgslayertreenode.h
layertree/qgslayertreeregistrybridge.h
layertree/qgslayertreefilterproxymodel.h
layertree/qgslayertreeutils.h
layertree/qgslegendpatchshape.h

0 comments on commit 3322d2b

Please sign in to comment.
You can’t perform that action at this time.