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