18#ifndef QGSPROVIDERSUBLAYERMODEL_H
19#define QGSPROVIDERSUBLAYERMODEL_H
25#include <QAbstractItemModel>
26#include <QSortFilterProxyModel>
32class QgsProviderSublayerModelNode;
33class QgsProviderSublayerModelGroup;
34class QgsProviderSublayerModelSublayerNode;
63 ProviderKey = Qt::UserRole + 1,
100 QString type()
const;
106 void setType(
const QString &type );
112 QString name()
const;
118 void setName(
const QString &name );
124 QString description()
const;
130 void setDescription(
const QString &description );
142 void setUri(
const QString &uri );
154 void setIcon(
const QIcon &icon );
160 SIP_PYOBJECT __repr__();
162 QString
str = QStringLiteral(
"<QgsProviderSublayerModel.NonLayerItem: %1 - %2>" ).arg( sipCpp->type(), sipCpp->name() );
163 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
171 QString mDescription;
187 void setSublayerDetails(
const QList< QgsProviderSublayerDetails > &details );
194 QList< QgsProviderSublayerDetails > sublayerDetails()
const;
211 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
212 QModelIndex parent(
const QModelIndex &index )
const override;
213 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
214 int rowCount(
const QModelIndex &parent )
const override;
215 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
216 QVariant data(
const QModelIndex &index,
int role )
const override;
217 QVariant headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole )
const override;
225 QgsProviderSublayerModelNode *index2node(
const QModelIndex &index )
const SIP_SKIP;
233 std::unique_ptr< QgsProviderSublayerModelGroup >
mRootNode;
236 QModelIndex indexOfParentNode( QgsProviderSublayerModelNode *parentNode )
const;
238 QModelIndex node2index( QgsProviderSublayerModelNode *node )
const;
245class CORE_EXPORT QgsProviderSublayerModelNode
249 virtual ~QgsProviderSublayerModelNode();
256 QgsProviderSublayerModelGroup *parent() {
return mParent; }
261 virtual QVariant data(
int role = Qt::DisplayRole,
int column = 0 )
const = 0;
266 virtual int childCount()
const = 0;
270 QgsProviderSublayerModelGroup *mParent =
nullptr;
272 friend class QgsProviderSublayerModelGroup;
275class CORE_EXPORT QgsProviderSublayerModelGroup :
public QgsProviderSublayerModelNode
282 QgsProviderSublayerModelGroup(
const QString &title );
284 QgsProviderSublayerModelGroup( QgsProviderSublayerModelGroup &&other ) =
default;
285 QgsProviderSublayerModelGroup &operator=( QgsProviderSublayerModelGroup && ) =
default;
290 QString name()
const {
return mGroupTitle; }
295 QgsProviderSublayerModelNode *addChild( std::unique_ptr< QgsProviderSublayerModelNode > child );
302 int indexOf( QgsProviderSublayerModelNode *child )
const;
307 QgsProviderSublayerModelNode *childAt(
int index );
312 void removeChildAt(
int index );
317 QgsProviderSublayerModelGroup *findGroup(
const QString &name )
const;
322 QgsProviderSublayerModelGroup *findGroupForPath(
const QStringList &path )
const;
326 int childCount() const override final {
return mChildren.size(); }
327 QVariant data(
int role = Qt::DisplayRole,
int column = 0 )
const override;
329 void populateFromSublayers(
const QList<QgsProviderSublayerDetails> &sublayers );
334 std::deque< std::unique_ptr< QgsProviderSublayerModelNode > > mChildren;
340class CORE_EXPORT QgsProviderSublayerModelSublayerNode :
public QgsProviderSublayerModelNode
345 int childCount() const override final {
return 0; }
346 QVariant data(
int role = Qt::DisplayRole,
int column = 0 )
const override;
354class CORE_EXPORT QgsProviderSublayerModelNonLayerItemNode :
public QgsProviderSublayerModelNode
359 int childCount() const override final {
return 0; }
360 QVariant data(
int role = Qt::DisplayRole,
int column = 0 )
const override;
395 QString filterString()
const;
402 void setFilterString(
const QString &filter );
409 bool includeSystemTables()
const;
416 void setIncludeSystemTables(
bool include );
424 bool includeEmptyLayers()
const;
432 void setIncludeEmptyLayers(
bool include );
435 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
436 bool lessThan(
const QModelIndex &source_left,
const QModelIndex &source_right )
const override;
440 QString mFilterString;
441 bool mIncludeSystemTables =
false;
442 bool mIncludeEmptyLayers =
true;
Contains details about a sub layer available from a dataset.
Contains details for a non-sublayer item to include in a QgsProviderSublayerModel.
A model for representing the sublayers present in a URI.
QList< QgsProviderSublayerDetails > mSublayers
Sublayer list.
std::unique_ptr< QgsProviderSublayerModelGroup > mRootNode
A QSortFilterProxyModel for filtering and sorting a QgsProviderSublayerModel.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)