QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
browser
qgsbrowserproxymodel.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsbrowserproxymodel.h
3
---------------------
4
begin : October 2018
5
copyright : (C) 2018 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
#ifndef QGSBROWSERPROXYMODEL_H
16
#define QGSBROWSERPROXYMODEL_H
17
18
#include "
qgis.h
"
19
#include "qgis_core.h"
20
#include "
qgis_sip.h
"
21
22
#include <QSortFilterProxyModel>
23
24
class
QgsBrowserModel
;
25
class
QgsDataItem
;
26
33
class
CORE_EXPORT
QgsBrowserProxyModel
:
public
QSortFilterProxyModel
34
{
35
Q_OBJECT
36
public
:
38
enum
FilterSyntax
39
{
40
Normal
,
41
Wildcards
,
42
RegularExpression
,
43
};
44
48
explicit
QgsBrowserProxyModel
( QObject *parent
SIP_TRANSFERTHIS
=
nullptr
);
49
55
void
setBrowserModel(
QgsBrowserModel
*model );
56
62
QgsBrowserModel
*
browserModel
() {
return
mModel
; }
63
68
QgsDataItem
*dataItem(
const
QModelIndex &index )
const
;
69
75
void
setFilterSyntax( FilterSyntax syntax );
76
82
FilterSyntax filterSyntax()
const
;
83
89
void
setFilterString(
const
QString &filter );
90
96
QString filterString()
const
;
97
103
void
setFilterCaseSensitivity( Qt::CaseSensitivity sensitivity );
104
110
Qt::CaseSensitivity caseSensitivity()
const
;
111
118
bool
filterByLayerType
()
const
{
return
mFilterByLayerType; }
119
126
void
setFilterByLayerType(
bool
enabled );
127
135
Qgis::LayerType
layerType()
const
;
136
144
void
setLayerType(
Qgis::LayerType
type );
145
162
void
setHiddenDataItemProviderKeyFilter(
const
QStringList &hiddenItemsFilter );
163
180
void
setShownDataItemProviderKeyFilter(
const
QStringList &shownItemsFilter );
181
188
bool
showLayers()
const
;
189
196
void
setShowLayers(
bool
showLayers );
197
198
protected
:
199
// It would be better to apply the filer only to expanded (visible) items, but using mapFromSource() + view here was causing strange errors
200
bool
filterAcceptsRow(
int
sourceRow,
const
QModelIndex &sourceParent )
const override
;
201
205
QgsBrowserModel
*
mModel
=
nullptr
;
206
207
private
:
208
QStringList mHiddenDataItemsKeys;
209
QStringList mShownDataItemsKeys;
210
QString mFilter;
//filter string provided
211
QVector<QRegularExpression> mREList;
//list of filters, separated by "|"
212
FilterSyntax
mPatternSyntax =
Normal
;
213
Qt::CaseSensitivity mCaseSensitivity = Qt::CaseInsensitive;
214
215
bool
mFilterByLayerType =
false
;
216
bool
mShowLayers =
true
;
217
Qgis::LayerType
mLayerType =
Qgis::LayerType::Vector
;
218
220
void
updateFilter();
221
223
bool
filterAcceptsString(
const
QString &value )
const
;
224
226
bool
filterAcceptsAncestor(
const
QModelIndex &sourceIndex )
const
;
227
229
bool
filterAcceptsDescendant(
const
QModelIndex &sourceIndex )
const
;
230
232
bool
filterAcceptsItem(
const
QModelIndex &sourceIndex )
const
;
233
235
bool
filterAcceptsProviderKey(
const
QModelIndex &sourceIndex )
const
;
236
238
bool
filterRootAcceptsProviderKey(
const
QModelIndex &sourceIndex )
const
;
239
240
241
// QAbstractItemModel interface
242
public
:
243
bool
hasChildren
(
const
QModelIndex &parent = QModelIndex() )
const override
;
244
};
245
246
#endif
// QGSBROWSERPROXYMODEL_H
Qgis::LayerType
LayerType
Types of layers that can be added to a map.
Definition
qgis.h:206
Qgis::LayerType::Vector
@ Vector
Vector layer.
Definition
qgis.h:207
QgsBrowserModel
A model for showing available data sources and other items in a structured tree.
Definition
qgsbrowsermodel.h:53
QgsBrowserProxyModel
A QSortFilterProxyModel subclass for filtering and sorting browser model items.
Definition
qgsbrowserproxymodel.h:34
QgsBrowserProxyModel::FilterSyntax
FilterSyntax
Filter syntax options.
Definition
qgsbrowserproxymodel.h:39
QgsBrowserProxyModel::RegularExpression
@ RegularExpression
Regular expression filtering.
Definition
qgsbrowserproxymodel.h:42
QgsBrowserProxyModel::Wildcards
@ Wildcards
Wildcard filtering.
Definition
qgsbrowserproxymodel.h:41
QgsBrowserProxyModel::Normal
@ Normal
Standard string filtering.
Definition
qgsbrowserproxymodel.h:40
QgsBrowserProxyModel::browserModel
QgsBrowserModel * browserModel()
Returns the underlying browser model.
Definition
qgsbrowserproxymodel.h:62
QgsBrowserProxyModel::hasChildren
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
Definition
qgsbrowserproxymodel.cpp:297
QgsBrowserProxyModel::QgsBrowserProxyModel
QgsBrowserProxyModel(QObject *parent=nullptr)
Constructor for QgsBrowserProxyModel, with the specified parent object.
Definition
qgsbrowserproxymodel.cpp:29
QgsBrowserProxyModel::filterByLayerType
bool filterByLayerType() const
Returns true if the model is filtered by map layer type.
Definition
qgsbrowserproxymodel.h:118
QgsBrowserProxyModel::mModel
QgsBrowserModel * mModel
Reference to associated browser model.
Definition
qgsbrowserproxymodel.h:205
QgsDataItem
Base class for all items in the model.
Definition
qgsdataitem.h:50
qgis.h
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
Generated on
for QGIS API Documentation by
1.17.0