QGIS API Documentation 3.41.0-Master (57ec4277f5e)
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 explicit QgsReadOnlyStyleModel( QgsStyleModel *sourceModel, QObject *parent = nullptr );
38 explicit QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent = nullptr );
39 explicit QgsReadOnlyStyleModel( QgsCombinedStyleModel *style, QObject *parent = nullptr );
40
41 Qt::ItemFlags flags( const QModelIndex &index ) const override;
42 QVariant data( const QModelIndex &index, int role ) const override;
43};
44
52class QgsStyleModelDelegate : public QStyledItemDelegate
53{
54 Q_OBJECT
55
56 public:
60 QgsStyleModelDelegate( QObject *parent );
61
62 QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
63 void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
64};
65
66#endif
68
75class GUI_EXPORT QgsStyleItemsListWidget : public QWidget, private Ui::QgsStyleItemsListWidgetBase
76{
77 Q_OBJECT
78
79 public:
84
91 void setStyle( QgsStyle *style );
92
98 void setEntityType( QgsStyle::StyleEntity type );
99
105 void setEntityTypes( const QList<QgsStyle::StyleEntity> &filters ) SIP_SKIP;
106
112 void setSymbolType( Qgis::SymbolType type );
113
120 void setLayerType( Qgis::GeometryType type );
121
125 QString currentTagFilter() const;
126
127#ifndef SIP_RUN
128
134 QMenu *advancedMenu();
135
145 void setAdvancedMenu( QMenu *menu );
146
154 void showAdvancedButton( bool enabled );
155#endif
156
161 QString currentItemName() const;
162
167 QgsStyle::StyleEntity currentEntityType() const;
168
169 protected:
170 void showEvent( QShowEvent *event ) override;
171
172 signals:
173
179 void selectionChanged( const QString &name, QgsStyle::StyleEntity type );
180
189 void selectionChangedWithStylePath( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath );
190
199
200 private slots:
201 void groupsCombo_currentIndexChanged( int index );
202 void updateModelFilters();
203 void onSelectionChanged( const QModelIndex &index );
204 void populateGroups();
205 void openStyleManager();
206
207 private:
208 QgsStyle *mStyle = nullptr;
209 QgsStyleProxyModel *mModel = nullptr;
210 QgsStyleModelDelegate *mDelegate = nullptr;
211 bool mUpdatingGroups = false;
212};
213
214#endif //QGSSTYLEITEMSLISTWIDGET_H
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