QGIS API Documentation 3.41.0-Master (88383c3d16f)
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 // drag'n'drop support
66 Qt::DropActions supportedDropActions() const override;
67 QStringList mimeTypes() const override;
68 QMimeData *mimeData( const QModelIndexList &indexes ) const override;
69 bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent ) override;
70
71 // new methods
73 QgsDiagramRenderer *subDiagramForIndex( const QModelIndex &index ) const;
74
76 void insertSubDiagram( const int index, QgsDiagramRenderer *newSubDiagram );
78 void updateSubDiagram( const QModelIndex &index, QgsDiagramRenderer *dr );
79
81 QList<QgsDiagramRenderer *> subRenderers() const;
82
84 QgsDiagramLayerSettings diagramLayerSettings() const;
85
89 void updateDiagramLayerSettings( QgsDiagramLayerSettings dls );
90
91 protected:
92 QList<QgsDiagramRenderer *> mRenderers;
94};
95
96
103class GUI_EXPORT QgsStackedDiagramProperties : public QgsPanelWidget, private Ui::QgsStackedDiagramPropertiesBase
104{
105 Q_OBJECT
106
107 public:
108 explicit QgsStackedDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
109
113 void syncToLayer();
114
115 signals:
117
118 public slots:
119 void apply();
120
121 private slots:
122
126 void addSubDiagramRenderer();
127
132 void appendSubDiagramRenderer( QgsDiagramRenderer *dr );
133
137 void editSubDiagramRenderer();
138
142 void editSubDiagramRenderer( const QModelIndex &index );
143
147 void removeSubDiagramRenderer();
148
149 private:
150 QgsVectorLayer *mLayer = nullptr;
151 QgsMapCanvas *mMapCanvas = nullptr;
152
153 QgsStackedDiagramPropertiesModel *mModel = nullptr;
154
161 bool couldBeFirstSubDiagram( const QModelIndex &index ) const;
162
163 private slots:
164 void subDiagramWidgetPanelAccepted( QgsPanelWidget *panel );
165 void liveUpdateSubDiagramFromPanel();
166};
167
176class GUI_EXPORT QgsStackedDiagramPropertiesDialog : public QDialog
177{
178 Q_OBJECT
179
180 public:
187 QgsStackedDiagramPropertiesDialog( QgsVectorLayer *layer, QWidget *parent = nullptr, QgsMapCanvas *mapCanvas = nullptr );
188
192 void syncToRenderer( const QgsDiagramRenderer *dr ) const;
193
197 void syncToSettings( const QgsDiagramLayerSettings *dls ) const;
198
203 QgsDiagramRenderer *renderer();
204
208 QgsDiagramLayerSettings diagramLayerSettings() const;
209
216 void setAllowedToEditDiagramLayerSettings( bool allowed ) const;
217
221 bool isAllowedToEditDiagramLayerSettings() const;
222
223 public slots:
224
228 void accept() override;
229
230 private slots:
231 void showHelp();
232
233 private:
234 QgsDiagramProperties *mPropsWidget = nullptr;
235 std::unique_ptr<QgsDiagramRenderer> mRenderer;
236 QgsDiagramLayerSettings mDiagramLayerSettings;
237 QDialogButtonBox *buttonBox = nullptr;
238};
239
240#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.