QGIS API Documentation 3.29.0-Master (8c80f25a4f)
Signals | Public Member Functions | List of all members
QgsProjectStyleSettings Class Reference

Contains settings and properties relating to how a QgsProject should handle styling. More...

#include <qgsprojectstylesettings.h>

Inheritance diagram for QgsProjectStyleSettings:
Inheritance graph
[legend]

Signals

void projectStyleChanged ()
 Emitted when the style returned by projectStyle() is changed. More...
 
void styleDatabaseAboutToBeAdded (const QString &path)
 Emitted when a style database path is about to be added. More...
 
void styleDatabaseAboutToBeRemoved (const QString &path)
 Emitted when a style database path is about to be removed. More...
 
void styleDatabaseAdded (const QString &path)
 Emitted when a style database path is added. More...
 
void styleDatabaseRemoved (const QString &path)
 Emitted when a style database path is removed. More...
 
void styleDatabasesChanged ()
 Emitted whenever the set of style databases associated with the project is changed. More...
 

Public Member Functions

 QgsProjectStyleSettings (QgsProject *project=nullptr)
 Constructor for QgsProjectStyleSettings for the specified project. More...
 
 ~QgsProjectStyleSettings () override
 
void addStyleDatabasePath (const QString &path)
 Adds a style database path to the project. More...
 
QgsCombinedStyleModelcombinedStyleModel ()
 Returns the combined style model which includes all style databases associated with the project. More...
 
QgsColorRampdefaultColorRamp () const SIP_FACTORY
 Returns the project default color ramp. More...
 
QgsSymboldefaultSymbol (Qgis::SymbolType symbolType) const SIP_FACTORY
 Returns the project default symbol for a given type. More...
 
double defaultSymbolOpacity () const
 Returns the default symbol opacity. More...
 
QgsTextFormat defaultTextFormat () const
 Returns the project default text format. More...
 
QgsStyleprojectStyle ()
 Returns the style database to use for project specific styles. More...
 
bool randomizeDefaultSymbolColor () const
 Returns whether the default symbol fill color is randomized. More...
 
bool readXml (const QDomElement &element, const QgsReadWriteContext &context, Qgis::ProjectReadFlags flags=Qgis::ProjectReadFlags())
 Reads the settings's state from a DOM element. More...
 
void reset ()
 Resets the settings to a default state. More...
 
void setDefaultColorRamp (QgsColorRamp *colorRamp)
 Sets the project default color ramp. More...
 
void setDefaultSymbol (Qgis::SymbolType symbolType, QgsSymbol *symbol)
 Sets the project default symbol for a given type. More...
 
void setDefaultSymbolOpacity (double opacity)
 Sets the default symbol opacity. More...
 
void setDefaultTextFormat (const QgsTextFormat &textFormat)
 Sets the project default text format. More...
 
void setProjectStyle (QgsStyle *style SIP_TRANSFER)
 Sets the style database to use for the project style. More...
 
void setRandomizeDefaultSymbolColor (bool randomized)
 Sets whether the default symbol fill color is randomized. More...
 
void setStyleDatabasePaths (const QStringList &paths)
 Sets the paths to all style databases associated with the project. More...
 
QgsStylestyleAtPath (const QString &path)
 Returns a reference to the style database associated with the project with matching file path. More...
 
QStringList styleDatabasePaths () const
 Returns a list of all style databases (file paths) associated with the project. More...
 
QList< QgsStyle * > styles () const
 Returns a list of all the styles associated with the project. More...
 
QDomElement writeXml (QDomDocument &doc, const QgsReadWriteContext &context) const
 Returns a DOM element representing the settings. More...
 

Detailed Description

Contains settings and properties relating to how a QgsProject should handle styling.

Since
QGIS 3.26

Definition at line 43 of file qgsprojectstylesettings.h.

Constructor & Destructor Documentation

◆ QgsProjectStyleSettings()

QgsProjectStyleSettings::QgsProjectStyleSettings ( QgsProject project = nullptr)

Constructor for QgsProjectStyleSettings for the specified project.

Ownership is transferred to the project.

Definition at line 31 of file qgsprojectstylesettings.cpp.

◆ ~QgsProjectStyleSettings()

QgsProjectStyleSettings::~QgsProjectStyleSettings ( )
override

Definition at line 38 of file qgsprojectstylesettings.cpp.

Member Function Documentation

◆ addStyleDatabasePath()

void QgsProjectStyleSettings::addStyleDatabasePath ( const QString &  path)

Adds a style database path to the project.

Paths can be either style .db databases, or .xml exports of style databases.

The file path added by this method must always be absolute paths. Depending on the project settings, they may be converted to relative paths when the project is saved.

See also
styleDatabasePaths()
setStyleDatabasePaths()
styleDatabasesChanged()

Definition at line 345 of file qgsprojectstylesettings.cpp.

◆ combinedStyleModel()

QgsCombinedStyleModel * QgsProjectStyleSettings::combinedStyleModel ( )

Returns the combined style model which includes all style databases associated with the project.

This model also includes QgsStyle::defaultStyle().

Note
This is only available on builds based on Qt 5.13 or later.
See also
styles()

Definition at line 428 of file qgsprojectstylesettings.cpp.

◆ defaultColorRamp()

QgsColorRamp * QgsProjectStyleSettings::defaultColorRamp ( ) const

Returns the project default color ramp.

Returns
a color ramp pointer or NULL if there is no default set
Note
the color ramp ownership is transferred to the caller

Definition at line 88 of file qgsprojectstylesettings.cpp.

◆ defaultSymbol()

QgsSymbol * QgsProjectStyleSettings::defaultSymbol ( Qgis::SymbolType  symbolType) const

Returns the project default symbol for a given type.

Parameters
symbolTypethe symbol type
Returns
a symbol pointer or NULL if there is no default set
Note
the symbol ownership is transferred to the caller

Definition at line 47 of file qgsprojectstylesettings.cpp.

◆ defaultSymbolOpacity()

double QgsProjectStyleSettings::defaultSymbolOpacity ( ) const
inline

Returns the default symbol opacity.

Definition at line 113 of file qgsprojectstylesettings.h.

◆ defaultTextFormat()

QgsTextFormat QgsProjectStyleSettings::defaultTextFormat ( ) const

Returns the project default text format.

Note
if no default is defined, the returned format will be invalid

Definition at line 98 of file qgsprojectstylesettings.cpp.

◆ projectStyle()

QgsStyle * QgsProjectStyleSettings::projectStyle ( )

Returns the style database to use for project specific styles.

See also
setProjectStyle()

Definition at line 154 of file qgsprojectstylesettings.cpp.

◆ projectStyleChanged

void QgsProjectStyleSettings::projectStyleChanged ( )
signal

Emitted when the style returned by projectStyle() is changed.

Note
Not available in Python bindings

◆ randomizeDefaultSymbolColor()

bool QgsProjectStyleSettings::randomizeDefaultSymbolColor ( ) const
inline

Returns whether the default symbol fill color is randomized.

Definition at line 103 of file qgsprojectstylesettings.h.

◆ readXml()

bool QgsProjectStyleSettings::readXml ( const QDomElement &  element,
const QgsReadWriteContext context,
Qgis::ProjectReadFlags  flags = Qgis::ProjectReadFlags() 
)

Reads the settings's state from a DOM element.

See also
writeXml()

Definition at line 159 of file qgsprojectstylesettings.cpp.

◆ reset()

void QgsProjectStyleSettings::reset ( )

Resets the settings to a default state.

Definition at line 108 of file qgsprojectstylesettings.cpp.

◆ setDefaultColorRamp()

void QgsProjectStyleSettings::setDefaultColorRamp ( QgsColorRamp colorRamp)

Sets the project default color ramp.

Parameters
colorRampthe color ramp, set to NULL to clear default
Note
the color ramp ownership is not transferred

Definition at line 93 of file qgsprojectstylesettings.cpp.

◆ setDefaultSymbol()

void QgsProjectStyleSettings::setDefaultSymbol ( Qgis::SymbolType  symbolType,
QgsSymbol symbol 
)

Sets the project default symbol for a given type.

Parameters
symbolTypethe symbol type
symbolthe symbol pointer, set to NULL to clear default
Note
the symbol ownership is not transferred

Definition at line 67 of file qgsprojectstylesettings.cpp.

◆ setDefaultSymbolOpacity()

void QgsProjectStyleSettings::setDefaultSymbolOpacity ( double  opacity)
inline

Sets the default symbol opacity.

Definition at line 118 of file qgsprojectstylesettings.h.

◆ setDefaultTextFormat()

void QgsProjectStyleSettings::setDefaultTextFormat ( const QgsTextFormat textFormat)

Sets the project default text format.

Parameters
textFormatthe text format, an invalid format is interpreted as no default

Definition at line 103 of file qgsprojectstylesettings.cpp.

◆ setProjectStyle()

void QgsProjectStyleSettings::setProjectStyle ( QgsStyle *style  SIP_TRANSFER)

Sets the style database to use for the project style.

See also
projectStyle()

Definition at line 133 of file qgsprojectstylesettings.cpp.

◆ setRandomizeDefaultSymbolColor()

void QgsProjectStyleSettings::setRandomizeDefaultSymbolColor ( bool  randomized)
inline

Sets whether the default symbol fill color is randomized.

Definition at line 108 of file qgsprojectstylesettings.h.

◆ setStyleDatabasePaths()

void QgsProjectStyleSettings::setStyleDatabasePaths ( const QStringList &  paths)

Sets the paths to all style databases associated with the project.

Paths can be either style .db databases, or .xml exports of style databases.

The file paths set by this method must always be absolute paths. Depending on the project settings, they may be converted to relative paths when the project is saved.

See also
addStyleDatabasePath()
styleDatabasePaths()
styleDatabasesChanged()

Definition at line 358 of file qgsprojectstylesettings.cpp.

◆ styleAtPath()

QgsStyle * QgsProjectStyleSettings::styleAtPath ( const QString &  path)

Returns a reference to the style database associated with the project with matching file path.

Definition at line 328 of file qgsprojectstylesettings.cpp.

◆ styleDatabaseAboutToBeAdded

void QgsProjectStyleSettings::styleDatabaseAboutToBeAdded ( const QString &  path)
signal

Emitted when a style database path is about to be added.

Note
Not available in Python bindings

◆ styleDatabaseAboutToBeRemoved

void QgsProjectStyleSettings::styleDatabaseAboutToBeRemoved ( const QString &  path)
signal

Emitted when a style database path is about to be removed.

Note
Not available in Python bindings

◆ styleDatabaseAdded

void QgsProjectStyleSettings::styleDatabaseAdded ( const QString &  path)
signal

Emitted when a style database path is added.

Note
Not available in Python bindings

◆ styleDatabasePaths()

QStringList QgsProjectStyleSettings::styleDatabasePaths ( ) const
inline

Returns a list of all style databases (file paths) associated with the project.

The file paths returned by this method will always be absolute paths. Depending on the project settings, they may be converted to relative paths when the project is saved.

See also
styles()
addStyleDatabasePath()
setStyleDatabasePaths()

Definition at line 161 of file qgsprojectstylesettings.h.

◆ styleDatabaseRemoved

void QgsProjectStyleSettings::styleDatabaseRemoved ( const QString &  path)
signal

Emitted when a style database path is removed.

Note
Not available in Python bindings

◆ styleDatabasesChanged

void QgsProjectStyleSettings::styleDatabasesChanged ( )
signal

Emitted whenever the set of style databases associated with the project is changed.

◆ styles()

QList< QgsStyle * > QgsProjectStyleSettings::styles ( ) const

Returns a list of all the styles associated with the project.

See also
styleDatabasePaths()

Definition at line 316 of file qgsprojectstylesettings.cpp.

◆ writeXml()

QDomElement QgsProjectStyleSettings::writeXml ( QDomDocument &  doc,
const QgsReadWriteContext context 
) const

Returns a DOM element representing the settings.

See also
readXml()

Definition at line 257 of file qgsprojectstylesettings.cpp.


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