QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 mWmsLegendWidthSpinBox_valueChanged( double d );
80  void mWmsLegendHeightSpinBox_valueChanged( double d );
81  void mTitleSpaceBottomSpinBox_valueChanged( double d );
82  void mGroupSpaceSpinBox_valueChanged( double d );
83  void mLayerSpaceSpinBox_valueChanged( double d );
84  void mSymbolSpaceSpinBox_valueChanged( double d );
85  void mIconLabelSpaceSpinBox_valueChanged( double d );
86  void mFontColorButton_colorChanged( const QColor &newFontColor );
87  void mBoxSpaceSpinBox_valueChanged( double d );
88  void mColumnSpaceSpinBox_valueChanged( double d );
89  void mLineSpacingSpinBox_valueChanged( double d );
90  void mCheckBoxAutoUpdate_stateChanged( int state, bool userTriggered = true );
91  void composerMapChanged( QgsLayoutItem *item );
92  void mCheckboxResizeContents_toggled( bool checked );
93 
94  void mRasterStrokeGroupBox_toggled( bool state );
95  void mRasterStrokeWidthSpinBox_valueChanged( double d );
96  void mRasterStrokeColorButton_colorChanged( const QColor &newColor );
97 
98  //item manipulation
99  void mMoveDownToolButton_clicked();
100  void mMoveUpToolButton_clicked();
101  void mRemoveToolButton_clicked();
102  void mAddToolButton_clicked();
103  void mEditPushButton_clicked();
104  void mCountToolButton_clicked( bool checked );
105  void mExpressionFilterButton_toggled( bool checked );
106  void mFilterByMapCheckBox_toggled( bool checked );
107  void mUpdateAllPushButton_clicked();
108  void mAddGroupToolButton_clicked();
109  void mLayerExpressionButton_clicked();
110 
111  void mFilterLegendByAtlasCheckBox_toggled( bool checked );
112 
113  void selectedChanged( const QModelIndex &current, const QModelIndex &previous );
114 
115  void setLegendMapViewData();
116 
117  private slots:
119  void setGuiElements();
120 
122  void updateFilterLegendByAtlasButton();
123 
124  void mItemTreeView_doubleClicked( const QModelIndex &index );
125  void titleFontChanged();
126  void groupFontChanged();
127  void layerFontChanged();
128  void itemFontChanged();
129 
130  void titleAlignmentChanged();
131  void groupAlignmentChanged();
132  void subgroupAlignmentChanged();
133  void itemAlignmentChanged();
134  void arrangementChanged();
135 
136  void spaceBelowSubGroupHeadingChanged( double space );
137  void spaceBelowGroupHeadingChanged( double space );
138 
139  void spaceGroupSideChanged( double space );
140  void spaceSubGroupSideChanged( double space );
141 
142  void spaceSymbolSideChanged( double space );
143 
144  private:
145  QgsLayoutLegendWidget() = delete;
146  void blockAllSignals( bool b );
147 
148  QPointer< QgsLayoutItemLegend > mLegend;
149  QgsMapCanvas *mMapCanvas = nullptr;
150  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
151 };
152 
160 class GUI_EXPORT QgsLayoutLegendMenuProvider : public QgsLayerTreeViewMenuProvider
161 {
162 
163  public:
165  QgsLayoutLegendMenuProvider( QgsLayerTreeView *view, QgsLayoutLegendWidget *w );
166 
167  QMenu *createContextMenu() override;
168 
169  protected:
170  QgsLayerTreeView *mView = nullptr;
171  QgsLayoutLegendWidget *mWidget = nullptr;
172 };
173 
174 #include "ui_qgslayoutlegendnodewidgetbase.h"
175 
183 class GUI_EXPORT QgsLayoutLegendNodeWidget: public QgsPanelWidget, private Ui::QgsLayoutLegendNodeWidgetBase
184 {
185  Q_OBJECT
186 
187  public:
188 
189  QgsLayoutLegendNodeWidget( QgsLayoutItemLegend *legend, QgsLayerTreeNode *node, QgsLayerTreeModelLegendNode *legendNode, int originalLegendNodeIndex, QWidget *parent = nullptr );
190 
191  private slots:
192 
193  void labelChanged();
194  void patchChanged();
195  void insertExpression();
196  void sizeChanged( double );
197  void customSymbolChanged();
198  void columnBreakToggled( bool checked );
199  void columnSplitChanged();
200 
201  private:
202 
203  QgsLayoutItemLegend *mLegend = nullptr;
204  QgsLayerTreeNode *mNode = nullptr;
205  QgsLayerTreeLayer *mLayer = nullptr;
206  QgsLayerTreeModelLegendNode *mLegendNode = nullptr;
207  int mOriginalLegendNodeIndex = -1;
208 
209 };
210 
212 
213 #endif //QGSLAYOUTLEGENDWIDGET_H
214 
QgsLayerTreeNode
Definition: qgslayertreenode.h:74
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsLayerTreeViewMenuProvider
Definition: qgslayertreeview.h:282
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
Definition: qgslayoutitemwidget.h:218
QgsLayoutItemLegend
Definition: qgslayoutitemlegend.h:113
qgslayoutitemwidget.h
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsLayerTreeLayer
Definition: qgslayertreelayer.h:43
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:112
QgsWms::legendNode
QgsLayerTreeModelLegendNode * legendNode(const QString &rule, QgsLayerTreeModel &model)
Definition: qgswmsgetlegendgraphics.cpp:358
QgsLayoutItemBaseWidget
Definition: qgslayoutitemwidget.h:122
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
Definition: qgslayertreeview.h:51
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:42
QgsLayerTreeModelLegendNode
Definition: qgslayertreemodellegendnode.h:50