QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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
26class QgsStyle;
27class QMenu;
29
30
31#ifndef SIP_RUN
33class 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 explicit QgsReadOnlyStyleModel( QgsCombinedStyleModel *style, QObject *parent = nullptr );
41
42 Qt::ItemFlags flags( const QModelIndex &index ) const override;
43 QVariant data( const QModelIndex &index, int role ) const override;
44
45};
46
54class QgsStyleModelDelegate : public QStyledItemDelegate
55{
56 Q_OBJECT
57
58 public:
59
63 QgsStyleModelDelegate( QObject *parent );
64
65 QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
66 void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
67
68};
69
70#endif
72
79class GUI_EXPORT QgsStyleItemsListWidget : public QWidget, private Ui::QgsStyleItemsListWidgetBase
80{
81 Q_OBJECT
82
83 public:
84
89
96 void setStyle( QgsStyle *style );
97
103 void setEntityType( QgsStyle::StyleEntity type );
104
110 void setEntityTypes( const QList<QgsStyle::StyleEntity> &filters ) SIP_SKIP;
111
117 void setSymbolType( Qgis::SymbolType type );
118
125 void setLayerType( Qgis::GeometryType type );
126
130 QString currentTagFilter() const;
131
132#ifndef SIP_RUN
133
139 QMenu *advancedMenu();
140
150 void setAdvancedMenu( QMenu *menu );
151
159 void showAdvancedButton( bool enabled );
160#endif
161
166 QString currentItemName() const;
167
172 QgsStyle::StyleEntity currentEntityType() const;
173
174 protected:
175
176 void showEvent( QShowEvent *event ) override;
177
178 signals:
179
185 void selectionChanged( const QString &name, QgsStyle::StyleEntity type );
186
195 void selectionChangedWithStylePath( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath );
196
205
206 private slots:
207 void groupsCombo_currentIndexChanged( int index );
208 void updateModelFilters();
209 void onSelectionChanged( const QModelIndex &index );
210 void populateGroups();
211 void openStyleManager();
212
213 private:
214 QgsStyle *mStyle = nullptr;
215 QgsStyleProxyModel *mModel = nullptr;
216 QgsStyleModelDelegate *mDelegate = nullptr;
217 bool mUpdatingGroups = false;
218};
219
220#endif //QGSSTYLEITEMSLISTWIDGET_H
221
222
223
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
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:203
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126