16 #include <QTreeWidget> 
   17 #include <QVBoxLayout> 
   33   mTree = 
new QTreeWidget( 
this );
 
   34   mTree->setHeaderHidden( 
true );
 
   36   connect( mTree, &QTreeWidget::itemChanged, 
this, [&]( QTreeWidgetItem *, 
int ) { emit this->
changed(); } );
 
   39   QVBoxLayout *vbox = 
new QVBoxLayout();
 
   40   vbox->setContentsMargins( 0, 0, 0, 0 );
 
   41   vbox->addWidget( mTree );
 
   55       TreeFillVisitor( QTreeWidgetItem *layerItem, 
const QgsVectorLayer *layer, QHash<QgsSymbolLayerId, QTreeWidgetItem *> &items ):
 
   56         mLayerItem( layerItem ), mLayer( layer ), mItems( items )
 
   70       void visitSymbol( QTreeWidgetItem *rootItem, 
const QString &identifier, 
const QgsSymbol *symbol, QVector<int> rootPath )
 
   81           QVector<int> indexPath = rootPath;
 
   82           indexPath.append( idx );
 
   84           QTreeWidgetItem *slItem = 
new QTreeWidgetItem();
 
   86           slItem->setData( 0, Qt::UserRole, idx );
 
   87           slItem->setIcon( 0, slIcon );
 
   88           auto flags = slItem->flags();
 
   91             flags.setFlag( Qt::ItemIsUserCheckable, 
true );
 
   92             slItem->setCheckState( 0, Qt::Unchecked );
 
   96             flags.setFlag( Qt::ItemIsUserCheckable, 
false );
 
   98           slItem->setFlags( flags );
 
   99           rootItem->addChild( slItem );
 
  100           slItem->setExpanded( 
true );
 
  102           mItems[
QgsSymbolLayerId( mCurrentIdentifier + identifier, indexPath )] = slItem;
 
  106             visitSymbol( slItem, identifier, subSymbol, indexPath );
 
  117         const QgsSymbol *symbol = symbolEntity->symbol();
 
  122         QTreeWidgetItem *symbolItem = 
new QTreeWidgetItem( QStringList() << ( mCurrentDescription + leaf.
description ) );
 
  124         symbolItem->setData( 0, Qt::UserRole, mCurrentIdentifier );
 
  125         symbolItem->setIcon( 0, icon );
 
  126         mLayerItem->addChild( symbolItem );
 
  127         symbolItem->setExpanded( 
true );
 
  129         visitSymbol( symbolItem, leaf.
identifier, symbol, {} );
 
  135       QString mCurrentDescription;
 
  136       QString mCurrentIdentifier;
 
  137       QTreeWidgetItem *mLayerItem;
 
  139       QHash<QgsSymbolLayerId, QTreeWidgetItem *> &mItems;
 
  148   TreeFillVisitor visitor( mTree->invisibleRootItem(), mLayer, mItems );
 
  154   QSet<QgsSymbolLayerId> sel;
 
  155   for ( 
auto it = mItems.begin(); it != mItems.end(); it++ )
 
  157     if ( it.value()->checkState( 0 ) == Qt::Checked )
 
  158       sel.insert( it.key() );
 
  166   for ( 
auto it = mItems.begin(); it != mItems.end(); it++ )
 
  168     if ( it.value()->flags() & Qt::ItemIsUserCheckable )
 
  169       it.value()->setCheckState( 0, Qt::Unchecked );
 
  175     const auto it = mItems.find( lid );
 
  176     if ( it != mItems.end() )
 
  177       ( *it )->setCheckState( 0, Qt::Checked );
 
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.
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.
We may need stable references to symbol layers, when pointers to symbol layers is not usable (when a ...
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0, QgsLegendPatchShape *shape=nullptr)
Returns an icon preview for a color ramp.
static QIcon symbolLayerPreviewIcon(const QgsSymbolLayer *layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid)
Draws a symbol layer preview to an icon.
virtual QString layerType() const =0
Returns a string that represents this layer type.
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.
@ RenderMillimeters
Millimeters.
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.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
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.