QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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 
38 class GUI_EXPORT QgsLayoutLegendWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutLegendWidgetBase
39 {
40  Q_OBJECT
41 
42  public:
44  explicit QgsLayoutLegendWidget( QgsLayoutItemLegend *legend, QgsMapCanvas *mapCanvas );
45  void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
46 
48  void updateLegend();
49 
51  QgsLayoutItemLegend *legend() { return mLegend; }
52  void setReportTypeString( const QString &string ) override;
53 
54  public slots:
56  void resetLayerNodeToDefaults();
57 
62  void setCurrentNodeStyleFromAction();
63 
64  protected:
65 
66  bool setNewItem( QgsLayoutItem *item ) override;
67 
68  private slots:
69 
70  void mWrapCharLineEdit_textChanged( const QString &text );
71  void mTitleLineEdit_textChanged( const QString &text );
72  void mColumnCountSpinBox_valueChanged( int c );
73  void mSplitLayerCheckBox_toggled( bool checked );
74  void mEqualColumnWidthCheckBox_toggled( bool checked );
75  void mSymbolWidthSpinBox_valueChanged( double d );
76  void mSymbolHeightSpinBox_valueChanged( double d );
77  void mWmsLegendWidthSpinBox_valueChanged( double d );
78  void mWmsLegendHeightSpinBox_valueChanged( double d );
79  void mTitleSpaceBottomSpinBox_valueChanged( double d );
80  void mGroupSpaceSpinBox_valueChanged( double d );
81  void mLayerSpaceSpinBox_valueChanged( double d );
82  void mSymbolSpaceSpinBox_valueChanged( double d );
83  void mIconLabelSpaceSpinBox_valueChanged( double d );
84  void mFontColorButton_colorChanged( const QColor &newFontColor );
85  void mBoxSpaceSpinBox_valueChanged( double d );
86  void mColumnSpaceSpinBox_valueChanged( double d );
87  void mLineSpacingSpinBox_valueChanged( double d );
88  void mCheckBoxAutoUpdate_stateChanged( int state );
89  void composerMapChanged( QgsLayoutItem *item );
90  void mCheckboxResizeContents_toggled( bool checked );
91 
92  void mRasterStrokeGroupBox_toggled( bool state );
93  void mRasterStrokeWidthSpinBox_valueChanged( double d );
94  void mRasterStrokeColorButton_colorChanged( const QColor &newColor );
95 
96  //item manipulation
97  void mMoveDownToolButton_clicked();
98  void mMoveUpToolButton_clicked();
99  void mRemoveToolButton_clicked();
100  void mAddToolButton_clicked();
101  void mEditPushButton_clicked();
102  void mCountToolButton_clicked( bool checked );
103  void mExpressionFilterButton_toggled( bool checked );
104  void mFilterByMapCheckBox_toggled( bool checked );
105  void mUpdateAllPushButton_clicked();
106  void mAddGroupToolButton_clicked();
107  void mLayerExpressionButton_clicked();
108 
109  void mFilterLegendByAtlasCheckBox_toggled( bool checked );
110 
111  void selectedChanged( const QModelIndex &current, const QModelIndex &previous );
112 
113  void setLegendMapViewData();
114 
115  private slots:
117  void setGuiElements();
118 
120  void updateFilterLegendByAtlasButton();
121 
122  void mItemTreeView_doubleClicked( const QModelIndex &index );
123  void titleFontChanged();
124  void groupFontChanged();
125  void layerFontChanged();
126  void itemFontChanged();
127 
128  void titleAlignmentChanged();
129  void groupAlignmentChanged();
130  void subgroupAlignmentChanged();
131  void itemAlignmentChanged();
132  void arrangementChanged();
133 
134  void spaceBelowSubGroupHeadingChanged( double space );
135  void spaceBelowGroupHeadingChanged( double space );
136 
137  private:
138  QgsLayoutLegendWidget() = delete;
139  void blockAllSignals( bool b );
140 
141  QPointer< QgsLayoutItemLegend > mLegend;
142  QgsMapCanvas *mMapCanvas = nullptr;
143  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
144 };
145 
154 {
155 
156  public:
159 
160  QMenu *createContextMenu() override;
161 
162  protected:
163  QgsLayerTreeView *mView = nullptr;
164  QgsLayoutLegendWidget *mWidget = nullptr;
165 };
166 
167 
168 #endif //QGSLAYOUTLEGENDWIDGET_H
169 
The QgsLayerTreeView class extends QTreeView and provides some additional functionality when working ...
Implementation of this interface can be implemented to allow QgsLayerTreeView instance to provide cus...
Base class for graphical items within a QgsLayout.
A widget for controlling the common properties of layout items (e.g.
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:75
virtual QMenu * createContextMenu()=0
Returns a newly created menu instance (or nullptr on error)
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
A widget for setting properties relating to a layout legend.
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
QgsLayoutItemLegend * legend()
Returns the legend item associated to this widget.
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
A base class for property widgets for layout items.
A layout item subclass for map legends.
Interface for master layout type objects, such as print layouts and reports.
Layout legend menu provider.