QgsProjectBadLayerHandler class
Interface for classes that handle missing layer files when reading project file.
Contents
Public functions
- void handleBadLayers(const QList<QDomNode>& layers) virtual
- This method will be called whenever the project tries to load layers which cannot be accessed.
Protected types
- enum DataType { IS_VECTOR, IS_RASTER, IS_BOGUS }
- file data representation
- enum ProviderType { IS_FILE, IS_DATABASE, IS_URL, IS_Unknown }
- the flavors for data storage
Protected functions
- auto dataSource(const QDomNode& layerNode) -> QString
- Returns the data source for the given layer.
- auto dataType(const QDomNode& layerNode) -> DataType
- Returns data type associated with the given QgsProject file Dom node.
- auto providerType(const QDomNode& layerNode) -> ProviderType
- Returns the physical storage type associated with the given layer.
- void setDataSource(QDomNode& layerNode, const QString& dataSource)
- Set the datasource element to the new value.
Enum documentation
enum QgsProjectBadLayerHandler:: ProviderType protected
the flavors for data storage
| Enumerators | |
|---|---|
| IS_FILE |
Saved in a file. |
| IS_DATABASE |
Saved in a database. |
| IS_URL |
Retrieved from a URL. |
| IS_Unknown |
Unknown type. |
Function documentation
void QgsProjectBadLayerHandler:: handleBadLayers(const QList<QDomNode>& layers) virtual
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.
QString QgsProjectBadLayerHandler:: dataSource(const QDomNode& layerNode) protected
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.
DataType QgsProjectBadLayerHandler:: dataType(const QDomNode& layerNode) protected
Returns data type associated with the given QgsProject file Dom node.
The Dom node should represent the state associated with a specific layer.
ProviderType QgsProjectBadLayerHandler:: providerType(const QDomNode& layerNode) protected
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.
void QgsProjectBadLayerHandler:: setDataSource(QDomNode& layerNode,
const QString& dataSource) protected
Set the datasource element to the new value.