QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgsstylemanagerdialog.h"
19 #include "qgsstylesavedialog.h"
20 #include "qgspanelwidget.h"
21 #include "qgssettings.h"
22 #include "qgsgui.h"
24 #include "qgsapplication.h"
25 #include "qgsproject.h"
27 #include <QScrollBar>
28 
29 //
30 // QgsReadOnlyStyleModel
31 //
32 
34 QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyleModel *sourceModel, QObject *parent )
35  : QgsStyleProxyModel( sourceModel, parent )
36 {
37 
38 }
39 
40 QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent )
41  : QgsStyleProxyModel( style, parent )
42 {
43 
44 }
45 
46 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
47 QgsReadOnlyStyleModel::QgsReadOnlyStyleModel( QgsCombinedStyleModel *style, QObject *parent )
48  : QgsStyleProxyModel( style, parent )
49 {
50 
51 }
52 #endif
53 
54 Qt::ItemFlags QgsReadOnlyStyleModel::flags( const QModelIndex &index ) const
55 {
56  return QgsStyleProxyModel::flags( index ) & ~Qt::ItemIsEditable;
57 }
58 
59 QVariant 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 
77 QgsStyleModelDelegate::QgsStyleModelDelegate( QObject *parent )
78  : QStyledItemDelegate( parent )
79 {
80 
81 }
82 
83 QSize QgsStyleModelDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
84 {
85  if ( const QListView *view = qobject_cast< const QListView * >( option.widget ) )
86  {
87  if ( index.data( QgsStyleModel::IsTitleRole ).toBool() )
88  {
89  // make titles take up full width of list view widgets
90  QFont f = option.font;
91  f.setPointSizeF( f.pointSizeF() * 1.4 );
92  const QFontMetrics fm( f );
93  return QSize( option.widget->width() - view->verticalScrollBar()->width() * 2, fm.height() );
94  }
95  else
96  {
97  // for normal entries we just apply a nice grid spacing to the icons. (This needs to be sufficient to
98  // allow enough of the item's name text to show without truncation).
99  const QSize iconSize = option.decorationSize;
100  return QSize( static_cast< int >( iconSize.width() * 1.4 ), static_cast< int >( iconSize.height() * 1.7 ) );
101  }
102  }
103  else if ( qobject_cast< const QTreeView * >( option.widget ) )
104  {
105  if ( index.data( QgsStyleModel::IsTitleRole ).toBool() )
106  {
107  QSize defaultSize = QStyledItemDelegate::sizeHint( option, index );
108  // add a little bit of vertical padding
109  return QSize( defaultSize.width(), static_cast< int >( defaultSize.height() * 1.2 ) );
110  }
111  }
112 
113  return QStyledItemDelegate::sizeHint( option, index );
114 }
115 
116 void QgsStyleModelDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
117 {
118  if ( index.data( QgsStyleModel::IsTitleRole ).toBool() )
119  {
120  QStyleOptionViewItem titleOption( option );
121  initStyleOption( &titleOption, index );
122  if ( qobject_cast< const QListView * >( option.widget ) )
123  {
124  titleOption.font.setBold( true );
125  titleOption.font.setPointSizeF( titleOption.font.pointSizeF() * 1.4 );
126 
127  painter->save();
128  painter->setBrush( titleOption.palette.windowText() );
129  painter->setFont( titleOption.font );
130  const QRect rect = QRect( titleOption.rect.left(), titleOption.rect.top(),
131  titleOption.rect.width(), titleOption.rect.height() );
132 
133  painter->drawText( rect, Qt::AlignLeft | Qt::AlignVCenter, index.data( Qt::DisplayRole ).toString() );
134  painter->setBrush( Qt::NoBrush );
135  QColor lineColor = titleOption.palette.windowText().color();
136  lineColor.setAlpha( 100 );
137  painter->setPen( QPen( lineColor, 1 ) );
138  painter->drawLine( titleOption.rect.left(), titleOption.rect.bottom(), titleOption.rect.right(), titleOption.rect.bottom() );
139  painter->restore();
140  return;
141  }
142  else if ( qobject_cast< const QTreeView * >( option.widget ) )
143  {
144  painter->save();
145  QColor lineColor = option.palette.windowText().color();
146  lineColor.setAlpha( 100 );
147  painter->setPen( QPen( lineColor, 1 ) );
148 
149  QFont f = option.font;
150  f.setBold( true );
151  f.setPointSize( 9 );
152  titleOption.font = f;
153  titleOption.fontMetrics = QFontMetrics( titleOption.font );
154 
155  painter->drawLine( index.column() == 0 ? 0 : option.rect.left(),
156  option.rect.bottom(),
157  index.column() == 0 ? option.rect.right() : option.widget->width(),
158  option.rect.bottom() );
159  painter->restore();
160 
161  titleOption.state |= QStyle::State_Enabled;
162  QStyledItemDelegate::paint( painter, titleOption, index );
163  return;
164  }
165  }
166 
167  QStyledItemDelegate::paint( painter, option, index );
168 
169 }
170 
171 
173 
174 
175 //
176 // QgsStyleItemsListWidget
177 //
178 
180  : QWidget( parent )
181 {
182  setupUi( this );
183 
184  mDelegate = new QgsStyleModelDelegate( this );
185 
186  btnAdvanced->hide(); // advanced button is hidden by default
187  btnAdvanced->setMenu( new QMenu( this ) );
188 
189  const double iconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 10;
190  viewSymbols->setIconSize( QSize( static_cast< int >( iconSize ), static_cast< int >( iconSize * 0.9 ) ) ); // ~100, 90 on low dpi
191 
192  const double treeIconSize = Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 2;
193  mSymbolTreeView->setIconSize( QSize( static_cast< int >( treeIconSize ), static_cast< int >( treeIconSize ) ) );
194  mSymbolTreeView->setMinimumHeight( mSymbolTreeView->fontMetrics().height() * 6 );
195 
196  viewSymbols->setItemDelegate( mDelegate );
197  mSymbolTreeView->setItemDelegate( mDelegate );
198 
199  viewSymbols->setSelectionBehavior( QAbstractItemView::SelectRows );
200  mSymbolTreeView->setSelectionMode( viewSymbols->selectionMode() );
201 
202  connect( openStyleManagerButton, &QToolButton::clicked, this, &QgsStyleItemsListWidget::openStyleManager );
203 
204  lblSymbolName->clear();
205 
206  connect( mButtonIconView, &QToolButton::toggled, this, [ = ]( bool active )
207  {
208  if ( active )
209  {
210  mSymbolViewStackedWidget->setCurrentIndex( 0 );
211  // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
212  QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui );
213  }
214  } );
215  connect( mButtonListView, &QToolButton::toggled, this, [ = ]( bool active )
216  {
217  if ( active )
218  {
219  QgsSettings().setValue( QStringLiteral( "UI/symbolsList/lastIconView" ), 1, QgsSettings::Gui );
220  mSymbolViewStackedWidget->setCurrentIndex( 1 );
221  }
222  } );
223 
224  // restore previous view
225  const QgsSettings settings;
226  const int currentView = settings.value( QStringLiteral( "UI/symbolsList/lastIconView" ), 0, QgsSettings::Gui ).toInt();
227  if ( currentView == 0 )
228  mButtonIconView->setChecked( true );
229  else
230  mButtonListView->setChecked( true );
231 
232  mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
233  connect( mSymbolTreeView->header(), &QHeaderView::sectionResized, this, [this]
234  {
235  // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
236  QgsSettings().setValue( QStringLiteral( "UI/symbolsList/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
237  } );
238 
239  QgsFilterLineEdit *groupEdit = new QgsFilterLineEdit();
240  groupEdit->setShowSearchIcon( true );
241  groupEdit->setShowClearButton( true );
242  groupEdit->setPlaceholderText( tr( "Filter symbols…" ) );
243  groupsCombo->setLineEdit( groupEdit );
244 
245  connect( btnSaveSymbol, &QPushButton::clicked, this, &QgsStyleItemsListWidget::saveEntity );
246 }
247 
249 {
250  mStyle = style;
251 
252 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
253  mModel = mStyle == QgsStyle::defaultStyle() ? new QgsReadOnlyStyleModel( QgsProject::instance()->styleSettings()->combinedStyleModel(), this )
254  : new QgsReadOnlyStyleModel( mStyle, this );
255 #else
256  mModel = mStyle == QgsStyle::defaultStyle() ? new QgsReadOnlyStyleModel( QgsApplication::defaultStyleModel(), this )
257  : new QgsReadOnlyStyleModel( mStyle, this );
258 #endif
259 
260  mModel->addDesiredIconSize( viewSymbols->iconSize() );
261  mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
262 
263  viewSymbols->setTextElideMode( Qt::TextElideMode::ElideRight );
264 
265  viewSymbols->setModel( mModel );
266  mSymbolTreeView->setModel( mModel );
267 
268  connect( mStyle, &QgsStyle::groupsModified, this, &QgsStyleItemsListWidget::populateGroups );
269 
270  mSymbolTreeView->setSelectionModel( viewSymbols->selectionModel() );
271  connect( viewSymbols->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsStyleItemsListWidget::onSelectionChanged );
272 
273  populateGroups();
274  connect( groupsCombo, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsStyleItemsListWidget::groupsCombo_currentIndexChanged );
275  connect( groupsCombo, &QComboBox::currentTextChanged, this, &QgsStyleItemsListWidget::updateModelFilters );
276 
277  const QgsSettings settings;
278  mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
279 }
280 
282 {
283  mModel->setEntityFilterEnabled( true );
284  mModel->setEntityFilter( type );
285  const int allGroup = groupsCombo->findData( QVariant( "all" ) );
286  switch ( type )
287  {
289  btnSaveSymbol->setText( tr( "Save Symbol…" ) );
290  btnSaveSymbol->setToolTip( tr( "Save symbol to styles" ) );
291  if ( allGroup >= 0 )
292  groupsCombo->setItemText( allGroup, tr( "All Symbols" ) );
293  break;
294 
296  btnSaveSymbol->setText( tr( "Save Color Ramp…" ) );
297  btnSaveSymbol->setToolTip( tr( "Save color ramp to styles" ) );
298  if ( allGroup >= 0 )
299  groupsCombo->setItemText( allGroup, tr( "All Color Ramps" ) );
300  break;
301 
303  btnSaveSymbol->setText( tr( "Save Format…" ) );
304  btnSaveSymbol->setToolTip( tr( "Save text format to styles" ) );
305  if ( allGroup >= 0 )
306  groupsCombo->setItemText( allGroup, tr( "All Text Formats" ) );
307  break;
308 
310  btnSaveSymbol->setText( tr( "Save Label Settings…" ) );
311  btnSaveSymbol->setToolTip( tr( "Save label settings to styles" ) );
312  if ( allGroup >= 0 )
313  groupsCombo->setItemText( allGroup, tr( "All Label Settings" ) );
314  break;
315 
317  btnSaveSymbol->setText( tr( "Save Legend Patch Shape…" ) );
318  btnSaveSymbol->setToolTip( tr( "Save legend patch shape to styles" ) );
319  if ( allGroup >= 0 )
320  groupsCombo->setItemText( allGroup, tr( "All Legend Patch Shapes" ) );
321  break;
322 
324  btnSaveSymbol->setText( tr( "Save 3D Symbol…" ) );
325  btnSaveSymbol->setToolTip( tr( "Save 3D symbol to styles" ) );
326  if ( allGroup >= 0 )
327  groupsCombo->setItemText( allGroup, tr( "All 3D Symbols" ) );
328  break;
329 
330  case QgsStyle::TagEntity:
332  break;
333  }
334 }
335 
336 void QgsStyleItemsListWidget::setEntityTypes( const QList<QgsStyle::StyleEntity> &filters )
337 {
338  mModel->setEntityFilterEnabled( true );
339  mModel->setEntityFilters( filters );
340 
341  // bit of a gross hack -- run now! this will need revisiting when other parent widgets use different filter combinations!
342  const int allGroup = groupsCombo->findData( QVariant( "all" ) );
343  if ( filters.length() == 2 && filters.contains( QgsStyle::LabelSettingsEntity ) && filters.contains( QgsStyle::TextFormatEntity ) )
344  {
345  btnSaveSymbol->setText( tr( "Save Settings…" ) );
346  btnSaveSymbol->setToolTip( tr( "Save label settings or text format to styles" ) );
347  if ( allGroup >= 0 )
348  groupsCombo->setItemText( allGroup, tr( "All Settings" ) );
349  }
350 }
351 
353 {
354  mModel->setSymbolTypeFilterEnabled( true );
355  mModel->setSymbolType( type );
356 }
357 
359 {
360  mModel->setLayerType( type );
361 }
362 
364 {
365  return groupsCombo->currentData().toString() == QLatin1String( "tag" ) ? groupsCombo->currentText() : QString();
366 }
367 
369 {
370  return btnAdvanced->menu();
371 }
372 
374 {
375  if ( menu ) // show it if there is a menu pointer
376  {
377  btnAdvanced->show();
378  btnAdvanced->setMenu( menu );
379  }
380 }
381 
383 {
384  btnAdvanced->setVisible( enabled );
385 }
386 
388 {
389  const QItemSelection selection = viewSymbols->selectionModel()->selection();
390  if ( selection.isEmpty() )
391  return QString();
392 
393  const QModelIndex index = selection.at( 0 ).topLeft();
394 
395  return mModel->data( index, QgsStyleModel::Name ).toString();
396 }
397 
399 {
400  const QItemSelection selection = viewSymbols->selectionModel()->selection();
401  if ( selection.isEmpty() )
402  return QgsStyle::SymbolEntity;
403 
404  const QModelIndex index = selection.at( 0 ).topLeft();
405 
406  return static_cast< QgsStyle::StyleEntity >( mModel->data( index, QgsStyleModel::TypeRole ).toInt() );
407 }
408 
409 void QgsStyleItemsListWidget::showEvent( QShowEvent *event )
410 {
411  // restore header sizes on show event -- because this widget is used in multiple places simultaneously
412  // (e.g. layer styling dock, it's shown in both the symbology and labeling sections), then we want
413  // to ensure that a header resize for any of the widgets applies the next time any other item list widgets
414  // are shown.
415  QWidget::showEvent( event );
416  const QgsSettings settings;
417  mSymbolTreeView->header()->restoreState( settings.value( QStringLiteral( "UI/symbolsList/treeState" ), QByteArray(), QgsSettings::Gui ).toByteArray() );
418 }
419 
420 void QgsStyleItemsListWidget::populateGroups()
421 {
422  if ( !mStyle )
423  return;
424 
425  mUpdatingGroups = true;
426  groupsCombo->blockSignals( true );
427  groupsCombo->clear();
428 
429  groupsCombo->addItem( tr( "Favorites" ), QVariant( "favorite" ) );
430 
431  QString allText = tr( "All Symbols" );
432  if ( mModel->entityFilterEnabled() )
433  {
434  switch ( mModel->entityFilter() )
435  {
437  allText = tr( "All Symbols" );
438  break;
439 
441  allText = tr( "All Color Ramps" );
442  break;
443 
445  allText = tr( "All Text Formats" );
446  break;
447 
449  allText = tr( "All Label Settings" );
450  break;
451 
453  allText = tr( "All Legend Patch Shapes" );
454  break;
455 
457  allText = tr( "All 3D Symbols" );
458  break;
459 
460  case QgsStyle::TagEntity:
462  break;
463  }
464  }
465 
466  groupsCombo->addItem( allText, QVariant( "all" ) );
467 
468  int index = 2;
469  QStringList tags = mStyle->tags();
470  if ( tags.count() > 0 )
471  {
472  tags.sort();
473  groupsCombo->insertSeparator( index );
474  const auto constTags = tags;
475  for ( const QString &tag : constTags )
476  {
477  groupsCombo->addItem( tag, QVariant( "tag" ) );
478  index++;
479  }
480  }
481 
482  QStringList groups = mStyle->smartgroupNames();
483  if ( groups.count() > 0 )
484  {
485  groups.sort();
486  groupsCombo->insertSeparator( index + 1 );
487  const auto constGroups = groups;
488  for ( const QString &group : constGroups )
489  {
490  groupsCombo->addItem( group, QVariant( "smartgroup" ) );
491  }
492  }
493  groupsCombo->blockSignals( false );
494 
495  const QgsSettings settings;
496  index = settings.value( QStringLiteral( "qgis/symbolsListGroupsIndex" ), 0 ).toInt();
497  groupsCombo->setCurrentIndex( index );
498 
499  mUpdatingGroups = false;
500 
501  updateModelFilters();
502 }
503 
504 void QgsStyleItemsListWidget::updateModelFilters()
505 {
506  if ( mUpdatingGroups || !mModel )
507  return;
508 
509  const QString text = groupsCombo->currentText();
510  const bool isFreeText = text != groupsCombo->itemText( groupsCombo->currentIndex() );
511 
512  if ( isFreeText )
513  {
514  mModel->setFavoritesOnly( false );
515  mModel->setTagString( QString() );
516  mModel->setSmartGroupId( -1 );
517  mModel->setFilterString( groupsCombo->currentText() );
518  }
519  else if ( groupsCombo->currentData().toString() == QLatin1String( "favorite" ) )
520  {
521  mModel->setFavoritesOnly( true );
522  mModel->setTagString( QString() );
523  mModel->setSmartGroupId( -1 );
524  mModel->setFilterString( QString() );
525  }
526  else if ( groupsCombo->currentData().toString() == QLatin1String( "all" ) )
527  {
528  mModel->setFavoritesOnly( false );
529  mModel->setTagString( QString() );
530  mModel->setSmartGroupId( -1 );
531  mModel->setFilterString( QString() );
532  }
533  else if ( groupsCombo->currentData().toString() == QLatin1String( "smartgroup" ) )
534  {
535  mModel->setFavoritesOnly( false );
536  mModel->setTagString( QString() );
537  mModel->setSmartGroupId( mStyle->smartgroupId( text ) );
538  mModel->setFilterString( QString() );
539  }
540  else
541  {
542  mModel->setFavoritesOnly( false );
543  mModel->setTagString( text );
544  mModel->setSmartGroupId( -1 );
545  mModel->setFilterString( QString() );
546  }
547 }
548 
549 void QgsStyleItemsListWidget::openStyleManager()
550 {
551  // prefer to use global window manager to open the style manager, if possible!
552  // this allows reuse of an existing non-modal window instead of opening a new modal window.
553  // Note that we only use the non-modal dialog if we're open in the panel -- if we're already
554  // open as part of a modal dialog, then we MUST use another modal dialog or the result will
555  // not be focusable!
557  if ( !panel || !panel->dockMode()
559  || !QgsGui::windowManager()->openStandardDialog( QgsWindowManagerInterface::DialogStyleManager ) )
560  {
561  // fallback to modal dialog
562  QgsStyleManagerDialog dlg( mStyle, this );
563  dlg.exec();
564 
565  updateModelFilters(); // probably not needed -- the model should automatically update if any changes were made
566  }
567 }
568 
569 void QgsStyleItemsListWidget::onSelectionChanged( const QModelIndex &index )
570 {
571  if ( !mModel )
572  return;
573 
574  const QString symbolName = mModel->data( mModel->index( index.row(), QgsStyleModel::Name ) ).toString();
575  lblSymbolName->setText( symbolName );
576 
577  const QString sourceName = mModel->data( mModel->index( index.row(), 0 ), QgsStyleModel::StyleFileName ).toString();
578 
579  emit selectionChanged( symbolName, static_cast< QgsStyle::StyleEntity >( mModel->data( index, QgsStyleModel::TypeRole ).toInt() ) );
580  emit selectionChangedWithStylePath( symbolName, static_cast< QgsStyle::StyleEntity >( mModel->data( index, QgsStyleModel::TypeRole ).toInt() ), sourceName );
581 }
582 
583 void QgsStyleItemsListWidget::groupsCombo_currentIndexChanged( int index )
584 {
585  QgsSettings settings;
586  settings.setValue( QStringLiteral( "qgis/symbolsListGroupsIndex" ), index );
587 }
QgsStyleProxyModel::setEntityFilters
void setEntityFilters(const QList< QgsStyle::StyleEntity > &filters)
Sets the style entity type filters.
Definition: qgsstylemodel.cpp:1070
QgsStyleItemsListWidget::saveEntity
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
qgsstyleitemslistwidget.h
QgsStyle::ColorrampEntity
@ ColorrampEntity
Color ramps.
Definition: qgsstyle.h:182
QgsStyleModel
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
Definition: qgsstylemodel.h:107
qgsprojectstylesettings.h
QgsCombinedStyleModel
A model which contains entities from multiple QgsStyle databases.
Definition: qgscombinedstylemodel.h:42
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:161
QgsPanelWidget::findParentPanel
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
Definition: qgspanelwidget.cpp:54
qgsstylemanagerdialog.h
qgsgui.h
QgsStyleItemsListWidget::setEntityType
void setEntityType(QgsStyle::StyleEntity type)
Sets the type of style entity to show in the widget.
Definition: qgsstyleitemslistwidget.cpp:281
QgsStyleItemsListWidget::setSymbolType
void setSymbolType(Qgis::SymbolType type)
Sets the type of symbols to show in the widget.
Definition: qgsstyleitemslistwidget.cpp:352
QgsStyleItemsListWidget::currentTagFilter
QString currentTagFilter() const
Returns the current tag filter set for the widget, if any is set.
Definition: qgsstyleitemslistwidget.cpp:363
QgsFilterLineEdit
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Definition: qgsfilterlineedit.h:39
QgsStyleProxyModel::setEntityFilterEnabled
void setEntityFilterEnabled(bool enabled)
Sets whether filtering by entity type is enabled.
Definition: qgsstylemodel.cpp:1053
QgsStyleItemsListWidget::QgsStyleItemsListWidget
QgsStyleItemsListWidget(QWidget *parent SIP_TRANSFERTHIS)
Constructor for QgsStyleItemsListWidget, with the specified parent widget.
Definition: qgsstyleitemslistwidget.cpp:179
QgsGui::windowManager
static QgsWindowManagerInterface * windowManager()
Returns the global window manager, if set.
Definition: qgsgui.cpp:189
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:480
QgsStyleProxyModel::setFilterString
void setFilterString(const QString &filter)
Sets a filter string, such that only symbol entities with names matching the specified string will be...
Definition: qgsstylemodel.cpp:932
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:61
QgsStyleManagerDialog
A dialog allowing users to customize and populate a QgsStyle.
Definition: qgsstylemanagerdialog.h:70
QgsStyleItemsListWidget::advancedMenu
QMenu * advancedMenu()
Returns a pointer to the widget's current advanced menu.
Definition: qgsstyleitemslistwidget.cpp:368
QgsStyle::LegendPatchShapeEntity
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
Definition: qgsstyle.h:186
QgsStyleItemsListWidget::selectionChangedWithStylePath
void selectionChangedWithStylePath(const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
Emitted when the selected item is changed in the widget.
QgsStyleModel::IsTitleRole
@ IsTitleRole
True if the index corresponds to a title item (since QGIS 3.26)
Definition: qgsstylemodel.h:132
QgsPanelWidget::dockMode
bool dockMode()
Returns the dock mode state.
Definition: qgspanelwidget.h:93
qgsstylesavedialog.h
QgsStyleProxyModel::setSmartGroupId
void setSmartGroupId(int id)
Sets a smart group id to filter style entities by.
Definition: qgsstylemodel.cpp:1015
QgsStyle::SymbolEntity
@ SymbolEntity
Symbols.
Definition: qgsstyle.h:180
QgsStyle::TagEntity
@ TagEntity
Tags.
Definition: qgsstyle.h:181
QgsGuiUtils::iconSize
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
Definition: qgsguiutils.cpp:264
QgsStyle::LabelSettingsEntity
@ LabelSettingsEntity
Label settings.
Definition: qgsstyle.h:185
QgsStyle::defaultStyle
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:145
qgsapplication.h
QgsStyleModel::TypeRole
@ TypeRole
Style entity type, see QgsStyle::StyleEntity.
Definition: qgsstylemodel.h:123
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
Qgis::SymbolType
SymbolType
Symbol types.
Definition: qgis.h:205
QgsFilterLineEdit::setShowSearchIcon
void setShowSearchIcon(bool visible)
Define if a search icon shall be shown on the left of the image when no text is entered.
Definition: qgsfilterlineedit.cpp:49
QgsStyle::Symbol3DEntity
@ Symbol3DEntity
3D symbol entity (since QGIS 3.14)
Definition: qgsstyle.h:187
QgsStyleItemsListWidget::selectionChanged
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
QgsApplication::defaultStyleModel
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
Definition: qgsapplication.cpp:2445
QgsStyle::smartgroupNames
QStringList smartgroupNames() const
Returns the smart groups list.
Definition: qgsstyle.cpp:2348
QgsStyle::tags
QStringList tags() const
Returns a list of all tags in the style database.
Definition: qgsstyle.cpp:1401
QgsStyleItemsListWidget::setAdvancedMenu
void setAdvancedMenu(QMenu *menu)
Sets the widget's advanced menu, which is shown when the user clicks the "Advanced" button in the wid...
Definition: qgsstyleitemslistwidget.cpp:373
QgsStyle::SmartgroupEntity
@ SmartgroupEntity
Smart groups.
Definition: qgsstyle.h:183
Qgis::UI_SCALE_FACTOR
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:2043
QgsStyle::groupsModified
void groupsModified()
Emitted every time a tag or smartgroup has been added, removed, or renamed.
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:279
QgsStyleItemsListWidget::showAdvancedButton
void showAdvancedButton(bool enabled)
Sets whether the advanced button should be shown in the widget.
Definition: qgsstyleitemslistwidget.cpp:382
QgsStyleProxyModel::setLayerType
void setLayerType(QgsWkbTypes::GeometryType type)
Sets the layer type filter.
Definition: qgsstylemodel.cpp:976
QgsStyleItemsListWidget::setStyle
void setStyle(QgsStyle *style)
Sets the style database associated with the widget.
Definition: qgsstyleitemslistwidget.cpp:248
QgsStyleProxyModel::setEntityFilter
void setEntityFilter(QgsStyle::StyleEntity filter)
Sets the style entity type filter.
Definition: qgsstylemodel.cpp:1064
QgsStyleProxyModel::setSymbolType
void setSymbolType(Qgis::SymbolType type)
Sets the symbol type filter.
Definition: qgsstylemodel.cpp:1042
QgsStyle::smartgroupId
int smartgroupId(const QString &smartgroup)
Returns the database id for the given smartgroup name.
Definition: qgsstyle.cpp:2233
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
QgsStyleProxyModel::setTagString
void setTagString(const QString &tag)
Sets a tag to filter style entities by.
Definition: qgsstylemodel.cpp:1003
QgsStyle
Definition: qgsstyle.h:159
QgsStyle::TextFormatEntity
@ TextFormatEntity
Text formats.
Definition: qgsstyle.h:184
QgsStyleProxyModel::entityFilterEnabled
bool entityFilterEnabled() const
Returns true if filtering by entity type is enabled.
Definition: qgsstylemodel.cpp:1048
QgsStyleItemsListWidget::setEntityTypes
void setEntityTypes(const QList< QgsStyle::StyleEntity > &filters) SIP_SKIP
Sets the types of style entity to show in the widget.
Definition: qgsstyleitemslistwidget.cpp:336
QgsStyleProxyModel::addDesiredIconSize
void addDesiredIconSize(QSize size)
Adds an additional icon size to generate for Qt::DecorationRole data.
Definition: qgsstylemodel.cpp:950
QgsStyleItemsListWidget::currentEntityType
QgsStyle::StyleEntity currentEntityType() const
Returns the type of the item currently selected in the widget.
Definition: qgsstyleitemslistwidget.cpp:398
QgsStyleProxyModel::setSymbolTypeFilterEnabled
void setSymbolTypeFilterEnabled(bool enabled)
Sets whether filtering by symbol type is enabled.
Definition: qgsstylemodel.cpp:965
qgssettings.h
QgsStyleProxyModel::setFavoritesOnly
void setFavoritesOnly(bool favoritesOnly)
Sets whether the model should show only favorited entities.
Definition: qgsstylemodel.cpp:944
QgsFilterLineEdit::setShowClearButton
void setShowClearButton(bool visible)
Sets whether the widget's clear button is visible.
Definition: qgsfilterlineedit.cpp:43
qgspanelwidget.h
QgsStyleProxyModel
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
Definition: qgsstylemodel.h:222
QgsStyleItemsListWidget::setLayerType
void setLayerType(QgsWkbTypes::GeometryType type)
Sets the layer type to show in the widget.
Definition: qgsstyleitemslistwidget.cpp:358
qgswindowmanagerinterface.h
QgsStyleItemsListWidget::currentItemName
QString currentItemName() const
Returns the name of the item currently selected in the widget.
Definition: qgsstyleitemslistwidget.cpp:387
QgsStyleProxyModel::entityFilter
QgsStyle::StyleEntity entityFilter() const
Returns the style entity type filter.
Definition: qgsstylemodel.cpp:1059
qgsproject.h
QgsStyleItemsListWidget::showEvent
void showEvent(QShowEvent *event) override
Definition: qgsstyleitemslistwidget.cpp:409
QgsSettings::Gui
@ Gui
Definition: qgssettings.h:71
QgsStyleModel::StyleFileName
@ StyleFileName
File name of associated QgsStyle (QgsStyle::fileName()) (since QGIS 3.26)
Definition: qgsstylemodel.h:131
QgsStyleModel::Name
@ Name
Name column.
Definition: qgsstylemodel.h:116
QgsStyle::StyleEntity
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:178