QGIS API Documentation  3.24.2-Tisler (13c1a02865)
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
QgsProviderSublayerModel Class Reference

A model for representing the sublayers present in a URI. More...

#include <qgsprovidersublayermodel.h>

Inheritance diagram for QgsProviderSublayerModel:
Inheritance graph
[legend]

Classes

class  NonLayerItem
 Contains details for a non-sublayer item to include in a QgsProviderSublayerModel. More...
 

Public Types

enum class  Column : int { Name = 0 , Description = 1 }
 Model columns. More...
 
enum class  Role : int {
  ProviderKey = Qt::UserRole + 1 , LayerType , Uri , Name ,
  Description , Path , FeatureCount , WkbType ,
  GeometryColumnName , LayerNumber , IsNonLayerItem , NonLayerItemType ,
  Flags
}
 Custom model roles. More...
 

Public Member Functions

 QgsProviderSublayerModel (QObject *parent=nullptr)
 Constructor for QgsProviderSublayerModel, with the specified parent object. More...
 
void addNonLayerItem (const QgsProviderSublayerModel::NonLayerItem &item)
 Adds a non-layer item (e.g. More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QgsProviderSublayerModel::NonLayerItem indexToNonLayerItem (const QModelIndex &index) const
 Returns the non layer item corresponding to the given index. More...
 
QgsProviderSublayerDetails indexToSublayer (const QModelIndex &index) const
 Returns the sublayer corresponding to the given index. More...
 
QModelIndex parent (const QModelIndex &index) const override
 
int rowCount (const QModelIndex &parent) const override
 
void setSublayerDetails (const QList< QgsProviderSublayerDetails > &details)
 Sets the sublayer details to show in the model. More...
 
QList< QgsProviderSublayerDetailssublayerDetails () const
 Returns the sublayer details shown in the model. More...
 

Protected Attributes

QList< NonLayerItemmNonLayerItems
 Non layer item list. More...
 
QList< QgsProviderSublayerDetailsmSublayers
 Sublayer list. More...
 

Detailed Description

A model for representing the sublayers present in a URI.

QgsProviderSublayerModel is designed to present a tree view of the sublayers available for a URI, including any vector, raster or mesh sublayers present.

Additionally, QgsProviderSublayerModel can include some non-sublayer items, e.g. in order to represent other content available for a URI, such as embedded project items. The non-sublayer items can be added by calling addNonLayerItem().

Since
QGIS 3.22

Definition at line 42 of file qgsprovidersublayermodel.h.

Member Enumeration Documentation

◆ Column

Model columns.

Enumerator
Name 

Layer name.

Description 

Layer description.

Definition at line 67 of file qgsprovidersublayermodel.h.

◆ Role

enum QgsProviderSublayerModel::Role : int
strong

Custom model roles.

Enumerator
ProviderKey 

Provider key.

LayerType 

Layer type.

Uri 

Layer URI.

Name 

Layer name.

Description 

Layer description.

Path 

Layer path.

FeatureCount 

Feature count (for vector sublayers)

WkbType 

WKB geometry type (for vector sublayers)

GeometryColumnName 

Geometry column name (for vector sublayers)

LayerNumber 

Layer number.

IsNonLayerItem 

true if item is a non-sublayer item (e.g. an embedded project)

NonLayerItemType 

Item type (for non-sublayer items)

Flags 

Sublayer flags.

Definition at line 49 of file qgsprovidersublayermodel.h.

Constructor & Destructor Documentation

◆ QgsProviderSublayerModel()

QgsProviderSublayerModel::QgsProviderSublayerModel ( QObject *  parent = nullptr)

Constructor for QgsProviderSublayerModel, with the specified parent object.

Definition at line 23 of file qgsprovidersublayermodel.cpp.

Member Function Documentation

◆ addNonLayerItem()

void QgsProviderSublayerModel::addNonLayerItem ( const QgsProviderSublayerModel::NonLayerItem item)

Adds a non-layer item (e.g.

an embedded QGIS project item) to the model.

Definition at line 79 of file qgsprovidersublayermodel.cpp.

◆ columnCount()

int QgsProviderSublayerModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 112 of file qgsprovidersublayermodel.cpp.

◆ data()

QVariant QgsProviderSublayerModel::data ( const QModelIndex &  index,
int  role 
) const
override

Definition at line 131 of file qgsprovidersublayermodel.cpp.

◆ headerData()

QVariant QgsProviderSublayerModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

Definition at line 292 of file qgsprovidersublayermodel.cpp.

◆ index()

QModelIndex QgsProviderSublayerModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

Definition at line 86 of file qgsprovidersublayermodel.cpp.

◆ indexToNonLayerItem()

QgsProviderSublayerModel::NonLayerItem QgsProviderSublayerModel::indexToNonLayerItem ( const QModelIndex &  index) const

Returns the non layer item corresponding to the given index.

Definition at line 69 of file qgsprovidersublayermodel.cpp.

◆ indexToSublayer()

QgsProviderSublayerDetails QgsProviderSublayerModel::indexToSublayer ( const QModelIndex &  index) const

Returns the sublayer corresponding to the given index.

Definition at line 59 of file qgsprovidersublayermodel.cpp.

◆ parent()

QModelIndex QgsProviderSublayerModel::parent ( const QModelIndex &  index) const
override

Definition at line 104 of file qgsprovidersublayermodel.cpp.

◆ rowCount()

int QgsProviderSublayerModel::rowCount ( const QModelIndex &  parent) const
override

Definition at line 118 of file qgsprovidersublayermodel.cpp.

◆ setSublayerDetails()

void QgsProviderSublayerModel::setSublayerDetails ( const QList< QgsProviderSublayerDetails > &  details)

Sets the sublayer details to show in the model.

See also
sublayerDetails()

Definition at line 29 of file qgsprovidersublayermodel.cpp.

◆ sublayerDetails()

QList< QgsProviderSublayerDetails > QgsProviderSublayerModel::sublayerDetails ( ) const

Returns the sublayer details shown in the model.

See also
setSublayerDetails()

Definition at line 54 of file qgsprovidersublayermodel.cpp.

Member Data Documentation

◆ mNonLayerItems

QList<NonLayerItem> QgsProviderSublayerModel::mNonLayerItems
protected

Non layer item list.

Definition at line 212 of file qgsprovidersublayermodel.h.

◆ mSublayers

QList<QgsProviderSublayerDetails> QgsProviderSublayerModel::mSublayers
protected

Sublayer list.

Definition at line 209 of file qgsprovidersublayermodel.h.


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