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