QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsstyleitemslistwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsstyleitemslistwidget.cpp
3 ---------------------------
4 begin : June 2019
5 copyright : (C) 2019 by Nyall Dawson
6 email : nyall dot dawson at gmail.com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16
18
19#include "qgsgui.h"
20#include "qgspanelwidget.h"
21#include "qgsproject.h"
23#include "qgssettings.h"
26
27#include <QScrollBar>
28
29#include "moc_qgsstyleitemslistwidget.cpp"
30
31//
32// QgsReadOnlyStyleModel
33//
34
36QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyleModel *sourceModel, QObject *parent )
37 : QgsStyleProxyModel( sourceModel, parent )
38{
39}
40
41QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent )
42 : QgsStyleProxyModel( style, parent )
43{
44}
45
46QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsCombinedStyleModel *style, QObject *parent )
47 : QgsStyleProxyModel( style, parent )
48{
49}
50
51Qt::ItemFlags QgsReadOnlyStyleModel::flags( const QModelIndex &index ) const
52{
53 return QgsStyleProxyModel::flags( index ) & ~Qt::ItemIsEditable;
54}
55
56QVariant QgsReadOnlyStyleModel::data( const QModelIndex &index, int role ) const
57{
58 if ( role == Qt::FontRole )
59 {
60 // drop font size to get reasonable amount of item name shown
61 QFont f = QgsStyleProxyModel::data( index, role ).value<QFont>();
62 f.setPointSize( 9 );
63
64 return f;
65 }
66 return QgsStyleProxyModel::data( index, role );
67}
68
69
70//
71// QgsStyleModelDelegate
72//
73
74QgsStyleModelDelegate::QgsStyleModelDelegate( QObject *parent )
75 : QStyledItemDelegate( parent )
76{
77}
78
79QSize QgsStyleModelDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
80{
81 if ( const QListView *view = qobject_cast<const QListView *>( option.widget ) )
82 {
83 if ( index.data( static_cast<int>( QgsStyleModel::CustomRole::IsTitle ) ).toBool() )
84 {
85 // make titles take up full width of list view widgets
86 QFont f = option.font;
87 f.setPointSizeF( f.pointSizeF() * 1.4 );
88 const QFontMetrics fm( f );
89 return QSize( option.widget->width() - view->verticalScrollBar()->width() * 2, fm.height() );
90 }
91 else
92 {
93 // for normal entries we just apply a nice grid spacing to the icons. (This needs to be sufficient to
94 // allow enough of the item's name text to show without truncation).
95 const QSize iconSize = option.decorationSize;
96 return QSize( static_cast<int>( iconSize.width() * 1.4 ), static_cast<int>( iconSize.height() * 1.7 ) );
97 }
98 }
99 else if ( qobject_cast<const QTreeView *>( option.widget ) )
100 {
101 if ( index.data( static_cast<int>( QgsStyleModel::CustomRole::IsTitle ) ).toBool() )
102 {
103 QSize defaultSize = QStyledItemDelegate::sizeHint( option, index );
104 // add a little bit of vertical padding
105 return QSize( defaultSize.width(), static_cast<int>( defaultSize.height() * 1.2 ) );
106 }
107 }
108
109 return QStyledItemDelegate::sizeHint( option, index );
110}
111
112void QgsStyleModelDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
113{
114 if ( index.data( static_cast<int>( QgsStyleModel::CustomRole::IsTitle ) ).toBool() )
115 {
116 QStyleOptionViewItem titleOption( option );
117 initStyleOption( &titleOption, index );
118 if ( qobject_cast<const QListView *>( option.widget ) )
119 {
120 titleOption.font.setBold( true );
121 titleOption.font.setPointSizeF( titleOption.font.pointSizeF() * 1.4 );
122
123 painter->save();
124 painter->setBrush( titleOption.palette.windowText() );
125 painter->setFont( titleOption.font );
126 const QRect rect = QRect( titleOption.rect.left(), titleOption.rect.top(), titleOption.rect.width(), titleOption.rect.height() );
127
128 painter->drawText( rect, Qt::AlignLeft | Qt::AlignVCenter, index.data( Qt::DisplayRole ).toString() );
129 painter->setBrush( Qt::NoBrush );
130 QColor lineColor = titleOption.palette.windowText().color();
131 lineColor.setAlpha( 100 );
132 painter->setPen( QPen( lineColor, 1 ) );
133 painter->drawLine( titleOption.rect.left(), titleOption.rect.bottom(), titleOption.rect.right(), titleOption.rect.bottom() );
134 painter->restore();
135 return;
136 }
137 else if ( qobject_cast<const QTreeView *>( option.widget ) )
138 {
139 painter->save();
140 QColor lineColor = option.palette.windowText().color();
141 lineColor.setAlpha( 100 );
142 painter->setPen( QPen( lineColor, 1 ) );
143
144 QFont f = option.font;
145 f.setBold( true );
146 f.setPointSize( 9 );
147 titleOption.font = f;
148 titleOption.fontMetrics = QFontMetrics( titleOption.font );
149
150 painter->drawLine( index.column() == 0 ? 0 : option.rect.left(), option.rect.bottom(), index.column() == 0 ? option.rect.right() : option.widget->width(), option.rect.bottom() );
151 painter->restore();
152
153 titleOption.state |= QStyle::State_Enabled;
154 QStyledItemDelegate::paint( painter, titleOption, index );
155 return;
156 }
157 }
158
159 QStyledItemDelegate::paint( painter, option, index );
160}
161
162
164
165
166//
167// QgsStyleItemsListWidget
168//
169
171 : QWidget( parent )
172{
173 setupUi( this );
174
175 mDelegate = new QgsStyleModelDelegate( this );
176
177 btnAdvanced->hide(); // advanced button is hidden by default
178 btnAdvanced->setMenu( new QMenu( this ) );
179
180 const double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 10;
181 viewSymbols->setIconSize( QSize( static_cast<int>( iconSize ), static_cast<int>( iconSize * 0.9 ) ) ); // ~100, 90 on low dpi
182
183 const double treeIconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 2;
184 mSymbolTreeView->setIconSize( QSize( static_cast<int>( treeIconSize ), static_cast<int>( treeIconSize ) ) );
185 mSymbolTreeView->setMinimumHeight( mSymbolTreeView->fontMetrics().height() * 6 );
186
187 viewSymbols->setItemDelegate( mDelegate );
188 mSymbolTreeView->setItemDelegate( mDelegate );
189
190 viewSymbols->setSelectionBehavior( QAbstractItemView::SelectRows );
191 mSymbolTreeView->setSelectionMode( viewSymbols->selectionMode() );
192
193 connect( openStyleManagerButton, &QToolButton::clicked, this, &QgsStyleItemsListWidget::openStyleManager );
194
195 lblSymbolName->clear();
196
197 connect( mButtonIconView, &QToolButton::toggled, this, [this]( bool active ) {
198 if ( active )
199 {
200 mSymbolViewStackedWidget->setCurrentIndex( 0 );
201 // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
202 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui );
203 }
204 } );
205 connect( mButtonListView, &QToolButton::toggled, this, [this]( bool active ) {
206 if ( active )
207 {
208 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 1, QgsSettings::Gui );
209 mSymbolViewStackedWidget->setCurrentIndex( 1 );
210 }
211 } );
212
213 // restore previous view
214 const QgsSettings settings;
215 const int currentView = settings.value( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui ).toInt();
216 if ( currentView == 0 )
217 mButtonIconView->setChecked( true );
218 else
219 mButtonListView->setChecked( true );
220
221 mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
222 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized, this, [this] {
223 // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
224 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
225 } );
226
227 QgsFilterLineEdit *groupEdit = new QgsFilterLineEdit();
228 groupEdit->setShowSearchIcon( true );
229 groupEdit->setShowClearButton( true );
230 groupEdit->setPlaceholderText( tr( "Filter symbols…" ) );
231 groupsCombo->setLineEdit( groupEdit );
232
233 connect( btnSaveSymbol, &QPushButton::clicked, this, &QgsStyleItemsListWidget::saveEntity );
234}
235
237{
238 mStyle = style;
239
240 mModel = mStyle == QgsStyle::defaultStyle() ? new QgsReadOnlyStyleModel( QgsProject::instance()->styleSettings()->combinedStyleModel(), this )
241 : new QgsReadOnlyStyleModel( mStyle, this );
242
243 mModel->addDesiredIconSize( viewSymbols->iconSize() );
244 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
245
246 mModel->addTargetScreenProperties( QgsScreenProperties( screen() ) );
247
248 viewSymbols->setTextElideMode( Qt::TextElideMode::ElideRight );
249
250 viewSymbols->setModel( mModel );
251 mSymbolTreeView->setModel( mModel );
252
253 connect( mStyle, &QgsStyle::groupsModified, this, &QgsStyleItemsListWidget::populateGroups );
254
255 mSymbolTreeView->setSelectionModel( viewSymbols->selectionModel() );
256 connect( viewSymbols->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsStyleItemsListWidget::onSelectionChanged );
257 connect( viewSymbols, &QListView::activated, this, [this]( const QModelIndex &index ) {
258 onSelectionChanged( index, QModelIndex() );
259 } );
260 connect( mSymbolTreeView, &QTreeView::activated, this, [this]( const QModelIndex &index ) {
261 onSelectionChanged( index, QModelIndex() );
262 } );
263
264 populateGroups();
265 connect( groupsCombo, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsStyleItemsListWidget::groupsCombo_currentIndexChanged );
266 connect( groupsCombo, &QComboBox::currentTextChanged, this, &QgsStyleItemsListWidget::updateModelFilters );
267
268 const QgsSettings settings;
269 mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
270}
271
273{
274 mModel->setEntityFilterEnabled( true );
275 mModel->setEntityFilter( type );
276 const int allGroup = groupsCombo->findData( QVariant( "all" ) );
277 switch ( type )
278 {
280 btnSaveSymbol->setText( tr( "Save Symbol…" ) );
281 btnSaveSymbol->setToolTip( tr( "Save symbol to styles" ) );
282 if ( allGroup >= 0 )
283 groupsCombo->setItemText( allGroup, tr( "All Symbols" ) );
284 break;
285
287 btnSaveSymbol->setText( tr( "Save Color Ramp…" ) );
288 btnSaveSymbol->setToolTip( tr( "Save color ramp to styles" ) );
289 if ( allGroup >= 0 )
290 groupsCombo->setItemText( allGroup, tr( "All Color Ramps" ) );
291 break;
292
294 btnSaveSymbol->setText( tr( "Save Format…" ) );
295 btnSaveSymbol->setToolTip( tr( "Save text format to styles" ) );
296 if ( allGroup >= 0 )
297 groupsCombo->setItemText( allGroup, tr( "All Text Formats" ) );
298 break;
299
301 btnSaveSymbol->setText( tr( "Save Label Settings…" ) );
302 btnSaveSymbol->setToolTip( tr( "Save label settings to styles" ) );
303 if ( allGroup >= 0 )
304 groupsCombo->setItemText( allGroup, tr( "All Label Settings" ) );
305 break;
306
308 btnSaveSymbol->setText( tr( "Save Legend Patch Shape…" ) );
309 btnSaveSymbol->setToolTip( tr( "Save legend patch shape to styles" ) );
310 if ( allGroup >= 0 )
311 groupsCombo->setItemText( allGroup, tr( "All Legend Patch Shapes" ) );
312 break;
313
315 btnSaveSymbol->setText( tr( "Save 3D Symbol…" ) );
316 btnSaveSymbol->setToolTip( tr( "Save 3D symbol to styles" ) );
317 if ( allGroup >= 0 )
318 groupsCombo->setItemText( allGroup, tr( "All 3D Symbols" ) );
319 break;
320
323 break;
324 }
325}
326
327void QgsStyleItemsListWidget::setEntityTypes( const QList<QgsStyle::StyleEntity> &filters )
328{
329 mModel->setEntityFilterEnabled( true );
330 mModel->setEntityFilters( filters );
331
332 // bit of a gross hack -- run now! this will need revisiting when other parent widgets use different filter combinations!
333 const int allGroup = groupsCombo->findData( QVariant( "all" ) );
334 if ( filters.length() == 2 && filters.contains( QgsStyle::LabelSettingsEntity ) && filters.contains( QgsStyle::TextFormatEntity ) )
335 {
336 btnSaveSymbol->setText( tr( "Save Settings…" ) );
337 btnSaveSymbol->setToolTip( tr( "Save label settings or text format to styles" ) );
338 if ( allGroup >= 0 )
339 groupsCombo->setItemText( allGroup, tr( "All Settings" ) );
340 }
341}
342
344{
345 mModel->setSymbolTypeFilterEnabled( true );
346 mModel->setSymbolType( type );
347}
348
350{
351 mModel->setLayerType( type );
352}
353
355{
356 return groupsCombo->currentData().toString() == QLatin1String( "tag" ) ? groupsCombo->currentText() : QString();
357}
358
360{
361 return btnAdvanced->menu();
362}
363
365{
366 if ( menu ) // show it if there is a menu pointer
367 {
368 btnAdvanced->show();
369 btnAdvanced->setMenu( menu );
370 }
371}
372
374{
375 btnAdvanced->setVisible( enabled );
376}
377
379{
380 const QItemSelection selection = viewSymbols->selectionModel()->selection();
381 if ( selection.isEmpty() )
382 return QString();
383
384 const QModelIndex index = selection.at( 0 ).topLeft();
385
386 return mModel->data( index, QgsStyleModel::Name ).toString();
387}
388
390{
391 const QItemSelection selection = viewSymbols->selectionModel()->selection();
392 if ( selection.isEmpty() )
394
395 const QModelIndex index = selection.at( 0 ).topLeft();
396
397 return static_cast<QgsStyle::StyleEntity>( mModel->data( index, static_cast<int>( QgsStyleModel::CustomRole::Type ) ).toInt() );
398}
399
400void QgsStyleItemsListWidget::showEvent( QShowEvent *event )
401{
402 // restore header sizes on show event -- because this widget is used in multiple places simultaneously
403 // (e.g. layer styling dock, it's shown in both the symbology and labeling sections), then we want
404 // to ensure that a header resize for any of the widgets applies the next time any other item list widgets
405 // are shown.
406 QWidget::showEvent( event );
407 const QgsSettings settings;
408 mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
409}
410
411void QgsStyleItemsListWidget::populateGroups()
412{
413 if ( !mStyle )
414 return;
415
416 mUpdatingGroups = true;
417 groupsCombo->blockSignals( true );
418 groupsCombo->clear();
419
420 groupsCombo->addItem( tr( "Favorites" ), QVariant( "favorite" ) );
421
422 QString allText = tr( "All Symbols" );
423 if ( mModel->entityFilterEnabled() )
424 {
425 switch ( mModel->entityFilter() )
426 {
428 allText = tr( "All Symbols" );
429 break;
430
432 allText = tr( "All Color Ramps" );
433 break;
434
436 allText = tr( "All Text Formats" );
437 break;
438
440 allText = tr( "All Label Settings" );
441 break;
442
444 allText = tr( "All Legend Patch Shapes" );
445 break;
446
448 allText = tr( "All 3D Symbols" );
449 break;
450
453 break;
454 }
455 }
456
457 groupsCombo->addItem( allText, QVariant( "all" ) );
458
459 int index = 2;
460 QStringList tags = mStyle->tags();
461 if ( tags.count() > 0 )
462 {
463 tags.sort();
464 groupsCombo->insertSeparator( index );
465 const auto constTags = tags;
466 for ( const QString &tag : constTags )
467 {
468 groupsCombo->addItem( tag, QVariant( "tag" ) );
469 index++;
470 }
471 }
472
473 QStringList groups = mStyle->smartgroupNames();
474 if ( groups.count() > 0 )
475 {
476 groups.sort();
477 groupsCombo->insertSeparator( index + 1 );
478 const auto constGroups = groups;
479 for ( const QString &group : constGroups )
480 {
481 groupsCombo->addItem( group, QVariant( "smartgroup" ) );
482 }
483 }
484 groupsCombo->blockSignals( false );
485
486 const QgsSettings settings;
487 index = settings.value( QStringLiteral( "qgis/symbolsListGroupsIndex" ), 0 ).toInt();
488 groupsCombo->setCurrentIndex( index );
489
490 mUpdatingGroups = false;
491
492 updateModelFilters();
493}
494
495void QgsStyleItemsListWidget::updateModelFilters()
496{
497 if ( mUpdatingGroups || !mModel )
498 return;
499
500 const QString text = groupsCombo->currentText();
501 const bool isFreeText = text != groupsCombo->itemText( groupsCombo->currentIndex() );
502
503 if ( isFreeText )
504 {
505 mModel->setFavoritesOnly( false );
506 mModel->setTagString( QString() );
507 mModel->setSmartGroupId( -1 );
508 mModel->setFilterString( groupsCombo->currentText() );
509 }
510 else if ( groupsCombo->currentData().toString() == QLatin1String( "favorite" ) )
511 {
512 mModel->setFavoritesOnly( true );
513 mModel->setTagString( QString() );
514 mModel->setSmartGroupId( -1 );
515 mModel->setFilterString( QString() );
516 }
517 else if ( groupsCombo->currentData().toString() == QLatin1String( "all" ) )
518 {
519 mModel->setFavoritesOnly( false );
520 mModel->setTagString( QString() );
521 mModel->setSmartGroupId( -1 );
522 mModel->setFilterString( QString() );
523 }
524 else if ( groupsCombo->currentData().toString() == QLatin1String( "smartgroup" ) )
525 {
526 mModel->setFavoritesOnly( false );
527 mModel->setTagString( QString() );
528 mModel->setSmartGroupId( mStyle->smartgroupId( text ) );
529 mModel->setFilterString( QString() );
530 }
531 else
532 {
533 mModel->setFavoritesOnly( false );
534 mModel->setTagString( text );
535 mModel->setSmartGroupId( -1 );
536 mModel->setFilterString( QString() );
537 }
538}
539
540void QgsStyleItemsListWidget::openStyleManager()
541{
542 // prefer to use global window manager to open the style manager, if possible!
543 // this allows reuse of an existing non-modal window instead of opening a new modal window.
544 // Note that we only use the non-modal dialog if we're open in the panel -- if we're already
545 // open as part of a modal dialog, then we MUST use another modal dialog or the result will
546 // not be focusable!
547 QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
548 if ( !panel || !panel->dockMode()
550 || !QgsGui::windowManager()->openStandardDialog( QgsWindowManagerInterface::DialogStyleManager ) )
551 {
552 // fallback to modal dialog
553 std::unique_ptr< QgsStyleManagerDialog > dlg;
554 if ( mStyle && mStyle != QgsStyle::defaultStyle() )
555 {
556 dlg = std::make_unique< QgsStyleManagerDialog >( mStyle, this );
557 }
558 else
559 {
560 dlg = std::make_unique< QgsStyleManagerDialog >( this );
561 }
562 dlg->exec();
563
564 updateModelFilters(); // probably not needed -- the model should automatically update if any changes were made
565 }
566}
567
568void QgsStyleItemsListWidget::onSelectionChanged( const QModelIndex &index, const QModelIndex &previous )
569{
570 if ( !mModel )
571 return;
572
573 if ( index.row() == previous.row() )
574 return;
575
576 const QString symbolName = mModel->data( mModel->index( index.row(), QgsStyleModel::Name ) ).toString();
577 lblSymbolName->setText( symbolName );
578
579 const QString sourceName = mModel->data( mModel->index( index.row(), 0 ), static_cast<int>( QgsStyleModel::CustomRole::StyleFileName ) ).toString();
580
581 emit selectionChanged( symbolName, static_cast<QgsStyle::StyleEntity>( mModel->data( index, static_cast<int>( QgsStyleModel::CustomRole::Type ) ).toInt() ) );
582 emit selectionChangedWithStylePath( symbolName, static_cast<QgsStyle::StyleEntity>( mModel->data( index, static_cast<int>( QgsStyleModel::CustomRole::Type ) ).toInt() ), sourceName );
583}
584
585void QgsStyleItemsListWidget::groupsCombo_currentIndexChanged( int index )
586{
587 QgsSettings settings;
588 settings.setValue( QStringLiteral( "qgis/symbolsListGroupsIndex" ), index );
589}
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
SymbolType
Symbol types.
Definition qgis.h:610
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition qgis.h:6222
A model which contains entities from multiple QgsStyle databases.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
void setShowSearchIcon(bool visible)
Define if a search icon shall be shown on the left of the image when no text is entered.
void setShowClearButton(bool visible)
Sets whether the widget's clear button is visible.
static QgsWindowManagerInterface * windowManager()
Returns the global window manager, if set.
Definition qgsgui.cpp:230
bool dockMode() const
Returns the dock mode state.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Stores properties relating to a screen.
Stores settings for use within QGIS.
Definition qgssettings.h:65
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
void setStyle(QgsStyle *style)
Sets the style database associated with the widget.
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
QString currentItemName() const
Returns the name of the item currently selected in the widget.
void setLayerType(Qgis::GeometryType type)
Sets the layer type to show in the widget.
void setAdvancedMenu(QMenu *menu)
Sets the widget's advanced menu, which is shown when the user clicks the "Advanced" button in the wid...
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
void showAdvancedButton(bool enabled)
Sets whether the advanced button should be shown in the widget.
QString currentTagFilter() const
Returns the current tag filter set for the widget, if any is set.
void setSymbolType(Qgis::SymbolType type)
Sets the type of symbols to show in the widget.
QgsStyle::StyleEntity currentEntityType() const
Returns the type of the item currently selected in the widget.
QgsStyleItemsListWidget(QWidget *parent SIP_TRANSFERTHIS)
Constructor for QgsStyleItemsListWidget, with the specified parent widget.
void setEntityType(QgsStyle::StyleEntity type)
Sets the type of style entity to show in the widget.
void setEntityTypes(const QList< QgsStyle::StyleEntity > &filters) SIP_SKIP
Sets the types of style entity to show in the widget.
void showEvent(QShowEvent *event) override
QMenu * advancedMenu()
Returns a pointer to the widget's current advanced menu.
void selectionChangedWithStylePath(const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
Emitted when the selected item is changed in the widget.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
@ IsTitle
True if the index corresponds to a title item.
@ StyleFileName
File name of associated QgsStyle (QgsStyle::fileName()).
@ Type
Style entity type, see QgsStyle::StyleEntity.
@ Name
Name column.
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
QgsStyle::StyleEntity entityFilter() const
Returns the style entity type filter.
bool entityFilterEnabled() const
Returns true if filtering by entity type is enabled.
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:88
StyleEntity
Enum for Entities involved in a style.
Definition qgsstyle.h:204
@ LabelSettingsEntity
Label settings.
Definition qgsstyle.h:210
@ TextFormatEntity
Text formats.
Definition qgsstyle.h:209
@ SmartgroupEntity
Smart groups.
Definition qgsstyle.h:208
@ Symbol3DEntity
3D symbol entity
Definition qgsstyle.h:212
@ SymbolEntity
Symbols.
Definition qgsstyle.h:205
@ TagEntity
Tags.
Definition qgsstyle.h:206
@ ColorrampEntity
Color ramps.
Definition qgsstyle.h:207
@ LegendPatchShapeEntity
Legend patch shape.
Definition qgsstyle.h:211
void groupsModified()
Emitted every time a tag or smartgroup has been added, removed, or renamed.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
Definition qgsstyle.cpp:147
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.