QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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#include "moc_qgsstyleitemslistwidget.cpp"
20#include "qgspanelwidget.h"
21#include "qgssettings.h"
22#include "qgsgui.h"
24#include "qgsproject.h"
26#include <QScrollBar>
27
28//
29// QgsReadOnlyStyleModel
30//
31
33QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyleModel *sourceModel, QObject *parent )
34 : QgsStyleProxyModel( sourceModel, parent )
35{
36
37}
38
39QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent )
40 : QgsStyleProxyModel( style, parent )
41{
42
43}
44
45QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsCombinedStyleModel *style, QObject *parent )
46 : QgsStyleProxyModel( style, parent )
47{
48
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
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(),
128 titleOption.rect.width(), titleOption.rect.height() );
129
130 painter->drawText( rect, Qt::AlignLeft | Qt::AlignVCenter, index.data( Qt::DisplayRole ).toString() );
131 painter->setBrush( Qt::NoBrush );
132 QColor lineColor = titleOption.palette.windowText().color();
133 lineColor.setAlpha( 100 );
134 painter->setPen( QPen( lineColor, 1 ) );
135 painter->drawLine( titleOption.rect.left(), titleOption.rect.bottom(), titleOption.rect.right(), titleOption.rect.bottom() );
136 painter->restore();
137 return;
138 }
139 else if ( qobject_cast< const QTreeView * >( option.widget ) )
140 {
141 painter->save();
142 QColor lineColor = option.palette.windowText().color();
143 lineColor.setAlpha( 100 );
144 painter->setPen( QPen( lineColor, 1 ) );
145
146 QFont f = option.font;
147 f.setBold( true );
148 f.setPointSize( 9 );
149 titleOption.font = f;
150 titleOption.fontMetrics = QFontMetrics( titleOption.font );
151
152 painter->drawLine( index.column() == 0 ? 0 : option.rect.left(),
153 option.rect.bottom(),
154 index.column() == 0 ? option.rect.right() : option.widget->width(),
155 option.rect.bottom() );
156 painter->restore();
157
158 titleOption.state |= QStyle::State_Enabled;
159 QStyledItemDelegate::paint( painter, titleOption, index );
160 return;
161 }
162 }
163
164 QStyledItemDelegate::paint( painter, option, index );
165
166}
167
168
170
171
172//
173// QgsStyleItemsListWidget
174//
175
177 : QWidget( parent )
178{
179 setupUi( this );
180
181 mDelegate = new QgsStyleModelDelegate( this );
182
183 btnAdvanced->hide(); // advanced button is hidden by default
184 btnAdvanced->setMenu( new QMenu( this ) );
185
186 const double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 10;
187 viewSymbols->setIconSize( QSize( static_cast< int >( iconSize ), static_cast< int >( iconSize * 0.9 ) ) ); // ~100, 90 on low dpi
188
189 const double treeIconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 2;
190 mSymbolTreeView->setIconSize( QSize( static_cast< int >( treeIconSize ), static_cast< int >( treeIconSize ) ) );
191 mSymbolTreeView->setMinimumHeight( mSymbolTreeView->fontMetrics().height() * 6 );
192
193 viewSymbols->setItemDelegate( mDelegate );
194 mSymbolTreeView->setItemDelegate( mDelegate );
195
196 viewSymbols->setSelectionBehavior( QAbstractItemView::SelectRows );
197 mSymbolTreeView->setSelectionMode( viewSymbols->selectionMode() );
198
199 connect( openStyleManagerButton, &QToolButton::clicked, this, &QgsStyleItemsListWidget::openStyleManager );
200
201 lblSymbolName->clear();
202
203 connect( mButtonIconView, &QToolButton::toggled, this, [ = ]( bool active )
204 {
205 if ( active )
206 {
207 mSymbolViewStackedWidget->setCurrentIndex( 0 );
208 // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
209 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui );
210 }
211 } );
212 connect( mButtonListView, &QToolButton::toggled, this, [ = ]( bool active )
213 {
214 if ( active )
215 {
216 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 1, QgsSettings::Gui );
217 mSymbolViewStackedWidget->setCurrentIndex( 1 );
218 }
219 } );
220
221 // restore previous view
222 const QgsSettings settings;
223 const int currentView = settings.value( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui ).toInt();
224 if ( currentView == 0 )
225 mButtonIconView->setChecked( true );
226 else
227 mButtonListView->setChecked( true );
228
229 mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
230 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized, this, [this]
231 {
232 // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
233 QgsSettings().setValue( QStringLiteral( "UI/symbolsList/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
234 } );
235
236 QgsFilterLineEdit *groupEdit = new QgsFilterLineEdit();
237 groupEdit->setShowSearchIcon( true );
238 groupEdit->setShowClearButton( true );
239 groupEdit->setPlaceholderText( tr( "Filter symbols…" ) );
240 groupsCombo->setLineEdit( groupEdit );
241
242 connect( btnSaveSymbol, &QPushButton::clicked, this, &QgsStyleItemsListWidget::saveEntity );
243}
244
246{
247 mStyle = style;
248
249 mModel = mStyle == QgsStyle::defaultStyle() ? new QgsReadOnlyStyleModel( QgsProject::instance()->styleSettings()->combinedStyleModel(), this )
250 : new QgsReadOnlyStyleModel( mStyle, this );
251
252 mModel->addDesiredIconSize( viewSymbols->iconSize() );
253 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
254
255 mModel->addTargetScreenProperties( QgsScreenProperties( screen() ) );
256
257 viewSymbols->setTextElideMode( Qt::TextElideMode::ElideRight );
258
259 viewSymbols->setModel( mModel );
260 mSymbolTreeView->setModel( mModel );
261
262 connect( mStyle, &QgsStyle::groupsModified, this, &QgsStyleItemsListWidget::populateGroups );
263
264 mSymbolTreeView->setSelectionModel( viewSymbols->selectionModel() );
265 connect( viewSymbols->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsStyleItemsListWidget::onSelectionChanged );
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( QStringLiteral( "UI/symbolsList/treeState" ), 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
356
358{
359 return groupsCombo->currentData().toString() == QLatin1String( "tag" ) ? 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( QStringLiteral( "UI/symbolsList/treeState" ), 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( QStringLiteral( "qgis/symbolsListGroupsIndex" ), 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() == QLatin1String( "favorite" ) )
514 {
515 mModel->setFavoritesOnly( true );
516 mModel->setTagString( QString() );
517 mModel->setSmartGroupId( -1 );
518 mModel->setFilterString( QString() );
519 }
520 else if ( groupsCombo->currentData().toString() == QLatin1String( "all" ) )
521 {
522 mModel->setFavoritesOnly( false );
523 mModel->setTagString( QString() );
524 mModel->setSmartGroupId( -1 );
525 mModel->setFilterString( QString() );
526 }
527 else if ( groupsCombo->currentData().toString() == QLatin1String( "smartgroup" ) )
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!
551 if ( !panel || !panel->dockMode()
553 || !QgsGui::windowManager()->openStandardDialog( QgsWindowManagerInterface::DialogStyleManager ) )
554 {
555 // fallback to modal dialog
556 QgsStyleManagerDialog dlg( mStyle, this );
557 dlg.exec();
558
559 updateModelFilters(); // probably not needed -- the model should automatically update if any changes were made
560 }
561}
562
563void QgsStyleItemsListWidget::onSelectionChanged( const QModelIndex &index )
564{
565 if ( !mModel )
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( QStringLiteral( "qgis/symbolsListGroupsIndex" ), index );
581}
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
SymbolType
Symbol types.
Definition qgis.h:574
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition qgis.h:5667
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:218
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:64
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 ...
@ 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 ...
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:203
@ LabelSettingsEntity
Label settings.
Definition qgsstyle.h:209
@ TextFormatEntity
Text formats.
Definition qgsstyle.h:208
@ SmartgroupEntity
Smart groups.
Definition qgsstyle.h:207
@ Symbol3DEntity
3D symbol entity
Definition qgsstyle.h:211
@ SymbolEntity
Symbols.
Definition qgsstyle.h:204
@ TagEntity
Tags.
Definition qgsstyle.h:205
@ ColorrampEntity
Color ramps.
Definition qgsstyle.h:206
@ LegendPatchShapeEntity
Legend patch shape.
Definition qgsstyle.h:210
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(bool initialize=true)
Returns the default application-wide style.
Definition qgsstyle.cpp:146
QStringList smartgroupNames() const
Returns the smart groups list.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.