Skip to content
Permalink
Browse files

Merge pull request #8359 from elpaso/handle-bad-layers2

[needs-docs][feature] Deferred handling of bad layers
  • Loading branch information
elpaso committed Nov 6, 2018
2 parents c54c559 + 64bd7a7 commit c8b26771cff4ef3d0f2059d6e88ceecc6b7cb149
Showing with 2,740 additions and 255 deletions.
  1. +8 −1 python/core/auto_generated/layertree/qgslayertreeutils.sip.in
  2. +61 −1 python/core/auto_generated/qgsmaplayer.sip.in
  3. +21 −1 python/core/auto_generated/qgsmaplayerstore.sip.in
  4. +9 −2 python/core/auto_generated/qgsproject.sip.in
  5. +9 −0 python/core/auto_generated/qgsrelation.sip.in
  6. +9 −0 python/core/auto_generated/qgsrelationmanager.sip.in
  7. +2 −15 python/core/auto_generated/qgsvectorlayer.sip.in
  8. +19 −1 python/core/auto_generated/raster/qgsrasterlayer.sip.in
  9. +6 −1 python/gui/auto_generated/qgsdatasourceselectdialog.sip.in
  10. +59 −1 src/app/qgisapp.cpp
  11. +13 −3 src/app/qgisapp.h
  12. +13 −1 src/app/qgsapplayertreeviewmenuprovider.cpp
  13. +33 −18 src/app/qgshandlebadlayers.cpp
  14. +1 −2 src/app/qgshandlebadlayers.h
  15. +14 −5 src/app/qgslayertreeviewbadlayerindicator.cpp
  16. +9 −0 src/app/qgslayertreeviewbadlayerindicator.h
  17. +15 −10 src/app/qgslayertreeviewindicatorprovider.cpp
  18. +4 −4 src/app/qgslayertreeviewindicatorprovider.h
  19. +3 −0 src/app/qgsrelationmanagerdialog.cpp
  20. +4 −1 src/core/layertree/qgslayertreemodellegendnode.cpp
  21. +34 −0 src/core/layertree/qgslayertreeutils.cpp
  22. +8 −1 src/core/layertree/qgslayertreeutils.h
  23. +31 −7 src/core/qgsmaplayer.cpp
  24. +68 −2 src/core/qgsmaplayer.h
  25. +1 −1 src/core/qgsmaplayerlegend.cpp
  26. +27 −2 src/core/qgsmaplayerstore.cpp
  27. +16 −1 src/core/qgsmaplayerstore.h
  28. +83 −45 src/core/qgsproject.cpp
  29. +7 −2 src/core/qgsproject.h
  30. +1 −1 src/core/qgsprojectbadlayerhandler.cpp
  31. +1 −1 src/core/qgsrelation.cpp
  32. +5 −2 src/core/qgsrelation.h
  33. +12 −1 src/core/qgsrelationmanager.cpp
  34. +9 −0 src/core/qgsrelationmanager.h
  35. +7 −20 src/core/qgsvectorlayer.cpp
  36. +1 −16 src/core/qgsvectorlayer.h
  37. +87 −19 src/core/raster/qgsrasterlayer.cpp
  38. +15 −4 src/core/raster/qgsrasterlayer.h
  39. +24 −5 src/gui/qgsdatasourceselectdialog.cpp
  40. +8 −2 src/gui/qgsdatasourceselectdialog.h
  41. +2 −0 src/gui/raster/qgsrastertransparencywidget.cpp
  42. +6 −1 src/gui/raster/qgsrendererrasterpropertieswidget.cpp
  43. +3 −2 src/providers/ogr/qgsogrprovider.cpp
  44. +2 −35 src/ui/qgshandlebadlayersbase.ui
  45. +1 −0 tests/src/python/CMakeLists.txt
  46. +11 −7 tests/src/python/test_qgsmaplayerstore.py
  47. +16 −8 tests/src/python/test_qgsproject.py
  48. +298 −0 tests/src/python/test_qgsprojectbadlayers.py
  49. +49 −2 tests/src/python/test_qgsrasterlayer.py
  50. +11 −1 tests/src/python/test_qgsrelation.py
  51. +6 −0 tests/testdata/projects/bad_layer_raster_test.tfw
  52. BIN tests/testdata/projects/bad_layer_raster_test.tiff
  53. +36 −0 tests/testdata/projects/bad_layer_raster_test.tiff.aux.xml
  54. BIN tests/testdata/projects/bad_layers_test.gpkg
  55. +832 −0 tests/testdata/projects/good_layers_test.qgs
  56. BIN tests/testdata/projects/relation_reference_test.gpkg
  57. +710 −0 tests/testdata/projects/relation_reference_test.qgs
@@ -56,7 +56,14 @@ Returns true if any of the layers is modified

static void removeInvalidLayers( QgsLayerTreeGroup *group );
%Docstring
Remove layer nodes that refer to invalid layers
Removes layer nodes that refer to invalid layers
%End

static void storeOriginalLayersProperties( QgsLayerTreeGroup *group, const QDomDocument *doc );
%Docstring
Stores in a layer's originalXmlProperties the layer properties information

.. versionadded:: 3.6
%End

static void replaceChildrenOfEmbeddedGroups( QgsLayerTreeGroup *group );
@@ -180,7 +180,7 @@ Returns the display name of the layer.

virtual QgsDataProvider *dataProvider();
%Docstring
Returns the layer's data provider.
Returns the layer's data provider, it may be null.
%End


@@ -966,6 +966,31 @@ Write just the symbology information for the layer into the document
.. versionadded:: 2.16
%End


virtual void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
%Docstring
Updates the data source of the layer. The layer's renderer and legend will be preserved only
if the geometry type of the new data source matches the current geometry type of the layer.

Subclasses should override this method: default implementation does nothing.

:param dataSource: new layer data source
:param baseName: base name of the layer
:param provider: provider string
:param options: provider options
:param loadDefaultStyleFlag: set to true to reset the layer's style to the default for the
data source

.. seealso:: :py:func:`dataSourceChanged`

.. versionadded:: 3.6
%End

QString providerType() const;
%Docstring
Returns the provider type (provider key) for this layer
%End

QUndoStack *undoStack();
%Docstring
Returns pointer to layer's undo stack
@@ -1210,6 +1235,25 @@ Returns the message that should be notified by the provider to triggerRepaint
Returns true if the refresh on provider nofification is enabled

.. versionadded:: 3.0
%End

QString originalXmlProperties() const;
%Docstring
Returns the XML properties of the original layer as they were when the layer
was first read from the project file. In case of new layers this is normally empty.

The storage format for the XML is qlr

.. versionadded:: 3.6
%End

void setOriginalXmlProperties( const QString &originalXmlProperties );
%Docstring
Sets the original XML properties for the layer to ``originalXmlProperties``

The storage format for the XML is qlr

.. versionadded:: 3.6
%End

public slots:
@@ -1432,6 +1476,15 @@ Emitted when layer's flags have been modified.
.. seealso:: :py:func:`flags`

.. versionadded:: 3.4
%End

void dataSourceChanged();
%Docstring
Emitted whenever the layer's data source has been changed.

.. seealso:: :py:func:`setDataSource`

.. versionadded:: 3.5
%End

protected:
@@ -1535,6 +1588,11 @@ Read style data common to all layer types
.. versionadded:: 3.0
%End

void setProviderType( const QString &providerType );
%Docstring
Sets the ``providerType`` (provider key)
%End


void appendError( const QgsErrorMessage &error );
%Docstring
@@ -1563,6 +1621,8 @@ Checks whether a new set of dependencies will introduce a cycle
%End




};

QFlags<QgsMapLayer::LayerFlag> operator|(QgsMapLayer::LayerFlag f1, QFlags<QgsMapLayer::LayerFlag> f2);
@@ -37,6 +37,13 @@ Constructor for QgsMapLayerStore.
Returns the number of layers contained in the store.
%End

int validCount() const;
%Docstring
Returns the number of valid layers contained in the store.

.. versionadded:: 3.6
%End


int __len__() const;
%Docstring
@@ -89,6 +96,19 @@ Returns a map of all layers by layer ID.
.. seealso:: :py:func:`layers`
%End

QMap<QString, QgsMapLayer *> validMapLayers() const;
%Docstring
Returns a map of all valid layers by layer ID.

.. seealso:: :py:func:`mapLayer`

.. seealso:: :py:func:`mapLayersByName`

.. seealso:: :py:func:`layers`

.. versionadded:: 3.6
%End


QList<QgsMapLayer *> addMapLayers( const QList<QgsMapLayer *> &layers /Transfer/);

@@ -104,7 +124,7 @@ The layersAdded() and layerWasAdded() signals will always be emitted.
the layers yourself. Not available in Python.

:return: a list of the map layers that were added
successfully. If a layer is invalid, or already exists in the store,
successfully. If a layer already exists in the store,
it will not be part of the returned list.


@@ -700,6 +700,11 @@ Returns a pointer to the project's internal layer store.
int count() const;
%Docstring
Returns the number of registered layers.
%End

int validCount() const;
%Docstring
Returns the number of registered valid layers.
%End

QgsMapLayer *mapLayer( const QString &layerId ) const;
@@ -728,10 +733,12 @@ Retrieve a list of matching registered layers by layer name.
.. seealso:: :py:func:`mapLayers`
%End

QMap<QString, QgsMapLayer *> mapLayers() const;
QMap<QString, QgsMapLayer *> mapLayers( const bool validOnly = false ) const;
%Docstring
Returns a map of all registered layers by layer ID.

:param validOnly: if set only valid layers will be returned

.. seealso:: :py:func:`mapLayer`

.. seealso:: :py:func:`mapLayersByName`
@@ -763,7 +770,7 @@ The legendLayersAdded() signal is emitted only if addToLegend is true.
the layers yourself. Not available in Python.

:return: a list of the map layers that were added
successfully. If a layer is invalid, or already exists in the registry,
successfully. If a layer or already exists in the registry,
it will not be part of the returned QList.


@@ -273,6 +273,7 @@ Returns a list of attributes used to form the referencing fields
bool isValid() const;
%Docstring
Returns the validity of this relation. Don't use the information if it's not valid.
A relation is considered valid if both referenced and referencig layers are valid.

:return: true if the relation is valid
%End
@@ -300,6 +301,14 @@ Gets the referenced field counterpart given a referencing field.
Gets the referencing field counterpart given a referenced field.

.. versionadded:: 3.0
%End

void updateRelationStatus();
%Docstring
Updates the validity status of this relation.
Will be called internally whenever a member is changed.

.. versionadded:: 3.6
%End

};
@@ -45,6 +45,8 @@ Gets access to the relations managed by this class.
void addRelation( const QgsRelation &relation );
%Docstring
Add a relation.
Invalid relations are added only if both referencing layer and referenced
layer exist.

:param relation: The relation to add.
%End
@@ -134,6 +136,13 @@ This signal is emitted when the relations were loaded after reading a project
Emitted when relations are added or removed to the manager.

.. versionadded:: 2.5
%End

public slots:

void updateRelationsStatus();
%Docstring
Updates relations status
%End

};
@@ -736,11 +736,6 @@ Returns point, line or polygon

%Docstring
Returns the WKBType or WKBUnknown in case of error
%End

QString providerType() const;
%Docstring
Returns the provider type for this layer
%End

virtual QgsCoordinateReferenceSystem sourceCrs() const ${SIP_FINAL};
@@ -988,7 +983,8 @@ if the geometry type of the new data source matches the current geometry type of
.. deprecated:: Use version with ProviderOptions argument instead
%End

void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
virtual void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );

%Docstring
Updates the data source of the layer. The layer's renderer and legend will be preserved only
if the geometry type of the new data source matches the current geometry type of the layer.
@@ -2326,15 +2322,6 @@ by the backend data provider).

signals:

void dataSourceChanged();
%Docstring
Emitted whenever the layer's data source has been changed.

.. seealso:: :py:func:`setDataSource`

.. versionadded:: 3.4
%End

void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
%Docstring
This signal is emitted when selection was changed
@@ -114,7 +114,7 @@ Constructor for LayerOptions.

explicit QgsRasterLayer( const QString &uri,
const QString &baseName = QString(),
const QString &providerKey = "gdal",
const QString &providerType = "gdal",
const QgsRasterLayer::LayerOptions &options = QgsRasterLayer::LayerOptions() );
%Docstring
This is the constructor for the RasterLayer class.
@@ -192,6 +192,24 @@ Set the data provider.
:param options: provider options

.. versionadded:: 3.2
%End

virtual void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );

%Docstring
Updates the data source of the layer. The layer's renderer and legend will be preserved only
if the geometry type of the new data source matches the current geometry type of the layer.

:param dataSource: new layer data source
:param baseName: base name of the layer
:param provider: provider string
:param options: provider options
:param loadDefaultStyleFlag: set to true to reset the layer's style to the default for the
data source

.. seealso:: :py:func:`dataSourceChanged`

.. versionadded:: 3.6
%End

LayerType rasterType();
@@ -31,17 +31,22 @@ will return a (possibly invalid) QgsMimeDataUtils.Uri.
%End
public:

QgsDataSourceSelectDialog( bool setFilterByLayerType = false,
QgsDataSourceSelectDialog( QgsBrowserModel *browserModel = 0,
bool setFilterByLayerType = false,
const QgsMapLayer::LayerType &layerType = QgsMapLayer::LayerType::VectorLayer,
QWidget *parent = 0 );
%Docstring
Constructs a QgsDataSourceSelectDialog, optionally filtering by layer type

:param browserModel: an existing browser model (typically from app), if null an instance will be created
:param setFilterByLayerType: activates filtering by layer type
:param layerType: sets the layer type filter, this is in effect only if filtering by layer type is also active
:param parent: the object
%End


~QgsDataSourceSelectDialog();

void setLayerTypeFilter( QgsMapLayer::LayerType layerType );
%Docstring
Sets layer type filter to ``layerType`` and activates the filtering

0 comments on commit c8b2677

Please sign in to comment.
You can’t perform that action at this time.