QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgis_gui.h"
22#include "qgsstylemodel.h"
23
24#include <QStyledItemDelegate>
25#include <QWidget>
26
27class QgsStyle;
28class QMenu;
30
31
32#ifndef SIP_RUN
34class QgsReadOnlyStyleModel : public QgsStyleProxyModel
35{
36 Q_OBJECT
37 public:
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
53class QgsStyleModelDelegate : public QStyledItemDelegate
54{
55 Q_OBJECT
56
57 public:
61 QgsStyleModelDelegate( QObject *parent );
62
63 QSize sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
64 void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
65};
66
67#endif
69
76class GUI_EXPORT QgsStyleItemsListWidget : public QWidget, private Ui::QgsStyleItemsListWidgetBase
77{
78 Q_OBJECT
79
80 public:
85
92 void setStyle( QgsStyle *style );
93
100
106 void setEntityTypes( const QList<QgsStyle::StyleEntity> &filters ) SIP_SKIP;
107
113 void setSymbolType( Qgis::SymbolType type );
114
121 void setLayerType( Qgis::GeometryType type );
122
126 QString currentTagFilter() const;
127
128#ifndef SIP_RUN
129
135 QMenu *advancedMenu();
136
146 void setAdvancedMenu( QMenu *menu );
147
155 void showAdvancedButton( bool enabled );
156#endif
157
162 QString currentItemName() const;
163
169
170 protected:
171 void showEvent( QShowEvent *event ) override;
172
173 signals:
174
180 void selectionChanged( const QString &name, QgsStyle::StyleEntity type );
181
190 void selectionChangedWithStylePath( const QString &name, QgsStyle::StyleEntity type, const QString &stylePath );
191
200
201 private slots:
202 void groupsCombo_currentIndexChanged( int index );
203 void updateModelFilters();
204 void onSelectionChanged( const QModelIndex &index, const QModelIndex &previous );
205 void populateGroups();
206 void openStyleManager();
207
208 private:
209 QgsStyle *mStyle = nullptr;
210 QgsStyleProxyModel *mModel = nullptr;
211 QgsStyleModelDelegate *mDelegate = nullptr;
212 bool mUpdatingGroups = false;
213};
214
215#endif //QGSSTYLEITEMSLISTWIDGET_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
SymbolType
Symbol types.
Definition qgis.h:610
A model which contains entities from multiple QgsStyle databases.
void setStyle(QgsStyle *style)
Sets the style database associated with the widget.
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
QString currentItemName() const
Returns the name of the item currently selected in the widget.
void setLayerType(Qgis::GeometryType type)
Sets the layer type to show in the widget.
void setAdvancedMenu(QMenu *menu)
Sets the widget's advanced menu, which is shown when the user clicks the "Advanced" button in the wid...
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
void showAdvancedButton(bool enabled)
Sets whether the advanced button should be shown in the widget.
QString currentTagFilter() const
Returns the current tag filter set for the widget, if any is set.
void setSymbolType(Qgis::SymbolType type)
Sets the type of symbols to show in the widget.
QgsStyle::StyleEntity currentEntityType() const
Returns the type of the item currently selected in the widget.
QgsStyleItemsListWidget(QWidget *parent SIP_TRANSFERTHIS)
Constructor for QgsStyleItemsListWidget, with the specified parent widget.
void setEntityType(QgsStyle::StyleEntity type)
Sets the type of style entity to show in the widget.
void setEntityTypes(const QList< QgsStyle::StyleEntity > &filters) SIP_SKIP
Sets the types of style entity to show in the widget.
void showEvent(QShowEvent *event) override
QMenu * advancedMenu()
Returns a pointer to the widget's current advanced menu.
void selectionChangedWithStylePath(const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
Emitted when the selected item is changed in the widget.
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:88
StyleEntity
Enum for Entities involved in a style.
Definition qgsstyle.h:204
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134