31 mTree =
new QTreeWidget(
this );
32 mTree->setHeaderHidden(
true );
34 connect( mTree, &QTreeWidget::itemChanged,
this, [&]( QTreeWidgetItem *,
int ) { emit this->
changed(); } );
37 QVBoxLayout *vbox =
new QVBoxLayout();
38 vbox->setContentsMargins( 0, 0, 0, 0 );
39 vbox->addWidget( mTree );
53 TreeFillVisitor( QTreeWidgetItem *layerItem,
const QgsVectorLayer *layer, QHash<QString, QTreeWidgetItem *> &items, QScreen *screen )
54 : mLayerItem( layerItem )
71 void visitSymbol( QTreeWidgetItem *rootItem,
const QString &identifier,
const QgsSymbol *symbol, QVector<int> rootPath )
82 QVector<int> indexPath = rootPath;
83 indexPath.append( idx );
85 QTreeWidgetItem *slItem =
new QTreeWidgetItem();
87 slItem->setData( 0, Qt::UserRole, idx );
88 slItem->setIcon( 0, slIcon );
89 auto flags = slItem->flags();
92 flags.setFlag( Qt::ItemIsUserCheckable,
true );
93 slItem->setCheckState( 0, Qt::Unchecked );
97 flags.setFlag( Qt::ItemIsUserCheckable,
false );
99 slItem->setFlags( flags );
100 rootItem->addChild( slItem );
101 slItem->setExpanded(
true );
103 mItems[sl->
id()] = slItem;
107 visitSymbol( slItem, identifier, subSymbol, indexPath );
118 const QgsSymbol *symbol = symbolEntity->symbol();
123 QTreeWidgetItem *symbolItem =
new QTreeWidgetItem( QStringList() << ( mCurrentDescription + leaf.
description ) );
125 symbolItem->setData( 0, Qt::UserRole, mCurrentIdentifier );
126 symbolItem->setIcon( 0, icon );
127 mLayerItem->addChild( symbolItem );
128 symbolItem->setExpanded(
true );
130 visitSymbol( symbolItem, leaf.
identifier, symbol, {} );
136 QString mCurrentDescription;
137 QString mCurrentIdentifier;
138 QTreeWidgetItem *mLayerItem;
140 QHash<QString, QTreeWidgetItem *> &mItems;
141 QPointer< QScreen > mScreen;
150 TreeFillVisitor visitor( mTree->invisibleRootItem(), mLayer, mItems, screen() );
157 for (
auto it = mItems.begin(); it != mItems.end(); it++ )
159 if ( it.value()->checkState( 0 ) == Qt::Checked )
160 sel.insert( it.key() );
168 for (
auto it = mItems.begin(); it != mItems.end(); it++ )
170 if ( it.value()->flags() & Qt::ItemIsUserCheckable )
171 it.value()->setCheckState( 0, Qt::Unchecked );
175 for (
const QString &lid : sel )
177 const auto it = mItems.find( lid );
178 if ( it != mItems.end() )
179 ( *it )->setCheckState( 0, Qt::Checked );
@ Millimeters
Millimeters.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Struct for storing maximum and minimum scales for measurements in map units.
Stores properties relating to a screen.
virtual QgsStyle::StyleEntity type() const =0
Returns the type of style entity.
An interface for classes which can visit style entity (e.g.
@ SymbolRule
Rule based symbology or label child rule.
A symbol entity for QgsStyle databases.
static QIcon symbolLayerPreviewIcon(const QgsSymbolLayer *layer, Qgis::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid, QgsMapLayer *mapLayer=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Draws a symbol layer preview to an icon.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0, QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Returns an icon preview for a color ramp.
virtual QString layerType() const =0
Returns a string that represents this layer type.
QString id() const
Returns symbol layer identifier This id is unique in the whole project.
Abstract base class for all rendered symbols.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Qgis::SymbolType type() const
Returns the symbol's type.
Represents a vector layer which manages a vector based data sets.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
Contains information relating to a node (i.e.
QString identifier
A string identifying the node.
QString description
A string describing the node.
QgsStyleEntityVisitorInterface::NodeType type
Node type.
Contains information relating to the style entity currently being visited.
QString description
A string describing the style entity.
const QgsStyleEntityInterface * entity
Reference to style entity being visited.
QString identifier
A string identifying the style entity.