QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgslayoutlegendwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutlegendwidget.h
3 -----------------------
4 begin : October 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
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 QGSLAYOUTLEGENDWIDGET_H
19#define QGSLAYOUTLEGENDWIDGET_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 "ui_qgslayoutlegendwidgetbase.h"
26#include "ui_qgslayoutlegendmapfilteringwidgetbase.h"
27#include "qgslayoutitemwidget.h"
28#include "qgslayoutitemlegend.h"
29#include <QWidget>
30#include <QItemDelegate>
31
32class QgsLayoutLegendMapFilteringWidget;
33
35
43class GUI_EXPORT QgsLayoutLegendWidget: public QgsLayoutItemBaseWidget, public QgsExpressionContextGenerator, private Ui::QgsLayoutLegendWidgetBase
44{
45 Q_OBJECT
46
47 public:
49 explicit QgsLayoutLegendWidget( QgsLayoutItemLegend *legend, QgsMapCanvas *mapCanvas );
50 void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
53 void updateLegend();
54
56 QgsLayoutItemLegend *legend() { return mLegend; }
57 void setReportTypeString( const QString &string ) override;
59 public slots:
61 void resetLayerNodeToDefaults();
62
67 void setCurrentNodeStyleFromAction();
68
69 protected:
70
71 bool setNewItem( QgsLayoutItem *item ) override;
72
73 private slots:
74
75 void mWrapCharLineEdit_textChanged( const QString &text );
76 void mTitleLineEdit_textChanged( const QString &text );
77 void mColumnCountSpinBox_valueChanged( int c );
78 void mSplitLayerCheckBox_toggled( bool checked );
79 void mEqualColumnWidthCheckBox_toggled( bool checked );
80 void mSymbolWidthSpinBox_valueChanged( double d );
81 void mSymbolHeightSpinBox_valueChanged( double d );
82 void mMaxSymbolSizeSpinBox_valueChanged( double d );
83 void mMinSymbolSizeSpinBox_valueChanged( double d );
84 void mWmsLegendWidthSpinBox_valueChanged( double d );
85 void mWmsLegendHeightSpinBox_valueChanged( double d );
86 void mTitleSpaceBottomSpinBox_valueChanged( double d );
87 void mGroupSpaceSpinBox_valueChanged( double d );
88 void mGroupIndentSpinBox_valueChanged( double d );
89 void mSubgroupIndentSpinBox_valueChanged( double d );
90 void mLayerSpaceSpinBox_valueChanged( double d );
91 void mSymbolSpaceSpinBox_valueChanged( double d );
92 void mIconLabelSpaceSpinBox_valueChanged( double d );
93 void mBoxSpaceSpinBox_valueChanged( double d );
94 void mColumnSpaceSpinBox_valueChanged( double d );
95 void mCheckBoxAutoUpdate_stateChanged( int state, bool userTriggered = true );
96 void composerMapChanged( QgsLayoutItem *item );
97 void mCheckboxResizeContents_toggled( bool checked );
98
99 void mRasterStrokeGroupBox_toggled( bool state );
100 void mRasterStrokeWidthSpinBox_valueChanged( double d );
101 void mRasterStrokeColorButton_colorChanged( const QColor &newColor );
102
103 //item manipulation
104 void mMoveDownToolButton_clicked();
105 void mMoveUpToolButton_clicked();
106 void mRemoveToolButton_clicked();
107 void mAddToolButton_clicked();
108 void mEditPushButton_clicked();
109 void mCountToolButton_clicked( bool checked );
110 void mExpressionFilterButton_toggled( bool checked );
111 void mFilterByMapCheckBox_toggled( bool checked );
112 void mUpdateAllPushButton_clicked();
113 void mAddGroupToolButton_clicked();
114 void mLayerExpressionButton_clicked();
115
116 void mFilterLegendByAtlasCheckBox_toggled( bool checked );
117
118 void selectedChanged( const QModelIndex &current, const QModelIndex &previous );
119
120 void setLegendMapViewData();
121
122 private slots:
124 void setGuiElements();
125
127 void updateFilterLegendByAtlasButton();
128
129 void mItemTreeView_doubleClicked( const QModelIndex &index );
130 void titleFontChanged();
131 void groupFontChanged();
132 void layerFontChanged();
133 void itemFontChanged();
134
135 void titleAlignmentChanged();
136 void groupAlignmentChanged();
137 void subgroupAlignmentChanged();
138 void itemAlignmentChanged();
139 void arrangementChanged();
140
141 void spaceBelowSubGroupHeadingChanged( double space );
142 void spaceBelowGroupHeadingChanged( double space );
143
144 void spaceGroupSideChanged( double space );
145 void spaceSubGroupSideChanged( double space );
146
147 void spaceSymbolSideChanged( double space );
148
149 private:
150 QgsLayoutLegendWidget() = delete;
151 void blockAllSignals( bool b );
152
153 QPointer< QgsLayoutItemLegend > mLegend;
154 QgsMapCanvas *mMapCanvas = nullptr;
155 QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
156
157 QPointer< QgsLayoutLegendMapFilteringWidget > mMapFilteringWidget;
158};
159
167class GUI_EXPORT QgsLayoutLegendMenuProvider : public QgsLayerTreeViewMenuProvider
168{
169
170 public:
172 QgsLayoutLegendMenuProvider( QgsLayerTreeView *view, QgsLayoutLegendWidget *w );
173
174 QMenu *createContextMenu() override;
175
176 protected:
177 QgsLayerTreeView *mView = nullptr;
178 QgsLayoutLegendWidget *mWidget = nullptr;
179};
180
181#include "ui_qgslayoutlegendnodewidgetbase.h"
182
190class GUI_EXPORT QgsLayoutLegendNodeWidget: public QgsPanelWidget, private Ui::QgsLayoutLegendNodeWidgetBase
191{
192 Q_OBJECT
193
194 public:
195
196 QgsLayoutLegendNodeWidget( QgsLayoutItemLegend *legend, QgsLayerTreeNode *node, QgsLayerTreeModelLegendNode *legendNode, int originalLegendNodeIndex, QWidget *parent = nullptr );
197
198 void setDockMode( bool dockMode ) override;
199
200 private slots:
201
202 void labelChanged();
203 void patchChanged();
204 void insertExpression();
205 void sizeChanged( double );
206 void customSymbolChanged();
207 void colorRampLegendChanged();
208 void columnBreakToggled( bool checked );
209 void columnSplitChanged();
210
211 private:
212
213 QgsLayoutItemLegend *mLegend = nullptr;
214 QgsLayerTreeNode *mNode = nullptr;
215 QgsLayerTreeLayer *mLayer = nullptr;
216 QgsLayerTreeModelLegendNode *mLegendNode = nullptr;
217 int mOriginalLegendNodeIndex = -1;
218
219};
220
221
229class GUI_EXPORT QgsLayoutLegendMapFilteringModel : public QSortFilterProxyModel
230{
231 Q_OBJECT
232
233 public:
235 explicit QgsLayoutLegendMapFilteringModel( QgsLayoutItemLegend *legend, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
236
237 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
238 QVariant data( const QModelIndex &index, int role ) const override;
239 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
240 Qt::ItemFlags flags( const QModelIndex &index ) const override;
241
242 protected:
243
244 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
245
246 private:
247 QgsLayoutModel *mLayoutModel = nullptr;
248 QPointer< QgsLayoutItemLegend > mLegendItem;
249
250};
251
259class GUI_EXPORT QgsLayoutLegendMapFilteringWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutLegendMapFilteringWidgetBase
260{
261 Q_OBJECT
262
263 public:
265 explicit QgsLayoutLegendMapFilteringWidget( QgsLayoutItemLegend *legend );
266
267 protected:
268 bool setNewItem( QgsLayoutItem *item ) final;
269
270 private slots:
271 void updateGuiElements();
272
273 private:
274 QPointer< QgsLayoutItemLegend > mLegendItem;
275 bool mBlockUpdates = false;
276};
277
279
280#endif //QGSLAYOUTLEGENDWIDGET_H
281
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...
Layer tree node points to a map layer.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
This class is a base class for nodes in a layer tree.
Implementation of this interface can be implemented to allow QgsLayerTreeView instance to provide cus...
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
A common interface for layout designer dialogs and widgets.
A base class for property widgets for layout items.
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
virtual void setDesignerInterface(QgsLayoutDesignerInterface *iface)
Sets the the layout designer interface in which the widget is being shown.
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
A layout item subclass for map legends.
A widget for controlling the common properties of layout items (e.g.
Base class for graphical items within a QgsLayout.
A model for items attached to a layout.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
Interface for master layout type objects, such as print layouts and reports.
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.
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c