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