QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsstyleitemslistwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsstyleitemslistwidget.h
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 #ifndef QGSSTYLEITEMSLISTWIDGET_H
17 #define QGSSTYLEITEMSLISTWIDGET_H
18 
19 #include "ui_qgsstyleitemslistwidgetbase.h"
20 
21 #include "qgsstylemodel.h"
22 #include <QWidget>
23 #include "qgis_gui.h"
24 
25 class QgsStyle;
26 class QMenu;
27 
28 
29 #ifndef SIP_RUN
31 class QgsReadOnlyStyleModel : public QgsStyleProxyModel
32 {
33  Q_OBJECT
34  public:
35 
36  explicit QgsReadOnlyStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr );
37  explicit QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent = nullptr );
38  Qt::ItemFlags flags( const QModelIndex &index ) const override;
39  QVariant data( const QModelIndex &index, int role ) const override;
40 
41 };
42 #endif
44 
51 class GUI_EXPORT QgsStyleItemsListWidget : public QWidget, private Ui::QgsStyleItemsListWidgetBase
52 {
53  Q_OBJECT
54 
55  public:
56 
60  QgsStyleItemsListWidget( QWidget *parent SIP_TRANSFERTHIS );
61 
68  void setStyle( QgsStyle *style );
69 
75  void setEntityType( QgsStyle::StyleEntity type );
76 
82  void setEntityTypes( const QList<QgsStyle::StyleEntity> &filters ) SIP_SKIP;
83 
89  void setSymbolType( Qgis::SymbolType type );
90 
97  void setLayerType( QgsWkbTypes::GeometryType type );
98 
102  QString currentTagFilter() const;
103 
104 #ifndef SIP_RUN
105 
111  QMenu *advancedMenu();
112 
122  void setAdvancedMenu( QMenu *menu );
123 
131  void showAdvancedButton( bool enabled );
132 #endif
133 
138  QString currentItemName() const;
139 
144  QgsStyle::StyleEntity currentEntityType() const;
145 
146  protected:
147 
148  void showEvent( QShowEvent *event ) override;
149 
150  signals:
151 
157  void selectionChanged( const QString &name, QgsStyle::StyleEntity type );
158 
166  void saveEntity();
167 
168  private slots:
169  void groupsCombo_currentIndexChanged( int index );
170  void updateModelFilters();
171  void onSelectionChanged( const QModelIndex &index );
172  void populateGroups();
173  void openStyleManager();
174 
175  private:
176  QgsStyle *mStyle = nullptr;
177  QgsStyleProxyModel *mModel = nullptr;
178  bool mUpdatingGroups = false;
179 };
180 
181 #endif //QGSSTYLEITEMSLISTWIDGET_H
182 
183 
184 
SymbolType
Symbol types.
Definition: qgis.h:168
A reusable widget for showing a filtered list of entities from a QgsStyle database.
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:179
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126