QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 "qgsdiagramrenderer.h"
28#include "qgscolorschemelist.h"
29
30#include <QDialog>
31#include <QStyledItemDelegate>
32
33class QgsVectorLayer;
34class QgsMapCanvas;
35
42class GUI_EXPORT QgsDiagramProperties : public QgsPanelWidget, private Ui::QgsDiagramPropertiesBase, private QgsExpressionContextGenerator
43{
44 Q_OBJECT
45
46 public:
47 QgsDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
48 ~QgsDiagramProperties() override;
49
55 void syncToLayer();
56
63 void syncToRenderer( const QgsDiagramRenderer *dr );
64
71 void syncToSettings( const QgsDiagramLayerSettings *dls );
72
74 void addAttribute( QTreeWidgetItem *item );
75
80 void setDockMode( bool dockMode ) override;
81
87 void setDiagramType( const QString diagramType );
88
97 void setAllowedToEditDiagramLayerSettings( bool allowed );
98
102 bool isAllowedToEditDiagramLayerSettings() const;
103
104 signals:
105
107
108 public slots:
109 void apply();
110 void mDiagramTypeComboBox_currentIndexChanged( int index );
111 void mAddCategoryPushButton_clicked();
112 void mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
113 void mFindMaximumValueButton_clicked();
114 void mRemoveCategoryPushButton_clicked();
115 void mDiagramAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
116 void showAddAttributeExpressionDialog();
117 void mDiagramStackedWidget_currentChanged( int index );
118 void updatePlacementWidgets();
119 void scalingTypeChanged();
120 void showSizeLegendDialog();
121
122 private slots:
123
124 void updateProperty();
125 void showHelp();
126
127 void createAuxiliaryField();
128
129 private:
130
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
239class EditBlockerDelegate: public QStyledItemDelegate
240{
241 Q_OBJECT
242 public:
243 EditBlockerDelegate( QObject *parent = nullptr )
244 : QStyledItemDelegate( parent )
245 {}
246
247 QWidget *createEditor( QWidget *, const QStyleOptionViewItem &, const QModelIndex & ) const override
248 {
249 return nullptr;
250 }
251};
252
253
254#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.
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 a 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 a integer key value.
A button for controlling property overrides which may apply to a widget.
Represents a vector layer which manages a vector based data sets.