QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
Contains settings and properties relating to how a QgsProject should handle styling. More...
#include <qgsprojectstylesettings.h>
Signals | |
void | projectStyleChanged () |
Emitted when the style returned by projectStyle() is changed. | |
void | styleDatabaseAboutToBeAdded (const QString &path) |
Emitted when a style database path is about to be added. | |
void | styleDatabaseAboutToBeRemoved (const QString &path) |
Emitted when a style database path is about to be removed. | |
void | styleDatabaseAdded (const QString &path) |
Emitted when a style database path is added. | |
void | styleDatabaseRemoved (const QString &path) |
Emitted when a style database path is removed. | |
void | styleDatabasesChanged () |
Emitted whenever the set of style databases associated with the project is changed. | |
Public Member Functions | |
QgsProjectStyleSettings (QgsProject *project=nullptr) | |
Constructor for QgsProjectStyleSettings for the specified project. | |
~QgsProjectStyleSettings () override | |
void | addStyleDatabasePath (const QString &path) |
Adds a style database path to the project. | |
Qgis::ColorModel | colorModel () const |
Returns the project's color model. | |
QColorSpace | colorSpace () const |
Returns the project's color space. | |
QgsCombinedStyleModel * | combinedStyleModel () |
Returns the combined style model which includes all style databases associated with the project. | |
QgsColorRamp * | defaultColorRamp () const |
Returns the project default color ramp. | |
QgsSymbol * | defaultSymbol (Qgis::SymbolType symbolType) const |
Returns the project default symbol for a given type. | |
double | defaultSymbolOpacity () const |
Returns the default symbol opacity. | |
QgsTextFormat | defaultTextFormat () const |
Returns the project default text format. | |
QgsStyle * | projectStyle () |
Returns the style database to use for project specific styles. | |
bool | randomizeDefaultSymbolColor () const |
Returns whether the default symbol fill color is randomized. | |
bool | readXml (const QDomElement &element, const QgsReadWriteContext &context, Qgis::ProjectReadFlags flags=Qgis::ProjectReadFlags()) |
Reads the settings's state from a DOM element. | |
void | removeProjectStyle () |
Removes and deletes the project style database. | |
void | reset () |
Resets the settings to a default state. | |
void | setColorModel (Qgis::ColorModel colorModel) |
Set the project's color model to colorModel. | |
void | setColorSpace (const QColorSpace &colorSpace) |
Set the project's current color space to colorSpace. | |
void | setDefaultColorRamp (QgsColorRamp *colorRamp) |
Sets the project default color ramp. | |
void | setDefaultSymbol (Qgis::SymbolType symbolType, QgsSymbol *symbol) |
Sets the project default symbol for a given type. | |
void | setDefaultSymbolOpacity (double opacity) |
Sets the default symbol opacity. | |
void | setDefaultTextFormat (const QgsTextFormat &textFormat) |
Sets the project default text format. | |
void | setProjectStyle (QgsStyle *style) |
Sets the style database to use for the project style. | |
void | setRandomizeDefaultSymbolColor (bool randomized) |
Sets whether the default symbol fill color is randomized. | |
void | setStyleDatabasePaths (const QStringList &paths) |
Sets the paths to all style databases associated with the project. | |
QgsStyle * | styleAtPath (const QString &path) |
Returns a reference to the style database associated with the project with matching file path. | |
QStringList | styleDatabasePaths () const |
Returns a list of all style databases (file paths) associated with the project. | |
QList< QgsStyle * > | styles () const |
Returns a list of all the styles associated with the project. | |
QDomElement | writeXml (QDomDocument &doc, const QgsReadWriteContext &context) const |
Returns a DOM element representing the settings. | |
Friends | |
class | TestQgsProjectProperties |
Contains settings and properties relating to how a QgsProject should handle styling.
Definition at line 45 of file qgsprojectstylesettings.h.
QgsProjectStyleSettings::QgsProjectStyleSettings | ( | QgsProject * | project = nullptr | ) |
Constructor for QgsProjectStyleSettings for the specified project.
Ownership is transferred to the project.
Definition at line 34 of file qgsprojectstylesettings.cpp.
|
override |
Definition at line 41 of file qgsprojectstylesettings.cpp.
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.
Definition at line 423 of file qgsprojectstylesettings.cpp.
Qgis::ColorModel QgsProjectStyleSettings::colorModel | ( | ) | const |
Returns the project's color model.
This model is used as the default color model when selecting a color in the whole application. Any color defined in a different color model than the returned model will be converted to this color model when exporting a layout.
The color model defaults to Qgis::ColorModel::Rgb
Definition at line 528 of file qgsprojectstylesettings.cpp.
QColorSpace QgsProjectStyleSettings::colorSpace | ( | ) | const |
Returns the project's color space.
The project color's space will be added to PDF layout exports when it is defined (i.e. it is different from the default invalid QColorSpace).
The color space defaults to an invalid color space.
Definition at line 578 of file qgsprojectstylesettings.cpp.
QgsCombinedStyleModel * QgsProjectStyleSettings::combinedStyleModel | ( | ) |
Returns the combined style model which includes all style databases associated with the project.
This model also includes QgsStyle::defaultStyle().
Definition at line 506 of file qgsprojectstylesettings.cpp.
QgsColorRamp * QgsProjectStyleSettings::defaultColorRamp | ( | ) | const |
Returns the project default color ramp.
nullptr
if there is no default set Definition at line 106 of file qgsprojectstylesettings.cpp.
QgsSymbol * QgsProjectStyleSettings::defaultSymbol | ( | Qgis::SymbolType | symbolType | ) | const |
Returns the project default symbol for a given type.
symbolType | the symbol type |
nullptr
if there is no default set Definition at line 50 of file qgsprojectstylesettings.cpp.
|
inline |
Returns the default symbol opacity.
Definition at line 115 of file qgsprojectstylesettings.h.
QgsTextFormat QgsProjectStyleSettings::defaultTextFormat | ( | ) | const |
Returns the project default text format.
Definition at line 121 of file qgsprojectstylesettings.cpp.
QgsStyle * QgsProjectStyleSettings::projectStyle | ( | ) |
Returns the style database to use for project specific styles.
Definition at line 212 of file qgsprojectstylesettings.cpp.
|
signal |
Emitted when the style returned by projectStyle() is changed.
|
inline |
Returns whether the default symbol fill color is randomized.
Definition at line 105 of file qgsprojectstylesettings.h.
bool QgsProjectStyleSettings::readXml | ( | const QDomElement & | element, |
const QgsReadWriteContext & | context, | ||
Qgis::ProjectReadFlags | flags = Qgis::ProjectReadFlags() |
||
) |
Reads the settings's state from a DOM element.
Definition at line 217 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::removeProjectStyle | ( | ) |
Removes and deletes the project style database.
Definition at line 181 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::reset | ( | ) |
Resets the settings to a default state.
Definition at line 156 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setColorModel | ( | Qgis::ColorModel | colorModel | ) |
Set the project's color model to colorModel.
This sets the default color model used when selecting a color in the whole application. Any color defined in a different color model than the one specified here will be converted to this color model when exporting a layout.
If a color space has already been set and its color model differs from colorModel, the project color space will be reset to invalid one (This is only true if QGIS is built against Qt 6.8.0 or greater).
The color model defaults to Qgis::ColorModel::Rgb
Definition at line 511 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setColorSpace | ( | const QColorSpace & | colorSpace | ) |
Set the project's current color space to colorSpace.
colorSpace must be a valid RGB or CMYK color space. The color space's ICC profile will be added as a project attached file.
The project color's space will be added to PDF layout exports when it is defined (i.e. it is different from the default invalid QColorSpace).
If a color model has already been set and it differs from colorSpace's color model, the project's color model is set to match the color space's color model (This is only true if QGIS is built against Qt 6.8.0 or greater).
The color space defaults to an invalid color space.
Definition at line 533 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setDefaultColorRamp | ( | QgsColorRamp * | colorRamp | ) |
Sets the project default color ramp.
colorRamp | the color ramp, set to nullptr to clear default |
Definition at line 111 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setDefaultSymbol | ( | Qgis::SymbolType | symbolType, |
QgsSymbol * | symbol | ||
) |
Sets the project default symbol for a given type.
symbolType | the symbol type |
symbol | the symbol pointer, set to nullptr to clear default |
Definition at line 70 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setDefaultSymbolOpacity | ( | double | opacity | ) |
Sets the default symbol opacity.
Definition at line 136 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setDefaultTextFormat | ( | const QgsTextFormat & | textFormat | ) |
Sets the project default text format.
textFormat | the text format, an invalid format is interpreted as no default |
Definition at line 126 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setProjectStyle | ( | QgsStyle * | style | ) |
Sets the style database to use for the project style.
Definition at line 191 of file qgsprojectstylesettings.cpp.
void QgsProjectStyleSettings::setRandomizeDefaultSymbolColor | ( | bool | randomized | ) |
Sets whether the default symbol fill color is randomized.
Definition at line 146 of file qgsprojectstylesettings.cpp.
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.
Definition at line 436 of file qgsprojectstylesettings.cpp.
QgsStyle * QgsProjectStyleSettings::styleAtPath | ( | const QString & | path | ) |
Returns a reference to the style database associated with the project with matching file path.
Definition at line 406 of file qgsprojectstylesettings.cpp.
|
signal |
Emitted when a style database path is about to be added.
|
signal |
Emitted when a style database path is about to be removed.
|
signal |
Emitted when a style database path is added.
|
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.
Definition at line 233 of file qgsprojectstylesettings.h.
|
signal |
Emitted when a style database path is removed.
|
signal |
Emitted whenever the set of style databases associated with the project is changed.
QList< QgsStyle * > QgsProjectStyleSettings::styles | ( | ) | const |
Returns a list of all the styles associated with the project.
Definition at line 394 of file qgsprojectstylesettings.cpp.
QDomElement QgsProjectStyleSettings::writeXml | ( | QDomDocument & | doc, |
const QgsReadWriteContext & | context | ||
) | const |
Returns a DOM element representing the settings.
Definition at line 328 of file qgsprojectstylesettings.cpp.
|
friend |
Definition at line 360 of file qgsprojectstylesettings.h.