QGIS API Documentation 3.41.0-Master (cea29feecf2)
|
QgsLayerTreeFilterProxyModel is a sort filter proxy model to easily reproduce the legend/layer tree in a tree view. More...
#include <qgslayertreefilterproxymodel.h>
Public Slots | |
virtual void | setFilterText (const QString &filterText=QString()) |
Sets the filter text to search for a layer in the tree. | |
Public Member Functions | |
QgsLayerTreeFilterProxyModel (QObject *parent=nullptr) | |
Constructor. | |
QList< QgsMapLayer * > | checkedLayers () const |
Returns the checked layers. | |
virtual int | columnCount (const QModelIndex &parent) const override |
virtual QVariant | data (const QModelIndex &index, int role) const override |
virtual Qt::ItemFlags | flags (const QModelIndex &idx) const override |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
QgsLayerTreeModel * | layerTreeModel () const |
Rerturns the layer tree model. | |
QgsMapLayer * | mapLayer (const QModelIndex &idx) const |
Returns the map layer at a given index. | |
bool | nodeShown (QgsLayerTreeNode *node) const |
Returns true if the specified node will be shown in the model. | |
QModelIndex | parent (const QModelIndex &child) const override |
void | setCheckedLayers (const QList< QgsMapLayer * > layers) |
Initialize the list of checked layers. | |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
void | setFilters (Qgis::LayerFilters filters) |
Defines the type layers (vector, raster, etc) shown in the tree If the list is empty, all types are shown. | |
void | setLayerTreeModel (QgsLayerTreeModel *layerTreeModel) |
Sets the layer tree model. | |
void | setShowPrivateLayers (bool showPrivate) |
Determines if private layers are shown. | |
bool | showPrivateLayers () const |
Returns if private layers are shown. | |
QModelIndex | sibling (int row, int column, const QModelIndex &idx) const override |
Protected Member Functions | |
bool | filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override |
virtual bool | isLayerChecked (QgsMapLayer *layer) const |
Returns if the layer is checked or not. | |
virtual void | setLayerChecked (QgsMapLayer *layer, bool checked) |
This will set if the layer is checked or not. | |
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. Layers can be filtered by their type.
For more complex use-cases, the model can be re-implemented to allow a different interaction or to add more columns.
Definition at line 41 of file qgslayertreefilterproxymodel.h.
QgsLayerTreeFilterProxyModel::QgsLayerTreeFilterProxyModel | ( | QObject * | parent = nullptr | ) |
Constructor.
Definition at line 24 of file qgslayertreefilterproxymodel.cpp.
|
inline |
Returns the checked layers.
Definition at line 55 of file qgslayertreefilterproxymodel.h.
|
overridevirtual |
Definition at line 42 of file qgslayertreefilterproxymodel.cpp.
|
overridevirtual |
Definition at line 209 of file qgslayertreefilterproxymodel.cpp.
|
overrideprotected |
Definition at line 131 of file qgslayertreefilterproxymodel.cpp.
|
overridevirtual |
Definition at line 48 of file qgslayertreefilterproxymodel.cpp.
|
override |
Definition at line 57 of file qgslayertreefilterproxymodel.cpp.
|
protectedvirtual |
Returns if the layer is checked or not.
Definition at line 137 of file qgslayertreefilterproxymodel.cpp.
QgsLayerTreeModel * QgsLayerTreeFilterProxyModel::layerTreeModel | ( | ) | const |
Rerturns the layer tree model.
Definition at line 100 of file qgslayertreefilterproxymodel.cpp.
QgsMapLayer * QgsLayerTreeFilterProxyModel::mapLayer | ( | const QModelIndex & | idx | ) | const |
Returns the map layer at a given index.
Definition at line 77 of file qgslayertreefilterproxymodel.cpp.
bool QgsLayerTreeFilterProxyModel::nodeShown | ( | QgsLayerTreeNode * | node | ) | const |
Returns true
if the specified node will be shown in the model.
Definition at line 175 of file qgslayertreefilterproxymodel.cpp.
|
override |
Definition at line 66 of file qgslayertreefilterproxymodel.cpp.
void QgsLayerTreeFilterProxyModel::setCheckedLayers | ( | const QList< QgsMapLayer * > | layers | ) |
Initialize the list of checked layers.
Definition at line 34 of file qgslayertreefilterproxymodel.cpp.
|
overridevirtual |
Definition at line 277 of file qgslayertreefilterproxymodel.cpp.
void QgsLayerTreeFilterProxyModel::setFilters | ( | Qgis::LayerFilters | filters | ) |
Defines the type layers (vector, raster, etc) shown in the tree If the list is empty, all types are shown.
Definition at line 125 of file qgslayertreefilterproxymodel.cpp.
|
virtualslot |
Sets the filter text to search for a layer in the tree.
Definition at line 91 of file qgslayertreefilterproxymodel.cpp.
|
protectedvirtual |
This will set if the layer is checked or not.
Definition at line 142 of file qgslayertreefilterproxymodel.cpp.
void QgsLayerTreeFilterProxyModel::setLayerTreeModel | ( | QgsLayerTreeModel * | layerTreeModel | ) |
Sets the layer tree model.
Definition at line 105 of file qgslayertreefilterproxymodel.cpp.
void QgsLayerTreeFilterProxyModel::setShowPrivateLayers | ( | bool | showPrivate | ) |
Determines if private layers are shown.
Defaults to true
.
Definition at line 116 of file qgslayertreefilterproxymodel.cpp.
bool QgsLayerTreeFilterProxyModel::showPrivateLayers | ( | ) | const |
Returns if private layers are shown.
Defaults to true
.
Definition at line 111 of file qgslayertreefilterproxymodel.cpp.
|
override |
Definition at line 71 of file qgslayertreefilterproxymodel.cpp.