QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Member Functions | Protected Types | Protected Member Functions | List of all members
QgsProjectBadLayerHandler Class Reference

Interface for classes that handle missing layer files when reading project file. More...

#include <qgsprojectbadlayerhandler.h>

Inheritance diagram for QgsProjectBadLayerHandler:
Inheritance graph
[legend]

Public Member Functions

virtual ~QgsProjectBadLayerHandler ()=default
 
virtual void handleBadLayers (const QList< QDomNode > &layers)
 This method will be called whenever the project tries to load layers which cannot be accessed. More...
 

Protected Types

enum  DataType { IS_VECTOR , IS_RASTER , IS_BOGUS }
 file data representation More...
 
enum  ProviderType { IS_FILE , IS_DATABASE , IS_URL , IS_Unknown }
 the flavors for data storage More...
 

Protected Member Functions

QString dataSource (const QDomNode &layerNode)
 Returns the data source for the given layer. More...
 
DataType dataType (const QDomNode &layerNode)
 Returns data type associated with the given QgsProject file Dom node. More...
 
ProviderType providerType (const QDomNode &layerNode)
 Returns the physical storage type associated with the given layer. More...
 
void setDataSource (QDomNode &layerNode, const QString &dataSource)
 Set the datasource element to the new value. More...
 

Detailed Description

Interface for classes that handle missing layer files when reading project file.

Definition at line 27 of file qgsprojectbadlayerhandler.h.

Member Enumeration Documentation

◆ DataType

file data representation

Enumerator
IS_VECTOR 

Vector data.

IS_RASTER 

Raster data.

IS_BOGUS 

Bogus data.

Definition at line 49 of file qgsprojectbadlayerhandler.h.

◆ ProviderType

the flavors for data storage

Enumerator
IS_FILE 

Saved in a file.

IS_DATABASE 

Saved in a database.

IS_URL 

Retrieved from a URL.

IS_Unknown 

Unknown type.

Definition at line 57 of file qgsprojectbadlayerhandler.h.

Constructor & Destructor Documentation

◆ ~QgsProjectBadLayerHandler()

virtual QgsProjectBadLayerHandler::~QgsProjectBadLayerHandler ( )
virtualdefault

Member Function Documentation

◆ dataSource()

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.

Since
QGIS 3.0

Definition at line 63 of file qgsprojectbadlayerhandler.cpp.

◆ dataType()

QgsProjectBadLayerHandler::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.

Since
QGIS 3.0

Definition at line 34 of file qgsprojectbadlayerhandler.cpp.

◆ handleBadLayers()

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.

Since
QGIS 3.0

Reimplemented in QgsStoreBadLayerInfo.

Definition at line 23 of file qgsprojectbadlayerhandler.cpp.

◆ providerType()

QgsProjectBadLayerHandler::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.

Since
QGIS 3.0

Definition at line 77 of file qgsprojectbadlayerhandler.cpp.

◆ setDataSource()

void QgsProjectBadLayerHandler::setDataSource ( QDomNode &  layerNode,
const QString &  dataSource 
)
protected

Set the datasource element to the new value.

Since
QGIS 3.0

Definition at line 114 of file qgsprojectbadlayerhandler.cpp.


The documentation for this class was generated from the following files: