16#ifndef QGSSYMBOLLAYERMODEL_H
17#define QGSSYMBOLLAYERMODEL_H
25#include <QAbstractItemModel>
78 QVariant data(
int role )
const;
112 void deleteChildren();
133 int rowCount()
const;
138 int rowIndex()
const;
149 QPointer<QgsVectorLayer> mVectorLayer;
150 bool mIsLayer =
false;
153 QPointer<QScreen> mScreen;
156 std::deque<std::unique_ptr<QgsSymbolLayerModelNode>> mChildren;
177 QVariant
data(
const QModelIndex &
index,
int role )
const override;
178 int rowCount(
const QModelIndex &
parent = QModelIndex() )
const override;
179 int columnCount(
const QModelIndex & = QModelIndex() )
const override;
180 QModelIndex
index(
int row,
int column,
const QModelIndex &
parent = QModelIndex() )
const override;
181 QModelIndex
parent(
const QModelIndex &child )
const override;
253 std::unique_ptr<QgsSymbolLayerModelNode> mRootNode;
257 QPointer<QgsVectorLayer> mVectorLayer;
259 QPointer<QScreen> mScreen;
A node contained within a QgsSymbolLayerModel.
QgsSymbolLayerModelNode * parent()
Returns the pointer of the parent node. If parent is nullptr, the node is a root node.
void setLayer(QgsSymbolLayer *layer, Qgis::SymbolType symbolType)
Sets the layer associated with the node, and the symbolType of the QgsSymbol it belongs to.
QgsSymbol * symbol()
Returns the symbol pointer; helpful in determining a layer's parent symbol.
QgsSymbolLayer * layer()
Returns the symbol layer pointer.
friend class TestQgsSymbolLayerModel
bool isRootNode() const
Returns true if the node is a root node (i.e. has no parent).
void setScreen(QScreen *screen)
Sets the screen associated with the node, which is used to render the preview icons.
bool isLayer() const
Returns true if the node is a symbol layer. And otherwise, it is a symbol.
QgsSymbolLayerModelNode()
Constructor for QgsSymbolLayerModelNode for an empty node.
int columnCount(const QModelIndex &=QModelIndex()) const override
void updateNode(QgsSymbol *symbol, QgsSymbolLayerModelNode *parent)
Updates the descendants of the given parent node with the given symbol.
QModelIndex parent(const QModelIndex &child) const override
QVariant data(const QModelIndex &index, int role) const override
QgsSymbolLayerModelNode * addLayer(QModelIndex index)
Adds the symbol layer node inserted right before the idx.
void removeLayer(QgsSymbolLayerModelNode *node)
Removes the symbol layer node from it's parent node hierarchy.
void updatePreview(QgsSymbolLayerModelNode *node)
Updates the preview icon of the given node.
void moveLayerByOffset(QgsSymbolLayerModelNode *node, int offset)
Moves the symbol layer node by the offset in the parent hierarchy.
QgsSymbolLayerModelNode * duplicateLayer(QgsSymbolLayerModelNode *node)
Duplicates the symbol layer node in the parent node hierarchy.
QgsSymbolLayerModelNode * rootNode() const
Returns the root node of the model.
QModelIndex node2index(QgsSymbolLayerModelNode *node) const
Returns the model index corresponding to the given node.
QgsSymbolLayerModel(QgsVectorLayer *vl, QObject *parent=nullptr, QScreen *screen=nullptr)
Constructor for QgsSymbolLayerModel, with the specified parent object.
void setSymbol(QgsSymbol *symbol)
Sets the symbol associated with the model.
void setScreen(QScreen *screen)
Set the QScreen of the model itself.
friend class TestQgsSymbolLayerModel
void changeLayer(QgsSymbolLayerModelNode *node, QgsSymbolLayer *newLayer)
Change the symbol layer associated with node by a newLayer symbol layer.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QgsSymbolLayerModelNode * index2node(const QModelIndex &index) const
Returns the model node corresponding to the given index.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Abstract base class for symbol layers.
Abstract base class for all rendered symbols.
Represents a vector layer which manages a vector based dataset.