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