QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
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
231 return mSublayer.description();
232 }
233 break;
234
235 }
236 }
237 return mSublayer.name();
238
239 }
240
241 case Qt::DecorationRole:
242 {
243 if ( column == 0 )
244 return mSublayer.type() == Qgis::LayerType::Vector
245 ? ( mSublayer.wkbType() != Qgis::WkbType::Unknown ? QgsIconUtils::iconForWkbType( mSublayer.wkbType() ) : QVariant() )
246 : QgsIconUtils::iconForLayerType( mSublayer.type() );
247 else
248 return QVariant();
249 }
250
251 case static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ):
252 return false;
253
254 case static_cast< int >( QgsProviderSublayerModel::Role::ProviderKey ):
255 return mSublayer.providerKey();
256
257 case static_cast< int >( QgsProviderSublayerModel::Role::LayerType ):
258 return static_cast< int >( mSublayer.type() );
259
260 case static_cast< int >( QgsProviderSublayerModel::Role::Uri ):
261 return mSublayer.uri();
262
263 case static_cast< int >( QgsProviderSublayerModel::Role::Name ):
264 return mSublayer.name();
265
266 case static_cast< int >( QgsProviderSublayerModel::Role::Description ):
267 return mSublayer.description();
268
269 case static_cast< int >( QgsProviderSublayerModel::Role::Path ):
270 return mSublayer.path();
271
272 case static_cast< int >( QgsProviderSublayerModel::Role::FeatureCount ):
273 return mSublayer.featureCount();
274
275 case static_cast< int >( QgsProviderSublayerModel::Role::WkbType ):
276 return static_cast< quint32>( mSublayer.wkbType() );
277
279 return mSublayer.geometryColumnName();
280
281 case static_cast< int >( QgsProviderSublayerModel::Role::LayerNumber ):
282 return mSublayer.layerNumber();
283
284 case static_cast< int >( QgsProviderSublayerModel::Role::Flags ):
285 return static_cast< int >( mSublayer.flags() );
286
287 default:
288 return QVariant();
289 }
290}
291
292QgsProviderSublayerModelNonLayerItemNode::QgsProviderSublayerModelNonLayerItemNode( const QgsProviderSublayerModel::NonLayerItem &item )
293 : mItem( item )
294{
295}
296
297QVariant QgsProviderSublayerModelNonLayerItemNode::data( int role, int column ) const
298{
299 switch ( role )
300 {
301 case Qt::DisplayRole:
302 case Qt::ToolTipRole:
303 case Qt::EditRole:
304 {
305 switch ( static_cast< QgsProviderSublayerModel::Column >( column ) )
306 {
308 return mItem.name();
310 return mItem.description();
311 }
312 return QVariant();
313 }
314
315 case Qt::DecorationRole:
316 {
317 if ( column == 0 )
318 return mItem.icon();
319 else
320 return QVariant();
321 }
322
323 case static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ):
324 return true;
325
326 case static_cast< int >( QgsProviderSublayerModel::Role::Uri ):
327 return mItem.uri();
328
329 case static_cast< int >( QgsProviderSublayerModel::Role::Name ):
330 return mItem.name();
331
332 case static_cast< int >( QgsProviderSublayerModel::Role::Description ):
333 return mItem.description();
334
335 case static_cast< int >( QgsProviderSublayerModel::Role::NonLayerItemType ):
336 return mItem.type();
337
338 default:
339 return QVariant();
340 }
341}
342
344
345//
346// QgsProviderSublayerModel
347//
348
350 : QAbstractItemModel( parent )
351 , mRootNode( std::make_unique< QgsProviderSublayerModelGroup >( QString() ) )
352{
353
354}
355
356void QgsProviderSublayerModel::setSublayerDetails( const QList<QgsProviderSublayerDetails> &details )
357{
358 if ( mSublayers.isEmpty() )
359 {
360 // initial population, just keep things simple and reset the model
361 beginResetModel();
362 mRootNode->populateFromSublayers( details );
363 mSublayers = details;
364 endResetModel();
365 }
366 else
367 {
368 // gracefully go item by item...
369
370 // remove layers which don't exist in new list
371 for ( int i = mSublayers.count() - 1; i >= 0; --i )
372 {
373 if ( !details.contains( mSublayers.at( i ) ) )
374 {
375 QgsProviderSublayerModelSublayerNode *sublayerNode = mRootNode->findSublayer( mSublayers.at( i ) );
376 Q_ASSERT( sublayerNode );
377 Q_ASSERT( sublayerNode->parent() );
378 const int row = sublayerNode->parent()->indexOf( sublayerNode );
379
380 beginRemoveRows( node2index( sublayerNode->parent() ), row, row );
381 sublayerNode->parent()->removeChildAt( row );
382 mSublayers.removeAt( i );
383 endRemoveRows();
384 }
385 }
386
387 // and add new layers which exist only in new list
388 for ( const QgsProviderSublayerDetails &sublayer : details )
389 {
390 if ( !mSublayers.contains( sublayer ) )
391 {
392 // need to add new layer
393 QgsProviderSublayerModelGroup *group = mRootNode->findGroupForPath( sublayer.path() );
394 beginInsertRows( node2index( group ), group->childCount(), group->childCount() );
395 group->addChild( std::make_unique< QgsProviderSublayerModelSublayerNode >( sublayer ) );
396 mSublayers.append( sublayer );
397 endInsertRows();
398 }
399 }
400 }
401}
402
403QList<QgsProviderSublayerDetails> QgsProviderSublayerModel::sublayerDetails() const
404{
405 return mSublayers;
406}
407
409{
410 if ( QgsProviderSublayerModelSublayerNode *n = dynamic_cast< QgsProviderSublayerModelSublayerNode *>( index2node( index ) ) )
411 return n->sublayer();
412 else
414}
415
417{
418 if ( QgsProviderSublayerModelNonLayerItemNode *n = dynamic_cast< QgsProviderSublayerModelNonLayerItemNode *>( index2node( index ) ) )
419 return n->item();
420 else
422}
423
425{
426 beginInsertRows( QModelIndex(), mRootNode->childCount(), mRootNode->childCount() );
427 mRootNode->addChild( std::make_unique< QgsProviderSublayerModelNonLayerItemNode >( item ) );
428 endInsertRows();
429}
430
431QModelIndex QgsProviderSublayerModel::index( int row, int column, const QModelIndex &parent ) const
432{
433 if ( column < 0 || column >= columnCount()
434 || row < 0 || row >= rowCount( parent ) )
435 {
436 // out of bounds
437 return QModelIndex();
438 }
439
440 QgsProviderSublayerModelGroup *n = dynamic_cast< QgsProviderSublayerModelGroup *>( index2node( parent ) );
441 if ( !n )
442 return QModelIndex(); // have no children
443
444 return createIndex( row, column, n->childAt( row ) );
445}
446
447QModelIndex QgsProviderSublayerModel::parent( const QModelIndex &child ) const
448{
449 if ( !child.isValid() )
450 return QModelIndex();
451
452 if ( QgsProviderSublayerModelNode *n = index2node( child ) )
453 {
454 return indexOfParentNode( n->parent() ); // must not be null
455 }
456 else
457 {
458 Q_ASSERT( false );
459 return QModelIndex();
460 }
461}
462
463int QgsProviderSublayerModel::columnCount( const QModelIndex &parent ) const
464{
465 Q_UNUSED( parent )
466 return static_cast< int >( Column::Description ) + 1;
467}
468
469int QgsProviderSublayerModel::rowCount( const QModelIndex &parent ) const
470{
471 QgsProviderSublayerModelNode *n = index2node( parent );
472 if ( !n )
473 return 0;
474
475 return n->childCount();
476}
477
478Qt::ItemFlags QgsProviderSublayerModel::flags( const QModelIndex &index ) const
479{
480 if ( !index.isValid() )
481 {
482 Qt::ItemFlags rootFlags = Qt::ItemFlags();
483 return rootFlags;
484 }
485
486 Qt::ItemFlags f = Qt::ItemIsEnabled;
487
488 // if index is a group, it is not selectable ...
489 if ( !dynamic_cast< QgsProviderSublayerModelGroup * >( index2node( index ) ) )
490 {
491 f |= Qt::ItemIsSelectable;
492 }
493 return f;
494}
495
496QVariant QgsProviderSublayerModel::data( const QModelIndex &index, int role ) const
497{
498 if ( !index.isValid() )
499 return QVariant();
500
501
502 QgsProviderSublayerModelNode *node = index2node( index );
503 if ( !node )
504 return QVariant();
505
506 return node->data( role, index.column() );
507}
508
509QVariant QgsProviderSublayerModel::headerData( int section, Qt::Orientation orientation, int role ) const
510{
511 switch ( orientation )
512 {
513 case Qt::Vertical:
514 break;
515 case Qt::Horizontal:
516 {
517 switch ( role )
518 {
519 case Qt::DisplayRole:
520 case Qt::ToolTipRole:
521 {
522 switch ( static_cast< Column>( section ) )
523 {
525 return tr( "Item" );
527 return tr( "Description" );
528 }
529 break;
530 }
531 }
532 break;
533 }
534 }
535 return QVariant();
536}
537
539QgsProviderSublayerModelNode *QgsProviderSublayerModel::index2node( const QModelIndex &index ) const
540{
541 if ( !index.isValid() )
542 return mRootNode.get();
543
544 return reinterpret_cast<QgsProviderSublayerModelNode *>( index.internalPointer() );
545}
546
547QModelIndex QgsProviderSublayerModel::indexOfParentNode( QgsProviderSublayerModelNode *parentNode ) const
548{
549 Q_ASSERT( parentNode );
550
551 QgsProviderSublayerModelGroup *grandParentNode = parentNode->parent();
552 if ( !grandParentNode )
553 return QModelIndex(); // root node -> invalid index
554
555 int row = grandParentNode->indexOf( parentNode );
556 Q_ASSERT( row >= 0 );
557
558 return createIndex( row, 0, parentNode );
559}
560
561QModelIndex QgsProviderSublayerModel::node2index( QgsProviderSublayerModelNode *node ) const
562{
563 if ( !node || !node->parent() )
564 return QModelIndex(); // this is the only root item -> invalid index
565
566 QModelIndex parentIndex = node2index( node->parent() );
567
568 int row = node->parent()->indexOf( node );
569 Q_ASSERT( row >= 0 );
570 return index( row, 0, parentIndex );
571}
573
574//
575// QgsProviderSublayerModel::NonLayerItem
576//
577
579{
580 return mType;
581}
582
584{
585 mType = type;
586}
587
589{
590 return mName;
591}
592
594{
595 mName = name;
596}
597
599{
600 return mDescription;
601}
602
604{
605 mDescription = description;
606}
607
609{
610 return mUri;
611}
612
614{
615 mUri = uri;
616}
617
619{
620 return mIcon;
621}
622
624{
625 mIcon = icon;
626}
627
629{
630 return mType == other.mType
631 && mName == other.mName
632 && mDescription == other.mDescription
633 && mUri == other.mUri;
634}
635
637{
638 return !( *this == other );
639}
640
641//
642// QgsProviderSublayerProxyModel
643//
644
646 : QSortFilterProxyModel( parent )
647{
648 setRecursiveFilteringEnabled( true );
649 setDynamicSortFilter( true );
650 sort( 0 );
651}
652
653bool QgsProviderSublayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
654{
655 const QModelIndex sourceIndex = sourceModel()->index( source_row, 0, source_parent );
656
657 if ( !mIncludeSystemTables && static_cast< Qgis::SublayerFlags >( sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::Flags ) ).toInt() ) & Qgis::SublayerFlag::SystemTable )
658 return false;
659
660 if ( !mIncludeEmptyLayers && sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::FeatureCount ) ) == 0 )
661 return false;
662
663 if ( mFilterString.trimmed().isEmpty() )
664 return true;
665
666 if ( sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString().contains( mFilterString, Qt::CaseInsensitive ) )
667 return true;
668
669 // check against the Description column's display role as it might be different from QgsProviderSublayerModel::Role::Description
670 const QModelIndex descriptionColumnIndex = sourceModel()->index( source_row, 1, source_parent );
671 if ( sourceModel()->data( descriptionColumnIndex, static_cast< int >( Qt::DisplayRole ) ).toString().contains( mFilterString, Qt::CaseInsensitive ) )
672 return true;
673
674 const QVariant wkbTypeVariant = sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::WkbType ) );
675 if ( wkbTypeVariant.isValid() )
676 {
677 const Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( wkbTypeVariant.toUInt() );
678 if ( QgsWkbTypes::displayString( wkbType ).contains( mFilterString, Qt::CaseInsensitive ) )
679 return true;
680 }
681
682 return false;
683}
684
685bool QgsProviderSublayerProxyModel::lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const
686{
687 const bool leftIsNonLayer = sourceModel()->data( source_left, static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ) ).toBool();
688 const bool rightIsNonLayer = sourceModel()->data( source_right, static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ) ).toBool();
689
690 if ( leftIsNonLayer && !rightIsNonLayer )
691 return true;
692 else if ( rightIsNonLayer && !leftIsNonLayer )
693 return false;
694
695 const QString leftName = sourceModel()->data( source_left, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString();
696 const QString rightName = sourceModel()->data( source_right, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString();
697
698 return QString::localeAwareCompare( leftName, rightName ) < 0;
699}
700
702{
703 return mIncludeSystemTables;
704}
705
707{
708 mIncludeSystemTables = include;
709 invalidateFilter();
710}
711
713{
714 return mIncludeEmptyLayers;
715}
716
718{
719 mIncludeEmptyLayers = include;
720 invalidateFilter();
721}
722
724{
725 return mFilterString;
726}
727
729{
730 mFilterString = filter;
731 invalidateFilter();
732}
@ SystemTable
Sublayer is a system or internal table, which should be hidden by default.
QFlags< SublayerFlag > SublayerFlags
Sublayer flags.
Definition qgis.h:1143
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ Vector
Vector layer.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ Raster
Raster layer.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:201
@ Unknown
Unknown.
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.
static QIcon iconForWkbType(Qgis::WkbType 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.
static QString displayString(Qgis::WkbType type)
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.