QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
QgsStyleModel Class Reference

A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle database. More...

#include <qgsstylemodel.h>

Inheritance diagram for QgsStyleModel:

Public Types

enum  Column { Name = 0 , Tags }
 Model columns. More...
enum class  CustomRole : int {
  Type = Qt::UserRole + 1 , Tag , EntityName , SymbolType ,
  IsFavorite , LayerType , CompatibleGeometryTypes , StyleName ,
  StyleFileName , IsTitle
}
 Custom model roles. More...

Public Member Functions

 QgsStyleModel (QgsStyle *style, QObject *parent=nullptr)
 Constructor for QgsStyleModel, for the specified style and parent object.
void addDesiredIconSize (QSize size)
 Adds an additional icon size to generate for Qt::DecorationRole data.
void addTargetScreenProperties (const QgsScreenProperties &properties)
 Adds additional target screen properties to use when generating icons for Qt::DecorationRole data.
int columnCount (const QModelIndex &parent=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role) const override
Qt::ItemFlags flags (const QModelIndex &index) const override
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
QModelIndex parent (const QModelIndex &index) const override
int rowCount (const QModelIndex &parent=QModelIndex()) const override
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QgsStylestyle ()
 Returns the style managed by the model.

Static Public Member Functions

static void setIconGenerator (QgsAbstractStyleEntityIconGenerator *generator)
 Sets the icon generator to use for deferred style entity icon generation.

Friends

class QgsCombinedStyleModel

Detailed Description

A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle database.

If you are creating a style model for the default application style (see QgsStyle::defaultStyle()), consider using the shared style model available at QgsApplication::defaultStyleModel() for performance instead.

See also
QgsStyleProxyModel
Since
QGIS 3.4

Definition at line 131 of file qgsstylemodel.h.

Member Enumeration Documentation

◆ Column

Model columns.

Enumerator
Name 

Name column.

Tags 

Tags column.

Definition at line 138 of file qgsstylemodel.h.

◆ CustomRole

enum class QgsStyleModel::CustomRole : int
strong

Custom model roles.

Note
Prior to QGIS 3.36 this was available as QgsStyleModel::Role
Since
QGIS 3.36
Enumerator
Type 

Style entity type, see QgsStyle::StyleEntity.

Tag 

String list of tags.

EntityName 

Entity name.

Since
QGIS 3.26
SymbolType 

Symbol type (for symbol or legend patch shape entities).

IsFavorite 

Whether entity is flagged as a favorite.

LayerType 

Layer type (for label settings entities).

CompatibleGeometryTypes 

Compatible layer geometry types (for 3D symbols).

StyleName 

Name of associated QgsStyle (QgsStyle::name()).

Since
QGIS 3.26
StyleFileName 

File name of associated QgsStyle (QgsStyle::fileName()).

Since
QGIS 3.26
IsTitle 

True if the index corresponds to a title item.

Since
QGIS 3.26

Definition at line 152 of file qgsstylemodel.h.

Constructor & Destructor Documentation

◆ QgsStyleModel()

QgsStyleModel::QgsStyleModel ( QgsStyle * style,
QObject * parent = nullptr )
explicit

Constructor for QgsStyleModel, for the specified style and parent object.

The style object must exist for the lifetime of this model.

Definition at line 72 of file qgsstylemodel.cpp.

Member Function Documentation

◆ addDesiredIconSize()

void QgsStyleModel::addDesiredIconSize ( QSize size)

Adds an additional icon size to generate for Qt::DecorationRole data.

This allows style icons to be generated at an icon size which corresponds exactly to the view's icon size in which this model is used.

Definition at line 646 of file qgsstylemodel.cpp.

◆ addTargetScreenProperties()

void QgsStyleModel::addTargetScreenProperties ( const QgsScreenProperties & properties)

Adds additional target screen properties to use when generating icons for Qt::DecorationRole data.

This allows style icons to be generated at an icon device pixel ratio and DPI which corresponds exactly to the view's screen properties in which this model is used.

Since
QGIS 3.32

Definition at line 659 of file qgsstylemodel.cpp.

◆ columnCount()

int QgsStyleModel::columnCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 641 of file qgsstylemodel.cpp.

◆ data()

QVariant QgsStyleModel::data ( const QModelIndex & index,
int role ) const
override

Definition at line 122 of file qgsstylemodel.cpp.

◆ flags()

Qt::ItemFlags QgsStyleModel::flags ( const QModelIndex & index) const
override

Definition at line 563 of file qgsstylemodel.cpp.

◆ headerData()

QVariant QgsStyleModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const
override

Definition at line 576 of file qgsstylemodel.cpp.

◆ index()

QModelIndex QgsStyleModel::index ( int row,
int column,
const QModelIndex & parent = QModelIndex() ) const
override

Definition at line 610 of file qgsstylemodel.cpp.

◆ parent()

QModelIndex QgsStyleModel::parent ( const QModelIndex & index) const
override

Definition at line 623 of file qgsstylemodel.cpp.

◆ rowCount()

int QgsStyleModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
override

Definition at line 629 of file qgsstylemodel.cpp.

◆ setData()

bool QgsStyleModel::setData ( const QModelIndex & index,
const QVariant & value,
int role = Qt::EditRole )
override

Definition at line 527 of file qgsstylemodel.cpp.

◆ setIconGenerator()

void QgsStyleModel::setIconGenerator ( QgsAbstractStyleEntityIconGenerator * generator)
static

Sets the icon generator to use for deferred style entity icon generation.

Currently this is used for 3D symbol icons only.

Note
Not available in Python bindings
Since
QGIS 3.16

Definition at line 672 of file qgsstylemodel.cpp.

◆ style()

QgsStyle * QgsStyleModel::style ( )
inline

Returns the style managed by the model.

Since
QGIS 3.10

Definition at line 180 of file qgsstylemodel.h.

◆ QgsCombinedStyleModel

friend class QgsCombinedStyleModel
friend

Definition at line 256 of file qgsstylemodel.h.


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