QGIS API Documentation  3.27.0-Master (aef1b1ec20)
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 <QStyledItemDelegate>
24 #include "qgis_gui.h"
25 
26 class QgsStyle;
27 class QMenu;
29 
30 
31 #ifndef SIP_RUN
33 class QgsReadOnlyStyleModel : public QgsStyleProxyModel
34 {
35  Q_OBJECT
36  public:
37 
38  explicit QgsReadOnlyStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr );
39  explicit QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent = nullptr );
40 
41 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
42  explicit QgsReadOnlyStyleModel( QgsCombinedStyleModel *style, QObject *parent = nullptr );
43 #endif
44 
45  Qt::ItemFlags flags( const QModelIndex &index ) const override;
46  QVariant data( const QModelIndex &index, int role ) const override;
47 
48 };
49 
57 class QgsStyleModelDelegate : public QStyledItemDelegate
58 {
59  Q_OBJECT
60 
61  public:
62 
66  QgsStyleModelDelegate( QObject *parent );
67 
68  QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
69  void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
70 
71 };
72 
73 #endif
75 
82 class GUI_EXPORT QgsStyleItemsListWidget : public QWidget, private Ui::QgsStyleItemsListWidgetBase
83 {
84  Q_OBJECT
85 
86  public:
87 
91  QgsStyleItemsListWidget( QWidget *parent SIP_TRANSFERTHIS );
92 
99  void setStyle( QgsStyle *style );
100 
106  void setEntityType( QgsStyle::StyleEntity type );
107 
113  void setEntityTypes( const QList<QgsStyle::StyleEntity> &filters ) SIP_SKIP;
114 
120  void setSymbolType( Qgis::SymbolType type );
121 
128  void setLayerType( QgsWkbTypes::GeometryType type );
129 
133  QString currentTagFilter() const;
134 
135 #ifndef SIP_RUN
136 
142  QMenu *advancedMenu();
143 
153  void setAdvancedMenu( QMenu *menu );
154 
162  void showAdvancedButton( bool enabled );
163 #endif
164 
169  QString currentItemName() const;
170 
175  QgsStyle::StyleEntity currentEntityType() const;
176 
177  protected:
178 
179  void showEvent( QShowEvent *event ) override;
180 
181  signals:
182 
188  void selectionChanged( const QString &name, QgsStyle::StyleEntity type );
189 
198  void selectionChangedWithStylePath( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath );
199 
207  void saveEntity();
208 
209  private slots:
210  void groupsCombo_currentIndexChanged( int index );
211  void updateModelFilters();
212  void onSelectionChanged( const QModelIndex &index );
213  void populateGroups();
214  void openStyleManager();
215 
216  private:
217  QgsStyle *mStyle = nullptr;
218  QgsStyleProxyModel *mModel = nullptr;
219  QgsStyleModelDelegate *mDelegate = nullptr;
220  bool mUpdatingGroups = false;
221 };
222 
223 #endif //QGSSTYLEITEMSLISTWIDGET_H
224 
225 
226 
SymbolType
Symbol types.
Definition: qgis.h:206
A model which contains entities from multiple QgsStyle databases.
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...
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 ...
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