QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsBrowserProxyModel Class Reference

A QSortFilterProxyModel subclass for filtering and sorting browser model items. More...

#include <qgsbrowserproxymodel.h>

Inheritance diagram for QgsBrowserProxyModel:
Inheritance graph
[legend]

Public Types

enum  FilterSyntax { Normal , Wildcards , RegularExpression }
 Filter syntax options. More...
 

Public Member Functions

 QgsBrowserProxyModel (QObject *parent=nullptr)
 Constructor for QgsBrowserProxyModel, with the specified parent object. More...
 
QgsBrowserModelbrowserModel ()
 Returns the underlying browser model. More...
 
Qt::CaseSensitivity caseSensitivity () const
 Returns whether item filtering is case sensitive. More...
 
QgsDataItemdataItem (const QModelIndex &index) const
 Returns the data item at the specified proxy index, or nullptr if no item exists at the index. More...
 
bool filterByLayerType () const
 Returns true if the model is filtered by map layer type. More...
 
QString filterString () const
 Returns the filter string used when filtering items in the model. More...
 
FilterSyntax filterSyntax () const
 Returns the filter syntax. More...
 
bool hasChildren (const QModelIndex &parent=QModelIndex()) const override
 
Qgis::LayerType layerType () const
 Returns the layer type to filter the model by. More...
 
void setBrowserModel (QgsBrowserModel *model)
 Sets the underlying browser model. More...
 
void setFilterByLayerType (bool enabled)
 Sets whether the model is filtered by map layer type. More...
 
void setFilterCaseSensitivity (Qt::CaseSensitivity sensitivity)
 Sets whether item filtering should be case sensitive. More...
 
void setFilterString (const QString &filter)
 Sets the filter string to use when filtering items in the model. More...
 
void setFilterSyntax (FilterSyntax syntax)
 Sets the filter syntax. More...
 
void setHiddenDataItemProviderKeyFilter (const QStringList &hiddenItemsFilter)
 Sets a filter to hide data items based on QgsDataItem::providerKey() associated with the item. More...
 
void setLayerType (Qgis::LayerType type)
 Sets the layer type to filter the model by. More...
 
void setShowLayers (bool showLayers)
 Sets show layers to showLayers. More...
 
void setShownDataItemProviderKeyFilter (const QStringList &shownItemsFilter)
 Sets a filter to show data items based on QgsDataItem::providerKey() associated with the item. More...
 
bool showLayers () const
 Returns true if layers must be shown, this flag is TRUE by default. More...
 

Protected Member Functions

bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override
 

Protected Attributes

QgsBrowserModelmModel = nullptr
 Reference to associated browser model. More...
 

Detailed Description

A QSortFilterProxyModel subclass for filtering and sorting browser model items.

Since
QGIS 3.4

Definition at line 32 of file qgsbrowserproxymodel.h.

Member Enumeration Documentation

◆ FilterSyntax

Filter syntax options.

Enumerator
Normal 

Standard string filtering.

Wildcards 

Wildcard filtering.

RegularExpression 

Regular expression filtering.

Definition at line 38 of file qgsbrowserproxymodel.h.

Constructor & Destructor Documentation

◆ QgsBrowserProxyModel()

QgsBrowserProxyModel::QgsBrowserProxyModel ( QObject *  parent = nullptr)
explicit

Constructor for QgsBrowserProxyModel, with the specified parent object.

Definition at line 23 of file qgsbrowserproxymodel.cpp.

Member Function Documentation

◆ browserModel()

QgsBrowserModel * QgsBrowserProxyModel::browserModel ( )
inline

Returns the underlying browser model.

See also
setBrowserModel()

Definition at line 62 of file qgsbrowserproxymodel.h.

◆ caseSensitivity()

Qt::CaseSensitivity QgsBrowserProxyModel::caseSensitivity ( ) const

Returns whether item filtering is case sensitive.

See also
setFilterCaseSensitivity()

Definition at line 76 of file qgsbrowserproxymodel.cpp.

◆ dataItem()

QgsDataItem * QgsBrowserProxyModel::dataItem ( const QModelIndex &  index) const

Returns the data item at the specified proxy index, or nullptr if no item exists at the index.

Definition at line 38 of file qgsbrowserproxymodel.cpp.

◆ filterAcceptsRow()

bool QgsBrowserProxyModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
overrideprotected

Definition at line 129 of file qgsbrowserproxymodel.cpp.

◆ filterByLayerType()

bool QgsBrowserProxyModel::filterByLayerType ( ) const
inline

Returns true if the model is filtered by map layer type.

See also
layerType()
setFilterByLayerType()

Definition at line 118 of file qgsbrowserproxymodel.h.

◆ filterString()

QString QgsBrowserProxyModel::filterString ( ) const

Returns the filter string used when filtering items in the model.

See also
setFilterString()

Definition at line 65 of file qgsbrowserproxymodel.cpp.

◆ filterSyntax()

QgsBrowserProxyModel::FilterSyntax QgsBrowserProxyModel::filterSyntax ( ) const

Returns the filter syntax.

See also
setFilterSyntax()

Definition at line 52 of file qgsbrowserproxymodel.cpp.

◆ hasChildren()

bool QgsBrowserProxyModel::hasChildren ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 278 of file qgsbrowserproxymodel.cpp.

◆ layerType()

Qgis::LayerType QgsBrowserProxyModel::layerType ( ) const

Returns the layer type to filter the model by.

This is only used if filterByLayerType() is true.

See also
setLayerType()
filterByLayerType()

Definition at line 160 of file qgsbrowserproxymodel.cpp.

◆ setBrowserModel()

void QgsBrowserProxyModel::setBrowserModel ( QgsBrowserModel model)

Sets the underlying browser model.

See also
browserModel()

Definition at line 32 of file qgsbrowserproxymodel.cpp.

◆ setFilterByLayerType()

void QgsBrowserProxyModel::setFilterByLayerType ( bool  enabled)

Sets whether the model is filtered by map layer type.

See also
filterByLayerType()
setLayerType()

Definition at line 171 of file qgsbrowserproxymodel.cpp.

◆ setFilterCaseSensitivity()

void QgsBrowserProxyModel::setFilterCaseSensitivity ( Qt::CaseSensitivity  sensitivity)

Sets whether item filtering should be case sensitive.

See also
caseSensitivity()

Definition at line 70 of file qgsbrowserproxymodel.cpp.

◆ setFilterString()

void QgsBrowserProxyModel::setFilterString ( const QString &  filter)

Sets the filter string to use when filtering items in the model.

See also
filterString()

Definition at line 57 of file qgsbrowserproxymodel.cpp.

◆ setFilterSyntax()

void QgsBrowserProxyModel::setFilterSyntax ( FilterSyntax  syntax)

Sets the filter syntax.

See also
filterSyntax()

Definition at line 44 of file qgsbrowserproxymodel.cpp.

◆ setHiddenDataItemProviderKeyFilter()

void QgsBrowserProxyModel::setHiddenDataItemProviderKeyFilter ( const QStringList &  hiddenItemsFilter)

Sets a filter to hide data items based on QgsDataItem::providerKey() associated with the item.

By default browser model shows all items from all available data item providers and few special items (e.g. Favorites). To customize the behavior, set the filter to not load certain data items. The items that are not based on data item providers have prefix "special:", for example "special:Favorites", "special:Home", "PostGIS", "MSSQL"

All items created by the providers listed in filter are hidden from the layer tree. This filter is always evaluated.

Parameters
hiddenItemsFiltera list of data provider prefixes that will be hidden.
Since
QGIS 3.12

Definition at line 265 of file qgsbrowserproxymodel.cpp.

◆ setLayerType()

void QgsBrowserProxyModel::setLayerType ( Qgis::LayerType  type)

Sets the layer type to filter the model by.

This is only used if filterByLayerType() is true.

See also
layerType()
setFilterByLayerType()

Definition at line 165 of file qgsbrowserproxymodel.cpp.

◆ setShowLayers()

void QgsBrowserProxyModel::setShowLayers ( bool  showLayers)

Sets show layers to showLayers.

See also
showLayers()
Since
QGIS 3.14

Definition at line 155 of file qgsbrowserproxymodel.cpp.

◆ setShownDataItemProviderKeyFilter()

void QgsBrowserProxyModel::setShownDataItemProviderKeyFilter ( const QStringList &  shownItemsFilter)

Sets a filter to show data items based on QgsDataItem::providerKey() associated with the item.

By default browser model shows all items from all available data item providers and few special items (e.g. Favorites). To customize the behavior, set the filter to load only certain data items. The items that are not based on data item providers have prefix "special:", for example "special:Favorites", "special:Home", "PostGIS", "MSSQL"

Only the items created by the providers listed in filter are shown in the layer tree. This filter is always evaluated.

Parameters
shownItemsFiltera list of data provider prefixes that will be hidden.
Since
QGIS 3.14

Definition at line 271 of file qgsbrowserproxymodel.cpp.

◆ showLayers()

bool QgsBrowserProxyModel::showLayers ( ) const

Returns true if layers must be shown, this flag is TRUE by default.

See also
setShowLayers()
Since
QGIS 3.14

Definition at line 150 of file qgsbrowserproxymodel.cpp.

Member Data Documentation

◆ mModel

QgsBrowserModel* QgsBrowserProxyModel::mModel = nullptr
protected

Reference to associated browser model.

Definition at line 206 of file qgsbrowserproxymodel.h.


The documentation for this class was generated from the following files: