QGIS API Documentation 4.1.0-Master (3b8ef1f72a3)
Loading...
Searching...
No Matches
QgsAbstractSymbolConverter Class Referenceabstract

An abstract base class for converting between QgsSymbol objects and QVariant representations. More...

#include <qgssymbolconverter.h>

Inheritance diagram for QgsAbstractSymbolConverter:

Public Member Functions

virtual ~QgsAbstractSymbolConverter ()
virtual Qgis::SymbolConverterCapabilities capabilities () const =0
 Returns the capabilities of the converter.
virtual std::unique_ptr< QgsSymbolcreateSymbol (const QVariant &variant, QgsSymbolConverterContext &context) const =0
 Creates a new QgsSymbol from a QVariant representation.
virtual QString formatName () const =0
 Returns a translated, user-friendly name for the converter's data format.
virtual QString name () const =0
 Returns the unique name for the converter.
virtual QVariant toVariant (const QgsSymbol *symbol, QgsSymbolConverterContext &context) const =0
 Converts a symbol into a QVariant representation.

Detailed Description

An abstract base class for converting between QgsSymbol objects and QVariant representations.

This interface provides a standard mechanism for serializing QGIS symbols to a generic data container (based on QVariant) and deserializing them back into native QgsSymbol objects.

Concrete implementations of this class are intended to handle specific external styling formats, such as SLD (Styled Layer Descriptor) or Mapbox GL styles.

Since
QGIS 4.2

Definition at line 121 of file qgssymbolconverter.h.

Constructor & Destructor Documentation

◆ ~QgsAbstractSymbolConverter()

QgsAbstractSymbolConverter::~QgsAbstractSymbolConverter ( )
virtualdefault

Member Function Documentation

◆ capabilities()

virtual Qgis::SymbolConverterCapabilities QgsAbstractSymbolConverter::capabilities ( ) const
pure virtual

◆ createSymbol()

virtual std::unique_ptr< QgsSymbol > QgsAbstractSymbolConverter::createSymbol ( const QVariant & variant,
QgsSymbolConverterContext & context ) const
pure virtual

Creates a new QgsSymbol from a QVariant representation.

Parameters
variantThe QVariant containing the serialized symbol data.
contextconversion context
Returns
A new QgsSymbol instance representing the data in the variant. The caller takes ownership of the returned object. Returns nullptr if the variant cannot be converted or parsed.
Exceptions
QgsNotSupportedExceptionif the converter does not support deserialization of symbols.

Implemented in QgsSymbolConverterEsriRest, QgsSymbolConverterMapBoxGl, QgsSymbolConverterOgrStyle, QgsSymbolConverterQml, and QgsSymbolConverterSld.

◆ formatName()

virtual QString QgsAbstractSymbolConverter::formatName ( ) const
pure virtual

Returns a translated, user-friendly name for the converter's data format.

E.g. "Styled Layer Descriptor (SLD)" for a converter which handles the SLD format.

See also
name()

Implemented in QgsSymbolConverterEsriRest, QgsSymbolConverterMapBoxGl, QgsSymbolConverterOgrStyle, QgsSymbolConverterQml, and QgsSymbolConverterSld.

◆ name()

virtual QString QgsAbstractSymbolConverter::name ( ) const
pure virtual

Returns the unique name for the converter.

This should be an untranslated string identifying the converter.

See also
formatName()

Implemented in QgsSymbolConverterEsriRest, QgsSymbolConverterMapBoxGl, QgsSymbolConverterOgrStyle, QgsSymbolConverterQml, and QgsSymbolConverterSld.

◆ toVariant()

virtual QVariant QgsAbstractSymbolConverter::toVariant ( const QgsSymbol * symbol,
QgsSymbolConverterContext & context ) const
pure virtual

Converts a symbol into a QVariant representation.

The resulting QVariant may be a dictionary (QVariantMap), a JSON string, an XML representation of the symbol, or some binary QByteArray value, depending on the concrete implementation (e.g., SLD vs. Mapbox GL).

Returns an invalid variant if the symbol could not be converted, or if serialization of symbols is not supported for this converter.

Exceptions
QgsNotSupportedExceptionif the converter does not support serialization of symbols.

Implemented in QgsSymbolConverterEsriRest, QgsSymbolConverterMapBoxGl, QgsSymbolConverterOgrStyle, QgsSymbolConverterQml, and QgsSymbolConverterSld.


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