24 : QAbstractItemModel( parent )
32 for (
int i =
mSublayers.count() - 1; i >= 0; --i )
36 beginRemoveRows( QModelIndex(), i, i );
97 return createIndex( row, column );
101 return QModelIndex();
109 return QModelIndex();
133 if ( !
index.isValid() )
145 case Qt::DisplayRole:
146 case Qt::ToolTipRole:
152 return details.
name();
155 switch ( details.
type() )
162 count = tr(
"Uncounted" );
167 return QStringLiteral(
"%1 - %2 (%3)" ).arg( details.
description(),
171 return QStringLiteral(
"%2 (%3)" ).arg(
189 return details.
name();
193 case Qt::DecorationRole:
195 if (
index.column() == 0 )
210 return static_cast< int >( details.
type() );
213 return details.
uri();
216 return details.
name();
222 return details.
path();
237 return static_cast< int >( details.
flags() );
249 case Qt::DisplayRole:
250 case Qt::ToolTipRole:
256 return details.
name();
263 case Qt::DecorationRole:
265 if (
index.column() == 0 )
266 return details.
icon();
275 return details.
uri();
278 return details.
name();
284 return details.
type();
294 switch ( orientation )
302 case Qt::DisplayRole:
303 case Qt::ToolTipRole:
305 switch (
static_cast< Column>( section ) )
310 return tr(
"Description" );
353 mDescription = description;
378 return mType == other.mType
379 && mName == other.mName
380 && mDescription == other.mDescription
381 && mUri == other.mUri;
386 return !( *
this == other );
394 : QSortFilterProxyModel(
parent )
396 setDynamicSortFilter(
true );
402 const QModelIndex sourceIndex = sourceModel()->index( source_row, 0, source_parent );
407 if ( mFilterString.trimmed().isEmpty() )
417 if ( wkbTypeVariant.isValid() )
432 if ( leftIsNonLayer && !rightIsNonLayer )
434 else if ( rightIsNonLayer && !leftIsNonLayer )
440 return QString::localeAwareCompare( leftName, rightName ) < 0;
445 return mIncludeSystemTables;
450 mIncludeSystemTables = include;
456 return mFilterString;
461 mFilterString = filter;
@ SystemTable
Sublayer is a system or internal table, which should be hidden by default.
static QIcon iconForWkbType(QgsWkbTypes::Type type)
Returns the icon for a vector layer whose geometry type is provided.
static QIcon iconForLayerType(QgsMapLayerType type)
Returns the default icon for the specified layer type.
Contains details about a sub layer available from a dataset.
QString description() const
Returns the layer's description.
QStringList path() const
Returns the path to the sublayer.
long long featureCount() const
Returns the layer's feature count.
int layerNumber() const
Returns the associated layer number, for providers which order sublayers.
QgsWkbTypes::Type wkbType() const
Returns the layer's WKB type, or QgsWkbTypes::Unknown if the WKB type is not application or unknown.
QString uri() const
Returns the layer's URI.
QgsMapLayerType type() const
Returns the layer type.
QString providerKey() const
Returns the associated data provider key.
QString geometryColumnName() const
Returns the layer's geometry column name, or an empty string if not applicable.
Qgis::SublayerFlags flags() const
Returns the layer's flags, which indicate properties of the layer.
QString name() const
Returns the layer's name.
Contains details for a non-sublayer item to include in a QgsProviderSublayerModel.
void setName(const QString &name)
Sets the item's name.
void setDescription(const QString &description)
Sets the item's description.
void setType(const QString &type)
Sets the item's type.
QString type() const
Returns the item's type.
QString uri() const
Returns the item's URI.
QString name() const
Returns the item's name.
QIcon icon() const
Returns the item's icon.
bool operator!=(const QgsProviderSublayerModel::NonLayerItem &other) const
void setUri(const QString &uri)
Set the item's uri.
bool operator==(const QgsProviderSublayerModel::NonLayerItem &other) const
QString description() const
Returns the item's description.
void setIcon(const QIcon &icon)
Sets the item's icon.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QList< QgsProviderSublayerDetails > mSublayers
Sublayer list.
QList< QgsProviderSublayerDetails > sublayerDetails() const
Returns the sublayer details shown in the model.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
QgsProviderSublayerModel(QObject *parent=nullptr)
Constructor for QgsProviderSublayerModel, with the specified parent object.
QgsProviderSublayerDetails indexToSublayer(const QModelIndex &index) const
Returns the sublayer corresponding to the given index.
@ NonLayerItemType
Item type (for non-sublayer items)
@ IsNonLayerItem
true if item is a non-sublayer item (e.g. an embedded project)
@ FeatureCount
Feature count (for vector sublayers)
@ GeometryColumnName
Geometry column name (for vector sublayers)
@ Description
Layer description.
@ WkbType
WKB geometry type (for vector sublayers)
@ ProviderKey
Provider key.
@ LayerNumber
Layer number.
QgsProviderSublayerModel::NonLayerItem indexToNonLayerItem(const QModelIndex &index) const
Returns the non layer item corresponding to the given index.
void addNonLayerItem(const QgsProviderSublayerModel::NonLayerItem &item)
Adds a non-layer item (e.g.
void setSublayerDetails(const QList< QgsProviderSublayerDetails > &details)
Sets the sublayer details to show in the model.
QModelIndex parent(const QModelIndex &index) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
int rowCount(const QModelIndex &parent) const override
@ Description
Layer description.
QList< NonLayerItem > mNonLayerItems
Non layer item list.
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
bool includeSystemTables() const
Returns true if system and internal tables will be shown in the model.
void setIncludeSystemTables(bool include)
Sets whether system and internal tables will be shown in the model.
QgsProviderSublayerProxyModel(QObject *parent=nullptr)
Constructor for QgsProviderSublayerProxyModel, with the specified parent object.
QString filterString() const
Returns the filter string used for filtering items in the model.
void setFilterString(const QString &filter)
Sets the filter string used for filtering items in the model.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
Type
The WKB type describes the number of dimensions a geometry has.
static QString displayString(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
@ Uncounted
Feature count not yet computed.
@ UnknownCount
Provider returned an unknown feature count.
@ PointCloudLayer
Point cloud layer. Added in QGIS 3.18.
@ MeshLayer
Mesh layer. Added in QGIS 3.2.
@ VectorLayer
Vector layer.
@ RasterLayer
Raster layer.
@ GroupLayer
Composite group layer. Added in QGIS 3.24.
@ VectorTileLayer
Vector tile layer. Added in QGIS 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ PluginLayer
Plugin based layer.