QGIS API Documentation 3.41.0-Master (3440c17df1d)
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,
58 int role = Qt::DisplayRole ) const override;
59 int rowCount( const QModelIndex & = QModelIndex() ) const override;
60 int columnCount( const QModelIndex & = QModelIndex() ) const override;
61
62 // editing support
63 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
64 bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) override;
65
66 // new methods
67
69 QgsDiagramRenderer *subDiagramForIndex( const QModelIndex &index ) const;
70
72 void insertSubDiagram( const int index, QgsDiagramRenderer *newSubDiagram );
74 void updateSubDiagram( const QModelIndex &index, QgsDiagramRenderer *dr );
75
77 QList< QgsDiagramRenderer *> subRenderers() const;
78
80 QgsDiagramLayerSettings diagramLayerSettings() const;
81
85 void updateDiagramLayerSettings( QgsDiagramLayerSettings dls );
86
87 protected:
88 QList< QgsDiagramRenderer *> mRenderers;
90};
91
92
99class GUI_EXPORT QgsStackedDiagramProperties : public QgsPanelWidget, private Ui::QgsStackedDiagramPropertiesBase
100{
101 Q_OBJECT
102
103 public:
104 explicit QgsStackedDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
105
109 void syncToLayer();
110
111 signals:
113
114 public slots:
115 void apply();
116
117 private slots:
118
122 void addSubDiagramRenderer();
123
128 void appendSubDiagramRenderer( QgsDiagramRenderer *dr );
129
133 void editSubDiagramRenderer();
134
138 void editSubDiagramRenderer( const QModelIndex &index );
139
143 void removeSubDiagramRenderer();
144
145 private:
146 QgsVectorLayer *mLayer = nullptr;
147 QgsMapCanvas *mMapCanvas = nullptr;
148
149 QgsStackedDiagramPropertiesModel *mModel = nullptr;
150
157 bool couldBeFirstSubDiagram( const QModelIndex &index ) const;
158
159 private slots:
160 void subDiagramWidgetPanelAccepted( QgsPanelWidget *panel );
161 void liveUpdateSubDiagramFromPanel();
162};
163
172class GUI_EXPORT QgsStackedDiagramPropertiesDialog : public QDialog
173{
174 Q_OBJECT
175
176 public:
177
184 QgsStackedDiagramPropertiesDialog( QgsVectorLayer *layer, QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr );
185
189 void syncToRenderer( const QgsDiagramRenderer *dr ) const;
190
194 void syncToSettings( const QgsDiagramLayerSettings *dls ) const;
195
200 QgsDiagramRenderer *renderer();
201
205 QgsDiagramLayerSettings diagramLayerSettings() const;
206
213 void setAllowedToEditDiagramLayerSettings( bool allowed ) const;
214
218 bool isAllowedToEditDiagramLayerSettings() const;
219
220 public slots:
221
225 void accept() override;
226
227 private slots:
228 void showHelp();
229
230 private:
231 QgsDiagramProperties *mPropsWidget = nullptr;
232 std::unique_ptr< QgsDiagramRenderer > mRenderer;
233 QgsDiagramLayerSettings mDiagramLayerSettings;
234 QDialogButtonBox *buttonBox = nullptr;
235};
236
237#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.