QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 "qgsproperty.h"
27 #include <QStyledItemDelegate>
28 
29 class QStandardItemModel;
30 
32 class QgsLayerTree;
33 class QgsLayerTreeLayer;
34 class QgsLayerTreeModel;
35 class QgsMapCanvas;
36 class QgsMarkerSymbol;
37 class QgsProperty;
38 class QgsVectorLayer;
39 
46 class GUI_EXPORT QgsDataDefinedSizeLegendWidget : public QgsPanelWidget, private Ui::QgsDataDefinedSizeLegendWidget
47 {
48  Q_OBJECT
49  public:
50 
57  explicit QgsDataDefinedSizeLegendWidget( const QgsDataDefinedSizeLegend *ddsLegend, const QgsProperty &ddSize, QgsMarkerSymbol *overrideSymbol SIP_TRANSFER, QgsMapCanvas *canvas = nullptr, QWidget *parent SIP_TRANSFERTHIS = nullptr );
58  ~QgsDataDefinedSizeLegendWidget() override;
59 
61  QgsDataDefinedSizeLegend *dataDefinedSizeLegend() const SIP_FACTORY;
62 
63  signals:
64 
65  private slots:
66  void updatePreview();
67  void changeSymbol();
68  void addSizeClass();
69  void removeSizeClass();
70  void onSizeClassesChanged();
71 
72  private:
73  std::unique_ptr<QgsMarkerSymbol> mSourceSymbol;
74  bool mOverrideSymbol = false;
75  QgsProperty mSizeProperty;
76  QgsLayerTreeModel *mPreviewModel = nullptr;
77  QgsLayerTree *mPreviewTree = nullptr;
78  QgsLayerTreeLayer *mPreviewLayerNode = nullptr;
79  QgsVectorLayer *mPreviewLayer = nullptr;
80  QgsMapCanvas *mMapCanvas = nullptr;
81  QStandardItemModel *mSizeClassesModel = nullptr;
82 };
83 
84 #ifndef SIP_RUN
85 
88 class SizeClassDelegate : public QStyledItemDelegate
89 {
90  Q_OBJECT
91 
92  public:
93  SizeClassDelegate( QObject *parent )
94  : QStyledItemDelegate( parent )
95  {
96  }
97 
98  QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const override
99  {
100  QLineEdit *lineEdit = new QLineEdit( parent );
101  QDoubleValidator *validator = new QDoubleValidator( 0, 1e6, 1, lineEdit );
102  lineEdit->setValidator( validator );
103  return lineEdit;
104  }
105 };
106 
108 #endif
109 
110 #endif // QGSDATADEFINEDSIZELEGENDWIDGET_H
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
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:54
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsLayerTree
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:33
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:30
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:931
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:44
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:387
qgsproperty.h
qgspanelwidget.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53