QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsdatadefinedsizelegendwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdatadefinedsizelegendwidget.h
3  --------------------------------------
4  Date : June 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk at gmail dot 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 QGSDATADEFINEDSIZELEGENDWIDGET_H
17 #define QGSDATADEFINEDSIZELEGENDWIDGET_H
18 
19 #include "qgis_sip.h"
20 #include "qgis_gui.h"
21 
22 #include <memory>
23 #include "ui_qgsdatadefinedsizelegendwidget.h"
24 
25 #include "qgspanelwidget.h"
26 #include "qgsdoublevalidator.h"
27 #include "qgsproperty.h"
28 #include <QStyledItemDelegate>
29 
30 class QStandardItemModel;
31 
33 class QgsLayerTree;
34 class QgsLayerTreeLayer;
35 class QgsLayerTreeModel;
36 class QgsMapCanvas;
37 class QgsMarkerSymbol;
38 class QgsProperty;
39 class QgsVectorLayer;
40 
47 class GUI_EXPORT QgsDataDefinedSizeLegendWidget : public QgsPanelWidget, private Ui::QgsDataDefinedSizeLegendWidget
48 {
49  Q_OBJECT
50  public:
51 
58  explicit QgsDataDefinedSizeLegendWidget( const QgsDataDefinedSizeLegend *ddsLegend, const QgsProperty &ddSize, QgsMarkerSymbol *overrideSymbol SIP_TRANSFER, QgsMapCanvas *canvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
59  ~QgsDataDefinedSizeLegendWidget() override;
60 
62  QgsDataDefinedSizeLegend *dataDefinedSizeLegend() const SIP_FACTORY;
63 
64  signals:
65 
66  private slots:
67  void updatePreview();
68  void changeSymbol();
69  void addSizeClass();
70  void removeSizeClass();
71  void onSizeClassesChanged();
72 
73  private:
74  std::unique_ptr<QgsMarkerSymbol> mSourceSymbol;
75  bool mOverrideSymbol = false;
76  QgsProperty mSizeProperty;
77  QgsLayerTreeModel *mPreviewModel = nullptr;
78  QgsLayerTree *mPreviewTree = nullptr;
79  QgsLayerTreeLayer *mPreviewLayerNode = nullptr;
80  QgsVectorLayer *mPreviewLayer = nullptr;
81  QgsMapCanvas *mMapCanvas = nullptr;
82  QStandardItemModel *mSizeClassesModel = nullptr;
83 };
84 
85 #ifndef SIP_RUN
86 
89 class SizeClassDelegate : public QStyledItemDelegate
90 {
91  Q_OBJECT
92 
93  public:
94  SizeClassDelegate( QObject *parent )
95  : QStyledItemDelegate( parent )
96  {
97  }
98 
99  QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const override
100  {
101  QLineEdit *lineEdit = new QLineEdit( parent );
102  QgsDoubleValidator *validator = new QgsDoubleValidator( 0, 1e6, 1, lineEdit );
103  lineEdit->setValidator( validator );
104  return lineEdit;
105  }
106 };
107 
109 #endif
110 
111 #endif // QGSDATADEFINEDSIZELEGENDWIDGET_H
QgsProperty
A store for object properties.
Definition: qgsproperty.h:230
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsDataDefinedSizeLegend
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Definition: qgsdatadefinedsizelegend.h:42
QgsLayerTreeModel
The QgsLayerTreeModel class is model implementation for Qt item views framework.
Definition: qgslayertreemodel.h:55
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsLayerTree
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:32
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:43
QgsDoubleValidator
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
Definition: qgsdoublevalidator.h:40
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
qgsproperty.h
qgsdoublevalidator.h
qgspanelwidget.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53