QGIS API Documentation  3.21.0-Master (5b68dc587e)
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 "qgslayoutitemwidget.h"
27 #include "qgslayoutitemlegend.h"
28 #include <QWidget>
29 #include <QItemDelegate>
30 
32 
40 class GUI_EXPORT QgsLayoutLegendWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutLegendWidgetBase
41 {
42  Q_OBJECT
43 
44  public:
46  explicit QgsLayoutLegendWidget( QgsLayoutItemLegend *legend, QgsMapCanvas *mapCanvas );
47  void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
48 
50  void updateLegend();
51 
53  QgsLayoutItemLegend *legend() { return mLegend; }
54  void setReportTypeString( const QString &string ) override;
55 
56  public slots:
58  void resetLayerNodeToDefaults();
59 
64  void setCurrentNodeStyleFromAction();
65 
66  protected:
67 
68  bool setNewItem( QgsLayoutItem *item ) override;
69 
70  private slots:
71 
72  void mWrapCharLineEdit_textChanged( const QString &text );
73  void mTitleLineEdit_textChanged( const QString &text );
74  void mColumnCountSpinBox_valueChanged( int c );
75  void mSplitLayerCheckBox_toggled( bool checked );
76  void mEqualColumnWidthCheckBox_toggled( bool checked );
77  void mSymbolWidthSpinBox_valueChanged( double d );
78  void mSymbolHeightSpinBox_valueChanged( double d );
79  void mMaxSymbolSizeSpinBox_valueChanged( double d );
80  void mMinSymbolSizeSpinBox_valueChanged( double d );
81  void mWmsLegendWidthSpinBox_valueChanged( double d );
82  void mWmsLegendHeightSpinBox_valueChanged( double d );
83  void mTitleSpaceBottomSpinBox_valueChanged( double d );
84  void mGroupSpaceSpinBox_valueChanged( double d );
85  void mGroupIndentSpinBox_valueChanged( double d );
86  void mSubgroupIndentSpinBox_valueChanged( double d );
87  void mLayerSpaceSpinBox_valueChanged( double d );
88  void mSymbolSpaceSpinBox_valueChanged( double d );
89  void mIconLabelSpaceSpinBox_valueChanged( double d );
90  void mFontColorButton_colorChanged( const QColor &newFontColor );
91  void mBoxSpaceSpinBox_valueChanged( double d );
92  void mColumnSpaceSpinBox_valueChanged( double d );
93  void mLineSpacingSpinBox_valueChanged( double d );
94  void mCheckBoxAutoUpdate_stateChanged( int state, bool userTriggered = true );
95  void composerMapChanged( QgsLayoutItem *item );
96  void mCheckboxResizeContents_toggled( bool checked );
97 
98  void mRasterStrokeGroupBox_toggled( bool state );
99  void mRasterStrokeWidthSpinBox_valueChanged( double d );
100  void mRasterStrokeColorButton_colorChanged( const QColor &newColor );
101 
102  //item manipulation
103  void mMoveDownToolButton_clicked();
104  void mMoveUpToolButton_clicked();
105  void mRemoveToolButton_clicked();
106  void mAddToolButton_clicked();
107  void mEditPushButton_clicked();
108  void mCountToolButton_clicked( bool checked );
109  void mExpressionFilterButton_toggled( bool checked );
110  void mFilterByMapCheckBox_toggled( bool checked );
111  void mUpdateAllPushButton_clicked();
112  void mAddGroupToolButton_clicked();
113  void mLayerExpressionButton_clicked();
114 
115  void mFilterLegendByAtlasCheckBox_toggled( bool checked );
116 
117  void selectedChanged( const QModelIndex &current, const QModelIndex &previous );
118 
119  void setLegendMapViewData();
120 
121  private slots:
123  void setGuiElements();
124 
126  void updateFilterLegendByAtlasButton();
127 
128  void mItemTreeView_doubleClicked( const QModelIndex &index );
129  void titleFontChanged();
130  void groupFontChanged();
131  void layerFontChanged();
132  void itemFontChanged();
133 
134  void titleAlignmentChanged();
135  void groupAlignmentChanged();
136  void subgroupAlignmentChanged();
137  void itemAlignmentChanged();
138  void arrangementChanged();
139 
140  void spaceBelowSubGroupHeadingChanged( double space );
141  void spaceBelowGroupHeadingChanged( double space );
142 
143  void spaceGroupSideChanged( double space );
144  void spaceSubGroupSideChanged( double space );
145 
146  void spaceSymbolSideChanged( double space );
147 
148  private:
149  QgsLayoutLegendWidget() = delete;
150  void blockAllSignals( bool b );
151 
152  QPointer< QgsLayoutItemLegend > mLegend;
153  QgsMapCanvas *mMapCanvas = nullptr;
154  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
155 };
156 
164 class GUI_EXPORT QgsLayoutLegendMenuProvider : public QgsLayerTreeViewMenuProvider
165 {
166 
167  public:
169  QgsLayoutLegendMenuProvider( QgsLayerTreeView *view, QgsLayoutLegendWidget *w );
170 
171  QMenu *createContextMenu() override;
172 
173  protected:
174  QgsLayerTreeView *mView = nullptr;
175  QgsLayoutLegendWidget *mWidget = nullptr;
176 };
177 
178 #include "ui_qgslayoutlegendnodewidgetbase.h"
179 
187 class GUI_EXPORT QgsLayoutLegendNodeWidget: public QgsPanelWidget, private Ui::QgsLayoutLegendNodeWidgetBase
188 {
189  Q_OBJECT
190 
191  public:
192 
193  QgsLayoutLegendNodeWidget( QgsLayoutItemLegend *legend, QgsLayerTreeNode *node, QgsLayerTreeModelLegendNode *legendNode, int originalLegendNodeIndex, QWidget *parent = nullptr );
194 
195  void setDockMode( bool dockMode ) override;
196 
197  private slots:
198 
199  void labelChanged();
200  void patchChanged();
201  void insertExpression();
202  void sizeChanged( double );
203  void customSymbolChanged();
204  void colorRampLegendChanged();
205  void columnBreakToggled( bool checked );
206  void columnSplitChanged();
207 
208  private:
209 
210  QgsLayoutItemLegend *mLegend = nullptr;
211  QgsLayerTreeNode *mNode = nullptr;
212  QgsLayerTreeLayer *mLayer = nullptr;
213  QgsLayerTreeModelLegendNode *mLegendNode = nullptr;
214  int mOriginalLegendNodeIndex = -1;
215 
216 };
217 
219 
220 #endif //QGSLAYOUTLEGENDWIDGET_H
221 
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 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 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.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:88
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