QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsprovidersublayermodel.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprovidersublayermodel.cpp
3 ----------------------
4 begin : June 2021
5 copyright : (C) 2021 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
20#include "qgsiconutils.h"
21#include "qgsapplication.h"
22#include <QLocale>
23
24//
25// QgsProviderSublayerModelNode
26//
27
29QgsProviderSublayerModelNode::~QgsProviderSublayerModelNode() = default;
30
31void QgsProviderSublayerModelGroup::populateFromSublayers( const QList<QgsProviderSublayerDetails> &sublayers )
32{
33 for ( const QgsProviderSublayerDetails &sublayer : sublayers )
34 {
35 if ( !sublayer.path().isEmpty() )
36 {
37 QStringList currentPath;
38 QStringList remainingPaths = sublayer.path();
39 QgsProviderSublayerModelGroup *groupNode = this;
40
41 while ( !remainingPaths.empty() )
42 {
43 currentPath << remainingPaths.takeAt( 0 );
44
45 QgsProviderSublayerModelGroup *nextChild = groupNode->findGroup( currentPath.constLast() );
46 if ( !nextChild )
47 {
48 std::unique_ptr< QgsProviderSublayerModelGroup > newNode = std::make_unique< QgsProviderSublayerModelGroup >( currentPath.constLast() );
49 groupNode = qgis::down_cast< QgsProviderSublayerModelGroup * >( groupNode->addChild( std::move( newNode ) ) );
50 }
51 else
52 {
53 groupNode = nextChild;
54 }
55 }
56
57 groupNode->addChild( std::make_unique< QgsProviderSublayerModelSublayerNode >( sublayer ) );
58 }
59 else
60 {
61 addChild( std::make_unique< QgsProviderSublayerModelSublayerNode >( sublayer ) );
62 }
63 }
64}
65
66QgsProviderSublayerModelGroup::QgsProviderSublayerModelGroup( const QString &title )
67 : mGroupTitle( title )
68{
69
70}
71
72QgsProviderSublayerModelNode *QgsProviderSublayerModelGroup::addChild( std::unique_ptr<QgsProviderSublayerModelNode> child )
73{
74 if ( !child )
75 return nullptr;
76
77 Q_ASSERT( !child->mParent );
78 child->mParent = this;
79
80 QgsProviderSublayerModelNode *res = child.get();
81 mChildren.emplace_back( std::move( child ) );
82 return res;
83}
84
85int QgsProviderSublayerModelGroup::indexOf( QgsProviderSublayerModelNode *child ) const
86{
87 Q_ASSERT( child->mParent == this );
88 auto it = std::find_if( mChildren.begin(), mChildren.end(), [&]( const std::unique_ptr<QgsProviderSublayerModelNode> &p )
89 {
90 return p.get() == child;
91 } );
92 if ( it != mChildren.end() )
93 return std::distance( mChildren.begin(), it );
94 return -1;
95}
96
97QgsProviderSublayerModelNode *QgsProviderSublayerModelGroup::childAt( int index )
98{
99 if ( static_cast< std::size_t >( index ) < mChildren.size() )
100 return mChildren[ index ].get();
101
102 return nullptr;
103}
104
105void QgsProviderSublayerModelGroup::removeChildAt( int index )
106{
107 mChildren.erase( mChildren.begin() + index );
108}
109
110QgsProviderSublayerModelGroup *QgsProviderSublayerModelGroup::findGroup( const QString &name ) const
111{
112 for ( const auto &node : mChildren )
113 {
114 if ( QgsProviderSublayerModelGroup *group = dynamic_cast< QgsProviderSublayerModelGroup * >( node.get() ) )
115 {
116 if ( group->name() == name )
117 return group;
118 }
119 }
120 return nullptr;
121}
122
123QgsProviderSublayerModelGroup *QgsProviderSublayerModelGroup::findGroupForPath( const QStringList &path ) const
124{
125 const QgsProviderSublayerModelGroup *currentGroup = this;
126 for ( const QString &part : path )
127 {
128 currentGroup = currentGroup->findGroup( part );
129 }
130 return const_cast< QgsProviderSublayerModelGroup * >( currentGroup );
131}
132
133QgsProviderSublayerModelSublayerNode *QgsProviderSublayerModelGroup::findSublayer( const QgsProviderSublayerDetails &sublayer )
134{
135 for ( const auto &node : mChildren )
136 {
137 if ( QgsProviderSublayerModelGroup *group = dynamic_cast< QgsProviderSublayerModelGroup * >( node.get() ) )
138 {
139 if ( QgsProviderSublayerModelSublayerNode *node = group->findSublayer( sublayer ) )
140 return node;
141 }
142 else if ( QgsProviderSublayerModelSublayerNode *sublayerNode = dynamic_cast< QgsProviderSublayerModelSublayerNode * >( node.get() ) )
143 {
144 if ( sublayerNode->sublayer() == sublayer )
145 return sublayerNode;
146 }
147 }
148 return nullptr;
149}
150
151QVariant QgsProviderSublayerModelGroup::data( int role, int column ) const
152{
153 switch ( role )
154 {
155 case Qt::DisplayRole:
156 case Qt::ToolTipRole:
157 case Qt::EditRole:
158 {
159 switch ( static_cast< QgsProviderSublayerModel::Column >( column ) )
160 {
162 return mGroupTitle;
163
165 return QVariant();
166 }
167 return QVariant();
168 }
169
170 case Qt::DecorationRole:
171 {
172 if ( column == 0 )
173 return QgsApplication::getThemeIcon( QStringLiteral( "/mIconDbSchema.svg" ) );
174 else
175 return QVariant();
176 }
177
178 default:
179 return QVariant();
180 }
181}
182
183QgsProviderSublayerModelSublayerNode::QgsProviderSublayerModelSublayerNode( const QgsProviderSublayerDetails &sublayer )
184 : mSublayer( sublayer )
185{
186}
187
188QVariant QgsProviderSublayerModelSublayerNode::data( int role, int column ) const
189{
190 switch ( role )
191 {
192 case Qt::DisplayRole:
193 case Qt::ToolTipRole:
194 case Qt::EditRole:
195 {
196 switch ( static_cast< QgsProviderSublayerModel::Column >( column ) )
197 {
199 return mSublayer.name();
201 {
202 switch ( mSublayer.type() )
203 {
205 {
206 QString count;
207 if ( mSublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::Uncounted )
208 || mSublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::UnknownCount ) )
209 count = QObject::tr( "Uncounted" );
210 else
211 count = QLocale().toString( mSublayer.featureCount() );
212
213 if ( !mSublayer.description().isEmpty() )
214 return QStringLiteral( "%1 - %2 (%3)" ).arg( mSublayer.description(),
215 QgsWkbTypes::displayString( mSublayer.wkbType() ),
216 count );
217 else
218 return QStringLiteral( "%2 (%3)" ).arg(
219 QgsWkbTypes::displayString( mSublayer.wkbType() ),
220 count );
221 }
222
230 return mSublayer.description();
231 }
232 break;
233
234 }
235 }
236 return mSublayer.name();
237
238 }
239
240 case Qt::DecorationRole:
241 {
242 if ( column == 0 )
243 return mSublayer.type() == QgsMapLayerType::VectorLayer
244 ? ( mSublayer.wkbType() != QgsWkbTypes::Unknown ? QgsIconUtils::iconForWkbType( mSublayer.wkbType() ) : QVariant() )
245 : QgsIconUtils::iconForLayerType( mSublayer.type() );
246 else
247 return QVariant();
248 }
249
250 case static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ):
251 return false;
252
253 case static_cast< int >( QgsProviderSublayerModel::Role::ProviderKey ):
254 return mSublayer.providerKey();
255
256 case static_cast< int >( QgsProviderSublayerModel::Role::LayerType ):
257 return static_cast< int >( mSublayer.type() );
258
259 case static_cast< int >( QgsProviderSublayerModel::Role::Uri ):
260 return mSublayer.uri();
261
262 case static_cast< int >( QgsProviderSublayerModel::Role::Name ):
263 return mSublayer.name();
264
265 case static_cast< int >( QgsProviderSublayerModel::Role::Description ):
266 return mSublayer.description();
267
268 case static_cast< int >( QgsProviderSublayerModel::Role::Path ):
269 return mSublayer.path();
270
271 case static_cast< int >( QgsProviderSublayerModel::Role::FeatureCount ):
272 return mSublayer.featureCount();
273
274 case static_cast< int >( QgsProviderSublayerModel::Role::WkbType ):
275 return mSublayer.wkbType();
276
278 return mSublayer.geometryColumnName();
279
280 case static_cast< int >( QgsProviderSublayerModel::Role::LayerNumber ):
281 return mSublayer.layerNumber();
282
283 case static_cast< int >( QgsProviderSublayerModel::Role::Flags ):
284 return static_cast< int >( mSublayer.flags() );
285
286 default:
287 return QVariant();
288 }
289}
290
291QgsProviderSublayerModelNonLayerItemNode::QgsProviderSublayerModelNonLayerItemNode( const QgsProviderSublayerModel::NonLayerItem &item )
292 : mItem( item )
293{
294}
295
296QVariant QgsProviderSublayerModelNonLayerItemNode::data( int role, int column ) const
297{
298 switch ( role )
299 {
300 case Qt::DisplayRole:
301 case Qt::ToolTipRole:
302 case Qt::EditRole:
303 {
304 switch ( static_cast< QgsProviderSublayerModel::Column >( column ) )
305 {
307 return mItem.name();
309 return mItem.description();
310 }
311 return QVariant();
312 }
313
314 case Qt::DecorationRole:
315 {
316 if ( column == 0 )
317 return mItem.icon();
318 else
319 return QVariant();
320 }
321
322 case static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ):
323 return true;
324
325 case static_cast< int >( QgsProviderSublayerModel::Role::Uri ):
326 return mItem.uri();
327
328 case static_cast< int >( QgsProviderSublayerModel::Role::Name ):
329 return mItem.name();
330
331 case static_cast< int >( QgsProviderSublayerModel::Role::Description ):
332 return mItem.description();
333
334 case static_cast< int >( QgsProviderSublayerModel::Role::NonLayerItemType ):
335 return mItem.type();
336
337 default:
338 return QVariant();
339 }
340}
341
343
344//
345// QgsProviderSublayerModel
346//
347
349 : QAbstractItemModel( parent )
350 , mRootNode( std::make_unique< QgsProviderSublayerModelGroup >( QString() ) )
351{
352
353}
354
355void QgsProviderSublayerModel::setSublayerDetails( const QList<QgsProviderSublayerDetails> &details )
356{
357 if ( mSublayers.isEmpty() )
358 {
359 // initial population, just keep things simple and reset the model
360 beginResetModel();
361 mRootNode->populateFromSublayers( details );
362 mSublayers = details;
363 endResetModel();
364 }
365 else
366 {
367 // gracefully go item by item...
368
369 // remove layers which don't exist in new list
370 for ( int i = mSublayers.count() - 1; i >= 0; --i )
371 {
372 if ( !details.contains( mSublayers.at( i ) ) )
373 {
374 QgsProviderSublayerModelSublayerNode *sublayerNode = mRootNode->findSublayer( mSublayers.at( i ) );
375 Q_ASSERT( sublayerNode );
376 Q_ASSERT( sublayerNode->parent() );
377 const int row = sublayerNode->parent()->indexOf( sublayerNode );
378
379 beginRemoveRows( node2index( sublayerNode->parent() ), row, row );
380 sublayerNode->parent()->removeChildAt( row );
381 mSublayers.removeAt( i );
382 endRemoveRows();
383 }
384 }
385
386 // and add new layers which exist only in new list
387 for ( const QgsProviderSublayerDetails &sublayer : details )
388 {
389 if ( !mSublayers.contains( sublayer ) )
390 {
391 // need to add new layer
392 QgsProviderSublayerModelGroup *group = mRootNode->findGroupForPath( sublayer.path() );
393 beginInsertRows( node2index( group ), group->childCount(), group->childCount() );
394 group->addChild( std::make_unique< QgsProviderSublayerModelSublayerNode >( sublayer ) );
395 mSublayers.append( sublayer );
396 endInsertRows();
397 }
398 }
399 }
400}
401
402QList<QgsProviderSublayerDetails> QgsProviderSublayerModel::sublayerDetails() const
403{
404 return mSublayers;
405}
406
408{
409 if ( QgsProviderSublayerModelSublayerNode *n = dynamic_cast< QgsProviderSublayerModelSublayerNode *>( index2node( index ) ) )
410 return n->sublayer();
411 else
413}
414
416{
417 if ( QgsProviderSublayerModelNonLayerItemNode *n = dynamic_cast< QgsProviderSublayerModelNonLayerItemNode *>( index2node( index ) ) )
418 return n->item();
419 else
421}
422
424{
425 beginInsertRows( QModelIndex(), mRootNode->childCount(), mRootNode->childCount() );
426 mRootNode->addChild( std::make_unique< QgsProviderSublayerModelNonLayerItemNode >( item ) );
427 endInsertRows();
428}
429
430QModelIndex QgsProviderSublayerModel::index( int row, int column, const QModelIndex &parent ) const
431{
432 if ( column < 0 || column >= columnCount()
433 || row < 0 || row >= rowCount( parent ) )
434 {
435 // out of bounds
436 return QModelIndex();
437 }
438
439 QgsProviderSublayerModelGroup *n = dynamic_cast< QgsProviderSublayerModelGroup *>( index2node( parent ) );
440 if ( !n )
441 return QModelIndex(); // have no children
442
443 return createIndex( row, column, n->childAt( row ) );
444}
445
446QModelIndex QgsProviderSublayerModel::parent( const QModelIndex &child ) const
447{
448 if ( !child.isValid() )
449 return QModelIndex();
450
451 if ( QgsProviderSublayerModelNode *n = index2node( child ) )
452 {
453 return indexOfParentNode( n->parent() ); // must not be null
454 }
455 else
456 {
457 Q_ASSERT( false );
458 return QModelIndex();
459 }
460}
461
462int QgsProviderSublayerModel::columnCount( const QModelIndex &parent ) const
463{
464 Q_UNUSED( parent )
465 return static_cast< int >( Column::Description ) + 1;
466}
467
468int QgsProviderSublayerModel::rowCount( const QModelIndex &parent ) const
469{
470 QgsProviderSublayerModelNode *n = index2node( parent );
471 if ( !n )
472 return 0;
473
474 return n->childCount();
475}
476
477Qt::ItemFlags QgsProviderSublayerModel::flags( const QModelIndex &index ) const
478{
479 if ( !index.isValid() )
480 {
481 Qt::ItemFlags rootFlags = Qt::ItemFlags();
482 return rootFlags;
483 }
484
485 Qt::ItemFlags f = Qt::ItemIsEnabled;
486
487 // if index is a group, it is not selectable ...
488 if ( !dynamic_cast< QgsProviderSublayerModelGroup * >( index2node( index ) ) )
489 {
490 f |= Qt::ItemIsSelectable;
491 }
492 return f;
493}
494
495QVariant QgsProviderSublayerModel::data( const QModelIndex &index, int role ) const
496{
497 if ( !index.isValid() )
498 return QVariant();
499
500
501 QgsProviderSublayerModelNode *node = index2node( index );
502 if ( !node )
503 return QVariant();
504
505 return node->data( role, index.column() );
506}
507
508QVariant QgsProviderSublayerModel::headerData( int section, Qt::Orientation orientation, int role ) const
509{
510 switch ( orientation )
511 {
512 case Qt::Vertical:
513 break;
514 case Qt::Horizontal:
515 {
516 switch ( role )
517 {
518 case Qt::DisplayRole:
519 case Qt::ToolTipRole:
520 {
521 switch ( static_cast< Column>( section ) )
522 {
524 return tr( "Item" );
526 return tr( "Description" );
527 }
528 break;
529 }
530 }
531 break;
532 }
533 }
534 return QVariant();
535}
536
538QgsProviderSublayerModelNode *QgsProviderSublayerModel::index2node( const QModelIndex &index ) const
539{
540 if ( !index.isValid() )
541 return mRootNode.get();
542
543 return reinterpret_cast<QgsProviderSublayerModelNode *>( index.internalPointer() );
544}
545
546QModelIndex QgsProviderSublayerModel::indexOfParentNode( QgsProviderSublayerModelNode *parentNode ) const
547{
548 Q_ASSERT( parentNode );
549
550 QgsProviderSublayerModelGroup *grandParentNode = parentNode->parent();
551 if ( !grandParentNode )
552 return QModelIndex(); // root node -> invalid index
553
554 int row = grandParentNode->indexOf( parentNode );
555 Q_ASSERT( row >= 0 );
556
557 return createIndex( row, 0, parentNode );
558}
559
560QModelIndex QgsProviderSublayerModel::node2index( QgsProviderSublayerModelNode *node ) const
561{
562 if ( !node || !node->parent() )
563 return QModelIndex(); // this is the only root item -> invalid index
564
565 QModelIndex parentIndex = node2index( node->parent() );
566
567 int row = node->parent()->indexOf( node );
568 Q_ASSERT( row >= 0 );
569 return index( row, 0, parentIndex );
570}
572
573//
574// QgsProviderSublayerModel::NonLayerItem
575//
576
578{
579 return mType;
580}
581
583{
584 mType = type;
585}
586
588{
589 return mName;
590}
591
593{
594 mName = name;
595}
596
598{
599 return mDescription;
600}
601
603{
604 mDescription = description;
605}
606
608{
609 return mUri;
610}
611
613{
614 mUri = uri;
615}
616
618{
619 return mIcon;
620}
621
623{
624 mIcon = icon;
625}
626
628{
629 return mType == other.mType
630 && mName == other.mName
631 && mDescription == other.mDescription
632 && mUri == other.mUri;
633}
634
636{
637 return !( *this == other );
638}
639
640//
641// QgsProviderSublayerProxyModel
642//
643
645 : QSortFilterProxyModel( parent )
646{
647 setRecursiveFilteringEnabled( true );
648 setDynamicSortFilter( true );
649 sort( 0 );
650}
651
652bool QgsProviderSublayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
653{
654 const QModelIndex sourceIndex = sourceModel()->index( source_row, 0, source_parent );
655
656 if ( !mIncludeSystemTables && static_cast< Qgis::SublayerFlags >( sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::Flags ) ).toInt() ) & Qgis::SublayerFlag::SystemTable )
657 return false;
658
659 if ( !mIncludeEmptyLayers && sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::FeatureCount ) ) == 0 )
660 return false;
661
662 if ( mFilterString.trimmed().isEmpty() )
663 return true;
664
665 if ( sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString().contains( mFilterString, Qt::CaseInsensitive ) )
666 return true;
667
668 // check against the Description column's display role as it might be different from QgsProviderSublayerModel::Role::Description
669 const QModelIndex descriptionColumnIndex = sourceModel()->index( source_row, 1, source_parent );
670 if ( sourceModel()->data( descriptionColumnIndex, static_cast< int >( Qt::DisplayRole ) ).toString().contains( mFilterString, Qt::CaseInsensitive ) )
671 return true;
672
673 const QVariant wkbTypeVariant = sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::WkbType ) );
674 if ( wkbTypeVariant.isValid() )
675 {
676 const QgsWkbTypes::Type wkbType = static_cast< QgsWkbTypes::Type >( wkbTypeVariant.toInt() );
677 if ( QgsWkbTypes::displayString( wkbType ).contains( mFilterString, Qt::CaseInsensitive ) )
678 return true;
679 }
680
681 return false;
682}
683
684bool QgsProviderSublayerProxyModel::lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const
685{
686 const bool leftIsNonLayer = sourceModel()->data( source_left, static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ) ).toBool();
687 const bool rightIsNonLayer = sourceModel()->data( source_right, static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ) ).toBool();
688
689 if ( leftIsNonLayer && !rightIsNonLayer )
690 return true;
691 else if ( rightIsNonLayer && !leftIsNonLayer )
692 return false;
693
694 const QString leftName = sourceModel()->data( source_left, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString();
695 const QString rightName = sourceModel()->data( source_right, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString();
696
697 return QString::localeAwareCompare( leftName, rightName ) < 0;
698}
699
701{
702 return mIncludeSystemTables;
703}
704
706{
707 mIncludeSystemTables = include;
708 invalidateFilter();
709}
710
712{
713 return mIncludeEmptyLayers;
714}
715
717{
718 mIncludeEmptyLayers = include;
719 invalidateFilter();
720}
721
723{
724 return mFilterString;
725}
726
728{
729 mFilterString = filter;
730 invalidateFilter();
731}
@ SystemTable
Sublayer is a system or internal table, which should be hidden by default.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Contains utility functions for working with icons.
Definition: qgsiconutils.h:34
static QIcon iconForWkbType(QgsWkbTypes::Type type)
Returns the icon for a vector layer whose geometry type is provided.
Contains details about a sub layer available from a dataset.
QStringList path() const
Returns the path to the sublayer.
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.
std::unique_ptr< QgsProviderSublayerModelGroup > mRootNode
@ 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)
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
Qt::ItemFlags flags(const QModelIndex &index) const override
@ Description
Layer description.
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.
bool includeEmptyLayers() const
Returns true if empty tables will be shown 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
void setIncludeEmptyLayers(bool include)
Sets whether empty tables will be shown in the model.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
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.