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