QGIS API Documentation 3.43.0-Master (0bee5d6404c)
qgsdiagramproperties.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdiagramproperties.h
3 Properties for diagram layers
4 -------------------
5 begin : August 2012
6 copyright : (C) Matthias Kuhn
7 email : matthias at opengis dot ch
8
9 ***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSDIAGRAMPROPERTIES_H
19#define QGSDIAGRAMPROPERTIES_H
20
21// We don't want to expose this in the public API
22#define SIP_NO_FILE
23
24#include "ui_qgsdiagrampropertiesbase.h"
25
26#include "qgis_gui.h"
27#include "qgsdiagramrenderer.h"
28#include "qgscolorschemelist.h"
29
30#include <QDialog>
31#include <QStyledItemDelegate>
32
33class QgsVectorLayer;
34class QgsMapCanvas;
35
43class GUI_EXPORT QgsDiagramProperties : public QgsPanelWidget, private Ui::QgsDiagramPropertiesBase, private QgsExpressionContextGenerator
44{
45 Q_OBJECT
46
47 public:
48 QgsDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
49 ~QgsDiagramProperties() override;
50
56 void syncToLayer();
57
64 void syncToRenderer( const QgsDiagramRenderer *dr );
65
72 void syncToSettings( const QgsDiagramLayerSettings *dls );
73
75 void addAttribute( QTreeWidgetItem *item );
76
81 void setDockMode( bool dockMode ) override;
82
88 void setDiagramType( const QString diagramType );
89
98 void setAllowedToEditDiagramLayerSettings( bool allowed );
99
103 bool isAllowedToEditDiagramLayerSettings() const;
104
105 signals:
106
108
109 public slots:
110 void apply();
111 void mDiagramTypeComboBox_currentIndexChanged( int index );
112 void mAddCategoryPushButton_clicked();
113 void mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
114 void mFindMaximumValueButton_clicked();
115 void mRemoveCategoryPushButton_clicked();
116 void mDiagramAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
117 void showAddAttributeExpressionDialog();
118 void mDiagramStackedWidget_currentChanged( int index );
119 void updatePlacementWidgets();
120 void scalingTypeChanged();
121 void showSizeLegendDialog();
122
123 private slots:
124
125 void updateProperty();
126 void showHelp();
127
128 void createAuxiliaryField();
129
130 private:
131 QgsVectorLayer *mLayer = nullptr;
133 QButtonGroup *mPlacePointBtnGrp = nullptr;
135 QButtonGroup *mPlaceLineBtnGrp = nullptr;
137 QButtonGroup *mPlacePolygonBtnGrp = nullptr;
138
139 std::unique_ptr<QgsPaintEffect> mPaintEffect;
140
141 enum Columns
142 {
143 ColumnAttributeExpression = 0,
144 ColumnColor,
145 ColumnLegendText,
146 };
147
148 enum Roles
149 {
150 RoleAttributeExpression = Qt::UserRole,
151 };
152
153 QString showExpressionBuilder( const QString &initialExpression );
154
155 QgsPropertyCollection mDataDefinedProperties;
156
157 // Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
158 QString mDiagramType;
159 std::unique_ptr<QgsDataDefinedSizeLegend> mSizeLegend;
160
161 QString guessLegendText( const QString &expression );
162 QgsMapCanvas *mMapCanvas = nullptr;
163
165
166 bool mAllowedToEditDls = true;
167
168 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsDiagramLayerSettings::Property key );
169
175 void connectValueChanged( const QList<QWidget *> &widgets );
176
182 std::unique_ptr<QgsDiagram> createDiagramObject();
183
189 std::unique_ptr<QgsDiagramSettings> createDiagramSettings();
190
196 std::unique_ptr<QgsDiagramRenderer> createRenderer();
197
203 QgsDiagramLayerSettings createDiagramLayerSettings();
204
208 void insertDefaults();
209
218 void setDiagramEnabled( const bool enabled );
219
228 bool isDiagramEnabled() const;
229
232};
233
234
240class EditBlockerDelegate : public QStyledItemDelegate
241{
242 Q_OBJECT
243 public:
244 EditBlockerDelegate( QObject *parent = nullptr )
245 : QStyledItemDelegate( parent )
246 {}
247
248 QWidget *createEditor( QWidget *, const QStyleOptionViewItem &, const QModelIndex & ) const override
249 {
250 return nullptr;
251 }
252};
253
254
255#endif // QGSDIAGRAMPROPERTIES_H
Custom item delegate which prevents editing.
EditBlockerDelegate(QObject *parent=nullptr)
QWidget * createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override
Stores the settings for rendering of all diagrams for a layer.
Property
Data definable properties.
A widget which configures diagrams for a vector layer.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for any widget that can be shown as an inline panel.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
A button for controlling property overrides which may apply to a widget.
A widget for editing sub diagrams.
Represents a vector layer which manages a vector based dataset.