QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 "qgscolorschemelist.h"
28#include "qgsdiagramrenderer.h"
29#include "qgswidgetwrapper.h"
30
31#include <QDialog>
32#include <QStyledItemDelegate>
33
34class QgsVectorLayer;
35class QgsMapCanvas;
36
44class GUI_EXPORT QgsDiagramProperties : public QgsPanelWidget, private Ui::QgsDiagramPropertiesBase, private QgsExpressionContextGenerator
45{
46 Q_OBJECT
47
48 public:
49 QgsDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
50 ~QgsDiagramProperties() override;
51
57 void syncToLayer();
58
65 void syncToRenderer( const QgsDiagramRenderer *dr );
66
73 void syncToSettings( const QgsDiagramLayerSettings *dls );
74
76 void addAttribute( QTreeWidgetItem *item );
77
82 void setDockMode( bool dockMode ) override;
83
89 void setDiagramType( const QString diagramType );
90
99 void setAllowedToEditDiagramLayerSettings( bool allowed );
100
105
106 signals:
107
109
110 public slots:
111 void apply();
114 void mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
117 void mDiagramAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
119 void mDiagramStackedWidget_currentChanged( int index );
121 void scalingTypeChanged();
123
124 private slots:
125
126 void updateProperty();
127 void showHelp();
128
129 void createAuxiliaryField();
130
131 private:
132 QgsVectorLayer *mLayer = nullptr;
134 QButtonGroup *mPlacePointBtnGrp = nullptr;
136 QButtonGroup *mPlaceLineBtnGrp = nullptr;
138 QButtonGroup *mPlacePolygonBtnGrp = nullptr;
139
140 std::unique_ptr<QgsPaintEffect> mPaintEffect;
141
142 enum Columns
143 {
144 ColumnAttributeExpression = 0,
145 ColumnColor,
146 ColumnLegendText,
147 };
148
149 enum Roles
150 {
151 RoleAttributeExpression = Qt::UserRole,
152 };
153
154 QString showExpressionBuilder( const QString &initialExpression );
155
156 QgsPropertyCollection mDataDefinedProperties;
157
158 // Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
159 QString mDiagramType;
160 std::unique_ptr<QgsDataDefinedSizeLegend> mSizeLegend;
161
162 QString guessLegendText( const QString &expression );
163 QgsMapCanvas *mMapCanvas = nullptr;
164
165 QgsExpressionContext createExpressionContext() const override;
166
167 bool mAllowedToEditDls = true;
168
169 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsDiagramLayerSettings::Property key );
170
176 void connectValueChanged( const QList<QWidget *> &widgets );
177
183 std::unique_ptr<QgsDiagram> createDiagramObject();
184
190 std::unique_ptr<QgsDiagramSettings> createDiagramSettings();
191
197 std::unique_ptr<QgsDiagramRenderer> createRenderer();
198
204 QgsDiagramLayerSettings createDiagramLayerSettings();
205
209 void insertDefaults();
210
214 void updateDataDefinedButtons();
215
219 void updateDataDefinedButton( QgsPropertyOverrideButton *button );
220
229 void setDiagramEnabled( const bool enabled );
230
239 bool isDiagramEnabled() const;
240
244};
245
246
252class EditBlockerDelegate : public QStyledItemDelegate
253{
254 Q_OBJECT
255 public:
256 EditBlockerDelegate( QObject *parent = nullptr )
257 : QStyledItemDelegate( parent )
258 {}
259
260 QWidget *createEditor( QWidget *, const QStyleOptionViewItem &, const QModelIndex & ) const override
261 {
262 return nullptr;
263 }
264};
265
266
267#endif // QGSDIAGRAMPROPERTIES_H
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.
friend class QgsStackedDiagramPropertiesDialog
void syncToSettings(const QgsDiagramLayerSettings *dls)
Updates the widget to reflect the diagram layer settings.
void mDiagramAttributesTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
bool isAllowedToEditDiagramLayerSettings() const
Returns whether this widget is allowed to edit diagram layer settings.
void mDiagramTypeComboBox_currentIndexChanged(int index)
void syncToLayer()
Updates the widget to reflect the layer's current diagram settings.
friend class QgsStackedDiagramProperties
QgsDiagramProperties(QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas)
void setDiagramType(const QString diagramType)
Defines the widget's diagram type and lets it know it should hide the type comboBox.
void addAttribute(QTreeWidgetItem *item)
Adds an attribute from the list of available attributes to the assigned attributes with a random colo...
void syncToRenderer(const QgsDiagramRenderer *dr)
Updates the widget to reflect the diagram renderer.
void mAttributesTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
friend class TestQgsDiagramProperties
void setAllowedToEditDiagramLayerSettings(bool allowed)
Sets whether the widget should show diagram layer settings.
void mDiagramStackedWidget_currentChanged(int index)
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...
Map canvas is a class for displaying all GIS data types on a canvas.
bool dockMode() const
Returns the dock mode state.
QgsPanelWidget(QWidget *parent=nullptr)
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.
Represents a vector layer which manages a vector based dataset.