QGIS API Documentation 3.39.0-Master (0c9320c8adc)
Loading...
Searching...
No Matches
qgsstackeddiagramproperties.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsstackeddiagramproperties.h
3 Properties for stacked diagram layers
4 -------------------
5 begin : August 2024
6 copyright : (C) Germán Carrillo
7 email : german 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 QGSSTACKEDDIAGRAMPROPERTIES_H
19#define QGSSTACKEDDIAGRAMPROPERTIES_H
20
21// We don't want to expose this in the public API
22#define SIP_NO_FILE
23
24#include "qgis_gui.h"
25#include "qgsdiagramrenderer.h"
26#include "ui_qgsstackeddiagrampropertiesbase.h"
27
28#include <QWidget>
29#include <QDialog>
30#include <QDialogButtonBox>
31
32class QgsVectorLayer;
33class QgsMapCanvas;
36
37
45class GUI_EXPORT QgsStackedDiagramPropertiesModel : public QAbstractTableModel
46{
47 Q_OBJECT
48
49 public:
51 QgsStackedDiagramPropertiesModel( QObject *parent = nullptr );
52
53 Qt::ItemFlags flags( const QModelIndex &index ) const override;
54 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
55 QVariant headerData( int section, Qt::Orientation orientation,
56 int role = Qt::DisplayRole ) const override;
57 int rowCount( const QModelIndex & = QModelIndex() ) const override;
58 int columnCount( const QModelIndex & = QModelIndex() ) const override;
59
60 // editing support
61 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
62 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
63
64 // new methods
65
67 QgsDiagramRenderer *subDiagramForIndex( const QModelIndex &index ) const;
68
70 void insertSubDiagram( const int index, QgsDiagramRenderer *newSubDiagram );
72 void updateSubDiagram( const QModelIndex &index, QgsDiagramRenderer *dr );
73
75 QList< QgsDiagramRenderer *> subRenderers() const;
76
78 QgsDiagramLayerSettings diagramLayerSettings() const;
79
83 void updateDiagramLayerSettings( QgsDiagramLayerSettings dls );
84
85 protected:
86 QList< QgsDiagramRenderer *> mRenderers;
88};
89
90
97class GUI_EXPORT QgsStackedDiagramProperties : public QgsPanelWidget, private Ui::QgsStackedDiagramPropertiesBase
98{
99 Q_OBJECT
100
101 public:
102 explicit QgsStackedDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
103
107 void syncToLayer();
108
109 signals:
111
112 public slots:
113 void apply();
114
115 private slots:
116
120 void addSubDiagram();
121
125 void appendSubDiagram( QgsDiagramRenderer *dr );
126
130 void editSubDiagram();
131
135 void editSubDiagram( const QModelIndex &index );
136
140 void removeSubDiagram();
141
142 private:
143 QgsVectorLayer *mLayer = nullptr;
144 QgsMapCanvas *mMapCanvas = nullptr;
145
146 QgsStackedDiagramPropertiesModel *mModel = nullptr;
147
154 bool couldBeFirstSubDiagram( const QModelIndex &index ) const;
155
156 private slots:
157 void subDiagramWidgetPanelAccepted( QgsPanelWidget *panel );
158 void liveUpdateSubDiagramFromPanel();
159};
160
169class GUI_EXPORT QgsStackedDiagramPropertiesDialog : public QDialog
170{
171 Q_OBJECT
172
173 public:
174
181 QgsStackedDiagramPropertiesDialog( QgsVectorLayer *layer, QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr );
182
186 void syncToRenderer( const QgsDiagramRenderer *dr ) const;
187
191 void syncToSettings( const QgsDiagramLayerSettings *dls ) const;
192
196 QgsDiagramRenderer *renderer();
197
201 QgsDiagramLayerSettings diagramLayerSettings() const;
202
209 void setAllowedToEditDiagramLayerSettings( bool allowed ) const;
210
214 bool isAllowedToEditDiagramLayerSettings() const;
215
216 public slots:
217
221 void accept() override;
222
223 private slots:
224 void showHelp();
225
226 private:
227 QgsDiagramProperties *mPropsWidget = nullptr;
228 std::unique_ptr< QgsDiagramRenderer > mRenderer;
229 QgsDiagramLayerSettings mDiagramLayerSettings;
230 QDialogButtonBox *buttonBox = nullptr;
231};
232
233#endif // QGSSTACKEDDIAGRAMPROPERTIES_H
Stores the settings for rendering of all diagrams for a layer.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
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.
Model for sub diagrams in a stacked diagram view.
QList< QgsDiagramRenderer * > mRenderers
Represents a vector layer which manages a vector based data sets.