Class: QgsProjectBadLayerHandler¶
Interface for classes that handle missing layer files when reading project files.
Class Hierarchy¶
Subclasses¶
Stores layer IDs for bad (broken) layers. |
Methods
Returns the data source for the given layer |
|
Returns data type associated with the given |
|
Returns the physical storage type associated with the given layer |
|
Set the datasource element to the new value |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsProjectBadLayerHandler. See the FAQ for more details.
This method will be called whenever the project tries to load layers which cannot be accessed. |
Attributes
- class qgis.core.QgsProjectBadLayerHandler[source]¶
Bases:
object
- class DataType¶
Bases:
int
- IS_BOGUS = 2¶
- IS_DATABASE = 1¶
- IS_FILE = 0¶
- IS_RASTER = 1¶
- IS_URL = 2¶
- IS_Unknown = 3¶
- IS_VECTOR = 0¶
- class ProviderType¶
Bases:
int
- dataSource(self, layerNode: QDomNode) str [source]¶
Returns the data source for the given layer
The QDomNode is a
QgsProject
Dom node corresponding to a map layer state.Essentially dumps datasource tag.
- Parameters:
layerNode (QDomNode)
- Return type:
str
- dataType(self, layerNode: QDomNode) QgsProjectBadLayerHandler.DataType [source]¶
Returns data type associated with the given
QgsProject
file Dom nodeThe Dom node should represent the state associated with a specific layer.
- Parameters:
layerNode (QDomNode)
- Return type:
- virtual handleBadLayers(self, layers: Iterable[QDomNode])[source]¶
This method will be called whenever the project tries to load layers which cannot be accessed. It should inform the user about this and if possible offer to fix the unavailable layers by setting a valid datasource, e.g. by showing a file dialog.
The default implementation will dismiss all bad layers and write information to the log.
- Parameters:
layers (Iterable[QDomNode])
- providerType(self, layerNode: QDomNode) QgsProjectBadLayerHandler.ProviderType [source]¶
Returns the physical storage type associated with the given layer
The QDomNode is a
QgsProject
Dom node corresponding to a map layer state.If the provider tag is “ogr”, then it’s a file type.
However, if the layer is a raster, then there won’t be a provider tag. It will always have an associated file.
If the layer doesn’t fall into either of the previous two categories, then it’s either a database or URL. If the datasource tag has “url=”, then it’s URL based and if it has “dbname=”>, then the layer data is in a database.
- Parameters:
layerNode (QDomNode)
- Return type: