Skip to content
Permalink
Browse files
Promote QgsDataItem enums to enum classes, move to Qgis
  • Loading branch information
nyalldawson committed May 27, 2021
1 parent 2b3d299 commit aa93d03ca92876a2cc9a90ec5f48c42f4f8e9aa6
Showing with 713 additions and 576 deletions.
  1. +83 −0 python/core/auto_additions/qgis.py
  2. +0 −3 python/core/auto_additions/qgsdataitem.py
  3. +0 −2 python/core/auto_additions/qgslayeritem.py
  4. +6 −3 python/core/auto_generated/browser/qgsbrowsermodel.sip.in
  5. +11 −43 python/core/auto_generated/browser/qgsdataitem.sip.in
  6. +1 −1 python/core/auto_generated/browser/qgsdirectoryitem.sip.in
  7. +8 −22 python/core/auto_generated/browser/qgslayeritem.sip.in
  8. +52 −0 python/core/auto_generated/qgis.sip.in
  9. +15 −15 src/app/browser/qgsinbuiltdataitemproviders.cpp
  10. +26 −26 src/app/qgsappbrowserproviders.cpp
  11. +8 −8 src/core/browser/qgsbrowsermodel.cpp
  12. +7 −4 src/core/browser/qgsbrowsermodel.h
  13. +2 −2 src/core/browser/qgsdatacollectionitem.cpp
  14. +24 −28 src/core/browser/qgsdataitem.cpp
  15. +17 −48 src/core/browser/qgsdataitem.h
  16. +10 −10 src/core/browser/qgsdirectoryitem.cpp
  17. +1 −1 src/core/browser/qgsdirectoryitem.h
  18. +5 −5 src/core/browser/qgsfavoritesitem.cpp
  19. +4 −4 src/core/browser/qgsfieldsitem.cpp
  20. +54 −55 src/core/browser/qgslayeritem.cpp
  21. +9 −24 src/core/browser/qgslayeritem.h
  22. +2 −2 src/core/browser/qgsprojectitem.cpp
  23. +1 −1 src/core/browser/qgszipitem.cpp
  24. +2 −2 src/core/providers/ept/qgseptdataitems.cpp
  25. +6 −6 src/core/providers/gdal/qgsgdaldataitems.cpp
  26. +10 −10 src/core/providers/ogr/qgsgeopackagedataitems.cpp
  27. +3 −3 src/core/providers/ogr/qgsgeopackagedataitems.h
  28. +24 −24 src/core/providers/ogr/qgsogrdataitems.cpp
  29. +5 −5 src/core/providers/ogr/qgsogrdataitems.h
  30. +73 −0 src/core/qgis.h
  31. +1 −0 src/core/qgsapplication.cpp
  32. +3 −3 src/core/vectortile/qgsvectortiledataitems.cpp
  33. +1 −1 src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp
  34. +1 −1 src/gui/providers/ogr/qgsogrdbtablemodel.cpp
  35. +1 −1 src/gui/providers/ogr/qgsogrdbtablemodel.h
  36. +10 −10 src/gui/qgsbrowserdockwidget.cpp
  37. +4 −4 src/gui/qgsbrowserdockwidget_p.cpp
  38. +2 −1 src/gui/qgsbrowserguimodel.cpp
  39. +3 −2 src/gui/qgsbrowsertreeview.cpp
  40. +3 −3 src/gui/qgsdatasourceselectdialog.cpp
  41. +3 −3 src/gui/qgsnewdatabasetablenamewidget.cpp
  42. +4 −0 src/plugins/grass/qgsgrassmapcalc.cpp
  43. +2 −2 src/plugins/grass/qgsgrassmapcalc.h
  44. +1 −1 src/plugins/grass/qgsgrassmodule.h
  45. +1 −1 src/plugins/grass/qgsgrassmoduleoptions.h
  46. +4 −0 src/plugins/grass/qgsgrassmoduleparam.cpp
  47. +9 −0 src/plugins/grass/qgsgrassnewmapset.cpp
  48. +1 −1 src/plugins/grass/qgsgrassnewmapset.h
  49. +1 −1 src/plugins/grass/qgsgrassregion.h
  50. +1 −1 src/plugins/grass/qgsgrasstools.h
  51. +17 −17 src/providers/arcgisrest/qgsarcgisrestdataitems.cpp
  52. +1 −1 src/providers/arcgisrest/qgsarcgisrestdataitems.h
  53. +3 −3 src/providers/arcgisrest/qgsarcgisrestsourceselect.cpp
  54. +11 −11 src/providers/db2/qgsdb2dataitems.cpp
  55. +1 −1 src/providers/db2/qgsdb2dataitems.h
  56. +1 −1 src/providers/geonode/qgsgeonodedataitems.cpp
  57. +2 −2 src/providers/grass/qgsgrassprovider.cpp
  58. +22 −22 src/providers/grass/qgsgrassprovidermodule.cpp
  59. +3 −3 src/providers/grass/qgsgrassprovidermodule.h
  60. +9 −9 src/providers/hana/qgshanadataitems.cpp
  61. +1 −1 src/providers/hana/qgshanadataitems.h
  62. +2 −2 src/providers/mdal/qgsmdaldataitems.cpp
  63. +19 −19 src/providers/mssql/qgsmssqldataitems.cpp
  64. +1 −1 src/providers/mssql/qgsmssqldataitems.h
  65. +4 −0 src/providers/oracle/ocispatial/qsql_ocispatial.cpp
  66. +15 −15 src/providers/oracle/qgsoracledataitems.cpp
  67. +1 −1 src/providers/oracle/qgsoracledataitems.h
  68. +2 −2 src/providers/ows/qgsowsdataitems.cpp
  69. +2 −2 src/providers/pdal/qgspdaldataitems.cpp
  70. +10 −10 src/providers/postgres/qgspostgresdataitems.cpp
  71. +1 −1 src/providers/postgres/qgspostgresdataitems.h
  72. +11 −11 src/providers/spatialite/qgsspatialitedataitems.cpp
  73. +1 −1 src/providers/spatialite/qgsspatialitedataitems.h
  74. +4 −4 src/providers/wcs/qgswcsdataitems.cpp
  75. +4 −4 src/providers/wfs/qgswfsdataitems.cpp
  76. +17 −17 src/providers/wms/qgswmsdataitems.cpp
  77. +1 −1 tests/src/app/testqgsappbrowserproviders.cpp
  78. +2 −2 tests/src/core/testqgsbrowsermodel.cpp
  79. +3 −3 tests/src/core/testqgsbrowserproxymodel.cpp
  80. +14 −14 tests/src/core/testqgsdataitem.cpp
  81. +1 −1 tests/src/core/testziplayer.cpp
  82. +1 −1 tests/src/gui/testqgsfilewidget.cpp
  83. +1 −0 tests/src/gui/testqgsnewdatabasetablewidget.cpp
@@ -63,6 +63,89 @@
QgsSymbol.FlagIncludeCrosshairsForMarkerSymbols.__doc__ = "Include a crosshairs reference image in the background of marker symbol previews"
Qgis.SymbolPreviewFlag.__doc__ = 'Flags for controlling how symbol preview images are generated.\n\n.. versionadded:: 3.20\n\n' + '* ``FlagIncludeCrosshairsForMarkerSymbols``: ' + Qgis.SymbolPreviewFlag.FlagIncludeCrosshairsForMarkerSymbols.__doc__
# --
QgsDataItem.Type = Qgis.BrowserItemType
# monkey patching scoped based enum
QgsDataItem.Collection = Qgis.BrowserItemType.Collection
QgsDataItem.Collection.__doc__ = "A collection of items"
QgsDataItem.Directory = Qgis.BrowserItemType.Directory
QgsDataItem.Directory.__doc__ = "Represents a file directory"
QgsDataItem.Layer = Qgis.BrowserItemType.Layer
QgsDataItem.Layer.__doc__ = "Represents a map layer"
QgsDataItem.Error = Qgis.BrowserItemType.Error
QgsDataItem.Error.__doc__ = "Contains an error message"
QgsDataItem.Favorites = Qgis.BrowserItemType.Favorites
QgsDataItem.Favorites.__doc__ = "Represents a favorite item"
QgsDataItem.Project = Qgis.BrowserItemType.Project
QgsDataItem.Project.__doc__ = "Represents a QGIS project"
QgsDataItem.Custom = Qgis.BrowserItemType.Custom
QgsDataItem.Custom.__doc__ = "Custom item type"
QgsDataItem.Fields = Qgis.BrowserItemType.Fields
QgsDataItem.Fields.__doc__ = "Collection of fields"
QgsDataItem.Field = Qgis.BrowserItemType.Field
QgsDataItem.Field.__doc__ = "Vector layer field"
Qgis.BrowserItemType.__doc__ = 'Browser item types.\n\n.. versionadded:: 3.20\n\n' + '* ``Collection``: ' + Qgis.BrowserItemType.Collection.__doc__ + '\n' + '* ``Directory``: ' + Qgis.BrowserItemType.Directory.__doc__ + '\n' + '* ``Layer``: ' + Qgis.BrowserItemType.Layer.__doc__ + '\n' + '* ``Error``: ' + Qgis.BrowserItemType.Error.__doc__ + '\n' + '* ``Favorites``: ' + Qgis.BrowserItemType.Favorites.__doc__ + '\n' + '* ``Project``: ' + Qgis.BrowserItemType.Project.__doc__ + '\n' + '* ``Custom``: ' + Qgis.BrowserItemType.Custom.__doc__ + '\n' + '* ``Fields``: ' + Qgis.BrowserItemType.Fields.__doc__ + '\n' + '* ``Field``: ' + Qgis.BrowserItemType.Field.__doc__
# --
Qgis.BrowserItemType.baseClass = Qgis
QgsDataItem.State = Qgis.BrowserItemState
# monkey patching scoped based enum
QgsDataItem.NotPopulated = Qgis.BrowserItemState.NotPopulated
QgsDataItem.NotPopulated.__doc__ = "Children not yet created"
QgsDataItem.Populating = Qgis.BrowserItemState.Populating
QgsDataItem.Populating.__doc__ = "Creating children in separate thread (populating or refreshing)"
QgsDataItem.Populated = Qgis.BrowserItemState.Populated
QgsDataItem.Populated.__doc__ = "Children created"
Qgis.BrowserItemState.__doc__ = 'Browser item states.\n\n.. versionadded:: 3.20\n\n' + '* ``NotPopulated``: ' + Qgis.BrowserItemState.NotPopulated.__doc__ + '\n' + '* ``Populating``: ' + Qgis.BrowserItemState.Populating.__doc__ + '\n' + '* ``Populated``: ' + Qgis.BrowserItemState.Populated.__doc__
# --
Qgis.BrowserItemState.baseClass = Qgis
QgsDataItem.Capability = Qgis.BrowserItemCapability
# monkey patching scoped based enum
QgsDataItem.NoCapabilities = Qgis.BrowserItemCapability.NoCapabilities
QgsDataItem.NoCapabilities.__doc__ = "Item has no capabilities"
QgsDataItem.SetCrs = Qgis.BrowserItemCapability.SetCrs
QgsDataItem.SetCrs.__doc__ = "Can set CRS on layer or group of layers. \deprecated since QGIS 3.6 -- no longer used by QGIS and will be removed in QGIS 4.0"
QgsDataItem.Fertile = Qgis.BrowserItemCapability.Fertile
QgsDataItem.Fertile.__doc__ = "Can create children. Even items without this capability may have children, but cannot create them, it means that children are created by item ancestors."
QgsDataItem.Fast = Qgis.BrowserItemCapability.Fast
QgsDataItem.Fast.__doc__ = "CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,wfs,wcs,postgres...) are considered fast because they are reading data only from QgsSettings"
QgsDataItem.Collapse = Qgis.BrowserItemCapability.Collapse
QgsDataItem.Collapse.__doc__ = "The collapse/expand status for this items children should be ignored in order to avoid undesired network connections (wms etc.)"
QgsDataItem.Rename = Qgis.BrowserItemCapability.Rename
QgsDataItem.Rename.__doc__ = "Item can be renamed"
QgsDataItem.Delete = Qgis.BrowserItemCapability.Delete
QgsDataItem.Delete.__doc__ = "Item can be deleted"
Qgis.BrowserItemCapability.__doc__ = 'Browser item capabilities.\n\n.. versionadded:: 3.20\n\n' + '* ``NoCapabilities``: ' + Qgis.BrowserItemCapability.NoCapabilities.__doc__ + '\n' + '* ``SetCrs``: ' + Qgis.BrowserItemCapability.SetCrs.__doc__ + '\n' + '* ``Fertile``: ' + Qgis.BrowserItemCapability.Fertile.__doc__ + '\n' + '* ``Fast``: ' + Qgis.BrowserItemCapability.Fast.__doc__ + '\n' + '* ``Collapse``: ' + Qgis.BrowserItemCapability.Collapse.__doc__ + '\n' + '* ``Rename``: ' + Qgis.BrowserItemCapability.Rename.__doc__ + '\n' + '* ``Delete``: ' + Qgis.BrowserItemCapability.Delete.__doc__
# --
QgsLayerItem.LayerType = Qgis.BrowserLayerType
# monkey patching scoped based enum
QgsLayerItem.NoType = Qgis.BrowserLayerType.NoType
QgsLayerItem.NoType.__doc__ = "No type"
QgsLayerItem.Vector = Qgis.BrowserLayerType.Vector
QgsLayerItem.Vector.__doc__ = "Generic vector layer"
QgsLayerItem.Raster = Qgis.BrowserLayerType.Raster
QgsLayerItem.Raster.__doc__ = "Raster layer"
QgsLayerItem.Point = Qgis.BrowserLayerType.Point
QgsLayerItem.Point.__doc__ = "Vector point layer"
QgsLayerItem.Line = Qgis.BrowserLayerType.Line
QgsLayerItem.Line.__doc__ = "Vector line layer"
QgsLayerItem.Polygon = Qgis.BrowserLayerType.Polygon
QgsLayerItem.Polygon.__doc__ = "Vector polygon layer"
QgsLayerItem.TableLayer = Qgis.BrowserLayerType.TableLayer
QgsLayerItem.TableLayer.__doc__ = "Vector non-spatial layer"
QgsLayerItem.Database = Qgis.BrowserLayerType.Database
QgsLayerItem.Database.__doc__ = "Database layer"
QgsLayerItem.Table = Qgis.BrowserLayerType.Table
QgsLayerItem.Table.__doc__ = "Database table"
QgsLayerItem.Plugin = Qgis.BrowserLayerType.Plugin
QgsLayerItem.Plugin.__doc__ = "Plugin based layer"
QgsLayerItem.Mesh = Qgis.BrowserLayerType.Mesh
QgsLayerItem.Mesh.__doc__ = "Mesh layer"
QgsLayerItem.VectorTile = Qgis.BrowserLayerType.VectorTile
QgsLayerItem.VectorTile.__doc__ = "Vector tile layer"
QgsLayerItem.PointCloud = Qgis.BrowserLayerType.PointCloud
QgsLayerItem.PointCloud.__doc__ = "Point cloud layer"
Qgis.BrowserLayerType.__doc__ = 'Browser item layer types\n\n.. versionadded:: 3.20\n\n' + '* ``NoType``: ' + Qgis.BrowserLayerType.NoType.__doc__ + '\n' + '* ``Vector``: ' + Qgis.BrowserLayerType.Vector.__doc__ + '\n' + '* ``Raster``: ' + Qgis.BrowserLayerType.Raster.__doc__ + '\n' + '* ``Point``: ' + Qgis.BrowserLayerType.Point.__doc__ + '\n' + '* ``Line``: ' + Qgis.BrowserLayerType.Line.__doc__ + '\n' + '* ``Polygon``: ' + Qgis.BrowserLayerType.Polygon.__doc__ + '\n' + '* ``TableLayer``: ' + Qgis.BrowserLayerType.TableLayer.__doc__ + '\n' + '* ``Database``: ' + Qgis.BrowserLayerType.Database.__doc__ + '\n' + '* ``Table``: ' + Qgis.BrowserLayerType.Table.__doc__ + '\n' + '* ``Plugin``: ' + Qgis.BrowserLayerType.Plugin.__doc__ + '\n' + '* ``Mesh``: ' + Qgis.BrowserLayerType.Mesh.__doc__ + '\n' + '* ``VectorTile``: ' + Qgis.BrowserLayerType.VectorTile.__doc__ + '\n' + '* ``PointCloud``: ' + Qgis.BrowserLayerType.PointCloud.__doc__
# --
Qgis.BrowserLayerType.baseClass = Qgis
QgsVectorLayerExporter.ExportError = Qgis.VectorExportResult
# monkey patching scoped based enum
QgsVectorLayerExporter.NoError = Qgis.VectorExportResult.Success

This file was deleted.

This file was deleted.

@@ -9,7 +9,6 @@




class QgsBrowserModel : QAbstractItemModel
{
%Docstring(signature="appended")
@@ -165,7 +164,7 @@ and on Linux the "/" root directory.
%End
signals:

void stateChanged( const QModelIndex &index, QgsDataItem::State oldState );
void stateChanged( const QModelIndex &index, Qgis::BrowserItemState oldState );
%Docstring
Emitted when item children fetch was finished
%End
@@ -196,7 +195,11 @@ drives and adding newly added drives.
void beginRemoveItems( QgsDataItem *parent, int first, int last );
void endRemoveItems();
void itemDataChanged( QgsDataItem *item );
void itemStateChanged( QgsDataItem *item, QgsDataItem::State oldState );

void itemStateChanged( QgsDataItem *item, Qgis::BrowserItemState oldState );
%Docstring
Emitted when an ``item``'s state is changed.
%End

void addFavoriteDirectory( const QString &directory, const QString &name = QString() );
%Docstring
@@ -47,21 +47,8 @@ Parent/children hierarchy is not based on QObject.
sipType = 0;
%End
public:
enum Type
{
Collection,
Directory,
Layer,
Error,
Favorites,
Project,
Custom,
Fields,
Field,
};


QgsDataItem( QgsDataItem::Type type, QgsDataItem *parent /TransferThis/, const QString &name, const QString &path, const QString &providerKey = QString() );
QgsDataItem( Qgis::BrowserItemType type, QgsDataItem *parent /TransferThis/, const QString &name, const QString &path, const QString &providerKey = QString() );
%Docstring
Constructor for QgsDataItem, with the specified ``parent`` item.

@@ -119,20 +106,13 @@ Create children. Children are not expected to have parent set.
}
%End

enum State
{
NotPopulated,
Populating,
Populated
};

State state() const;
Qgis::BrowserItemState state() const;
%Docstring

.. versionadded:: 2.8
%End

virtual void setState( State state );
virtual void setState( Qgis::BrowserItemState state );
%Docstring
Set item state. It also take care about starting/stopping loading icon animation.

@@ -276,19 +256,6 @@ Items that return valid URI will be returned in mime data when dragging a select
.. versionadded:: 3.18
%End

enum Capability
{
NoCapabilities,
SetCrs,
Fertile,
Fast,
Collapse,
Rename,
Delete,
};
typedef QFlags<QgsDataItem::Capability> Capabilities;


virtual bool setCrs( const QgsCoordinateReferenceSystem &crs ) /Deprecated/;
%Docstring
Writes the selected crs into data source. The original data source will be modified when calling this
@@ -315,14 +282,14 @@ Use :py:class:`QgsDataItemGuiProvider`:
%End


virtual Capabilities capabilities2() const;
virtual Qgis::BrowserItemCapabilities capabilities2() const;
%Docstring
Returns the capabilities for the data item.

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

virtual void setCapabilities( Capabilities capabilities );
virtual void setCapabilities( Qgis::BrowserItemCapabilities capabilities );
%Docstring
Sets the capabilities for the data item.

@@ -333,7 +300,7 @@ Sets the capabilities for the data item.
static int findItem( QVector<QgsDataItem *> items, QgsDataItem *item );


Type type() const;
Qgis::BrowserItemType type() const;

QgsDataItem *parent() const;
%Docstring
@@ -496,7 +463,11 @@ all providers will be refreshed (which is potentially very expensive!).
void beginRemoveItems( QgsDataItem *parent, int first, int last );
void endRemoveItems();
void dataChanged( QgsDataItem *item );
void stateChanged( QgsDataItem *item, QgsDataItem::State oldState );

void stateChanged( QgsDataItem *item, Qgis::BrowserItemState oldState );
%Docstring
Emitted when an item's state is changed.
%End

void connectionsChanged( const QString &providerKey = QString() );
%Docstring
@@ -518,9 +489,6 @@ Will request a repaint of this icon.

};

QFlags<QgsDataItem::Capability> operator|(QgsDataItem::Capability f1, QFlags<QgsDataItem::Capability> f2);


class QgsErrorItem : QgsDataItem
{
%Docstring(signature="appended")
@@ -52,7 +52,7 @@ items pointing to different ``dirPaths`` should always use a different item ``pa
The optional ``providerKey`` string can be used to specify the key for the :py:class:`QgsDataItemProvider` that created this item.
%End

virtual void setState( State state );
virtual void setState( Qgis::BrowserItemState state );


virtual QVector<QgsDataItem *> createChildren();
@@ -18,25 +18,11 @@ Item that represents a layer that can be opened with one of the providers
#include "qgslayeritem.h"
%End
public:
enum LayerType
{
NoType,
Vector,
Raster,
Point,
Line,
Polygon,
TableLayer,
Database,
Table,
Plugin,
Mesh,
VectorTile,
PointCloud
};


QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, LayerType layerType, const QString &providerKey );

QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey );
%Docstring
Constructor for QgsLayerItem.
%End


virtual bool equal( const QgsDataItem *other );
@@ -53,7 +39,7 @@ Item that represents a layer that can be opened with one of the providers
Returns :py:class:`QgsMapLayerType`
%End

static LayerType typeFromMapLayer( QgsMapLayer *layer );
static Qgis::BrowserLayerType typeFromMapLayer( QgsMapLayer *layer );
%Docstring
Returns the layer item type corresponding to a :py:class:`QgsMapLayer` ``layer``.

@@ -91,14 +77,14 @@ Returns comments of the layer
.. versionadded:: 2.12
%End

static QString layerTypeAsString( LayerType layerType );
static QString layerTypeAsString( Qgis::BrowserLayerType layerType );
%Docstring
Returns the string representation of the given ``layerType``

.. versionadded:: 3
%End

static QString iconName( LayerType layerType );
static QString iconName( Qgis::BrowserLayerType layerType );
%Docstring
Returns the icon name of the given ``layerType``

@@ -152,6 +152,56 @@ The development version
typedef QFlags<Qgis::SymbolPreviewFlag> SymbolPreviewFlags;


enum class BrowserItemType
{
Collection,
Directory,
Layer,
Error,
Favorites,
Project,
Custom,
Fields,
Field,
};

enum class BrowserItemState
{
NotPopulated,
Populating,
Populated,
};

enum class BrowserItemCapability
{
NoCapabilities,
SetCrs,
Fertile,
Fast,
Collapse,
Rename,
Delete,
};
typedef QFlags<Qgis::BrowserItemCapability> BrowserItemCapabilities;


enum class BrowserLayerType
{
NoType,
Vector,
Raster,
Point,
Line,
Polygon,
TableLayer,
Database,
Table,
Plugin,
Mesh,
VectorTile,
PointCloud
};

enum class VectorExportResult
{
Success,
@@ -256,6 +306,8 @@ QFlags<Qgis::SymbolFlag> operator|(Qgis::SymbolFlag f1, QFlags<Qgis::SymbolFlag>

QFlags<Qgis::SymbolPreviewFlag> operator|(Qgis::SymbolPreviewFlag f1, QFlags<Qgis::SymbolPreviewFlag> f2);

QFlags<Qgis::BrowserItemCapability> operator|(Qgis::BrowserItemCapability f1, QFlags<Qgis::BrowserItemCapability> f2);




0 comments on commit aa93d03

Please sign in to comment.