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