QGIS API Documentation  3.9.0-Master (3ff8ca5736)
Public Types | Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsStyle Class Reference

#include <qgsstyle.h>

Inheritance diagram for QgsStyle:
Inheritance graph
[legend]

Public Types

enum  StyleEntity {
  SymbolEntity, TagEntity, ColorrampEntity, SmartgroupEntity,
  TextFormatEntity, LabelSettingsEntity
}
 Enum for Entities involved in a style. More...
 

Signals

void entityTagsChanged (QgsStyle::StyleEntity entity, const QString &name, const QStringList &newTags)
 Emitted whenever an entity's tags are changed. More...
 
void favoritedChanged (QgsStyle::StyleEntity entity, const QString &name, bool isFavorite)
 Emitted whenever an entity is either favorited or un-favorited. More...
 
void groupsModified ()
 Emitted every time a tag or smartgroup has been added, removed, or renamed. More...
 
void labelSettingsAdded (const QString &name)
 Emitted whenever label settings have been added to the style and the database has been updated as a result. More...
 
void labelSettingsChanged (const QString &name)
 Emitted whenever a label setting's definition is changed. More...
 
void labelSettingsRemoved (const QString &name)
 Emitted whenever label settings have been removed from the style and the database has been updated as a result. More...
 
void labelSettingsRenamed (const QString &oldName, const QString &newName)
 Emitted whenever label settings have been renamed from oldName to newName. More...
 
void rampAdded (const QString &name)
 Emitted whenever a color ramp has been added to the style and the database has been updated as a result. More...
 
void rampChanged (const QString &name)
 Emitted whenever a color ramp's definition is changed. More...
 
void rampRemoved (const QString &name)
 Emitted whenever a color ramp has been removed from the style and the database has been updated as a result. More...
 
void rampRenamed (const QString &oldName, const QString &newName)
 Emitted whenever a color ramp has been renamed from oldName to newName. More...
 
void symbolChanged (const QString &name)
 Emitted whenever a symbol's definition is changed. More...
 
void symbolRemoved (const QString &name)
 Emitted whenever a symbol has been removed from the style and the database has been updated as a result. More...
 
void symbolRenamed (const QString &oldName, const QString &newName)
 Emitted whenever a symbol has been renamed from oldName to newName. More...
 
void symbolSaved (const QString &name, QgsSymbol *symbol)
 Emitted every time a new symbol has been added to the database. More...
 
void textFormatAdded (const QString &name)
 Emitted whenever a text format has been added to the style and the database has been updated as a result. More...
 
void textFormatChanged (const QString &name)
 Emitted whenever a text format's definition is changed. More...
 
void textFormatRemoved (const QString &name)
 Emitted whenever a text format has been removed from the style and the database has been updated as a result. More...
 
void textFormatRenamed (const QString &oldName, const QString &newName)
 Emitted whenever a text format has been renamed from oldName to newName. More...
 

Public Member Functions

 QgsStyle ()=default
 Constructor for QgsStyle. More...
 
 ~QgsStyle () override
 
bool addColorRamp (const QString &name, QgsColorRamp *colorRamp, bool update=false)
 Adds a color ramp to the style. More...
 
bool addEntity (const QString &name, const QgsStyleEntityInterface *entity, bool update=false)
 Adds an entity to the style, with the specified name. More...
 
bool addFavorite (StyleEntity type, const QString &name)
 Adds the specified symbol to favorites. More...
 
bool addLabelSettings (const QString &name, const QgsPalLayerSettings &settings, bool update=false)
 Adds label settings with the specified name to the style. More...
 
int addSmartgroup (const QString &name, const QString &op, const QgsSmartConditionMap &conditions)
 Adds a new smartgroup to the database and returns the id. More...
 
int addSmartgroup (const QString &name, const QString &op, const QStringList &matchTag, const QStringList &noMatchTag, const QStringList &matchName, const QStringList &noMatchName)
 Adds a new smartgroup to the database and returns the id. More...
 
bool addSymbol (const QString &name, QgsSymbol *symbol, bool update=false)
 Adds a symbol to style and takes symbol's ownership. More...
 
int addTag (const QString &tagName)
 Adds a new tag and returns the tag's id. More...
 
bool addTextFormat (const QString &name, const QgsTextFormat &format, bool update=false)
 Adds a text format with the specified name to the style. More...
 
QStringList allNames (StyleEntity type) const
 Returns a list of the names of all existing entities of the specified type. More...
 
void clear ()
 Removes all contents of the style. More...
 
QgsColorRampcolorRamp (const QString &name) const
 Returns a new copy of the specified color ramp. More...
 
int colorRampCount ()
 Returns count of color ramps. More...
 
int colorrampId (const QString &name)
 Returns the id in the style database for the given colorramp name returns 0 if not found. More...
 
QStringList colorRampNames () const
 Returns a list of names of color ramps. More...
 
const QgsColorRampcolorRampRef (const QString &name) const
 Returns a const pointer to a symbol (doesn't create new instance) More...
 
bool createDatabase (const QString &filename)
 Creates an on-disk database. More...
 
bool createMemoryDatabase ()
 Creates a temporary memory database. More...
 
void createTables ()
 Creates tables structure for new database. More...
 
bool detagSymbol (StyleEntity type, const QString &symbol, const QStringList &tags)
 Detags the symbol with the given list. More...
 
bool detagSymbol (StyleEntity type, const QString &symbol)
 Clears the symbol from all attached tags. More...
 
QString errorString ()
 Returns last error from load/save operation. More...
 
bool exportXml (const QString &filename)
 Exports the style as a XML file. More...
 
QString fileName ()
 Returns current file name of the style. More...
 
QStringList findSymbols (StyleEntity type, const QString &qword)
 Returns the names of the symbols which have a matching 'substring' in its definition. More...
 
bool importXml (const QString &filename)
 Imports the symbols and colorramps into the default style database from the given XML file. More...
 
bool isFavorite (StyleEntity type, const QString &name)
 Returns true if the symbol with matching type and name is marked as a favorite. More...
 
QgsPalLayerSettings labelSettings (const QString &name) const
 Returns the label settings with the specified name. More...
 
int labelSettingsCount () const
 Returns count of label settings in the style. More...
 
int labelSettingsId (const QString &name)
 Returns the ID in the style database for the given label settings by name. More...
 
QgsWkbTypes::GeometryType labelSettingsLayerType (const QString &name) const
 Returns the layer geometry type corresponding to the label settings with the specified name, or QgsWkbTypes::UnknownGeometry if matching label settings are not present. More...
 
QStringList labelSettingsNames () const
 Returns a list of names of label settings in the style. More...
 
bool load (const QString &filename)
 Loads a file into the style. More...
 
bool remove (StyleEntity type, int id)
 Removes the specified entity from the db. More...
 
bool removeColorRamp (const QString &name)
 Removes color ramp from style (and delete it) More...
 
bool removeFavorite (StyleEntity type, const QString &name)
 Removes the specified symbol from favorites. More...
 
bool removeLabelSettings (const QString &name)
 Removes label settings from the style. More...
 
bool removeSymbol (const QString &name)
 Removes symbol from style (and delete it) More...
 
bool removeTextFormat (const QString &name)
 Removes a text format from the style. More...
 
bool rename (StyleEntity type, int id, const QString &newName)
 Renames the given entity with the specified id. More...
 
bool renameColorRamp (const QString &oldName, const QString &newName)
 Changes ramp's name. More...
 
bool renameLabelSettings (const QString &oldName, const QString &newName)
 Changes a label setting's name. More...
 
bool renameSymbol (const QString &oldName, const QString &newName)
 Renames a symbol from oldName to newName. More...
 
bool renameTextFormat (const QString &oldName, const QString &newName)
 Changes a text format's name. More...
 
bool save (QString filename=QString())
 Saves style into a file (will use current filename if empty string is passed) More...
 
bool saveColorRamp (const QString &name, QgsColorRamp *ramp, bool favorite, const QStringList &tags)
 Adds the colorramp to the DB. More...
 
bool saveLabelSettings (const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags)
 Adds label settings to the database. More...
 
bool saveSymbol (const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
 Adds the symbol to the DB with the tags. More...
 
bool saveTextFormat (const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
 Adds a text format to the database. More...
 
QgsSmartConditionMap smartgroup (int id)
 Returns the QgsSmartConditionMap for the given id. More...
 
int smartgroupId (const QString &smartgroup)
 Returns the DB id for the given smartgroup name. More...
 
QStringList smartgroupNames () const
 Returns the smart groups list. More...
 
QString smartgroupOperator (int id)
 Returns the operator for the smartgroup clumsy implementation TODO create a class for smartgroups. More...
 
QgsSymbolGroupMap smartgroupsListMap ()
 Returns the smart groups map with id as key and name as value. More...
 
QgsSymbolsymbol (const QString &name)
 Returns a NEW copy of symbol. More...
 
int symbolCount ()
 Returns count of symbols in style. More...
 
bool symbolHasTag (StyleEntity type, const QString &symbol, const QString &tag)
 Returns whether a given tag is associated with the symbol. More...
 
int symbolId (const QString &name)
 Returns the id in the style database for the given symbol name returns 0 if not found. More...
 
QStringList symbolNames () const
 Returns a list of names of symbols. More...
 
const QgsSymbolsymbolRef (const QString &name) const
 Returns a const pointer to a symbol (doesn't create new instance) More...
 
QStringList symbolsOfFavorite (StyleEntity type) const
 Returns the symbol names which are flagged as favorite. More...
 
QStringList symbolsOfSmartgroup (StyleEntity type, int id)
 Returns the symbols for the smartgroup. More...
 
QStringList symbolsWithTag (StyleEntity type, int tagid) const
 Returns the symbol names with which have the given tag. More...
 
QString tag (int id) const
 Returns the tag name for the given id. More...
 
int tagId (const QString &tag)
 Returns the DB id for the given tag name. More...
 
QStringList tags () const
 Returns a list of all tags in the style database. More...
 
QStringList tagsOfSymbol (StyleEntity type, const QString &symbol)
 Returns the tags associated with the symbol. More...
 
bool tagSymbol (StyleEntity type, const QString &symbol, const QStringList &tags)
 Tags the symbol with the tags in the list. More...
 
QgsTextFormat textFormat (const QString &name) const
 Returns the text format with the specified name. More...
 
int textFormatCount () const
 Returns count of text formats in the style. More...
 
int textFormatId (const QString &name)
 Returns the ID in the style database for the given text format by name. More...
 
QStringList textFormatNames () const
 Returns a list of names of text formats in the style. More...
 

Static Public Member Functions

static void cleanDefaultStyle ()
 Deletes the default style. Only to be used by QgsApplication::exitQgis() More...
 
static QgsStyledefaultStyle ()
 Returns default application-wide style. More...
 
static bool isXmlStyleFile (const QString &path)
 Tests if the file at path is a QGIS style XML file. More...
 

Detailed Description

Definition at line 158 of file qgsstyle.h.

Member Enumeration Documentation

◆ StyleEntity

Enum for Entities involved in a style.

The enumerator is used for identifying the entity being operated on when generic database functions are being run.

See also
rename(), remove(), symbolsOfFavorite(), symbolsWithTag(), symbolsOfSmartgroup()
Enumerator
SymbolEntity 

Symbols.

TagEntity 

Tags.

ColorrampEntity 

Color ramps.

SmartgroupEntity 

Smart groups.

TextFormatEntity 

Text formats.

LabelSettingsEntity 

Label settings.

Definition at line 177 of file qgsstyle.h.

Constructor & Destructor Documentation

◆ QgsStyle()

QgsStyle::QgsStyle ( )
default

Constructor for QgsStyle.

◆ ~QgsStyle()

QgsStyle::~QgsStyle ( )
override

Definition at line 41 of file qgsstyle.cpp.

Member Function Documentation

◆ addColorRamp()

bool QgsStyle::addColorRamp ( const QString &  name,
QgsColorRamp colorRamp,
bool  update = false 
)

Adds a color ramp to the style.

Calling this method takes the ramp's ownership.

Note
Adding a color ramp with the name of existing one replaces it.
Parameters
nameis the name of the color ramp being added or updated
colorRampis the color ramp. Ownership is transferred.
updateset to true when the style DB has to be updated, by default it is false
Returns
success status of the operation

Definition at line 236 of file qgsstyle.cpp.

◆ addEntity()

bool QgsStyle::addEntity ( const QString &  name,
const QgsStyleEntityInterface entity,
bool  update = false 
)

Adds an entity to the style, with the specified name.

Ownership is not transferred.

If update is true then the style database is updated automatically as a result.

Returns true if the add operation was successful.

Note
Adding an entity with the name of existing one replaces the existing one automatically.
Since
QGIS 3.10

Definition at line 46 of file qgsstyle.cpp.

◆ addFavorite()

bool QgsStyle::addFavorite ( StyleEntity  type,
const QString &  name 
)

Adds the specified symbol to favorites.

Parameters
typeis either SymbolEntity of ColorrampEntity
nameis the name of the symbol or coloramp whose is to be added to favorites
Returns
returns the success state as bool

Definition at line 1189 of file qgsstyle.cpp.

◆ addLabelSettings()

bool QgsStyle::addLabelSettings ( const QString &  name,
const QgsPalLayerSettings settings,
bool  update = false 
)

Adds label settings with the specified name to the style.

If update is set to true, the style DB will be automatically updated with the new text format.

Returns true if the operation was successful.

Note
Adding label settings with the name of existing ones replaces them.
Since
QGIS 3.10

Definition at line 281 of file qgsstyle.cpp.

◆ addSmartgroup() [1/2]

int QgsStyle::addSmartgroup ( const QString &  name,
const QString &  op,
const QgsSmartConditionMap conditions 
)

Adds a new smartgroup to the database and returns the id.

Parameters
nameis the name of the new Smart Group to be added
opis the operator between the conditions; AND/OR as QString
conditionsare the smart group conditions
Note
Not available from Python bindings

Definition at line 2111 of file qgsstyle.cpp.

◆ addSmartgroup() [2/2]

int QgsStyle::addSmartgroup ( const QString &  name,
const QString &  op,
const QStringList &  matchTag,
const QStringList &  noMatchTag,
const QStringList &  matchName,
const QStringList &  noMatchName 
)

Adds a new smartgroup to the database and returns the id.

Parameters
nameis the name of the new Smart Group to be added
opis the operator between the conditions; AND/OR as QString
matchTaglist of strings to match within tags
noMatchTaglist of strings to exclude matches from tags
matchNamelist of string to match within names
noMatchNamelist of strings to exclude matches from names
Since
QGIS 3.4

Definition at line 2119 of file qgsstyle.cpp.

◆ addSymbol()

bool QgsStyle::addSymbol ( const QString &  name,
QgsSymbol symbol,
bool  update = false 
)

Adds a symbol to style and takes symbol's ownership.

Note
Adding a symbol with the name of existing one replaces it.
Parameters
nameis the name of the symbol being added or updated
symbolis the Vector symbol
updateset to true when the style DB has to be updated, by default it is false
Returns
success status of the operation

Definition at line 124 of file qgsstyle.cpp.

◆ addTag()

int QgsStyle::addTag ( const QString &  tagName)

Adds a new tag and returns the tag's id.

Parameters
tagNamethe name of the new tag to be created
Returns
returns an int, which is the DB id of the new tag created, 0 if the tag couldn't be created

Definition at line 1012 of file qgsstyle.cpp.

◆ addTextFormat()

bool QgsStyle::addTextFormat ( const QString &  name,
const QgsTextFormat format,
bool  update = false 
)

Adds a text format with the specified name to the style.

If update is set to true, the style DB will be automatically updated with the new text format.

Returns true if the operation was successful.

Note
Adding a text format with the name of existing one replaces it.
Since
QGIS 3.10

Definition at line 260 of file qgsstyle.cpp.

◆ allNames()

QStringList QgsStyle::allNames ( QgsStyle::StyleEntity  type) const

Returns a list of the names of all existing entities of the specified type.

Since
QGIS 3.10

Definition at line 2086 of file qgsstyle.cpp.

◆ cleanDefaultStyle()

void QgsStyle::cleanDefaultStyle ( )
static

Deletes the default style. Only to be used by QgsApplication::exitQgis()

Definition at line 99 of file qgsstyle.cpp.

◆ clear()

void QgsStyle::clear ( )

Removes all contents of the style.

Definition at line 105 of file qgsstyle.cpp.

◆ colorRamp()

QgsColorRamp * QgsStyle::colorRamp ( const QString &  name) const

Returns a new copy of the specified color ramp.

The caller takes responsibility for deleting the returned object.

Definition at line 356 of file qgsstyle.cpp.

◆ colorRampCount()

int QgsStyle::colorRampCount ( )

Returns count of color ramps.

Definition at line 367 of file qgsstyle.cpp.

◆ colorrampId()

int QgsStyle::colorrampId ( const QString &  name)

Returns the id in the style database for the given colorramp name returns 0 if not found.

Definition at line 2023 of file qgsstyle.cpp.

◆ colorRampNames()

QStringList QgsStyle::colorRampNames ( ) const

Returns a list of names of color ramps.

Definition at line 372 of file qgsstyle.cpp.

◆ colorRampRef()

const QgsColorRamp * QgsStyle::colorRampRef ( const QString &  name) const

Returns a const pointer to a symbol (doesn't create new instance)

Definition at line 362 of file qgsstyle.cpp.

◆ createDatabase()

bool QgsStyle::createDatabase ( const QString &  filename)

Creates an on-disk database.

This function creates a new on-disk permanent style database.

Returns
returns the success state of the database creation
See also
createMemoryDatabase()
Since
QGIS 3.0

Definition at line 389 of file qgsstyle.cpp.

◆ createMemoryDatabase()

bool QgsStyle::createMemoryDatabase ( )

Creates a temporary memory database.

This function is used to create a temporary style database in case a permanent on-disk database is not needed.

Returns
returns the success state of the temporary memory database creation
See also
createDatabase()
Since
QGIS 3.0

Definition at line 404 of file qgsstyle.cpp.

◆ createTables()

void QgsStyle::createTables ( )

Creates tables structure for new database.

This function is used to create the tables structure in a newly-created database.

Returns
returns the success state of the temporary memory database creation
See also
createDatabase()
createMemoryDatabase()
Since
QGIS 3.0

Definition at line 419 of file qgsstyle.cpp.

◆ defaultStyle()

QgsStyle * QgsStyle::defaultStyle ( )
static

Returns default application-wide style.

Definition at line 74 of file qgsstyle.cpp.

◆ detagSymbol() [1/2]

bool QgsStyle::detagSymbol ( StyleEntity  type,
const QString &  symbol,
const QStringList &  tags 
)

Detags the symbol with the given list.

Removes the given tags for the specified symbol or colorramp

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or colorramp
tagsis the list of tags that are to be removed as QStringList
Returns
returns the success state of the operation

Definition at line 1495 of file qgsstyle.cpp.

◆ detagSymbol() [2/2]

bool QgsStyle::detagSymbol ( StyleEntity  type,
const QString &  symbol 
)

Clears the symbol from all attached tags.

Removes all tags for the specified symbol or colorramp

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or colorramp
Returns
returns the success state of the operation

Definition at line 1593 of file qgsstyle.cpp.

◆ entityTagsChanged

void QgsStyle::entityTagsChanged ( QgsStyle::StyleEntity  entity,
const QString &  name,
const QStringList &  newTags 
)
signal

Emitted whenever an entity's tags are changed.

Since
QGIS 3.4

◆ errorString()

QString QgsStyle::errorString ( )
inline

Returns last error from load/save operation.

Definition at line 622 of file qgsstyle.h.

◆ exportXml()

bool QgsStyle::exportXml ( const QString &  filename)

Exports the style as a XML file.

Definition at line 2374 of file qgsstyle.cpp.

◆ favoritedChanged

void QgsStyle::favoritedChanged ( QgsStyle::StyleEntity  entity,
const QString &  name,
bool  isFavorite 
)
signal

Emitted whenever an entity is either favorited or un-favorited.

Since
QGIS 3.4

◆ fileName()

QString QgsStyle::fileName ( )
inline

Returns current file name of the style.

Definition at line 625 of file qgsstyle.h.

◆ findSymbols()

QStringList QgsStyle::findSymbols ( StyleEntity  type,
const QString &  qword 
)

Returns the names of the symbols which have a matching 'substring' in its definition.

Parameters
typeis either SymbolEntity or ColorrampEntity
qwordis the query string to search the symbols or colorramps.
Returns
A QStringList of the matched symbols or colorramps

Definition at line 1293 of file qgsstyle.cpp.

◆ groupsModified

void QgsStyle::groupsModified ( )
signal

Emitted every time a tag or smartgroup has been added, removed, or renamed.

◆ importXml()

bool QgsStyle::importXml ( const QString &  filename)

Imports the symbols and colorramps into the default style database from the given XML file.

Definition at line 2489 of file qgsstyle.cpp.

◆ isFavorite()

bool QgsStyle::isFavorite ( QgsStyle::StyleEntity  type,
const QString &  name 
)

Returns true if the symbol with matching type and name is marked as a favorite.

Since
QGIS 3.10

Definition at line 1806 of file qgsstyle.cpp.

◆ isXmlStyleFile()

bool QgsStyle::isXmlStyleFile ( const QString &  path)
static

Tests if the file at path is a QGIS style XML file.

This method samples only the first line in the file, so is safe to call on large xml files.

Since
QGIS 3.6

Definition at line 2701 of file qgsstyle.cpp.

◆ labelSettings()

QgsPalLayerSettings QgsStyle::labelSettings ( const QString &  name) const

Returns the label settings with the specified name.

Since
QGIS 3.10

Definition at line 2048 of file qgsstyle.cpp.

◆ labelSettingsAdded

void QgsStyle::labelSettingsAdded ( const QString &  name)
signal

Emitted whenever label settings have been added to the style and the database has been updated as a result.

See also
labelSettingsRemoved()
symbolSaved()
Since
QGIS 3.10

◆ labelSettingsChanged

void QgsStyle::labelSettingsChanged ( const QString &  name)
signal

Emitted whenever a label setting's definition is changed.

This does not include name or tag changes.

See also
labelSettingsAdded()
Since
QGIS 3.10

◆ labelSettingsCount()

int QgsStyle::labelSettingsCount ( ) const

Returns count of label settings in the style.

Since
QGIS 3.10

Definition at line 2061 of file qgsstyle.cpp.

◆ labelSettingsId()

int QgsStyle::labelSettingsId ( const QString &  name)

Returns the ID in the style database for the given label settings by name.

Returns 0 if the label settings were not found.

Since
QGIS 3.10

Definition at line 2071 of file qgsstyle.cpp.

◆ labelSettingsLayerType()

QgsWkbTypes::GeometryType QgsStyle::labelSettingsLayerType ( const QString &  name) const

Returns the layer geometry type corresponding to the label settings with the specified name, or QgsWkbTypes::UnknownGeometry if matching label settings are not present.

Since
QGIS 3.10

Definition at line 2053 of file qgsstyle.cpp.

◆ labelSettingsNames()

QStringList QgsStyle::labelSettingsNames ( ) const

Returns a list of names of label settings in the style.

Since
QGIS 3.10

Definition at line 2066 of file qgsstyle.cpp.

◆ labelSettingsRemoved

void QgsStyle::labelSettingsRemoved ( const QString &  name)
signal

Emitted whenever label settings have been removed from the style and the database has been updated as a result.

See also
labelSettingsAdded()
symbolRemoved()
Since
QGIS 3.10

◆ labelSettingsRenamed

void QgsStyle::labelSettingsRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever label settings have been renamed from oldName to newName.

See also
symbolRenamed()
Since
QGIS 3.10

◆ load()

bool QgsStyle::load ( const QString &  filename)

Loads a file into the style.

This function will load an on-disk database and populate styles.

Parameters
filenamelocation of the database to load styles from
Returns
returns the success state of the database being loaded

Definition at line 463 of file qgsstyle.cpp.

◆ rampAdded

void QgsStyle::rampAdded ( const QString &  name)
signal

Emitted whenever a color ramp has been added to the style and the database has been updated as a result.

See also
rampRemoved()
symbolSaved()
Since
QGIS 3.4

◆ rampChanged

void QgsStyle::rampChanged ( const QString &  name)
signal

Emitted whenever a color ramp's definition is changed.

This does not include name or tag changes.

See also
rampAdded()
Since
QGIS 3.4

◆ rampRemoved

void QgsStyle::rampRemoved ( const QString &  name)
signal

Emitted whenever a color ramp has been removed from the style and the database has been updated as a result.

See also
rampAdded()
symbolRemoved()
Since
QGIS 3.4

◆ rampRenamed

void QgsStyle::rampRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever a color ramp has been renamed from oldName to newName.

See also
symbolRenamed()
Since
QGIS 3.4

◆ remove()

bool QgsStyle::remove ( StyleEntity  type,
int  id 
)

Removes the specified entity from the db.

Parameters
typeis any of the style entities. Refer enum StyleEntity.
idis the DB id of the entity to be removed

Definition at line 1116 of file qgsstyle.cpp.

◆ removeColorRamp()

bool QgsStyle::removeColorRamp ( const QString &  name)

Removes color ramp from style (and delete it)

Definition at line 335 of file qgsstyle.cpp.

◆ removeFavorite()

bool QgsStyle::removeFavorite ( StyleEntity  type,
const QString &  name 
)

Removes the specified symbol from favorites.

Parameters
typeis either SymbolEntity of ColorrampEntity
nameis the name of the symbol or coloramp whose is to be removed from favorites
Returns
returns the success state as bool

Definition at line 1241 of file qgsstyle.cpp.

◆ removeLabelSettings()

bool QgsStyle::removeLabelSettings ( const QString &  name)

Removes label settings from the style.

Since
QGIS 3.10

Definition at line 833 of file qgsstyle.cpp.

◆ removeSymbol()

bool QgsStyle::removeSymbol ( const QString &  name)

Removes symbol from style (and delete it)

Definition at line 181 of file qgsstyle.cpp.

◆ removeTextFormat()

bool QgsStyle::removeTextFormat ( const QString &  name)

Removes a text format from the style.

Since
QGIS 3.10

Definition at line 745 of file qgsstyle.cpp.

◆ rename()

bool QgsStyle::rename ( StyleEntity  type,
int  id,
const QString &  newName 
)

Renames the given entity with the specified id.

Parameters
typeis any of the style entities. Refer enum StyleEntity.
idis the DB id of the entity which is to be renamed
newNameis the new name of the entity

Definition at line 1052 of file qgsstyle.cpp.

◆ renameColorRamp()

bool QgsStyle::renameColorRamp ( const QString &  oldName,
const QString &  newName 
)

Changes ramp's name.

Definition at line 680 of file qgsstyle.cpp.

◆ renameLabelSettings()

bool QgsStyle::renameLabelSettings ( const QString &  oldName,
const QString &  newName 
)

Changes a label setting's name.

Since
QGIS 3.10

Definition at line 855 of file qgsstyle.cpp.

◆ renameSymbol()

bool QgsStyle::renameSymbol ( const QString &  oldName,
const QString &  newName 
)

Renames a symbol from oldName to newName.

Returns true if symbol was successfully renamed.

Definition at line 643 of file qgsstyle.cpp.

◆ renameTextFormat()

bool QgsStyle::renameTextFormat ( const QString &  oldName,
const QString &  newName 
)

Changes a text format's name.

Since
QGIS 3.10

Definition at line 768 of file qgsstyle.cpp.

◆ save()

bool QgsStyle::save ( QString  filename = QString())

Saves style into a file (will use current filename if empty string is passed)

Definition at line 597 of file qgsstyle.cpp.

◆ saveColorRamp()

bool QgsStyle::saveColorRamp ( const QString &  name,
QgsColorRamp ramp,
bool  favorite,
const QStringList &  tags 
)

Adds the colorramp to the DB.

Parameters
nameis the name of the colorramp as QString
rampis the pointer to the new QgsColorRamp being saved
favoriteis a boolean value to specify whether the colorramp should be added to favorites
tagsis a list of tags that are associated with the color ramp as a QStringList.
Returns
returns the success state of the save operation

Definition at line 302 of file qgsstyle.cpp.

◆ saveLabelSettings()

bool QgsStyle::saveLabelSettings ( const QString &  name,
const QgsPalLayerSettings settings,
bool  favorite,
const QStringList &  tags 
)

Adds label settings to the database.

Parameters
nameis the name of the label settings
settingslabel settings to save
favoriteis a boolean value to specify whether the label settings should be added to favorites
tagsis a list of tags that are associated with the label settings
Returns
returns the success state of the save operation

Definition at line 800 of file qgsstyle.cpp.

◆ saveSymbol()

bool QgsStyle::saveSymbol ( const QString &  name,
QgsSymbol symbol,
bool  favorite,
const QStringList &  tags 
)

Adds the symbol to the DB with the tags.

Parameters
nameis the name of the symbol as QString
symbolis the pointer to the new QgsSymbol being saved
favoriteis a boolean value to specify whether the symbol should be added to favorites
tagsis a list of tags that are associated with the symbol as a QStringList.
Returns
returns the success state of the save operation

Definition at line 148 of file qgsstyle.cpp.

◆ saveTextFormat()

bool QgsStyle::saveTextFormat ( const QString &  name,
const QgsTextFormat format,
bool  favorite,
const QStringList &  tags 
)

Adds a text format to the database.

Parameters
nameis the name of the text format
formattext format to save
favoriteis a boolean value to specify whether the text format should be added to favorites
tagsis a list of tags that are associated with the text format
Returns
returns the success state of the save operation

Definition at line 712 of file qgsstyle.cpp.

◆ smartgroup()

QgsSmartConditionMap QgsStyle::smartgroup ( int  id)

Returns the QgsSmartConditionMap for the given id.

Definition at line 2304 of file qgsstyle.cpp.

◆ smartgroupId()

int QgsStyle::smartgroupId ( const QString &  smartgroup)

Returns the DB id for the given smartgroup name.

Definition at line 2081 of file qgsstyle.cpp.

◆ smartgroupNames()

QStringList QgsStyle::smartgroupNames ( ) const

Returns the smart groups list.

Definition at line 2188 of file qgsstyle.cpp.

◆ smartgroupOperator()

QString QgsStyle::smartgroupOperator ( int  id)

Returns the operator for the smartgroup clumsy implementation TODO create a class for smartgroups.

Definition at line 2344 of file qgsstyle.cpp.

◆ smartgroupsListMap()

QgsSymbolGroupMap QgsStyle::smartgroupsListMap ( )

Returns the smart groups map with id as key and name as value.

Definition at line 2163 of file qgsstyle.cpp.

◆ symbol()

QgsSymbol * QgsStyle::symbol ( const QString &  name)

Returns a NEW copy of symbol.

Definition at line 214 of file qgsstyle.cpp.

◆ symbolChanged

void QgsStyle::symbolChanged ( const QString &  name)
signal

Emitted whenever a symbol's definition is changed.

This does not include name or tag changes.

See also
symbolSaved()
Since
QGIS 3.4

◆ symbolCount()

int QgsStyle::symbolCount ( )

Returns count of symbols in style.

Definition at line 225 of file qgsstyle.cpp.

◆ symbolHasTag()

bool QgsStyle::symbolHasTag ( StyleEntity  type,
const QString &  symbol,
const QString &  tag 
)

Returns whether a given tag is associated with the symbol.

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or color ramp
tagthe name of the tag to look for
Returns
A boolean value identicating whether a tag was found attached to the symbol

Definition at line 1880 of file qgsstyle.cpp.

◆ symbolId()

int QgsStyle::symbolId ( const QString &  name)

Returns the id in the style database for the given symbol name returns 0 if not found.

Definition at line 2018 of file qgsstyle.cpp.

◆ symbolNames()

QStringList QgsStyle::symbolNames ( ) const

Returns a list of names of symbols.

Definition at line 230 of file qgsstyle.cpp.

◆ symbolRef()

const QgsSymbol * QgsStyle::symbolRef ( const QString &  name) const

Returns a const pointer to a symbol (doesn't create new instance)

Definition at line 220 of file qgsstyle.cpp.

◆ symbolRemoved

void QgsStyle::symbolRemoved ( const QString &  name)
signal

Emitted whenever a symbol has been removed from the style and the database has been updated as a result.

See also
symbolSaved()
rampRemoved()
Since
QGIS 3.4

◆ symbolRenamed

void QgsStyle::symbolRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever a symbol has been renamed from oldName to newName.

See also
rampRenamed()
Since
QGIS 3.4

◆ symbolSaved

void QgsStyle::symbolSaved ( const QString &  name,
QgsSymbol symbol 
)
signal

Emitted every time a new symbol has been added to the database.

Emitted whenever a symbol has been added to the style and the database has been updated as a result.

See also
symbolRemoved()
rampAdded()
symbolChanged()

◆ symbolsOfFavorite()

QStringList QgsStyle::symbolsOfFavorite ( StyleEntity  type) const

Returns the symbol names which are flagged as favorite.

Parameters
typeis either SymbolEntity or ColorampEntity
Returns
A QStringList of the symbol or colorramp names flagged as favorite

Definition at line 887 of file qgsstyle.cpp.

◆ symbolsOfSmartgroup()

QStringList QgsStyle::symbolsOfSmartgroup ( StyleEntity  type,
int  id 
)

Returns the symbols for the smartgroup.

Definition at line 2212 of file qgsstyle.cpp.

◆ symbolsWithTag()

QStringList QgsStyle::symbolsWithTag ( StyleEntity  type,
int  tagid 
) const

Returns the symbol names with which have the given tag.

Parameters
typeis either SymbolEntity or ColorampEntity
tagidis id of the tag which has been applied over the symbol as int
Returns
A QStringList of the symbol or colorramp names for the given tag id

Definition at line 933 of file qgsstyle.cpp.

◆ tag()

QString QgsStyle::tag ( int  id) const

Returns the tag name for the given id.

Definition at line 1953 of file qgsstyle.cpp.

◆ tagId()

int QgsStyle::tagId ( const QString &  tag)

Returns the DB id for the given tag name.

Definition at line 2076 of file qgsstyle.cpp.

◆ tags()

QStringList QgsStyle::tags ( ) const

Returns a list of all tags in the style database.

See also
addTag()
Since
QGIS 2.16

Definition at line 1032 of file qgsstyle.cpp.

◆ tagsOfSymbol()

QStringList QgsStyle::tagsOfSymbol ( StyleEntity  type,
const QString &  symbol 
)

Returns the tags associated with the symbol.

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or color ramp
Returns
A QStringList of the tags that have been applied to that symbol/colorramp

Definition at line 1674 of file qgsstyle.cpp.

◆ tagSymbol()

bool QgsStyle::tagSymbol ( StyleEntity  type,
const QString &  symbol,
const QStringList &  tags 
)

Tags the symbol with the tags in the list.

Applies the given tags to the given symbol or colorramp

Parameters
typeis either SymbolEntity or ColorrampEntity
symbolis the name of the symbol or colorramp as QString
tagsis the list of the tags that are to be applied as QStringList
Returns
returns the success state of the operation

Definition at line 1397 of file qgsstyle.cpp.

◆ textFormat()

QgsTextFormat QgsStyle::textFormat ( const QString &  name) const

Returns the text format with the specified name.

Since
QGIS 3.10

Definition at line 2028 of file qgsstyle.cpp.

◆ textFormatAdded

void QgsStyle::textFormatAdded ( const QString &  name)
signal

Emitted whenever a text format has been added to the style and the database has been updated as a result.

See also
textFormatRemoved()
symbolSaved()
Since
QGIS 3.10

◆ textFormatChanged

void QgsStyle::textFormatChanged ( const QString &  name)
signal

Emitted whenever a text format's definition is changed.

This does not include name or tag changes.

See also
textFormatAdded()
Since
QGIS 3.10

◆ textFormatCount()

int QgsStyle::textFormatCount ( ) const

Returns count of text formats in the style.

Since
QGIS 3.10

Definition at line 2033 of file qgsstyle.cpp.

◆ textFormatId()

int QgsStyle::textFormatId ( const QString &  name)

Returns the ID in the style database for the given text format by name.

Returns 0 if the text format was not found.

Since
QGIS 3.10

Definition at line 2043 of file qgsstyle.cpp.

◆ textFormatNames()

QStringList QgsStyle::textFormatNames ( ) const

Returns a list of names of text formats in the style.

Since
QGIS 3.10

Definition at line 2038 of file qgsstyle.cpp.

◆ textFormatRemoved

void QgsStyle::textFormatRemoved ( const QString &  name)
signal

Emitted whenever a text format has been removed from the style and the database has been updated as a result.

See also
textFormatAdded()
symbolRemoved()
Since
QGIS 3.10

◆ textFormatRenamed

void QgsStyle::textFormatRenamed ( const QString &  oldName,
const QString &  newName 
)
signal

Emitted whenever a text format has been renamed from oldName to newName.

See also
symbolRenamed()
Since
QGIS 3.10

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