QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
24 #include <QDomElement>
25 #include <QTextStream>
35 return !mXmlData.isEmpty();
54 if ( !errorMsg.isEmpty() )
56 QgsDebugMsg(
"Failed to export style from layer: " + errorMsg );
61 QTextStream stream( &mXmlData );
62 doc.documentElement().save( stream, 0 );
72 QDomDocument doc( QStringLiteral(
"qgis" ) );
73 if ( !doc.setContent( mXmlData ) )
75 QgsDebugMsg( QStringLiteral(
"Failed to parse XML of previously stored XML data - this should not happen!" ) );
82 QgsDebugMsg(
"Failed to import style to layer: " + errorMsg );
89 QTextStream stream( &mXmlData );
90 styleElement.firstChildElement().save( stream, 0 );
100 docX.setContent( mXmlData );
101 styleElement.appendChild( docX.documentElement() );
106 if ( mLayer && mStyleOverridden )
114 if ( mStyleOverridden )
118 mStyleOverridden =
true;
bool setOverrideStyle(const QString &styleDef)
Temporarily apply a different style to the layer.
void writeToLayer(QgsMapLayer *layer) const
Apply stored layer's style information to the layer.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Import the properties of this layer from a QDomDocument.
void readFromLayer(QgsMapLayer *layer)
Store layer's active style information in the instance.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
~QgsMapLayerStyleOverride()
QgsMapLayerStyle()=default
construct invalid style
virtual void exportNamedStyle(QDomDocument &doc, QString &errorMsg, const QgsReadWriteContext &context=QgsReadWriteContext(), QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const
Export the properties of this layer as named style in a QDomDocument.
bool isValid() const
Tell whether the style is valid (i.e. there is something stored in it)
void clear()
Remove any stored style data (will get invalid)
QString xmlData() const
Returns XML content of the style.
void setOverrideStyle(const QString &style)
Temporarily apply a different style to the layer.
void writeXml(QDomElement &styleElement) const
Write style configuration (for project file writing)
bool restoreOverrideStyle()
Restore the original store after a call to setOverrideStyle()
void readXml(const QDomElement &styleElement)
Read style configuration (for project file reading)