25#include "moc_qgsvectorlayerselectionproperties.cpp"
27using namespace Qt::StringLiterals;
39 QDomElement element = document.createElement( u
"selection"_s );
45 if ( mSelectionSymbol )
47 QDomElement selectionSymbolElement = document.createElement( u
"selectionSymbol"_s );
49 element.appendChild( selectionSymbolElement );
52 parentElement.appendChild( element );
58 const QDomElement selectionElement = element.firstChildElement( u
"selection"_s ).toElement();
59 if ( selectionElement.isNull() )
66 const QDomElement selectionSymbolElement = selectionElement.firstChildElement( u
"selectionSymbol"_s ).firstChildElement( u
"symbol"_s );
74 auto res = std::make_unique< QgsVectorLayerSelectionProperties >(
nullptr );
75 res->mSelectionRenderingMode = mSelectionRenderingMode;
76 res->mSelectionColor = mSelectionColor;
77 res->mSelectionSymbol.reset( mSelectionSymbol ? mSelectionSymbol->clone() :
nullptr );
83 return mSelectionColor;
88 if ( mSelectionColor == color )
93 mSelectionColor = color;
99 return mSelectionSymbol.get();
104 mSelectionSymbol.reset( symbol );
110 return mSelectionRenderingMode;
115 if ( mSelectionRenderingMode == mode )
120 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.
QgsMapLayerSelectionProperties(QObject *parent)
Constructor for QgsMapLayerSelectionProperties, with the specified parent object.
A container for the context for various read/write operations on objects.
static std::unique_ptr< 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.
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.
Qgis::SelectionRenderingMode selectionRenderingMode
QgsSymbol * selectionSymbol() const
Returns the symbol used to render selected features in the layer.
void selectionSymbolChanged()
Emitted whenever the selection symbol changes.
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 selectionColorChanged()
Emitted whenever the selection color changes.
void setSelectionRenderingMode(Qgis::SelectionRenderingMode mode)
Sets the selection rendering mode to use for selected features in the layer.
void selectionRenderingModeChanged()
Emitted whenever the selection rendering mode changes.
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.