QGIS API Documentation 4.3.0-Master (621ced71bd7)
Loading...
Searching...
No Matches
QgsSymbolLayerModel Class Reference

A QAbstractItemModel subclass for displaying a QgsSymbol in a tree view in the symbology panel. More...

#include <qgssymbollayermodel.h>

Inheritance diagram for QgsSymbolLayerModel:

Public Member Functions

 QgsSymbolLayerModel (QgsVectorLayer *vl, QObject *parent=nullptr, QScreen *screen=nullptr)
 Constructor for QgsSymbolLayerModel, with the specified parent object.
QgsSymbolLayerModelNodeaddLayer (QModelIndex index)
 Adds the symbol layer node inserted right before the idx.
void changeLayer (QgsSymbolLayerModelNode *node, QgsSymbolLayer *newLayer)
 Change the symbol layer associated with node by a newLayer symbol layer.
int columnCount (const QModelIndex &=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role) const override
QgsSymbolLayerModelNodeduplicateLayer (QgsSymbolLayerModelNode *node)
 Duplicates the symbol layer node in the parent node hierarchy.
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
QgsSymbolLayerModelNodeindex2node (const QModelIndex &index) const
 Returns the model node corresponding to the given index.
void moveLayerByOffset (QgsSymbolLayerModelNode *node, int offset)
 Moves the symbol layer node by the offset in the parent hierarchy.
QModelIndex node2index (QgsSymbolLayerModelNode *node) const
 Returns the model index corresponding to the given node.
QModelIndex parent (const QModelIndex &child) const override
void removeLayer (QgsSymbolLayerModelNode *node)
 Removes the symbol layer node from it's parent node hierarchy.
QgsSymbolLayerModelNoderootNode () const
 Returns the root node of the model.
int rowCount (const QModelIndex &parent=QModelIndex()) const override
void setScreen (QScreen *screen)
 Set the QScreen of the model itself.
void setSymbol (QgsSymbol *symbol)
 Sets the symbol associated with the model.
void updateNode (QgsSymbol *symbol, QgsSymbolLayerModelNode *parent)
 Updates the descendants of the given parent node with the given symbol.
void updatePreview (QgsSymbolLayerModelNode *node)
 Updates the preview icon of the given node.

Friends

class TestQgsSymbolLayerModel

Detailed Description

A QAbstractItemModel subclass for displaying a QgsSymbol in a tree view in the symbology panel.

Warning
Not part of stable API and may change in future QGIS releases.
Since
QGIS 4.4

Definition at line 167 of file qgssymbollayermodel.h.

Constructor & Destructor Documentation

◆ QgsSymbolLayerModel()

QgsSymbolLayerModel::QgsSymbolLayerModel ( QgsVectorLayer * vl,
QObject * parent = nullptr,
QScreen * screen = nullptr )

Constructor for QgsSymbolLayerModel, with the specified parent object.

Definition at line 239 of file qgssymbollayermodel.cpp.

Member Function Documentation

◆ addLayer()

QgsSymbolLayerModelNode * QgsSymbolLayerModel::addLayer ( QModelIndex index)

Adds the symbol layer node inserted right before the idx.

Definition at line 417 of file qgssymbollayermodel.cpp.

◆ changeLayer()

void QgsSymbolLayerModel::changeLayer ( QgsSymbolLayerModelNode * node,
QgsSymbolLayer * newLayer )

Change the symbol layer associated with node by a newLayer symbol layer.

Definition at line 487 of file qgssymbollayermodel.cpp.

◆ columnCount()

int QgsSymbolLayerModel::columnCount ( const QModelIndex & = QModelIndex()) const
override

Definition at line 268 of file qgssymbollayermodel.cpp.

◆ data()

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

Definition at line 247 of file qgssymbollayermodel.cpp.

◆ duplicateLayer()

QgsSymbolLayerModelNode * QgsSymbolLayerModel::duplicateLayer ( QgsSymbolLayerModelNode * node)

Duplicates the symbol layer node in the parent node hierarchy.

Definition at line 378 of file qgssymbollayermodel.cpp.

◆ index()

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

Definition at line 273 of file qgssymbollayermodel.cpp.

◆ index2node()

QgsSymbolLayerModelNode * QgsSymbolLayerModel::index2node ( const QModelIndex & index) const

Returns the model node corresponding to the given index.

See also
node2index()

Definition at line 315 of file qgssymbollayermodel.cpp.

◆ moveLayerByOffset()

void QgsSymbolLayerModel::moveLayerByOffset ( QgsSymbolLayerModelNode * node,
int offset )

Moves the symbol layer node by the offset in the parent hierarchy.

Definition at line 357 of file qgssymbollayermodel.cpp.

◆ node2index()

QModelIndex QgsSymbolLayerModel::node2index ( QgsSymbolLayerModelNode * node) const

Returns the model index corresponding to the given node.

See also
index2node()

Definition at line 323 of file qgssymbollayermodel.cpp.

◆ parent()

QModelIndex QgsSymbolLayerModel::parent ( const QModelIndex & child) const
override

Definition at line 285 of file qgssymbollayermodel.cpp.

◆ removeLayer()

void QgsSymbolLayerModel::removeLayer ( QgsSymbolLayerModelNode * node)

Removes the symbol layer node from it's parent node hierarchy.

Definition at line 468 of file qgssymbollayermodel.cpp.

◆ rootNode()

QgsSymbolLayerModelNode * QgsSymbolLayerModel::rootNode ( ) const
inline

Returns the root node of the model.

Definition at line 245 of file qgssymbollayermodel.h.

◆ rowCount()

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

Definition at line 259 of file qgssymbollayermodel.cpp.

◆ setScreen()

void QgsSymbolLayerModel::setScreen ( QScreen * screen)

Set the QScreen of the model itself.

And traverses all the nodes in the model to set their QScreen and update their preview icons.

Used to determine the icon size on different dpi monitors.

Definition at line 532 of file qgssymbollayermodel.cpp.

◆ setSymbol()

void QgsSymbolLayerModel::setSymbol ( QgsSymbol * symbol)

Sets the symbol associated with the model.

Note
The ownership of the symbol is not transferred and must exist for the lifetime of the model.

Definition at line 522 of file qgssymbollayermodel.cpp.

◆ updateNode()

void QgsSymbolLayerModel::updateNode ( QgsSymbol * symbol,
QgsSymbolLayerModelNode * parent )

Updates the descendants of the given parent node with the given symbol.

Definition at line 343 of file qgssymbollayermodel.cpp.

◆ updatePreview()

void QgsSymbolLayerModel::updatePreview ( QgsSymbolLayerModelNode * node)

Updates the preview icon of the given node.

And recursively updates the parents of the node.

Definition at line 511 of file qgssymbollayermodel.cpp.

◆ TestQgsSymbolLayerModel

friend class TestQgsSymbolLayerModel
friend

Definition at line 261 of file qgssymbollayermodel.h.


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