QGIS API Documentation 3.41.0-Master (cea29feecf2)
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
54
55 Qt::ItemFlags flags( const QModelIndex &index ) const override;
56 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
57 QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
58 int rowCount( const QModelIndex & = QModelIndex() ) const override;
59 int columnCount( const QModelIndex & = QModelIndex() ) const override;
60
61 // editing support
62 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
63 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
64
65 // new methods
66
68 QgsDiagramRenderer *subDiagramForIndex( const QModelIndex &index ) const;
69
71 void insertSubDiagram( const int index, QgsDiagramRenderer *newSubDiagram );
73 void updateSubDiagram( const QModelIndex &index, QgsDiagramRenderer *dr );
74
76 QList<QgsDiagramRenderer *> subRenderers() const;
77
79 QgsDiagramLayerSettings diagramLayerSettings() const;
80
84 void updateDiagramLayerSettings( QgsDiagramLayerSettings dls );
85
86 protected:
87 QList<QgsDiagramRenderer *> mRenderers;
89};
90
91
98class GUI_EXPORT QgsStackedDiagramProperties : public QgsPanelWidget, private Ui::QgsStackedDiagramPropertiesBase
99{
100 Q_OBJECT
101
102 public:
103 explicit QgsStackedDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
104
108 void syncToLayer();
109
110 signals:
112
113 public slots:
114 void apply();
115
116 private slots:
117
121 void addSubDiagramRenderer();
122
127 void appendSubDiagramRenderer( QgsDiagramRenderer *dr );
128
132 void editSubDiagramRenderer();
133
137 void editSubDiagramRenderer( const QModelIndex &index );
138
142 void removeSubDiagramRenderer();
143
144 private:
145 QgsVectorLayer *mLayer = nullptr;
146 QgsMapCanvas *mMapCanvas = nullptr;
147
148 QgsStackedDiagramPropertiesModel *mModel = nullptr;
149
156 bool couldBeFirstSubDiagram( const QModelIndex &index ) const;
157
158 private slots:
159 void subDiagramWidgetPanelAccepted( QgsPanelWidget *panel );
160 void liveUpdateSubDiagramFromPanel();
161};
162
171class GUI_EXPORT QgsStackedDiagramPropertiesDialog : public QDialog
172{
173 Q_OBJECT
174
175 public:
182 QgsStackedDiagramPropertiesDialog( QgsVectorLayer *layer, QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr );
183
187 void syncToRenderer( const QgsDiagramRenderer *dr ) const;
188
192 void syncToSettings( const QgsDiagramLayerSettings *dls ) const;
193
198 QgsDiagramRenderer *renderer();
199
203 QgsDiagramLayerSettings diagramLayerSettings() const;
204
211 void setAllowedToEditDiagramLayerSettings( bool allowed ) const;
212
216 bool isAllowedToEditDiagramLayerSettings() const;
217
218 public slots:
219
223 void accept() override;
224
225 private slots:
226 void showHelp();
227
228 private:
229 QgsDiagramProperties *mPropsWidget = nullptr;
230 std::unique_ptr<QgsDiagramRenderer> mRenderer;
231 QgsDiagramLayerSettings mDiagramLayerSettings;
232 QDialogButtonBox *buttonBox = nullptr;
233};
234
235#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.