Skip to content

Commit

Permalink
Merge pull request #8359 from elpaso/handle-bad-layers2
Browse files Browse the repository at this point in the history
[needs-docs][feature] Deferred handling of bad layers
  • Loading branch information
elpaso committed Nov 6, 2018
2 parents c54c559 + 64bd7a7 commit c8b2677
Show file tree
Hide file tree
Showing 57 changed files with 2,740 additions and 255 deletions.
Expand Up @@ -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 );
Expand Down
62 changes: 61 additions & 1 deletion python/core/auto_generated/qgsmaplayer.sip.in
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
22 changes: 21 additions & 1 deletion python/core/auto_generated/qgsmaplayerstore.sip.in
Expand Up @@ -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
Expand Down Expand Up @@ -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/);

Expand All @@ -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.


Expand Down
11 changes: 9 additions & 2 deletions python/core/auto_generated/qgsproject.sip.in
Expand Up @@ -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;
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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.


Expand Down
9 changes: 9 additions & 0 deletions python/core/auto_generated/qgsrelation.sip.in
Expand Up @@ -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
Expand Down Expand Up @@ -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

};
Expand Down
9 changes: 9 additions & 0 deletions python/core/auto_generated/qgsrelationmanager.sip.in
Expand Up @@ -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
Expand Down Expand Up @@ -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

};
Expand Down
17 changes: 2 additions & 15 deletions python/core/auto_generated/qgsvectorlayer.sip.in
Expand Up @@ -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};
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion python/core/auto_generated/raster/qgsrasterlayer.sip.in
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion python/gui/auto_generated/qgsdatasourceselectdialog.sip.in
Expand Up @@ -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
Expand Down

0 comments on commit c8b2677

Please sign in to comment.