QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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  private slots:
194 
195  void labelChanged();
196  void patchChanged();
197  void insertExpression();
198  void sizeChanged( double );
199  void customSymbolChanged();
200  void columnBreakToggled( bool checked );
201  void columnSplitChanged();
202 
203  private:
204 
205  QgsLayoutItemLegend *mLegend = nullptr;
206  QgsLayerTreeNode *mNode = nullptr;
207  QgsLayerTreeLayer *mLayer = nullptr;
208  QgsLayerTreeModelLegendNode *mLegendNode = nullptr;
209  int mOriginalLegendNodeIndex = -1;
210 
211 };
212 
214 
215 #endif //QGSLAYOUTLEGENDWIDGET_H
216 
QgsLayerTreeNode
This class is a base class for nodes in a layer tree.
Definition: qgslayertreenode.h:75
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsLayerTreeViewMenuProvider
Implementation of this interface can be implemented to allow QgsLayerTreeView instance to provide cus...
Definition: qgslayertreeview.h:285
QgsLayoutItemBaseWidget::setReportTypeString
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
Definition: qgslayoutitemwidget.cpp:184
QgsLayoutItemPropertiesWidget
A widget for controlling the common properties of layout items (e.g.
Definition: qgslayoutitemwidget.h:219
QgsLayoutItemLegend
A layout item subclass for map legends.
Definition: qgslayoutitemlegend.h:114
qgslayoutitemwidget.h
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:30
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:44
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:113
QgsWms::legendNode
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)
Definition: qgswmsgetlegendgraphics.cpp:345
QgsLayoutItemBaseWidget
A base class for property widgets for layout items.
Definition: qgslayoutitemwidget.h:123
QgsLayoutItemBaseWidget::setNewItem
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
Definition: qgslayoutitemwidget.cpp:222
qgslayoutitemlegend.h
QgsLayoutItemBaseWidget::setMasterLayout
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Definition: qgslayoutitemwidget.cpp:202
c
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
Definition: porting_processing.dox:1
QgsLayerTreeView
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
Definition: qgslayertreeview.h:52
QgsLayerTreeViewMenuProvider::createContextMenu
virtual QMenu * createContextMenu()=0
Returns a newly created menu instance (or nullptr on error)
QgsMasterLayoutInterface
Interface for master layout type objects, such as print layouts and reports.
Definition: qgsmasterlayoutinterface.h:43
QgsLayerTreeModelLegendNode
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
Definition: qgslayertreemodellegendnode.h:51