QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 mLayerSpaceSpinBox_valueChanged( double d );
86  void mSymbolSpaceSpinBox_valueChanged( double d );
87  void mIconLabelSpaceSpinBox_valueChanged( double d );
88  void mFontColorButton_colorChanged( const QColor &newFontColor );
89  void mBoxSpaceSpinBox_valueChanged( double d );
90  void mColumnSpaceSpinBox_valueChanged( double d );
91  void mLineSpacingSpinBox_valueChanged( double d );
92  void mCheckBoxAutoUpdate_stateChanged( int state, bool userTriggered = true );
93  void composerMapChanged( QgsLayoutItem *item );
94  void mCheckboxResizeContents_toggled( bool checked );
95 
96  void mRasterStrokeGroupBox_toggled( bool state );
97  void mRasterStrokeWidthSpinBox_valueChanged( double d );
98  void mRasterStrokeColorButton_colorChanged( const QColor &newColor );
99 
100  //item manipulation
101  void mMoveDownToolButton_clicked();
102  void mMoveUpToolButton_clicked();
103  void mRemoveToolButton_clicked();
104  void mAddToolButton_clicked();
105  void mEditPushButton_clicked();
106  void mCountToolButton_clicked( bool checked );
107  void mExpressionFilterButton_toggled( bool checked );
108  void mFilterByMapCheckBox_toggled( bool checked );
109  void mUpdateAllPushButton_clicked();
110  void mAddGroupToolButton_clicked();
111  void mLayerExpressionButton_clicked();
112 
113  void mFilterLegendByAtlasCheckBox_toggled( bool checked );
114 
115  void selectedChanged( const QModelIndex &current, const QModelIndex &previous );
116 
117  void setLegendMapViewData();
118 
119  private slots:
121  void setGuiElements();
122 
124  void updateFilterLegendByAtlasButton();
125 
126  void mItemTreeView_doubleClicked( const QModelIndex &index );
127  void titleFontChanged();
128  void groupFontChanged();
129  void layerFontChanged();
130  void itemFontChanged();
131 
132  void titleAlignmentChanged();
133  void groupAlignmentChanged();
134  void subgroupAlignmentChanged();
135  void itemAlignmentChanged();
136  void arrangementChanged();
137 
138  void spaceBelowSubGroupHeadingChanged( double space );
139  void spaceBelowGroupHeadingChanged( double space );
140 
141  void spaceGroupSideChanged( double space );
142  void spaceSubGroupSideChanged( double space );
143 
144  void spaceSymbolSideChanged( double space );
145 
146  private:
147  QgsLayoutLegendWidget() = delete;
148  void blockAllSignals( bool b );
149 
150  QPointer< QgsLayoutItemLegend > mLegend;
151  QgsMapCanvas *mMapCanvas = nullptr;
152  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
153 };
154 
162 class GUI_EXPORT QgsLayoutLegendMenuProvider : public QgsLayerTreeViewMenuProvider
163 {
164 
165  public:
167  QgsLayoutLegendMenuProvider( QgsLayerTreeView *view, QgsLayoutLegendWidget *w );
168 
169  QMenu *createContextMenu() override;
170 
171  protected:
172  QgsLayerTreeView *mView = nullptr;
173  QgsLayoutLegendWidget *mWidget = nullptr;
174 };
175 
176 #include "ui_qgslayoutlegendnodewidgetbase.h"
177 
185 class GUI_EXPORT QgsLayoutLegendNodeWidget: public QgsPanelWidget, private Ui::QgsLayoutLegendNodeWidgetBase
186 {
187  Q_OBJECT
188 
189  public:
190 
191  QgsLayoutLegendNodeWidget( QgsLayoutItemLegend *legend, QgsLayerTreeNode *node, QgsLayerTreeModelLegendNode *legendNode, int originalLegendNodeIndex, QWidget *parent = nullptr );
192 
193  void setDockMode( bool dockMode ) override;
194 
195  private slots:
196 
197  void labelChanged();
198  void patchChanged();
199  void insertExpression();
200  void sizeChanged( double );
201  void customSymbolChanged();
202  void colorRampLegendChanged();
203  void columnBreakToggled( bool checked );
204  void columnSplitChanged();
205 
206  private:
207 
208  QgsLayoutItemLegend *mLegend = nullptr;
209  QgsLayerTreeNode *mNode = nullptr;
210  QgsLayerTreeLayer *mLayer = nullptr;
211  QgsLayerTreeModelLegendNode *mLegendNode = nullptr;
212  int mOriginalLegendNodeIndex = -1;
213 
214 };
215 
217 
218 #endif //QGSLAYOUTLEGENDWIDGET_H
219 
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:86
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