QGIS API Documentation 3.99.0-Master (a5475b57e34)
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
23#include "ui_qgslayoutlegendmapfilteringwidgetbase.h"
24#include "ui_qgslayoutlegendwidgetbase.h"
25
26#include "qgis_gui.h"
27#include "qgslayoutitemlegend.h"
28#include "qgslayoutitemwidget.h"
29
30#include <QItemDelegate>
31#include <QWidget>
32
33#define SIP_NO_FILE
34
35class QgsLayoutLegendMapFilteringWidget;
36
38
39#ifndef SIP_RUN
46class GUI_EXPORT QgsLegendLayerTreeProxyModel : public QgsLayerTreeProxyModel
47{
48 Q_OBJECT
49 public:
53 QgsLegendLayerTreeProxyModel( QgsLayoutItemLegend *legend, QObject *parent SIP_TRANSFERTHIS = nullptr );
54
58 void setSyncMode( Qgis::LegendSyncMode mode );
59
60 protected:
61 bool nodeShown( QgsLayerTreeNode *node ) const override;
62
63 private:
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;
84
86 QgsLayoutItemLegend *legend() { return mLegend; }
87 void setReportTypeString( const QString &string ) override;
88 QgsExpressionContext createExpressionContext() const override;
89 public slots:
91 void resetLayerNodeToDefaults();
92
97 void setCurrentNodeStyleFromAction();
98
99 protected:
100 bool setNewItem( QgsLayoutItem *item ) override;
101
102 private slots:
103
104 void mWrapCharLineEdit_textChanged( const QString &text );
105 void mTitleLineEdit_textChanged( const QString &text );
106 void mColumnCountSpinBox_valueChanged( int c );
107 void mSplitLayerCheckBox_toggled( bool checked );
108 void mEqualColumnWidthCheckBox_toggled( bool checked );
109 void mSymbolWidthSpinBox_valueChanged( double d );
110 void mSymbolHeightSpinBox_valueChanged( double d );
111 void mMaxSymbolSizeSpinBox_valueChanged( double d );
112 void mMinSymbolSizeSpinBox_valueChanged( double d );
113 void mWmsLegendWidthSpinBox_valueChanged( double d );
114 void mWmsLegendHeightSpinBox_valueChanged( double d );
115 void mTitleSpaceBottomSpinBox_valueChanged( double d );
116 void mGroupSpaceSpinBox_valueChanged( double d );
117 void mGroupIndentSpinBox_valueChanged( double d );
118 void mSubgroupIndentSpinBox_valueChanged( double d );
119 void mLayerSpaceSpinBox_valueChanged( double d );
120 void mSymbolSpaceSpinBox_valueChanged( double d );
121 void mIconLabelSpaceSpinBox_valueChanged( double d );
122 void mBoxSpaceSpinBox_valueChanged( double d );
123 void mColumnSpaceSpinBox_valueChanged( double d );
124 void maxWidthChanged( double width );
125 void syncModeChanged( bool userTriggered );
126 void composerMapChanged( QgsLayoutItem *item );
127 void mCheckboxResizeContents_toggled( bool checked );
128
129 void mRasterStrokeGroupBox_toggled( bool state );
130 void mRasterStrokeWidthSpinBox_valueChanged( double d );
131 void mRasterStrokeColorButton_colorChanged( const QColor &newColor );
132
133 //item manipulation
134 void mMoveDownToolButton_clicked();
135 void mMoveUpToolButton_clicked();
136 void mRemoveToolButton_clicked();
137 void mAddToolButton_clicked();
138 void mEditPushButton_clicked();
139 void mCountToolButton_clicked( bool checked );
140 void mExpressionFilterButton_toggled( bool checked );
141 void mFilterByMapCheckBox_toggled( bool checked );
142 void resetLayers( Qgis::LegendSyncMode mode );
143 void mAddGroupToolButton_clicked();
144 void mLayerExpressionButton_clicked();
145
146 void mFilterLegendByAtlasCheckBox_toggled( bool checked );
147
148 void selectedChanged( const QModelIndex &current, const QModelIndex &previous );
149
150 void setLegendMapViewData();
151
152 void expandLegendTree();
153 void collapseLegendTree();
154
155 private slots:
157 void setGuiElements();
158
160 void updateFilterLegendByAtlasButton();
161
162 void mItemTreeView_doubleClicked( const QModelIndex &index );
163 void titleFontChanged();
164 void groupFontChanged();
165 void layerFontChanged();
166 void itemFontChanged();
167
168 void titleAlignmentChanged();
169 void groupAlignmentChanged();
170 void subgroupAlignmentChanged();
171 void itemAlignmentChanged();
172 void arrangementChanged();
173
174 void spaceBelowSubGroupHeadingChanged( double space );
175 void spaceBelowGroupHeadingChanged( double space );
176
177 void spaceGroupSideChanged( double space );
178 void spaceSubGroupSideChanged( double space );
179
180 void spaceSymbolSideChanged( double space );
181
182 private:
183 QgsLayoutLegendWidget() = delete;
184 void blockAllSignals( bool b );
185
186 QPointer<QgsLayoutItemLegend> mLegend;
187 QgsMapCanvas *mMapCanvas = nullptr;
188 QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
189
190 QgsLegendLayerTreeProxyModel *mLegendProxyModel = nullptr;
191
192 QPointer<QgsLayoutLegendMapFilteringWidget> mMapFilteringWidget;
193};
194
202class GUI_EXPORT QgsLayoutLegendMenuProvider : public QgsLayerTreeViewMenuProvider
203{
204 public:
206 QgsLayoutLegendMenuProvider( QgsLayerTreeView *view, QgsLayoutLegendWidget *w );
207
208 QMenu *createContextMenu() override;
209
210 protected:
211 QgsLayerTreeView *mView = nullptr;
212 QgsLayoutLegendWidget *mWidget = nullptr;
213};
214
215#include "ui_qgslayoutlegendnodewidgetbase.h"
216
224class GUI_EXPORT QgsLayoutLegendNodeWidget : public QgsPanelWidget, private Ui::QgsLayoutLegendNodeWidgetBase
225{
226 Q_OBJECT
227
228 public:
229 QgsLayoutLegendNodeWidget( QgsLayoutItemLegend *legend, QgsLayerTreeNode *node, QgsLayerTreeModelLegendNode *legendNode, int originalLegendNodeIndex, QWidget *parent = nullptr );
230
231 void setDockMode( bool dockMode ) override;
232
233 private slots:
234
235 void labelChanged();
236 void patchChanged();
237 void insertExpression();
238 void sizeChanged( double );
239 void customSymbolChanged();
240 void colorRampLegendChanged();
241 void columnBreakToggled( bool checked );
242 void columnSplitChanged();
243
244 private:
245 QgsLayoutItemLegend *mLegend = nullptr;
246 QgsLayerTreeNode *mNode = nullptr;
247 QgsLayerTreeLayer *mLayer = nullptr;
248 QgsLayerTreeModelLegendNode *mLegendNode = nullptr;
249 int mOriginalLegendNodeIndex = -1;
250};
251
252
260class GUI_EXPORT QgsLayoutLegendMapFilteringModel : public QSortFilterProxyModel
261{
262 Q_OBJECT
263
264 public:
266 explicit QgsLayoutLegendMapFilteringModel( QgsLayoutItemLegend *legend, QgsLayoutModel *layoutModel, QObject *parent = nullptr );
267
268 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
269 QVariant data( const QModelIndex &index, int role ) const override;
270 bool setData( const QModelIndex &index, const QVariant &value, int role ) override;
271 Qt::ItemFlags flags( const QModelIndex &index ) const override;
272
273 protected:
274 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
275
276 private:
277 QgsLayoutModel *mLayoutModel = nullptr;
278 QPointer<QgsLayoutItemLegend> mLegendItem;
279};
280
288class GUI_EXPORT QgsLayoutLegendMapFilteringWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayoutLegendMapFilteringWidgetBase
289{
290 Q_OBJECT
291
292 public:
294 explicit QgsLayoutLegendMapFilteringWidget( QgsLayoutItemLegend *legend );
295
296 protected:
297 bool setNewItem( QgsLayoutItem *item ) final;
298
299 private slots:
300 void updateGuiElements();
301
302 private:
303 QPointer<QgsLayoutItemLegend> mLegendItem;
304 bool mBlockUpdates = false;
305};
306
308
309#endif //QGSLAYOUTLEGENDWIDGET_H
LegendSyncMode
Legend synchronization mode.
Definition qgis.h:4702
@ AllProjectLayers
Synchronize to all project layers.
Definition qgis.h:4703
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:52