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(
188 return details.
name();
192 case Qt::DecorationRole:
194 if (
index.column() == 0 )
209 return static_cast< int >( details.
type() );
212 return details.
uri();
215 return details.
name();
221 return details.
path();
236 return static_cast< int >( details.
flags() );
248 case Qt::DisplayRole:
249 case Qt::ToolTipRole:
255 return details.
name();
262 case Qt::DecorationRole:
264 if (
index.column() == 0 )
265 return details.
icon();
274 return details.
uri();
277 return details.
name();
283 return details.
type();
293 switch ( orientation )
301 case Qt::DisplayRole:
302 case Qt::ToolTipRole:
304 switch (
static_cast< Column>( section ) )
309 return tr(
"Description" );
352 mDescription = description;
377 return mType == other.mType
378 && mName == other.mName
379 && mDescription == other.mDescription
380 && mUri == other.mUri;
385 return !( *
this == other );
393 : QSortFilterProxyModel(
parent )
395 setDynamicSortFilter(
true );
401 const QModelIndex sourceIndex = sourceModel()->index( source_row, 0, source_parent );
406 if ( mFilterString.trimmed().isEmpty() )
416 if ( wkbTypeVariant.isValid() )
431 if ( leftIsNonLayer && !rightIsNonLayer )
433 else if ( rightIsNonLayer && !leftIsNonLayer )
439 return QString::localeAwareCompare( leftName, rightName ) < 0;
444 return mIncludeSystemTables;
449 mIncludeSystemTables = include;
455 return mFilterString;
460 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
Added in 3.18.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.