26 const auto constLayers = layers;
27 for (
const QDomNode &layer : constLayers )
35 QString type = layerNode.toElement().attribute( QStringLiteral(
"type" ) );
39 QgsDebugMsg( QStringLiteral(
"cannot find ``type'' attribute" ) );
44 if (
"raster" == type )
50 else if (
"vector" == type )
64 QDomNode dataSourceNode = layerNode.namedItem( QStringLiteral(
"datasource" ) );
66 if ( dataSourceNode.isNull() )
68 QgsDebugMsg( QStringLiteral(
"cannot find datasource node" ) );
73 return dataSourceNode.toElement().text();
88 if ( ds.contains( QLatin1String(
"host=" ) ) )
92 else if ( ds.contains( QLatin1String(
"dbname=" ) ) )
107 QgsDebugMsg( QStringLiteral(
"unknown ``type'' attribute" ) );
115 QDomNode dataSourceNode = layerNode.namedItem( QStringLiteral(
"datasource" ) );
116 QDomElement dataSourceElement = dataSourceNode.toElement();
117 QDomText dataSourceText = dataSourceElement.firstChild().toText();
119 QgsDebugMsg(
"datasource changed from " + dataSourceText.data() );
121 dataSourceText.setData( dataSource );
DataType
file data representation
void setDataSource(QDomNode &layerNode, const QString &dataSource)
Set the datasource element to the new value.
ProviderType
the flavors for data storage
static QgsMessageLog * messageLog()
Returns the application's message log.
DataType dataType(const QDomNode &layerNode)
Returns data type associated with the given QgsProject file Dom node.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QString dataSource(const QDomNode &layerNode)
Returns the data source for the given layer.
virtual void handleBadLayers(const QList< QDomNode > &layers)
This method will be called whenever the project tries to load layers which cannot be accessed...
ProviderType providerType(const QDomNode &layerNode)
Returns the physical storage type associated with the given layer.