QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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 // cppcheck-suppress returnDanglingLifetime
83 return res;
84}
85
86int QgsProviderSublayerModelGroup::indexOf( QgsProviderSublayerModelNode *child ) const
87{
88 Q_ASSERT( child->mParent == this );
89 auto it = std::find_if( mChildren.begin(), mChildren.end(), [&]( const std::unique_ptr<QgsProviderSublayerModelNode> &p )
90 {
91 return p.get() == child;
92 } );
93 if ( it != mChildren.end() )
94 return std::distance( mChildren.begin(), it );
95 return -1;
96}
97
98QgsProviderSublayerModelNode *QgsProviderSublayerModelGroup::childAt( int index )
99{
100 if ( static_cast< std::size_t >( index ) < mChildren.size() )
101 return mChildren[ index ].get();
102
103 return nullptr;
104}
105
106void QgsProviderSublayerModelGroup::removeChildAt( int index )
107{
108 mChildren.erase( mChildren.begin() + index );
109}
110
111QgsProviderSublayerModelGroup *QgsProviderSublayerModelGroup::findGroup( const QString &name ) const
112{
113 for ( const auto &node : mChildren )
114 {
115 if ( QgsProviderSublayerModelGroup *group = dynamic_cast< QgsProviderSublayerModelGroup * >( node.get() ) )
116 {
117 if ( group->name() == name )
118 return group;
119 }
120 }
121 return nullptr;
122}
123
124QgsProviderSublayerModelGroup *QgsProviderSublayerModelGroup::findGroupForPath( const QStringList &path ) const
125{
126 const QgsProviderSublayerModelGroup *currentGroup = this;
127 for ( const QString &part : path )
128 {
129 currentGroup = currentGroup->findGroup( part );
130 }
131 return const_cast< QgsProviderSublayerModelGroup * >( currentGroup );
132}
133
134QgsProviderSublayerModelSublayerNode *QgsProviderSublayerModelGroup::findSublayer( const QgsProviderSublayerDetails &sublayer )
135{
136 for ( const auto &node : mChildren )
137 {
138 if ( QgsProviderSublayerModelGroup *group = dynamic_cast< QgsProviderSublayerModelGroup * >( node.get() ) )
139 {
140 if ( QgsProviderSublayerModelSublayerNode *node = group->findSublayer( sublayer ) )
141 return node;
142 }
143 else if ( QgsProviderSublayerModelSublayerNode *sublayerNode = dynamic_cast< QgsProviderSublayerModelSublayerNode * >( node.get() ) )
144 {
145 if ( sublayerNode->sublayer() == sublayer )
146 return sublayerNode;
147 }
148 }
149 return nullptr;
150}
151
152QVariant QgsProviderSublayerModelGroup::data( int role, int column ) const
153{
154 switch ( role )
155 {
156 case Qt::DisplayRole:
157 case Qt::ToolTipRole:
158 case Qt::EditRole:
159 {
160 switch ( static_cast< QgsProviderSublayerModel::Column >( column ) )
161 {
163 return mGroupTitle;
164
166 return QVariant();
167 }
168 return QVariant();
169 }
170
171 case Qt::DecorationRole:
172 {
173 if ( column == 0 )
174 return QgsApplication::getThemeIcon( QStringLiteral( "/mIconDbSchema.svg" ) );
175 else
176 return QVariant();
177 }
178
179 default:
180 return QVariant();
181 }
182}
183
184QgsProviderSublayerModelSublayerNode::QgsProviderSublayerModelSublayerNode( const QgsProviderSublayerDetails &sublayer )
185 : mSublayer( sublayer )
186{
187}
188
189QVariant QgsProviderSublayerModelSublayerNode::data( int role, int column ) const
190{
191 switch ( role )
192 {
193 case Qt::DisplayRole:
194 case Qt::ToolTipRole:
195 case Qt::EditRole:
196 {
197 switch ( static_cast< QgsProviderSublayerModel::Column >( column ) )
198 {
200 return mSublayer.name();
202 {
203 switch ( mSublayer.type() )
204 {
206 {
207 QString count;
208 if ( mSublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::Uncounted )
209 || mSublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::UnknownCount ) )
210 count = QObject::tr( "Uncounted" );
211 else
212 count = QLocale().toString( mSublayer.featureCount() );
213
214 if ( !mSublayer.description().isEmpty() )
215 return QStringLiteral( "%1 - %2 (%3)" ).arg( mSublayer.description(),
216 QgsWkbTypes::displayString( mSublayer.wkbType() ),
217 count );
218 else
219 return QStringLiteral( "%2 (%3)" ).arg(
220 QgsWkbTypes::displayString( mSublayer.wkbType() ),
221 count );
222 }
223
232 return mSublayer.description();
233 }
234 break;
235
236 }
237 }
238 return mSublayer.name();
239
240 }
241
242 case Qt::DecorationRole:
243 {
244 if ( column == 0 )
245 return mSublayer.type() == Qgis::LayerType::Vector
246 ? ( mSublayer.wkbType() != Qgis::WkbType::Unknown ? QgsIconUtils::iconForWkbType( mSublayer.wkbType() ) : QVariant() )
247 : QgsIconUtils::iconForLayerType( mSublayer.type() );
248 else
249 return QVariant();
250 }
251
252 case static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ):
253 return false;
254
255 case static_cast< int >( QgsProviderSublayerModel::Role::ProviderKey ):
256 return mSublayer.providerKey();
257
258 case static_cast< int >( QgsProviderSublayerModel::Role::LayerType ):
259 return static_cast< int >( mSublayer.type() );
260
261 case static_cast< int >( QgsProviderSublayerModel::Role::Uri ):
262 return mSublayer.uri();
263
264 case static_cast< int >( QgsProviderSublayerModel::Role::Name ):
265 return mSublayer.name();
266
267 case static_cast< int >( QgsProviderSublayerModel::Role::Description ):
268 return mSublayer.description();
269
270 case static_cast< int >( QgsProviderSublayerModel::Role::Path ):
271 return mSublayer.path();
272
273 case static_cast< int >( QgsProviderSublayerModel::Role::FeatureCount ):
274 return mSublayer.featureCount();
275
276 case static_cast< int >( QgsProviderSublayerModel::Role::WkbType ):
277 return static_cast< quint32>( mSublayer.wkbType() );
278
280 return mSublayer.geometryColumnName();
281
282 case static_cast< int >( QgsProviderSublayerModel::Role::LayerNumber ):
283 return mSublayer.layerNumber();
284
285 case static_cast< int >( QgsProviderSublayerModel::Role::Flags ):
286 return static_cast< int >( mSublayer.flags() );
287
288 default:
289 return QVariant();
290 }
291}
292
293QgsProviderSublayerModelNonLayerItemNode::QgsProviderSublayerModelNonLayerItemNode( const QgsProviderSublayerModel::NonLayerItem &item )
294 : mItem( item )
295{
296}
297
298QVariant QgsProviderSublayerModelNonLayerItemNode::data( int role, int column ) const
299{
300 switch ( role )
301 {
302 case Qt::DisplayRole:
303 case Qt::ToolTipRole:
304 case Qt::EditRole:
305 {
306 switch ( static_cast< QgsProviderSublayerModel::Column >( column ) )
307 {
309 return mItem.name();
311 return mItem.description();
312 }
313 return QVariant();
314 }
315
316 case Qt::DecorationRole:
317 {
318 if ( column == 0 )
319 return mItem.icon();
320 else
321 return QVariant();
322 }
323
324 case static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ):
325 return true;
326
327 case static_cast< int >( QgsProviderSublayerModel::Role::Uri ):
328 return mItem.uri();
329
330 case static_cast< int >( QgsProviderSublayerModel::Role::Name ):
331 return mItem.name();
332
333 case static_cast< int >( QgsProviderSublayerModel::Role::Description ):
334 return mItem.description();
335
336 case static_cast< int >( QgsProviderSublayerModel::Role::NonLayerItemType ):
337 return mItem.type();
338
339 default:
340 return QVariant();
341 }
342}
343
345
346//
347// QgsProviderSublayerModel
348//
349
351 : QAbstractItemModel( parent )
352 , mRootNode( std::make_unique< QgsProviderSublayerModelGroup >( QString() ) )
353{
354
355}
356
357void QgsProviderSublayerModel::setSublayerDetails( const QList<QgsProviderSublayerDetails> &details )
358{
359 if ( mSublayers.isEmpty() )
360 {
361 // initial population, just keep things simple and reset the model
362 beginResetModel();
363 mRootNode->populateFromSublayers( details );
364 mSublayers = details;
365 endResetModel();
366 }
367 else
368 {
369 // gracefully go item by item...
370
371 // remove layers which don't exist in new list
372 for ( int i = mSublayers.count() - 1; i >= 0; --i )
373 {
374 if ( !details.contains( mSublayers.at( i ) ) )
375 {
376 QgsProviderSublayerModelSublayerNode *sublayerNode = mRootNode->findSublayer( mSublayers.at( i ) );
377 Q_ASSERT( sublayerNode );
378 Q_ASSERT( sublayerNode->parent() );
379 const int row = sublayerNode->parent()->indexOf( sublayerNode );
380
381 beginRemoveRows( node2index( sublayerNode->parent() ), row, row );
382 sublayerNode->parent()->removeChildAt( row );
383 mSublayers.removeAt( i );
384 endRemoveRows();
385 }
386 }
387
388 // and add new layers which exist only in new list
389 for ( const QgsProviderSublayerDetails &sublayer : details )
390 {
391 if ( !mSublayers.contains( sublayer ) )
392 {
393 // need to add new layer
394 QgsProviderSublayerModelGroup *group = mRootNode->findGroupForPath( sublayer.path() );
395 beginInsertRows( node2index( group ), group->childCount(), group->childCount() );
396 group->addChild( std::make_unique< QgsProviderSublayerModelSublayerNode >( sublayer ) );
397 mSublayers.append( sublayer );
398 endInsertRows();
399 }
400 }
401 }
402}
403
404QList<QgsProviderSublayerDetails> QgsProviderSublayerModel::sublayerDetails() const
405{
406 return mSublayers;
407}
408
410{
411 if ( QgsProviderSublayerModelSublayerNode *n = dynamic_cast< QgsProviderSublayerModelSublayerNode *>( index2node( index ) ) )
412 return n->sublayer();
413 else
415}
416
418{
419 if ( QgsProviderSublayerModelNonLayerItemNode *n = dynamic_cast< QgsProviderSublayerModelNonLayerItemNode *>( index2node( index ) ) )
420 return n->item();
421 else
423}
424
426{
427 beginInsertRows( QModelIndex(), mRootNode->childCount(), mRootNode->childCount() );
428 mRootNode->addChild( std::make_unique< QgsProviderSublayerModelNonLayerItemNode >( item ) );
429 endInsertRows();
430}
431
432QModelIndex QgsProviderSublayerModel::index( int row, int column, const QModelIndex &parent ) const
433{
434 if ( column < 0 || column >= columnCount()
435 || row < 0 || row >= rowCount( parent ) )
436 {
437 // out of bounds
438 return QModelIndex();
439 }
440
441 QgsProviderSublayerModelGroup *n = dynamic_cast< QgsProviderSublayerModelGroup *>( index2node( parent ) );
442 if ( !n )
443 return QModelIndex(); // have no children
444
445 return createIndex( row, column, n->childAt( row ) );
446}
447
448QModelIndex QgsProviderSublayerModel::parent( const QModelIndex &child ) const
449{
450 if ( !child.isValid() )
451 return QModelIndex();
452
453 if ( QgsProviderSublayerModelNode *n = index2node( child ) )
454 {
455 return indexOfParentNode( n->parent() ); // must not be null
456 }
457 else
458 {
459 Q_ASSERT( false );
460 return QModelIndex();
461 }
462}
463
464int QgsProviderSublayerModel::columnCount( const QModelIndex &parent ) const
465{
466 Q_UNUSED( parent )
467 return static_cast< int >( Column::Description ) + 1;
468}
469
470int QgsProviderSublayerModel::rowCount( const QModelIndex &parent ) const
471{
472 QgsProviderSublayerModelNode *n = index2node( parent );
473 if ( !n )
474 return 0;
475
476 return n->childCount();
477}
478
479Qt::ItemFlags QgsProviderSublayerModel::flags( const QModelIndex &index ) const
480{
481 if ( !index.isValid() )
482 {
483 Qt::ItemFlags rootFlags = Qt::ItemFlags();
484 return rootFlags;
485 }
486
487 Qt::ItemFlags f = Qt::ItemIsEnabled;
488
489 // if index is a group, it is not selectable ...
490 if ( !dynamic_cast< QgsProviderSublayerModelGroup * >( index2node( index ) ) )
491 {
492 f |= Qt::ItemIsSelectable;
493 }
494 return f;
495}
496
497QVariant QgsProviderSublayerModel::data( const QModelIndex &index, int role ) const
498{
499 if ( !index.isValid() )
500 return QVariant();
501
502
503 QgsProviderSublayerModelNode *node = index2node( index );
504 if ( !node )
505 return QVariant();
506
507 return node->data( role, index.column() );
508}
509
510QVariant QgsProviderSublayerModel::headerData( int section, Qt::Orientation orientation, int role ) const
511{
512 switch ( orientation )
513 {
514 case Qt::Vertical:
515 break;
516 case Qt::Horizontal:
517 {
518 switch ( role )
519 {
520 case Qt::DisplayRole:
521 case Qt::ToolTipRole:
522 {
523 switch ( static_cast< Column>( section ) )
524 {
526 return tr( "Item" );
528 return tr( "Description" );
529 }
530 break;
531 }
532 }
533 break;
534 }
535 }
536 return QVariant();
537}
538
540QgsProviderSublayerModelNode *QgsProviderSublayerModel::index2node( const QModelIndex &index ) const
541{
542 if ( !index.isValid() )
543 return mRootNode.get();
544
545 return reinterpret_cast<QgsProviderSublayerModelNode *>( index.internalPointer() );
546}
547
548QModelIndex QgsProviderSublayerModel::indexOfParentNode( QgsProviderSublayerModelNode *parentNode ) const
549{
550 Q_ASSERT( parentNode );
551
552 QgsProviderSublayerModelGroup *grandParentNode = parentNode->parent();
553 if ( !grandParentNode )
554 return QModelIndex(); // root node -> invalid index
555
556 int row = grandParentNode->indexOf( parentNode );
557 Q_ASSERT( row >= 0 );
558
559 return createIndex( row, 0, parentNode );
560}
561
562QModelIndex QgsProviderSublayerModel::node2index( QgsProviderSublayerModelNode *node ) const
563{
564 if ( !node || !node->parent() )
565 return QModelIndex(); // this is the only root item -> invalid index
566
567 QModelIndex parentIndex = node2index( node->parent() );
568
569 int row = node->parent()->indexOf( node );
570 Q_ASSERT( row >= 0 );
571 return index( row, 0, parentIndex );
572}
574
575//
576// QgsProviderSublayerModel::NonLayerItem
577//
578
580{
581 return mType;
582}
583
585{
586 mType = type;
587}
588
590{
591 return mName;
592}
593
595{
596 mName = name;
597}
598
600{
601 return mDescription;
602}
603
605{
606 mDescription = description;
607}
608
610{
611 return mUri;
612}
613
615{
616 mUri = uri;
617}
618
620{
621 return mIcon;
622}
623
625{
626 mIcon = icon;
627}
628
630{
631 return mType == other.mType
632 && mName == other.mName
633 && mDescription == other.mDescription
634 && mUri == other.mUri;
635}
636
638{
639 return !( *this == other );
640}
641
642//
643// QgsProviderSublayerProxyModel
644//
645
647 : QSortFilterProxyModel( parent )
648{
649 setRecursiveFilteringEnabled( true );
650 setDynamicSortFilter( true );
651 sort( 0 );
652}
653
654bool QgsProviderSublayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const
655{
656 const QModelIndex sourceIndex = sourceModel()->index( source_row, 0, source_parent );
657
658 if ( !mIncludeSystemTables && static_cast< Qgis::SublayerFlags >( sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::Flags ) ).toInt() ) & Qgis::SublayerFlag::SystemTable )
659 return false;
660
661 if ( !mIncludeEmptyLayers && sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::FeatureCount ) ) == 0 )
662 return false;
663
664 if ( mFilterString.trimmed().isEmpty() )
665 return true;
666
667 if ( sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString().contains( mFilterString, Qt::CaseInsensitive ) )
668 return true;
669
670 // check against the Description column's display role as it might be different from QgsProviderSublayerModel::Role::Description
671 const QModelIndex descriptionColumnIndex = sourceModel()->index( source_row, 1, source_parent );
672 if ( sourceModel()->data( descriptionColumnIndex, static_cast< int >( Qt::DisplayRole ) ).toString().contains( mFilterString, Qt::CaseInsensitive ) )
673 return true;
674
675 const QVariant wkbTypeVariant = sourceModel()->data( sourceIndex, static_cast< int >( QgsProviderSublayerModel::Role::WkbType ) );
676 if ( wkbTypeVariant.isValid() )
677 {
678 const Qgis::WkbType wkbType = static_cast< Qgis::WkbType >( wkbTypeVariant.toUInt() );
679 if ( QgsWkbTypes::displayString( wkbType ).contains( mFilterString, Qt::CaseInsensitive ) )
680 return true;
681 }
682
683 return false;
684}
685
686bool QgsProviderSublayerProxyModel::lessThan( const QModelIndex &source_left, const QModelIndex &source_right ) const
687{
688 const bool leftIsNonLayer = sourceModel()->data( source_left, static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ) ).toBool();
689 const bool rightIsNonLayer = sourceModel()->data( source_right, static_cast< int >( QgsProviderSublayerModel::Role::IsNonLayerItem ) ).toBool();
690
691 if ( leftIsNonLayer && !rightIsNonLayer )
692 return true;
693 else if ( rightIsNonLayer && !leftIsNonLayer )
694 return false;
695
696 const QString leftName = sourceModel()->data( source_left, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString();
697 const QString rightName = sourceModel()->data( source_right, static_cast< int >( QgsProviderSublayerModel::Role::Name ) ).toString();
698
699 return QString::localeAwareCompare( leftName, rightName ) < 0;
700}
701
703{
704 return mIncludeSystemTables;
705}
706
708{
709 mIncludeSystemTables = include;
710 invalidateFilter();
711}
712
714{
715 return mIncludeEmptyLayers;
716}
717
719{
720 mIncludeEmptyLayers = include;
721 invalidateFilter();
722}
723
725{
726 return mFilterString;
727}
728
730{
731 mFilterString = filter;
732 invalidateFilter();
733}
@ SystemTable
Sublayer is a system or internal table, which should be hidden by default.
QFlags< SublayerFlag > SublayerFlags
Sublayer flags.
Definition qgis.h:1323
@ 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:256
@ 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.