QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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 "ui_qgslayoutlegendmapfilteringwidgetbase.h"
25#include "ui_qgslayoutlegendwidgetbase.h"
26
27#include "qgis_gui.h"
28#include "qgslayoutitemlegend.h"
29#include "qgslayoutitemwidget.h"
30
31#include <QItemDelegate>
32#include <QWidget>
33
34class QgsLayoutLegendMapFilteringWidget;
35
37
38#ifndef SIP_RUN
45class GUI_EXPORT QgsLegendLayerTreeProxyModel : public QgsLayerTreeProxyModel
46{
47 Q_OBJECT
48 public:
52 QgsLegendLayerTreeProxyModel( QgsLayoutItemLegend *legend, QObject *parent SIP_TRANSFERTHIS = nullptr );
53
58 void setIsDefaultLegend( bool isDefault );
59
60 protected:
61 bool nodeShown( QgsLayerTreeNode *node ) const override;
62
63 private:
64 bool mIsDefaultLegend = true;
65};
66#endif
67
75class GUI_EXPORT QgsLayoutLegendWidget : public QgsLayoutItemBaseWidget, public QgsExpressionContextGenerator, private Ui::QgsLayoutLegendWidgetBase
76{
77 Q_OBJECT
78
79 public:
81 explicit QgsLayoutLegendWidget( QgsLayoutItemLegend *legend, QgsMapCanvas *mapCanvas );
82 void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
83 void setDesignerInterface( QgsLayoutDesignerInterface *iface ) override;
85 void updateLegend();
86
88 QgsLayoutItemLegend *legend() { return mLegend; }
89 void setReportTypeString( const QString &string ) override;
90 QgsExpressionContext createExpressionContext() const override;
91 public slots:
93 void resetLayerNodeToDefaults();
94
99 void setCurrentNodeStyleFromAction();
100
101 protected:
102 bool setNewItem( QgsLayoutItem *item ) override;
103
104 private slots:
105
106 void mWrapCharLineEdit_textChanged( const QString &text );
107 void mTitleLineEdit_textChanged( const QString &text );
108 void mColumnCountSpinBox_valueChanged( int c );
109 void mSplitLayerCheckBox_toggled( bool checked );
110 void mEqualColumnWidthCheckBox_toggled( bool checked );
111 void mSymbolWidthSpinBox_valueChanged( double d );
112 void mSymbolHeightSpinBox_valueChanged( double d );
113 void mMaxSymbolSizeSpinBox_valueChanged( double d );
114 void mMinSymbolSizeSpinBox_valueChanged( double d );
115 void mWmsLegendWidthSpinBox_valueChanged( double d );
116 void mWmsLegendHeightSpinBox_valueChanged( double d );
117 void mTitleSpaceBottomSpinBox_valueChanged( double d );
118 void mGroupSpaceSpinBox_valueChanged( double d );
119 void mGroupIndentSpinBox_valueChanged( double d );
120 void mSubgroupIndentSpinBox_valueChanged( double d );
121 void mLayerSpaceSpinBox_valueChanged( double d );
122 void mSymbolSpaceSpinBox_valueChanged( double d );
123 void mIconLabelSpaceSpinBox_valueChanged( double d );
124 void mBoxSpaceSpinBox_valueChanged( double d );
125 void mColumnSpaceSpinBox_valueChanged( double d );
126 void maxWidthChanged( double width );
127 void mCheckBoxAutoUpdate_stateChanged( int state, bool userTriggered = true );
128 void composerMapChanged( QgsLayoutItem *item );
129 void mCheckboxResizeContents_toggled( bool checked );
130
131 void mRasterStrokeGroupBox_toggled( bool state );
132 void mRasterStrokeWidthSpinBox_valueChanged( double d );
133 void mRasterStrokeColorButton_colorChanged( const QColor &newColor );
134
135 //item manipulation
136 void mMoveDownToolButton_clicked();
137 void mMoveUpToolButton_clicked();
138 void mRemoveToolButton_clicked();
139 void mAddToolButton_clicked();
140 void mEditPushButton_clicked();
141 void mCountToolButton_clicked( bool checked );
142 void mExpressionFilterButton_toggled( bool checked );
143 void mFilterByMapCheckBox_toggled( bool checked );
144 void mUpdateAllPushButton_clicked();
145 void mAddGroupToolButton_clicked();
146 void mLayerExpressionButton_clicked();
147
148 void mFilterLegendByAtlasCheckBox_toggled( bool checked );
149
150 void selectedChanged( const QModelIndex &current, const QModelIndex &previous );
151
152 void setLegendMapViewData();
153
154 void expandLegendTree();
155 void collapseLegendTree();
156
157 private slots:
159 void setGuiElements();
160
162 void updateFilterLegendByAtlasButton();
163
164 void mItemTreeView_doubleClicked( const QModelIndex &index );
165 void titleFontChanged();
166 void groupFontChanged();
167 void layerFontChanged();
168 void itemFontChanged();
169
170 void titleAlignmentChanged();
171 void groupAlignmentChanged();
172 void subgroupAlignmentChanged();
173 void itemAlignmentChanged();
174 void arrangementChanged();
175
176 void spaceBelowSubGroupHeadingChanged( double space );
177 void spaceBelowGroupHeadingChanged( double space );
178
179 void spaceGroupSideChanged( double space );
180 void spaceSubGroupSideChanged( double space );
181
182 void spaceSymbolSideChanged( double space );
183
184 private:
185 QgsLayoutLegendWidget() = delete;
186 void blockAllSignals( bool b );
187
188 QPointer<QgsLayoutItemLegend> mLegend;
189 QgsMapCanvas *mMapCanvas = nullptr;
190 QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
191
192 QgsLegendLayerTreeProxyModel *mLegendProxyModel = nullptr;
193
194 QPointer<QgsLayoutLegendMapFilteringWidget> mMapFilteringWidget;
195};
196
204class GUI_EXPORT QgsLayoutLegendMenuProvider : public QgsLayerTreeViewMenuProvider
205{
206 public:
208 QgsLayoutLegendMenuProvider( QgsLayerTreeView *view, QgsLayoutLegendWidget *w );
209
210 QMenu *createContextMenu() override;
211
212 protected:
213 QgsLayerTreeView *mView = nullptr;
214 QgsLayoutLegendWidget *mWidget = nullptr;
215};
216
217#include "ui_qgslayoutlegendnodewidgetbase.h"
218
226class GUI_EXPORT QgsLayoutLegendNodeWidget : public QgsPanelWidget, private Ui::QgsLayoutLegendNodeWidgetBase
227{
228 Q_OBJECT
229
230 public:
231 QgsLayoutLegendNodeWidget( QgsLayoutItemLegend *legend, QgsLayerTreeNode *node, QgsLayerTreeModelLegendNode *legendNode, int originalLegendNodeIndex, QWidget *parent = nullptr );
232
233 void setDockMode( bool dockMode ) override;
234
235 private slots:
236
237 void labelChanged();
238 void patchChanged();
239 void insertExpression();
240 void sizeChanged( double );
241 void customSymbolChanged();
242 void colorRampLegendChanged();
243 void columnBreakToggled( bool checked );
244 void columnSplitChanged();
245
246 private:
247 QgsLayoutItemLegend *mLegend = nullptr;
248 QgsLayerTreeNode *mNode = nullptr;
249 QgsLayerTreeLayer *mLayer = nullptr;
250 QgsLayerTreeModelLegendNode *mLegendNode = nullptr;
251 int mOriginalLegendNodeIndex = -1;
252};
253
254
262class GUI_EXPORT QgsLayoutLegendMapFilteringModel : public QSortFilterProxyModel
263{
264 Q_OBJECT
265
266 public:
268 explicit QgsLayoutLegendMapFilteringModel( QgsLayoutItemLegend *legend, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
269
270 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
271 QVariant data( const QModelIndex &index, int role ) const override;
272 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
273 Qt::ItemFlags flags( const QModelIndex &index ) const override;
274
275 protected:
276 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
277
278 private:
279 QgsLayoutModel *mLayoutModel = nullptr;
280 QPointer<QgsLayoutItemLegend> mLegendItem;
281};
282
290class GUI_EXPORT QgsLayoutLegendMapFilteringWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutLegendMapFilteringWidgetBase
291{
292 Q_OBJECT
293
294 public:
296 explicit QgsLayoutLegendMapFilteringWidget( QgsLayoutItemLegend *legend );
297
298 protected:
299 bool setNewItem( QgsLayoutItem *item ) final;
300
301 private slots:
302 void updateGuiElements();
303
304 private:
305 QPointer<QgsLayoutItemLegend> mLegendItem;
306 bool mBlockUpdates = false;
307};
308
310
311#endif //QGSLAYOUTLEGENDWIDGET_H
Abstract interface for generating an expression context.
Base class for nodes in a layer tree.
A proxy model for QgsLayerTreeModel, supporting private layers and text filtering.
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
virtual bool nodeShown(QgsLayerTreeNode *node) const
Returns true if the specified node should be shown.
Implementation of this interface can be implemented to allow QgsLayerTreeView instance to provide cus...
A base class for property widgets for layout items.
A layout item subclass for map legends.
Base class for any widget that can be shown as an inline panel.
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
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53