QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
layertree
qgslayertreefilterproxymodel.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgslayertreefilterproxymodel.h
3
4
---------------------
5
begin : 05.06.2020
6
copyright : (C) 2020 by Denis Rouzaud
7
email : denis@opengis.ch
8
***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
17
#ifndef QGSLAYERTREEFILTERPROXYMODEL_H
18
#define QGSLAYERTREEFILTERPROXYMODEL_H
19
20
#include "qgis_core.h"
21
#include "
qgsmaplayer.h
"
22
#include "
qgsmaplayerproxymodel.h
"
23
24
#include <QSortFilterProxyModel>
25
26
class
QgsLayerTreeModel
;
27
class
QgsLayerTreeNode
;
28
41
class
CORE_EXPORT
QgsLayerTreeFilterProxyModel
:
public
QSortFilterProxyModel
42
{
43
Q_OBJECT
44
public
:
46
QgsLayerTreeFilterProxyModel
( QObject *
parent
=
nullptr
);
47
52
void
setCheckedLayers
(
const
QList<QgsMapLayer *> layers );
53
55
QList<QgsMapLayer *>
checkedLayers
()
const
{
return
mCheckedLayers; }
56
58
QgsMapLayer
*mapLayer(
const
QModelIndex &idx )
const
;
59
61
QgsLayerTreeModel
*layerTreeModel()
const
;
63
void
setLayerTreeModel(
QgsLayerTreeModel
*layerTreeModel );
64
72
bool
showPrivateLayers()
const
;
73
81
void
setShowPrivateLayers(
bool
showPrivate );
82
87
void
setFilters(
Qgis::LayerFilters
filters );
88
89
int
columnCount(
const
QModelIndex &parent )
const override
;
90
Qt::ItemFlags flags(
const
QModelIndex &idx )
const override
;
91
QModelIndex index(
int
row,
int
column,
const
QModelIndex &parent = QModelIndex() )
const override
;
92
QModelIndex parent(
const
QModelIndex &child )
const override
;
93
QModelIndex sibling(
int
row,
int
column,
const
QModelIndex &idx )
const override
;
94
QVariant data(
const
QModelIndex &index,
int
role )
const override
;
95
bool
setData(
const
QModelIndex &index,
const
QVariant &value,
int
role )
override
;
96
102
bool
nodeShown(
QgsLayerTreeNode
*node )
const
;
103
104
public
slots:
106
virtual
void
setFilterText(
const
QString &filterText = QString() );
107
108
protected
:
110
virtual
bool
isLayerChecked(
QgsMapLayer
*layer )
const
;
111
113
virtual
void
setLayerChecked(
QgsMapLayer
*layer,
bool
checked );
114
115
bool
filterAcceptsRow(
int
sourceRow,
const
QModelIndex &sourceParent )
const override
;
116
117
private
:
122
virtual
bool
layerShown(
QgsMapLayer
*layer )
const
;
123
125
void
setLayerCheckedPrivate(
QgsMapLayer
*layer,
bool
checked );
126
127
QgsLayerTreeModel
*mLayerTreeModel =
nullptr
;
128
QList<QgsMapLayer *> mCheckedLayers;
129
QString mFilterText;
130
// for compatibility this defaults to true
131
bool
mShowPrivateLayers =
true
;
132
Qgis::LayerFilters
mFilters =
Qgis::LayerFilter::All
;
133
};
134
135
#endif
// QGSLAYERTREEFILTERPROXYMODEL_H
Qgis::LayerFilter::All
@ All
All layers.
Definition
qgis.h:240
Qgis::LayerFilters
QFlags< LayerFilter > LayerFilters
Definition
qgis.h:243
QgsLayerTreeFilterProxyModel::checkedLayers
QList< QgsMapLayer * > checkedLayers() const
Returns the checked layers.
Definition
qgslayertreefilterproxymodel.h:55
QgsLayerTreeFilterProxyModel::setCheckedLayers
void setCheckedLayers(const QList< QgsMapLayer * > layers)
Initialize the list of checked layers.
Definition
qgslayertreefilterproxymodel.cpp:39
QgsLayerTreeFilterProxyModel::parent
QModelIndex parent(const QModelIndex &child) const override
Definition
qgslayertreefilterproxymodel.cpp:71
QgsLayerTreeFilterProxyModel::QgsLayerTreeFilterProxyModel
QgsLayerTreeFilterProxyModel(QObject *parent=nullptr)
Constructor.
Definition
qgslayertreefilterproxymodel.cpp:25
QgsLayerTreeModel
A model representing the layer tree, including layers and groups of layers.
Definition
qgslayertreemodel.h:61
QgsLayerTreeNode
Base class for nodes in a layer tree.
Definition
qgslayertreenode.h:81
QgsMapLayer
Base class for all map layer types.
Definition
qgsmaplayer.h:83
qgsmaplayer.h
qgsmaplayerproxymodel.h
Generated on
for QGIS API Documentation by
1.17.0