QGIS API Documentation 3.99.0-Master (7d2ca374f2d)
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
23#include "ui_qgsdiagrampropertiesbase.h"
24
25#include "qgis_gui.h"
26#include "qgscolorschemelist.h"
27#include "qgsdiagramrenderer.h"
28#include "qgswidgetwrapper.h"
29
30#include <QDialog>
31#include <QStyledItemDelegate>
32
33#define SIP_NO_FILE
34
35class QgsVectorLayer;
36class QgsMapCanvas;
37
45class GUI_EXPORT QgsDiagramProperties : public QgsPanelWidget, private Ui::QgsDiagramPropertiesBase, private QgsExpressionContextGenerator
46{
47 Q_OBJECT
48
49 public:
50 QgsDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
51 ~QgsDiagramProperties() override;
52
58 void syncToLayer();
59
66 void syncToRenderer( const QgsDiagramRenderer *dr );
67
74 void syncToSettings( const QgsDiagramLayerSettings *dls );
75
77 void addAttribute( QTreeWidgetItem *item );
78
83 void setDockMode( bool dockMode ) override;
84
90 void setDiagramType( const QString diagramType );
91
100 void setAllowedToEditDiagramLayerSettings( bool allowed );
101
106
107 signals:
108
110
111 public slots:
112 void apply();
115 void mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
118 void mDiagramAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
120 void mDiagramStackedWidget_currentChanged( int index );
122 void scalingTypeChanged();
124
125 private slots:
126
127 void updateProperty();
128 void showHelp();
129
130 void createAuxiliaryField();
131
132 private:
133 QgsVectorLayer *mLayer = nullptr;
135 QButtonGroup *mPlacePointBtnGrp = nullptr;
137 QButtonGroup *mPlaceLineBtnGrp = nullptr;
139 QButtonGroup *mPlacePolygonBtnGrp = nullptr;
140
141 std::unique_ptr<QgsPaintEffect> mPaintEffect;
142
143 enum Columns
144 {
145 ColumnAttributeExpression = 0,
146 ColumnColor,
147 ColumnLegendText,
148 };
149
150 enum Roles
151 {
152 RoleAttributeExpression = Qt::UserRole,
153 };
154
155 QString showExpressionBuilder( const QString &initialExpression );
156
157 QgsPropertyCollection mDataDefinedProperties;
158
159 // Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
160 QString mDiagramType;
161 std::unique_ptr<QgsDataDefinedSizeLegend> mSizeLegend;
162
163 QString guessLegendText( const QString &expression );
164 QgsMapCanvas *mMapCanvas = nullptr;
165
166 QgsExpressionContext createExpressionContext() const override;
167
168 bool mAllowedToEditDls = true;
169
170 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsDiagramLayerSettings::Property key );
171
177 void connectValueChanged( const QList<QWidget *> &widgets );
178
184 std::unique_ptr<QgsDiagram> createDiagramObject();
185
191 std::unique_ptr<QgsDiagramSettings> createDiagramSettings();
192
198 std::unique_ptr<QgsDiagramRenderer> createRenderer();
199
205 QgsDiagramLayerSettings createDiagramLayerSettings();
206
210 void insertDefaults();
211
215 void updateDataDefinedButtons();
216
220 void updateDataDefinedButton( QgsPropertyOverrideButton *button );
221
230 void setDiagramEnabled( const bool enabled );
231
240 bool isDiagramEnabled() const;
241
245};
246
247
253class EditBlockerDelegate : public QStyledItemDelegate
254{
255 Q_OBJECT
256 public:
257 EditBlockerDelegate( QObject *parent = nullptr )
258 : QStyledItemDelegate( parent )
259 {}
260
261 QWidget *createEditor( QWidget *, const QStyleOptionViewItem &, const QModelIndex & ) const override
262 {
263 return nullptr;
264 }
265};
266
267
268#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.