QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgslayoutitemwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemwidget.h
3 ------------------------
4 Date : July 2017
5 Copyright : (C) 2017 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSLAYOUTITEMWIDGET_H
16#define QGSLAYOUTITEMWIDGET_H
17
18#include "qgis_gui.h"
19#include "qgslayoutobject.h"
20#include "qgspanelwidget.h"
21#include "qgslayoutitem.h"
22#include "ui_qgslayoutitemwidgetbase.h"
23#include <QObject>
24#include <QPointer>
25
28class QgsLayoutAtlas;
30
31// NOTE - the inheritance here is tricky, as we need to avoid the multiple inheritance
32// diamond problem and the ideal base object (QgsLayoutConfigObject) MUST be a QObject
33// because of its slots.
34
35// So here we go:
36// QgsLayoutItemWidget is just a QWidget which is embedded inside specific item property
37// widgets and contains common settings like position and rotation of the items. While the
38// actual individual item type widgets MUST be QgsPanelWidgets unfortunately QgsLayoutItemWidget
39// CANNOT be a QgsPanelWidget and must instead be a generic QWidget (otherwise a QgsPanelWidget
40// contains a child QgsPanelWidget, which breaks lots of assumptions made in QgsPanelWidget
41// and related classes).
42// So QgsLayoutItemWidget HAS a QgsLayoutConfigObject to handle these common tasks.
43// Specific item property widgets (e.g., QgsLayoutMapWidget) should inherit from QgsLayoutItemBaseWidget
44// (which is a QgsPanelWidget) and also HAS a QgsLayoutConfigObject, with protected methods
45// which are just proxied through to the QgsLayoutConfigObject.
46// phew!
47// long story short - don't change this without good reason. If you add a new item type, inherit
48// from QgsLayoutItemBaseWidget and trust that everything else has been done for you.
49
61class GUI_EXPORT QgsLayoutConfigObject: public QObject
62{
63 Q_OBJECT
64 public:
65
69 QgsLayoutConfigObject( QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject );
70
75 void initializeDataDefinedButton( QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty key );
76
80 void updateDataDefinedButton( QgsPropertyOverrideButton *button );
81
85 QgsVectorLayer *coverageLayer() const;
86
88 QgsLayoutAtlas *layoutAtlas() const;
89
97 void setObject( QgsLayoutObject *object ) SIP_SKIP;
98
99 private slots:
101 void updateDataDefinedProperty();
102
104 void updateDataDefinedButtons();
105
106 private:
107
108 QPointer< QgsLayoutObject > mLayoutObject;
109};
110
121{
122 Q_OBJECT
123
124 public:
125
129 QgsLayoutItemBaseWidget( QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject );
130
134 QgsLayoutObject *layoutObject();
135
144 bool setItem( QgsLayoutItem *item );
145
152 virtual void setReportTypeString( const QString &string );
153
160 virtual void setDesignerInterface( QgsLayoutDesignerInterface *iface );
161
167 virtual void setMasterLayout( QgsMasterLayoutInterface *masterLayout );
168
169 protected:
170
175 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property );
176
180 void updateDataDefinedButton( QgsPropertyOverrideButton *button );
181
185 QgsVectorLayer *coverageLayer() const;
186
196 virtual bool setNewItem( QgsLayoutItem *item );
197
199 QgsLayoutAtlas *layoutAtlas() const;
200
201 private:
202 QgsLayoutConfigObject *mConfigObject = nullptr;
203
204 QgsLayoutObject *mObject = nullptr;
205};
206
207
214class GUI_EXPORT QgsLayoutItemPropertiesWidget: public QWidget, private Ui::QgsLayoutItemWidgetBase
215{
216 Q_OBJECT
217 public:
218
222 QgsLayoutItemPropertiesWidget( QWidget *parent, QgsLayoutItem *item );
223
225 QgsLayoutItem::ReferencePoint positionMode() const;
226
228 void showBackgroundGroup( bool showGroup );
229
231 void showFrameGroup( bool showGroup );
232
234 void setItem( QgsLayoutItem *item );
235
241 void setMasterLayout( QgsMasterLayoutInterface *masterLayout );
242
248 void updateVariables();
249
250 protected slots:
252 void initializeDataDefinedButtons();
254 void populateDataDefinedButtons();
255
256 private slots:
257
261 void mFrameColorButton_colorChanged( const QColor &newFrameColor );
262
266 void mBackgroundColorButton_colorChanged( const QColor &newBackgroundColor );
267// void on_mTransparencySlider_valueChanged( int value );
268// void on_mTransparencySpinBox_valueChanged( int value );
269 void mStrokeWidthSpinBox_valueChanged( double d );
270 void strokeUnitChanged( Qgis::LayoutUnit unit );
271 void mFrameGroupBox_toggled( bool state );
272 void mFrameJoinStyleCombo_currentIndexChanged( int index );
273 void mBackgroundGroupBox_toggled( bool state );
274 void mItemIdLineEdit_editingFinished();
275 void exportGroupNameEditingFinished();
276
277 //adjust coordinates in line edits
278 void mPageSpinBox_valueChanged( int );
279 void mXPosSpin_valueChanged( double );
280 void mYPosSpin_valueChanged( double );
281 void positionUnitsChanged( Qgis::LayoutUnit unit );
282 void mWidthSpin_valueChanged( double );
283 void mHeightSpin_valueChanged( double );
284 void sizeUnitsChanged( Qgis::LayoutUnit unit );
285
286 void mUpperLeftCheckBox_stateChanged( bool state );
287 void mUpperMiddleCheckBox_stateChanged( bool state );
288 void mUpperRightCheckBox_stateChanged( bool state );
289 void mMiddleLeftCheckBox_stateChanged( bool state );
290 void mMiddleCheckBox_stateChanged( bool state );
291 void mMiddleRightCheckBox_stateChanged( bool state );
292 void mLowerLeftCheckBox_stateChanged( bool state );
293 void mLowerMiddleCheckBox_stateChanged( bool state );
294 void mLowerRightCheckBox_stateChanged( bool state );
295
296 void mBlendModeCombo_currentIndexChanged( int index );
297 void opacityChanged( double value );
298
299 void mItemRotationSpinBox_valueChanged( double val );
300 void mExcludeFromPrintsCheckBox_toggled( bool checked );
301
302 void setValuesForGuiElements();
303 //sets the values for all position related (x, y, width, height) elements
304 void setValuesForGuiPositionElements();
305 //sets the values for all non-position related elements
306 void setValuesForGuiNonPositionElements();
307
308 void variablesChanged();
309
310 private:
311
312 QPointer< QgsLayoutItem > mItem;
313 QgsLayoutConfigObject *mConfigObject = nullptr;
314
315 bool mFreezeXPosSpin = false;
316 bool mFreezeYPosSpin = false;
317 bool mFreezeWidthSpin = false;
318 bool mFreezeHeightSpin = false;
319 bool mFreezePageSpin = false;
320 bool mBlockVariableUpdates = false;
321// void changeItemTransparency( int value );
322 void changeItemPosition();
323 void changeItemReference( QgsLayoutItem::ReferencePoint point );
324 void changeItemSize();
325
326};
327
328
329#endif // QGSLAYOUTITEMWIDGET_H
LayoutUnit
Layout measurement units.
Definition qgis.h:4859
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
An object for property widgets for layout items.
A common interface for layout designer dialogs and widgets.
A base class for property widgets for layout items.
A widget for controlling the common properties of layout items (e.g.
Base class for graphical items within a QgsLayout.
ReferencePoint
Fixed position reference point.
A base class for objects which belong to a layout.
DataDefinedProperty
Data defined properties for different item types.
Interface for master layout type objects, such as print layouts and reports.
Base class for any widget that can be shown as a inline panel.
A button for controlling property overrides which may apply to a widget.
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126