QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "ui_qgslayoutitemwidgetbase.h"
19
20#include "qgis_gui.h"
21#include "qgslayoutitem.h"
22#include "qgslayoutobject.h"
23#include "qgspanelwidget.h"
24
25#include <QObject>
26#include <QPointer>
27
30class QgsLayoutAtlas;
32
33// NOTE - the inheritance here is tricky, as we need to avoid the multiple inheritance
34// diamond problem and the ideal base object (QgsLayoutConfigObject) MUST be a QObject
35// because of its slots.
36
37// So here we go:
38// QgsLayoutItemWidget is just a QWidget which is embedded inside specific item property
39// widgets and contains common settings like position and rotation of the items. While the
40// actual individual item type widgets MUST be QgsPanelWidgets unfortunately QgsLayoutItemWidget
41// CANNOT be a QgsPanelWidget and must instead be a generic QWidget (otherwise a QgsPanelWidget
42// contains a child QgsPanelWidget, which breaks lots of assumptions made in QgsPanelWidget
43// and related classes).
44// So QgsLayoutItemWidget HAS a QgsLayoutConfigObject to handle these common tasks.
45// Specific item property widgets (e.g., QgsLayoutMapWidget) should inherit from QgsLayoutItemBaseWidget
46// (which is a QgsPanelWidget) and also HAS a QgsLayoutConfigObject, with protected methods
47// which are just proxied through to the QgsLayoutConfigObject.
48// phew!
49// long story short - don't change this without good reason. If you add a new item type, inherit
50// from QgsLayoutItemBaseWidget and trust that everything else has been done for you.
51
64class GUI_EXPORT QgsLayoutConfigObject : public QObject
65{
66 Q_OBJECT
67 public:
71 QgsLayoutConfigObject( QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject );
72
78
83
88
91
99 void setObject( QgsLayoutObject *object ) SIP_SKIP;
100
101 private slots:
103 void updateDataDefinedProperty();
104
106 void updateDataDefinedButtons();
107
108 private:
109 QPointer<QgsLayoutObject> mLayoutObject;
110};
111
122{
123 Q_OBJECT
124
125 public:
130
135
144 bool setItem( QgsLayoutItem *item );
145
152 virtual void setReportTypeString( const QString &string );
153
161
167 virtual void setMasterLayout( QgsMasterLayoutInterface *masterLayout );
168
169 protected:
175
180
185
195 virtual bool setNewItem( QgsLayoutItem *item );
196
199
200 private:
201 QgsLayoutConfigObject *mConfigObject = nullptr;
202
203 QgsLayoutObject *mObject = nullptr;
204};
205
206
213class GUI_EXPORT QgsLayoutItemPropertiesWidget : public QWidget, private Ui::QgsLayoutItemWidgetBase
214{
215 Q_OBJECT
216 public:
220 QgsLayoutItemPropertiesWidget( QWidget *parent, QgsLayoutItem *item );
221
224
226 void showBackgroundGroup( bool showGroup );
227
229 void showFrameGroup( bool showGroup );
230
232 void setItem( QgsLayoutItem *item );
233
239 void setMasterLayout( QgsMasterLayoutInterface *masterLayout );
240
246 void updateVariables();
247
248 protected slots:
253
254 private slots:
255
259 void mFrameColorButton_colorChanged( const QColor &newFrameColor );
260
264 void mBackgroundColorButton_colorChanged( const QColor &newBackgroundColor );
265 // void on_mTransparencySlider_valueChanged( int value );
266 // void on_mTransparencySpinBox_valueChanged( int value );
267 void mStrokeWidthSpinBox_valueChanged( double d );
268 void strokeUnitChanged( Qgis::LayoutUnit unit );
269 void mFrameGroupBox_toggled( bool state );
270 void mFrameJoinStyleCombo_currentIndexChanged( int index );
271 void mBackgroundGroupBox_toggled( bool state );
272 void mItemIdLineEdit_editingFinished();
273 void exportGroupNameEditingFinished();
274
275 //adjust coordinates in line edits
276 void mPageSpinBox_valueChanged( int );
277 void mXPosSpin_valueChanged( double );
278 void mYPosSpin_valueChanged( double );
279 void positionUnitsChanged( Qgis::LayoutUnit unit );
280 void mWidthSpin_valueChanged( double );
281 void mHeightSpin_valueChanged( double );
282 void sizeUnitsChanged( Qgis::LayoutUnit unit );
283
284 void mUpperLeftCheckBox_stateChanged( bool state );
285 void mUpperMiddleCheckBox_stateChanged( bool state );
286 void mUpperRightCheckBox_stateChanged( bool state );
287 void mMiddleLeftCheckBox_stateChanged( bool state );
288 void mMiddleCheckBox_stateChanged( bool state );
289 void mMiddleRightCheckBox_stateChanged( bool state );
290 void mLowerLeftCheckBox_stateChanged( bool state );
291 void mLowerMiddleCheckBox_stateChanged( bool state );
292 void mLowerRightCheckBox_stateChanged( bool state );
293
294 void mBlendModeCombo_currentIndexChanged( int index );
295 void opacityChanged( double value );
296
297 void mItemRotationSpinBox_valueChanged( double val );
298 void mExcludeFromPrintsCheckBox_toggled( bool checked );
299
300 void setValuesForGuiElements();
301 //sets the values for all position related (x, y, width, height) elements
302 void setValuesForGuiPositionElements();
303 //sets the values for all non-position related elements
304 void setValuesForGuiNonPositionElements();
305
306 void variablesChanged();
307
308 private:
309 QPointer<QgsLayoutItem> mItem;
310 QgsLayoutConfigObject *mConfigObject = nullptr;
311
312 bool mFreezeXPosSpin = false;
313 bool mFreezeYPosSpin = false;
314 bool mFreezeWidthSpin = false;
315 bool mFreezeHeightSpin = false;
316 bool mFreezePageSpin = false;
317 bool mBlockVariableUpdates = false;
318 // void changeItemTransparency( int value );
319 void changeItemPosition();
320 void changeItemReference( QgsLayoutItem::ReferencePoint point );
321 void changeItemSize();
322};
323
324
325#endif // QGSLAYOUTITEMWIDGET_H
LayoutUnit
Layout measurement units.
Definition qgis.h:5203
Used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
An object for property widgets for layout items.
QgsLayoutAtlas * layoutAtlas() const
Returns the atlas for the layout, if available.
void setObject(QgsLayoutObject *object) SIP_SKIP
Links a new layout object to this QgsLayoutConfigObject.
void initializeDataDefinedButton(QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty key)
Registers a data defined button, setting up its initial value, connections and description.
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a data defined button to reflect the item's current properties.
QgsLayoutConfigObject(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutConfigObject, linked with the specified layoutObject.
A common interface for layout designer dialogs and widgets.
QgsLayoutObject * layoutObject()
Returns the layout object associated with this widget.
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a previously registered data defined button to reflect the item's current properties.
bool setItem(QgsLayoutItem *item)
Sets the current item to show in the widget.
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property)
Registers a data defined button, setting up its initial value, connections and description.
virtual void setDesignerInterface(QgsLayoutDesignerInterface *iface)
Sets the the layout designer interface in which the widget is being shown.
QgsLayoutAtlas * layoutAtlas() const
Returns the atlas for the layout (if available).
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
virtual void setReportTypeString(const QString &string)
Sets the string to use to describe the current report type (e.g.
void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
void populateDataDefinedButtons()
Sets data defined button state to match item.
QgsLayoutItemPropertiesWidget(QWidget *parent, QgsLayoutItem *item)
Constructs a QgsLayoutItemPropertiesWidget with a parent and for the given layout item.
void initializeDataDefinedButtons()
Initializes data defined buttons to current atlas coverage layer.
void showFrameGroup(bool showGroup)
Determines if the frame of the group box shall be shown.
void setItem(QgsLayoutItem *item)
Sets the layout item.
QgsLayoutItem::ReferencePoint positionMode() const
Returns the position mode.
void updateVariables()
Updates the variables widget, refreshing the values of variables shown.
void showBackgroundGroup(bool showGroup)
Determines if the background of the group box shall be shown.
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.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
A button for controlling property overrides which may apply to a widget.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134