QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
#include <qgsstyle.h>
Public Types | |
enum | StyleEntity { SymbolEntity , TagEntity , ColorrampEntity , SmartgroupEntity , TextFormatEntity , LabelSettingsEntity , LegendPatchShapeEntity , Symbol3DEntity } |
Enum for Entities involved in a style. More... | |
enum class | TextFormatContext : int { Labeling } |
Text format context. More... | |
Signals | |
void | entityAdded (QgsStyle::StyleEntity entity, const QString &name) |
Emitted every time a new entity has been added to the database. More... | |
void | entityChanged (QgsStyle::StyleEntity entity, const QString &name) |
Emitted whenever an entity's definition is changed. More... | |
void | entityRemoved (QgsStyle::StyleEntity entity, const QString &name) |
Emitted whenever an entity of the specified type is removed from the style and the database has been updated as a result. More... | |
void | entityRenamed (QgsStyle::StyleEntity entity, const QString &oldName, const QString &newName) |
Emitted whenever a entity of the specified type has been renamed from oldName to newName. More... | |
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 () | |
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... | |
bool | addLegendPatchShape (const QString &name, const QgsLegendPatchShape &shape, bool update=false) |
Adds a legend patch shape 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... | |
bool | addSymbol3D (const QString &name, QgsAbstract3DSymbol *symbol, bool update=false) |
Adds a 3d symbol with the specified name to the style. 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... | |
QgsColorRamp * | colorRamp (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 QgsColorRamp * | colorRampRef (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... | |
QgsLegendPatchShape | defaultPatch (Qgis::SymbolType type, QSizeF size) const |
Returns the default legend patch shape for the given symbol type. More... | |
QList< QList< QPolygonF > > | defaultPatchAsQPolygonF (Qgis::SymbolType type, QSizeF size) const |
Returns the default patch geometry for the given symbol type and size as a set of QPolygonF objects (parts and rings). More... | |
QgsTextFormat | defaultTextFormat (QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling) const |
Returns the default text format to use for new text based objects in the specified context. More... | |
bool | detagSymbol (StyleEntity type, const QString &symbol) |
Clears the symbol from all attached tags. More... | |
bool | detagSymbol (StyleEntity type, const QString &symbol, const QStringList &tags) |
Detags the symbol with the given list. More... | |
int | entityId (StyleEntity type, const QString &name) |
Returns the id in the style database for the given name of the specified entity type. 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... | |
QgsLegendPatchShape | legendPatchShape (const QString &name) const |
Returns the legend patch shape with the specified name. More... | |
QStringList | legendPatchShapeNames () const |
Returns a list of names of legend patch shapes in the style. More... | |
int | legendPatchShapesCount () const |
Returns count of legend patch shapes in the style. More... | |
Qgis::SymbolType | legendPatchShapeSymbolType (const QString &name) const |
Returns the symbol type corresponding to the legend patch shape with the specified name, or QgsSymbol::Hybrid if a matching legend patch shape is not present. More... | |
bool | load (const QString &filename) |
Loads a file into the style. More... | |
const QgsSymbol * | previewSymbolForPatchShape (const QgsLegendPatchShape &shape) const |
Returns a symbol to use for rendering preview icons for a patch shape. More... | |
bool | remove (StyleEntity type, int id) |
Removes the specified entity from the database. More... | |
bool | removeColorRamp (const QString &name) |
Removes color ramp from style (and delete it) More... | |
bool | removeEntityByName (StyleEntity type, const QString &name) |
Removes the entry of the specified type with matching name from the database. 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 | renameEntity (StyleEntity type, const QString &oldName, const QString &newName) |
Renames an entity of the specified type from oldName to newName. More... | |
bool | renameLabelSettings (const QString &oldName, const QString &newName) |
Changes a label setting's name. More... | |
bool | renameLegendPatchShape (const QString &oldName, const QString &newName) |
Changes a legend patch shape's name. More... | |
bool | renameSymbol (const QString &oldName, const QString &newName) |
Renames a symbol from oldName to newName. More... | |
bool | renameSymbol3D (const QString &oldName, const QString &newName) |
Changes a 3d symbol's name. 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 database. More... | |
bool | saveLabelSettings (const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags) |
Adds label settings to the database. More... | |
bool | saveLegendPatchShape (const QString &name, const QgsLegendPatchShape &shape, bool favorite, const QStringList &tags) |
Adds a legend patch shape to the database. More... | |
bool | saveSymbol (const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags) |
Adds the symbol to the database with tags. More... | |
bool | saveSymbol3D (const QString &name, QgsAbstract3DSymbol *symbol, bool favorite, const QStringList &tags) |
Adds a 3d symbol to the database. 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 database 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. More... | |
QgsSymbolGroupMap | smartgroupsListMap () |
Returns the smart groups map with id as key and name as value. More... | |
QgsSymbol * | symbol (const QString &name) |
Returns a NEW copy of symbol. More... | |
QgsAbstract3DSymbol * | symbol3D (const QString &name) const |
Returns a new copy of the 3D symbol with the specified name. More... | |
QList< QgsWkbTypes::GeometryType > | symbol3DCompatibleGeometryTypes (const QString &name) const |
Returns the list of the vector layer geometry types which are compatible with the 3D symbol with the specified name, or an empty list if a matching 3d symbol is not present. More... | |
int | symbol3DCount () const |
Returns count of 3D symbols in the style. More... | |
QStringList | symbol3DNames () const |
Returns a list of names of 3d symbols in the style. 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 QgsSymbol * | symbolRef (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 database 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 QgsStyle * | defaultStyle () |
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... | |
Friends | |
class | Qgs3D |
class | TestStyle |
Definition at line 159 of file qgsstyle.h.
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.
Definition at line 178 of file qgsstyle.h.
|
strong |
Text format context.
Enumerator | |
---|---|
Labeling | Text format used in labeling. |
Definition at line 730 of file qgsstyle.h.
QgsStyle::QgsStyle | ( | ) |
Constructor for QgsStyle.
Definition at line 77 of file qgsstyle.cpp.
|
override |
Definition at line 92 of file qgsstyle.cpp.
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.
name | is the name of the color ramp being added or updated |
colorRamp | is the color ramp. Ownership is transferred. |
update | set to true when the style database has to be updated, by default it is false |
Definition at line 297 of file qgsstyle.cpp.
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.
Definition at line 97 of file qgsstyle.cpp.
bool QgsStyle::addFavorite | ( | StyleEntity | type, |
const QString & | name | ||
) |
Adds the specified symbol to favorites.
type | is either SymbolEntity of ColorrampEntity |
name | is the name of the symbol or coloramp whose is to be added to favorites |
Definition at line 1628 of file qgsstyle.cpp.
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 database will be automatically updated with the new text format.
Returns true
if the operation was successful.
Definition at line 342 of file qgsstyle.cpp.
bool QgsStyle::addLegendPatchShape | ( | const QString & | name, |
const QgsLegendPatchShape & | shape, | ||
bool | update = false |
||
) |
Adds a legend patch shape with the specified name to the style.
If update is set to true
, the style database will be automatically updated with the new legend patch shape.
Returns true
if the operation was successful.
Definition at line 363 of file qgsstyle.cpp.
int QgsStyle::addSmartgroup | ( | const QString & | name, |
const QString & | op, | ||
const QgsSmartConditionMap & | conditions | ||
) |
Adds a new smartgroup to the database and returns the id.
name | is the name of the new Smart Group to be added |
op | is the operator between the conditions; AND/OR as QString |
conditions | are the smart group conditions |
Definition at line 2271 of file qgsstyle.cpp.
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.
name | is the name of the new Smart Group to be added |
op | is the operator between the conditions; AND/OR as QString |
matchTag | list of strings to match within tags |
noMatchTag | list of strings to exclude matches from tags |
matchName | list of string to match within names |
noMatchName | list of strings to exclude matches from names |
Definition at line 2279 of file qgsstyle.cpp.
bool QgsStyle::addSymbol | ( | const QString & | name, |
QgsSymbol * | symbol, | ||
bool | update = false |
||
) |
Adds a symbol to style and takes symbol's ownership.
name | is the name of the symbol being added or updated |
symbol | is the Vector symbol |
update | set to true when the style database has to be updated, by default it is false |
Definition at line 181 of file qgsstyle.cpp.
bool QgsStyle::addSymbol3D | ( | const QString & | name, |
QgsAbstract3DSymbol * | symbol, | ||
bool | update = false |
||
) |
Adds a 3d symbol with the specified name to the style.
Ownership of symbol is transferred.
If update is set to true
, the style database will be automatically updated with the new legend patch shape.
Returns true
if the operation was successful.
Definition at line 384 of file qgsstyle.cpp.
int QgsStyle::addTag | ( | const QString & | tagName | ) |
Adds a new tag and returns the tag's id.
tagName | the name of the new tag to be created |
Definition at line 1383 of file qgsstyle.cpp.
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 database will be automatically updated with the new text format.
Returns true
if the operation was successful.
Definition at line 321 of file qgsstyle.cpp.
QStringList QgsStyle::allNames | ( | QgsStyle::StyleEntity | type | ) | const |
Returns a list of the names of all existing entities of the specified type.
Definition at line 2240 of file qgsstyle.cpp.
|
static |
Deletes the default style. Only to be used by QgsApplication::exitQgis()
Definition at line 160 of file qgsstyle.cpp.
void QgsStyle::clear | ( | ) |
Removes all contents of the style.
Definition at line 166 of file qgsstyle.cpp.
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 446 of file qgsstyle.cpp.
int QgsStyle::colorRampCount | ( | ) |
Returns count of color ramps.
Definition at line 457 of file qgsstyle.cpp.
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 2117 of file qgsstyle.cpp.
QStringList QgsStyle::colorRampNames | ( | ) | const |
Returns a list of names of color ramps.
Definition at line 462 of file qgsstyle.cpp.
const QgsColorRamp * QgsStyle::colorRampRef | ( | const QString & | name | ) | const |
Returns a const pointer to a symbol (doesn't create new instance)
Definition at line 452 of file qgsstyle.cpp.
bool QgsStyle::createDatabase | ( | const QString & | filename | ) |
Creates an on-disk database.
This function creates a new on-disk permanent style database.
Definition at line 500 of file qgsstyle.cpp.
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.
Definition at line 515 of file qgsstyle.cpp.
void QgsStyle::createTables | ( | ) |
Creates tables structure for new database.
This function is used to create the tables structure in a newly-created database.
Definition at line 530 of file qgsstyle.cpp.
QgsLegendPatchShape QgsStyle::defaultPatch | ( | Qgis::SymbolType | type, |
QSizeF | size | ||
) | const |
Returns the default legend patch shape for the given symbol type.
Definition at line 1173 of file qgsstyle.cpp.
QList< QList< QPolygonF > > QgsStyle::defaultPatchAsQPolygonF | ( | Qgis::SymbolType | type, |
QSizeF | size | ||
) | const |
Returns the default patch geometry for the given symbol type and size as a set of QPolygonF objects (parts and rings).
Definition at line 1215 of file qgsstyle.cpp.
|
static |
Returns default application-wide style.
Definition at line 131 of file qgsstyle.cpp.
QgsTextFormat QgsStyle::defaultTextFormat | ( | QgsStyle::TextFormatContext | context = QgsStyle::TextFormatContext::Labeling | ) | const |
Returns the default text format to use for new text based objects in the specified context.
Definition at line 1228 of file qgsstyle.cpp.
bool QgsStyle::detagSymbol | ( | StyleEntity | type, |
const QString & | symbol | ||
) |
Clears the symbol from all attached tags.
Removes all tags for the specified symbol or colorramp
type | is either SymbolEntity or ColorrampEntity |
symbol | is the name of the symbol or colorramp |
Definition at line 1875 of file qgsstyle.cpp.
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
type | is either SymbolEntity or ColorrampEntity |
symbol | is the name of the symbol or colorramp |
tags | is the list of tags that are to be removed as QStringList |
Definition at line 1820 of file qgsstyle.cpp.
|
signal |
Emitted every time a new entity has been added to the database.
|
signal |
Emitted whenever an entity's definition is changed.
This does not include name or tag changes.
int QgsStyle::entityId | ( | QgsStyle::StyleEntity | type, |
const QString & | name | ||
) |
Returns the id in the style database for the given name of the specified entity type.
Returns 0 if not found.
Definition at line 2112 of file qgsstyle.cpp.
|
signal |
Emitted whenever an entity of the specified type is removed from the style and the database has been updated as a result.
|
signal |
Emitted whenever a entity of the specified type has been renamed from oldName to newName.
|
signal |
Emitted whenever an entity's tags are changed.
|
inline |
Returns last error from load/save operation.
Definition at line 812 of file qgsstyle.h.
bool QgsStyle::exportXml | ( | const QString & | filename | ) |
Exports the style as a XML file.
Definition at line 2536 of file qgsstyle.cpp.
|
signal |
Emitted whenever an entity is either favorited or un-favorited.
|
inline |
Returns current file name of the style.
Definition at line 815 of file qgsstyle.h.
QStringList QgsStyle::findSymbols | ( | StyleEntity | type, |
const QString & | qword | ||
) |
Returns the names of the symbols which have a matching 'substring' in its definition.
type | is either SymbolEntity or ColorrampEntity |
qword | is the query string to search the symbols or colorramps. |
Definition at line 1690 of file qgsstyle.cpp.
|
signal |
Emitted every time a tag or smartgroup has been added, removed, or renamed.
bool QgsStyle::importXml | ( | const QString & | filename | ) |
Imports the symbols and colorramps into the default style database from the given XML file.
Definition at line 2700 of file qgsstyle.cpp.
bool QgsStyle::isFavorite | ( | QgsStyle::StyleEntity | type, |
const QString & | name | ||
) |
Returns true
if the symbol with matching type and name is marked as a favorite.
Definition at line 1964 of file qgsstyle.cpp.
|
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.
Definition at line 3044 of file qgsstyle.cpp.
QgsPalLayerSettings QgsStyle::labelSettings | ( | const QString & | name | ) | const |
Returns the label settings with the specified name.
Definition at line 2142 of file qgsstyle.cpp.
|
signal |
Emitted whenever label settings have been added to the style and the database has been updated as a result.
|
signal |
Emitted whenever a label setting's definition is changed.
This does not include name or tag changes.
int QgsStyle::labelSettingsCount | ( | ) | const |
Returns count of label settings in the style.
Definition at line 2191 of file qgsstyle.cpp.
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.
Definition at line 2201 of file qgsstyle.cpp.
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.
Definition at line 2183 of file qgsstyle.cpp.
QStringList QgsStyle::labelSettingsNames | ( | ) | const |
Returns a list of names of label settings in the style.
Definition at line 2196 of file qgsstyle.cpp.
|
signal |
Emitted whenever label settings have been removed from the style and the database has been updated as a result.
|
signal |
Emitted whenever label settings have been renamed from oldName to newName.
QgsLegendPatchShape QgsStyle::legendPatchShape | ( | const QString & | name | ) | const |
Returns the legend patch shape with the specified name.
Definition at line 2147 of file qgsstyle.cpp.
QStringList QgsStyle::legendPatchShapeNames | ( | ) | const |
Returns a list of names of legend patch shapes in the style.
Definition at line 2206 of file qgsstyle.cpp.
int QgsStyle::legendPatchShapesCount | ( | ) | const |
Returns count of legend patch shapes in the style.
Definition at line 2152 of file qgsstyle.cpp.
Qgis::SymbolType QgsStyle::legendPatchShapeSymbolType | ( | const QString & | name | ) | const |
Returns the symbol type corresponding to the legend patch shape with the specified name, or QgsSymbol::Hybrid if a matching legend patch shape is not present.
Definition at line 2157 of file qgsstyle.cpp.
bool QgsStyle::load | ( | const QString & | filename | ) |
Loads a file into the style.
This function will load an on-disk database and populate styles.
filename | location of the database to load styles from |
Definition at line 590 of file qgsstyle.cpp.
const QgsSymbol * QgsStyle::previewSymbolForPatchShape | ( | const QgsLegendPatchShape & | shape | ) | const |
Returns a symbol to use for rendering preview icons for a patch shape.
Ownership of the symbol is not transferred.
Definition at line 2211 of file qgsstyle.cpp.
|
signal |
Emitted whenever a color ramp has been added to the style and the database has been updated as a result.
|
signal |
Emitted whenever a color ramp's definition is changed.
This does not include name or tag changes.
|
signal |
Emitted whenever a color ramp has been removed from the style and the database has been updated as a result.
|
signal |
Emitted whenever a color ramp has been renamed from oldName to newName.
bool QgsStyle::remove | ( | StyleEntity | type, |
int | id | ||
) |
Removes the specified entity from the database.
type | is any of the style entities. Refer enum StyleEntity. |
id | is the database id of the entity to be removed |
Definition at line 1458 of file qgsstyle.cpp.
bool QgsStyle::removeColorRamp | ( | const QString & | name | ) |
Removes color ramp from style (and delete it)
Definition at line 441 of file qgsstyle.cpp.
bool QgsStyle::removeEntityByName | ( | QgsStyle::StyleEntity | type, |
const QString & | name | ||
) |
Removes the entry of the specified type with matching name from the database.
Definition at line 1504 of file qgsstyle.cpp.
bool QgsStyle::removeFavorite | ( | StyleEntity | type, |
const QString & | name | ||
) |
Removes the specified symbol from favorites.
type | is either SymbolEntity of ColorrampEntity |
name | is the name of the symbol or coloramp whose is to be removed from favorites |
Definition at line 1664 of file qgsstyle.cpp.
bool QgsStyle::removeLabelSettings | ( | const QString & | name | ) |
bool QgsStyle::removeSymbol | ( | const QString & | name | ) |
Removes symbol from style (and delete it)
Definition at line 241 of file qgsstyle.cpp.
bool QgsStyle::removeTextFormat | ( | const QString & | name | ) |
bool QgsStyle::rename | ( | StyleEntity | type, |
int | id, | ||
const QString & | newName | ||
) |
Renames the given entity with the specified id.
type | is any of the style entities. Refer enum StyleEntity. |
id | is the database id of the entity which is to be renamed |
newName | is the new name of the entity |
Definition at line 1423 of file qgsstyle.cpp.
bool QgsStyle::renameColorRamp | ( | const QString & | oldName, |
const QString & | newName | ||
) |
Changes ramp's name.
Definition at line 922 of file qgsstyle.cpp.
bool QgsStyle::renameEntity | ( | QgsStyle::StyleEntity | type, |
const QString & | oldName, | ||
const QString & | newName | ||
) |
Renames an entity of the specified type from oldName to newName.
Returns true
if the entity was successfully renamed.
Definition at line 246 of file qgsstyle.cpp.
bool QgsStyle::renameLabelSettings | ( | const QString & | oldName, |
const QString & | newName | ||
) |
bool QgsStyle::renameLegendPatchShape | ( | const QString & | oldName, |
const QString & | newName | ||
) |
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 882 of file qgsstyle.cpp.
bool QgsStyle::renameSymbol3D | ( | const QString & | oldName, |
const QString & | newName | ||
) |
bool QgsStyle::renameTextFormat | ( | const QString & | oldName, |
const QString & | newName | ||
) |
bool QgsStyle::save | ( | QString | filename = QString() | ) |
Saves style into a file (will use current filename if empty string is passed)
Definition at line 836 of file qgsstyle.cpp.
bool QgsStyle::saveColorRamp | ( | const QString & | name, |
QgsColorRamp * | ramp, | ||
bool | favorite, | ||
const QStringList & | tags | ||
) |
Adds the colorramp to the database.
name | is the name of the colorramp as QString |
ramp | is the pointer to the new QgsColorRamp being saved |
favorite | is a boolean value to specify whether the colorramp should be added to favorites |
tags | is a list of tags that are associated with the color ramp as a QStringList. |
Definition at line 405 of file qgsstyle.cpp.
bool QgsStyle::saveLabelSettings | ( | const QString & | name, |
const QgsPalLayerSettings & | settings, | ||
bool | favorite, | ||
const QStringList & | tags | ||
) |
Adds label settings to the database.
name | is the name of the label settings |
settings | label settings to save |
favorite | is a boolean value to specify whether the label settings should be added to favorites |
tags | is a list of tags that are associated with the label settings |
Definition at line 1033 of file qgsstyle.cpp.
bool QgsStyle::saveLegendPatchShape | ( | const QString & | name, |
const QgsLegendPatchShape & | shape, | ||
bool | favorite, | ||
const QStringList & | tags | ||
) |
Adds a legend patch shape to the database.
name | is the name of the legend patch shape |
shape | legend patch shape to save |
favorite | is a boolean value to specify whether the legend patch shape should be added to favorites |
tags | is a list of tags that are associated with the legend patch shape |
Definition at line 1109 of file qgsstyle.cpp.
bool QgsStyle::saveSymbol | ( | const QString & | name, |
QgsSymbol * | symbol, | ||
bool | favorite, | ||
const QStringList & | tags | ||
) |
Adds the symbol to the database with tags.
name | is the name of the symbol as QString |
symbol | is the pointer to the new QgsSymbol being saved |
favorite | is a boolean value to specify whether the symbol should be added to favorites |
tags | is a list of tags that are associated with the symbol as a QStringList. |
Definition at line 205 of file qgsstyle.cpp.
bool QgsStyle::saveSymbol3D | ( | const QString & | name, |
QgsAbstract3DSymbol * | symbol, | ||
bool | favorite, | ||
const QStringList & | tags | ||
) |
Adds a 3d symbol to the database.
name | is the name of the 3d symbol |
symbol | 3d symbol to save. Ownership is transferred. |
favorite | is a boolean value to specify whether the 3d symbol should be added to favorites |
tags | is a list of tags that are associated with the 3d symbol |
Definition at line 1233 of file qgsstyle.cpp.
bool QgsStyle::saveTextFormat | ( | const QString & | name, |
const QgsTextFormat & | format, | ||
bool | favorite, | ||
const QStringList & | tags | ||
) |
Adds a text format to the database.
name | is the name of the text format |
format | text format to save |
favorite | is a boolean value to specify whether the text format should be added to favorites |
tags | is a list of tags that are associated with the text format |
Definition at line 957 of file qgsstyle.cpp.
QgsSmartConditionMap QgsStyle::smartgroup | ( | int | id | ) |
Returns the QgsSmartConditionMap for the given id.
Definition at line 2466 of file qgsstyle.cpp.
int QgsStyle::smartgroupId | ( | const QString & | smartgroup | ) |
Returns the database id for the given smartgroup name.
Definition at line 2235 of file qgsstyle.cpp.
QStringList QgsStyle::smartgroupNames | ( | ) | const |
Returns the smart groups list.
Definition at line 2350 of file qgsstyle.cpp.
QString QgsStyle::smartgroupOperator | ( | int | id | ) |
Returns the operator for the smartgroup.
Definition at line 2506 of file qgsstyle.cpp.
QgsSymbolGroupMap QgsStyle::smartgroupsListMap | ( | ) |
Returns the smart groups map with id as key and name as value.
Definition at line 2325 of file qgsstyle.cpp.
QgsSymbol * QgsStyle::symbol | ( | const QString & | name | ) |
Returns a NEW copy of symbol.
Definition at line 275 of file qgsstyle.cpp.
QgsAbstract3DSymbol * QgsStyle::symbol3D | ( | const QString & | name | ) | const |
Returns a new copy of the 3D symbol with the specified name.
Definition at line 2165 of file qgsstyle.cpp.
QList< QgsWkbTypes::GeometryType > QgsStyle::symbol3DCompatibleGeometryTypes | ( | const QString & | name | ) | const |
Returns the list of the vector layer geometry types which are compatible with the 3D symbol with the specified name, or an empty list if a matching 3d symbol is not present.
Definition at line 2175 of file qgsstyle.cpp.
int QgsStyle::symbol3DCount | ( | ) | const |
Returns count of 3D symbols in the style.
Definition at line 2170 of file qgsstyle.cpp.
QStringList QgsStyle::symbol3DNames | ( | ) | const |
Returns a list of names of 3d symbols in the style.
Definition at line 1298 of file qgsstyle.cpp.
|
signal |
Emitted whenever a symbol's definition is changed.
This does not include name or tag changes.
int QgsStyle::symbolCount | ( | ) |
Returns count of symbols in style.
Definition at line 286 of file qgsstyle.cpp.
bool QgsStyle::symbolHasTag | ( | StyleEntity | type, |
const QString & | symbol, | ||
const QString & | tag | ||
) |
Returns whether a given tag is associated with the symbol.
type | is either SymbolEntity or ColorrampEntity |
symbol | is the name of the symbol or color ramp |
tag | the name of the tag to look for |
Definition at line 2002 of file qgsstyle.cpp.
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 2107 of file qgsstyle.cpp.
QStringList QgsStyle::symbolNames | ( | ) | const |
Returns a list of names of symbols.
Definition at line 291 of file qgsstyle.cpp.
const QgsSymbol * QgsStyle::symbolRef | ( | const QString & | name | ) | const |
Returns a const pointer to a symbol (doesn't create new instance)
Definition at line 281 of file qgsstyle.cpp.
|
signal |
Emitted whenever a symbol has been removed from the style and the database has been updated as a result.
|
signal |
Emitted whenever a symbol has been renamed from oldName to newName.
|
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.
QStringList QgsStyle::symbolsOfFavorite | ( | StyleEntity | type | ) | const |
Returns the symbol names which are flagged as favorite.
type | is either SymbolEntity or ColorampEntity |
Definition at line 1303 of file qgsstyle.cpp.
QStringList QgsStyle::symbolsOfSmartgroup | ( | StyleEntity | type, |
int | id | ||
) |
Returns the symbols for the smartgroup.
Definition at line 2374 of file qgsstyle.cpp.
QStringList QgsStyle::symbolsWithTag | ( | StyleEntity | type, |
int | tagid | ||
) | const |
Returns the symbol names with which have the given tag.
type | is either SymbolEntity or ColorampEntity |
tagid | is id of the tag which has been applied over the symbol as int |
Definition at line 1337 of file qgsstyle.cpp.
QString QgsStyle::tag | ( | int | id | ) | const |
Returns the tag name for the given id.
Definition at line 2042 of file qgsstyle.cpp.
int QgsStyle::tagId | ( | const QString & | tag | ) |
Returns the database id for the given tag name.
Definition at line 2230 of file qgsstyle.cpp.
QStringList QgsStyle::tags | ( | ) | const |
Returns a list of all tags in the style database.
Definition at line 1403 of file qgsstyle.cpp.
QStringList QgsStyle::tagsOfSymbol | ( | StyleEntity | type, |
const QString & | symbol | ||
) |
Returns the tags associated with the symbol.
type | is either SymbolEntity or ColorrampEntity |
symbol | is the name of the symbol or color ramp |
Definition at line 1913 of file qgsstyle.cpp.
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
type | is either SymbolEntity or ColorrampEntity |
symbol | is the name of the symbol or colorramp as QString |
tags | is the list of the tags that are to be applied as QStringList |
Definition at line 1757 of file qgsstyle.cpp.
QgsTextFormat QgsStyle::textFormat | ( | const QString & | name | ) | const |
Returns the text format with the specified name.
Definition at line 2122 of file qgsstyle.cpp.
|
signal |
Emitted whenever a text format has been added to the style and the database has been updated as a result.
|
signal |
Emitted whenever a text format's definition is changed.
This does not include name or tag changes.
int QgsStyle::textFormatCount | ( | ) | const |
Returns count of text formats in the style.
Definition at line 2127 of file qgsstyle.cpp.
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.
Definition at line 2137 of file qgsstyle.cpp.
QStringList QgsStyle::textFormatNames | ( | ) | const |
Returns a list of names of text formats in the style.
Definition at line 2132 of file qgsstyle.cpp.
|
signal |
Emitted whenever a text format has been removed from the style and the database has been updated as a result.
|
signal |
Emitted whenever a text format has been renamed from oldName to newName.
|
friend |
Definition at line 1158 of file qgsstyle.h.
|
friend |
Definition at line 1159 of file qgsstyle.h.