QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
19#include "qgspanelwidget.h"
20#include "qgssettings.h"
21#include "qgsgui.h"
23#include "qgsproject.h"
25#include <QScrollBar>
26
27//
28// QgsReadOnlyStyleModel
29//
30
32QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyleModel *sourceModel, QObject *parent )
33 : QgsStyleProxyModel( sourceModel, parent )
34{
35
36}
37
38QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent )
39 : QgsStyleProxyModel( style, parent )
40{
41
42}
43
44QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsCombinedStyleModel *style, QObject *parent )
45 : QgsStyleProxyModel( style, parent )
46{
47
48}
49
50Qt::ItemFlags QgsReadOnlyStyleModel::flags( const QModelIndex &index ) const
51{
52 return QgsStyleProxyModel::flags( index ) & ~Qt::ItemIsEditable;
53}
54
55QVariant QgsReadOnlyStyleModel::data( const QModelIndex &index, int role ) const
56{
57 if ( role == Qt::FontRole )
58 {
59 // drop font size to get reasonable amount of item name shown
60 QFont f = QgsStyleProxyModel::data( index, role ).value< QFont >();
61 f.setPointSize( 9 );
62
63 return f;
64 }
65 return QgsStyleProxyModel::data( index, role );
66}
67
68
69//
70// QgsStyleModelDelegate
71//
72
73QgsStyleModelDelegate::QgsStyleModelDelegate( QObject *parent )
74 : QStyledItemDelegate( parent )
75{
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( QgsStyleModel::IsTitleRole ).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( QgsStyleModel::IsTitleRole ).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( QgsStyleModel::IsTitleRole ).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(),
127 titleOption.rect.width(), titleOption.rect.height() );
128
129 painter->drawText( rect, Qt::AlignLeft | Qt::AlignVCenter, index.data( Qt::DisplayRole ).toString() );
130 painter->setBrush( Qt::NoBrush );
131 QColor lineColor = titleOption.palette.windowText().color();
132 lineColor.setAlpha( 100 );
133 painter->setPen( QPen( lineColor, 1 ) );
134 painter->drawLine( titleOption.rect.left(), titleOption.rect.bottom(), titleOption.rect.right(), titleOption.rect.bottom() );
135 painter->restore();
136 return;
137 }
138 else if ( qobject_cast< const QTreeView * >( option.widget ) )
139 {
140 painter->save();
141 QColor lineColor = option.palette.windowText().color();
142 lineColor.setAlpha( 100 );
143 painter->setPen( QPen( lineColor, 1 ) );
144
145 QFont f = option.font;
146 f.setBold( true );
147 f.setPointSize( 9 );
148 titleOption.font = f;
149 titleOption.fontMetrics = QFontMetrics( titleOption.font );
150
151 painter->drawLine( index.column() == 0 ? 0 : option.rect.left(),
152 option.rect.bottom(),
153 index.column() == 0 ? option.rect.right() : option.widget->width(),
154 option.rect.bottom() );
155 painter->restore();
156
157 titleOption.state |= QStyle::State_Enabled;
158 QStyledItemDelegate::paint( painter, titleOption, index );
159 return;
160 }
161 }
162
163 QStyledItemDelegate::paint( painter, option, index );
164
165}
166
167
169
170
171//
172// QgsStyleItemsListWidget
173//
174
176 : QWidget( parent )
177{
178 setupUi( this );
179
180 mDelegate = new QgsStyleModelDelegate( this );
181
182 btnAdvanced->hide(); // advanced button is hidden by default
183 btnAdvanced->setMenu( new QMenu( this ) );
184
185 const double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 10;
186 viewSymbols->setIconSize( QSize( static_cast< int >( iconSize ), static_cast< int >( iconSize * 0.9 ) ) ); // ~100, 90 on low dpi
187
188 const double treeIconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 2;
189 mSymbolTreeView->setIconSize( QSize( static_cast< int >( treeIconSize ), static_cast< int >( treeIconSize ) ) );
190 mSymbolTreeView->setMinimumHeight( mSymbolTreeView->fontMetrics().height() * 6 );
191
192 viewSymbols->setItemDelegate( mDelegate );
193 mSymbolTreeView->setItemDelegate( mDelegate );
194
195 viewSymbols->setSelectionBehavior( QAbstractItemView::SelectRows );
196 mSymbolTreeView->setSelectionMode( viewSymbols->selectionMode() );
197
198 connect( openStyleManagerButton, &QToolButton::clicked, this, &QgsStyleItemsListWidget::openStyleManager );
199
200 lblSymbolName->clear();
201
202 connect( mButtonIconView, &QToolButton::toggled, this, [ = ]( bool active )
203 {
204 if ( active )
205 {
206 mSymbolViewStackedWidget->setCurrentIndex( 0 );
207 // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
208 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui );
209 }
210 } );
211 connect( mButtonListView, &QToolButton::toggled, this, [ = ]( bool active )
212 {
213 if ( active )
214 {
215 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 1, QgsSettings::Gui );
216 mSymbolViewStackedWidget->setCurrentIndex( 1 );
217 }
218 } );
219
220 // restore previous view
221 const QgsSettings settings;
222 const int currentView = settings.value( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui ).toInt();
223 if ( currentView == 0 )
224 mButtonIconView->setChecked( true );
225 else
226 mButtonListView->setChecked( true );
227
228 mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
229 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized, this, [this]
230 {
231 // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
232 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
233 } );
234
235 QgsFilterLineEdit *groupEdit = new QgsFilterLineEdit();
236 groupEdit->setShowSearchIcon( true );
237 groupEdit->setShowClearButton( true );
238 groupEdit->setPlaceholderText( tr( "Filter symbols…" ) );
239 groupsCombo->setLineEdit( groupEdit );
240
241 connect( btnSaveSymbol, &QPushButton::clicked, this, &QgsStyleItemsListWidget::saveEntity );
242}
243
245{
246 mStyle = style;
247
248 mModel = mStyle == QgsStyle::defaultStyle() ? new QgsReadOnlyStyleModel( QgsProject::instance()->styleSettings()->combinedStyleModel(), this )
249 : new QgsReadOnlyStyleModel( mStyle, this );
250
251 mModel->addDesiredIconSize( viewSymbols->iconSize() );
252 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
253
254 mModel->addTargetScreenProperties( QgsScreenProperties( screen() ) );
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
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:255
SymbolType
Attribute editing capabilities which may be supported by vector data providers.
Definition qgis.h:368
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition qgis.h:4086
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:203
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.
Stores properties relating to a screen.
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 addTargetScreenProperties(const QgsScreenProperties &properties)
Adds additional target screen properties to use when generating icons 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.
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.
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition qgsstyle.cpp:145
QStringList smartgroupNames() const
Returns the smart groups list.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.