32 QDomElement element = document.createElement( QStringLiteral(
"selection" ) );
34 element.setAttribute( QStringLiteral(
"mode" ),
qgsEnumValueToKey( mSelectionRenderingMode ) );
38 if ( mSelectionSymbol )
40 QDomElement selectionSymbolElement = document.createElement( QStringLiteral(
"selectionSymbol" ) );
42 element.appendChild( selectionSymbolElement );
45 parentElement.appendChild( element );
51 const QDomElement selectionElement = element.firstChildElement( QStringLiteral(
"selection" ) ).toElement();
52 if ( selectionElement.isNull() )
59 const QDomElement selectionSymbolElement = selectionElement.firstChildElement( QStringLiteral(
"selectionSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
67 std::unique_ptr< QgsVectorLayerSelectionProperties > res = std::make_unique< QgsVectorLayerSelectionProperties >(
nullptr );
68 res->mSelectionRenderingMode = mSelectionRenderingMode;
69 res->mSelectionColor = mSelectionColor;
70 res->mSelectionSymbol.reset( mSelectionSymbol ? mSelectionSymbol->clone() : nullptr );
76 return mSelectionColor;
81 mSelectionColor = color;
86 return mSelectionSymbol.get();
91 mSelectionSymbol.reset( symbol );
96 return mSelectionRenderingMode;
101 mSelectionRenderingMode = mode;
SelectionRenderingMode
Specifies how a selection should be rendered.
@ Default
Use default symbol and selection colors.
static QColor readXml(const QDomElement &element, const QString &identifier, const QgsReadWriteContext &context)
Reads a color from an XML element, matching the specified identifier string.
static void writeXml(const QColor &color, const QString &identifier, QDomDocument &document, QDomElement &element, const QgsReadWriteContext &context)
Writes a color to an XML element, storing it under the specified identifier.
Base class for storage of map layer selection properties.
The class is used as a container of context for various read/write operations on other objects.
static QgsSymbol * loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
Abstract base class for all rendered symbols.
Implementation of layer selection properties for vector layers.
void setSelectionSymbol(QgsSymbol *symbol)
Sets the symbol used to render selected features in the layer.
QgsVectorLayerSelectionProperties(QObject *parent=nullptr)
Constructor for QgsVectorLayerSelectionProperties, with the specified parent object.
QgsSymbol * selectionSymbol() const
Returns the symbol used to render selected features in the layer.
Qgis::SelectionRenderingMode selectionRenderingMode() const
Returns the selection rendering mode to use for selected features in the layer.
QColor selectionColor() const
Returns the color to use for rendering selected features in the layer.
QgsVectorLayerSelectionProperties * clone() const override
Creates a clone of the properties.
~QgsVectorLayerSelectionProperties() override
QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) override
Writes the properties to a DOM element, to be used later with readXml().
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads temporal properties from a DOM element previously written by writeXml().
void setSelectionColor(const QColor &color)
Sets the color to use for rendering selected features in the layer.
void setSelectionRenderingMode(Qgis::SelectionRenderingMode mode)
Sets the selection rendering mode to use for selected features in the layer.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.