Skip to content
Permalink
Browse files
Allow non sublayer items to be added to QgsProviderSublayerModel
E.g. embedded project items
  • Loading branch information
nyalldawson committed Jul 6, 2021
1 parent 2883215 commit 73f45ee46781001df30190e6dddd37ab693279c9
@@ -10,7 +10,9 @@
QgsProviderSublayerModel.Role.WkbType.__doc__ = "WKB geometry type (for vector sublayers)"
QgsProviderSublayerModel.Role.GeometryColumnName.__doc__ = "Geometry column name (for vector sublayers)"
QgsProviderSublayerModel.Role.LayerNumber.__doc__ = "Layer number"
QgsProviderSublayerModel.Role.__doc__ = 'Custom model roles\n\n' + '* ``ProviderKey``: ' + QgsProviderSublayerModel.Role.ProviderKey.__doc__ + '\n' + '* ``LayerType``: ' + QgsProviderSublayerModel.Role.LayerType.__doc__ + '\n' + '* ``Uri``: ' + QgsProviderSublayerModel.Role.Uri.__doc__ + '\n' + '* ``Name``: ' + QgsProviderSublayerModel.Role.Name.__doc__ + '\n' + '* ``Description``: ' + QgsProviderSublayerModel.Role.Description.__doc__ + '\n' + '* ``Path``: ' + QgsProviderSublayerModel.Role.Path.__doc__ + '\n' + '* ``FeatureCount``: ' + QgsProviderSublayerModel.Role.FeatureCount.__doc__ + '\n' + '* ``WkbType``: ' + QgsProviderSublayerModel.Role.WkbType.__doc__ + '\n' + '* ``GeometryColumnName``: ' + QgsProviderSublayerModel.Role.GeometryColumnName.__doc__ + '\n' + '* ``LayerNumber``: ' + QgsProviderSublayerModel.Role.LayerNumber.__doc__
QgsProviderSublayerModel.Role.IsNonLayerItem.__doc__ = "``True`` if item is a non-sublayer item (e.g. an embedded project)"
QgsProviderSublayerModel.Role.NonLayerItemType.__doc__ = "Item type (for non-sublayer items)"
QgsProviderSublayerModel.Role.__doc__ = 'Custom model roles\n\n' + '* ``ProviderKey``: ' + QgsProviderSublayerModel.Role.ProviderKey.__doc__ + '\n' + '* ``LayerType``: ' + QgsProviderSublayerModel.Role.LayerType.__doc__ + '\n' + '* ``Uri``: ' + QgsProviderSublayerModel.Role.Uri.__doc__ + '\n' + '* ``Name``: ' + QgsProviderSublayerModel.Role.Name.__doc__ + '\n' + '* ``Description``: ' + QgsProviderSublayerModel.Role.Description.__doc__ + '\n' + '* ``Path``: ' + QgsProviderSublayerModel.Role.Path.__doc__ + '\n' + '* ``FeatureCount``: ' + QgsProviderSublayerModel.Role.FeatureCount.__doc__ + '\n' + '* ``WkbType``: ' + QgsProviderSublayerModel.Role.WkbType.__doc__ + '\n' + '* ``GeometryColumnName``: ' + QgsProviderSublayerModel.Role.GeometryColumnName.__doc__ + '\n' + '* ``LayerNumber``: ' + QgsProviderSublayerModel.Role.LayerNumber.__doc__ + '\n' + '* ``IsNonLayerItem``: ' + QgsProviderSublayerModel.Role.IsNonLayerItem.__doc__ + '\n' + '* ``NonLayerItemType``: ' + QgsProviderSublayerModel.Role.NonLayerItemType.__doc__
# --
# monkey patching scoped based enum
QgsProviderSublayerModel.Column.Name.__doc__ = "Layer name"
@@ -35,6 +35,8 @@ class QgsProviderSublayerModel: QAbstractItemModel
WkbType,
GeometryColumnName,
LayerNumber,
IsNonLayerItem,
NonLayerItemType,
};

enum class Column
@@ -43,6 +45,91 @@ class QgsProviderSublayerModel: QAbstractItemModel
Description,
};

class NonLayerItem
{
%Docstring(signature="appended")


.. versionadded:: 3.22
%End

%TypeHeaderCode
#include "qgsprovidersublayermodel.h"
%End
public:

QString type() const;
%Docstring
Returns the item's type.

.. seealso:: :py:func:`setType`
%End

void setType( const QString &type );
%Docstring
Sets the item's ``type``.

.. seealso:: :py:func:`type`
%End

QString name() const;
%Docstring
Returns the item's name.

.. seealso:: :py:func:`setName`
%End

void setName( const QString &name );
%Docstring
Sets the item's ``name``.

.. seealso:: :py:func:`setName`
%End

QString description() const;
%Docstring
Returns the item's description.

.. seealso:: :py:func:`setDescription`
%End

void setDescription( const QString &description );
%Docstring
Sets the item's ``description``.

.. seealso:: :py:func:`setDescription`
%End

QString uri() const;
%Docstring
Returns the item's URI.

.. seealso:: :py:func:`setUri`
%End

void setUri( const QString &uri );
%Docstring
Set the item's ``uri``.

.. seealso:: :py:func:`setUri`
%End

QIcon icon() const;
%Docstring
Returns the item's icon.

.. seealso:: :py:func:`setIcon`
%End

void setIcon( const QIcon &icon );
%Docstring
Sets the item's ``icon``.

.. seealso:: :py:func:`setIcon`
%End

};

QgsProviderSublayerModel( QObject *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsProviderSublayerModel, with the specified ``parent`` object.
@@ -61,6 +148,12 @@ Returns the sublayer details shown in the model.

.. seealso:: :py:func:`setSublayerDetails`
%End

void addNonLayerItem( const QgsProviderSublayerModel::NonLayerItem &item );
%Docstring
Adds a non-layer item (e.g. an embedded QGIS project item) to the model.
%End

virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;

virtual QModelIndex parent( const QModelIndex &index ) const;

0 comments on commit 73f45ee

Please sign in to comment.