QGIS API Documentation 3.99.0-Master (26c88405ac0)
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:
68
72 QgsLayoutConfigObject( QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject );
73
79
84
89
92
100 void setObject( QgsLayoutObject *object ) SIP_SKIP;
101
102 private slots:
104 void updateDataDefinedProperty();
105
107 void updateDataDefinedButtons();
108
109 private:
110 QPointer<QgsLayoutObject> mLayoutObject;
111};
112
123{
124 Q_OBJECT
125
126 public:
127
132
137
146 bool setItem( QgsLayoutItem *item );
147
154 virtual void setReportTypeString( const QString &string );
155
163
169 virtual void setMasterLayout( QgsMasterLayoutInterface *masterLayout );
170
171 protected:
172
178
183
188
198 virtual bool setNewItem( QgsLayoutItem *item );
199
202
203 private:
204 QgsLayoutConfigObject *mConfigObject = nullptr;
205
206 QgsLayoutObject *mObject = nullptr;
207};
208
209
216class GUI_EXPORT QgsLayoutItemPropertiesWidget : public QWidget, private Ui::QgsLayoutItemWidgetBase
217{
218 Q_OBJECT
219 public:
220
224 QgsLayoutItemPropertiesWidget( QWidget *parent, QgsLayoutItem *item );
225
228
230 void showBackgroundGroup( bool showGroup );
231
233 void showFrameGroup( bool showGroup );
234
236 void setItem( QgsLayoutItem *item );
237
243 void setMasterLayout( QgsMasterLayoutInterface *masterLayout );
244
250 void updateVariables();
251
252 protected slots:
257
258 private slots:
259
263 void mFrameColorButton_colorChanged( const QColor &newFrameColor );
264
268 void mBackgroundColorButton_colorChanged( const QColor &newBackgroundColor );
269 // void on_mTransparencySlider_valueChanged( int value );
270 // void on_mTransparencySpinBox_valueChanged( int value );
271 void mStrokeWidthSpinBox_valueChanged( double d );
272 void strokeUnitChanged( Qgis::LayoutUnit unit );
273 void mFrameGroupBox_toggled( bool state );
274 void mFrameJoinStyleCombo_currentIndexChanged( int index );
275 void mBackgroundGroupBox_toggled( bool state );
276 void mItemIdLineEdit_editingFinished();
277 void exportGroupNameEditingFinished();
278
279 //adjust coordinates in line edits
280 void mPageSpinBox_valueChanged( int );
281 void mXPosSpin_valueChanged( double );
282 void mYPosSpin_valueChanged( double );
283 void positionUnitsChanged( Qgis::LayoutUnit unit );
284 void mWidthSpin_valueChanged( double );
285 void mHeightSpin_valueChanged( double );
286 void sizeUnitsChanged( Qgis::LayoutUnit unit );
287
288 void mUpperLeftCheckBox_stateChanged( bool state );
289 void mUpperMiddleCheckBox_stateChanged( bool state );
290 void mUpperRightCheckBox_stateChanged( bool state );
291 void mMiddleLeftCheckBox_stateChanged( bool state );
292 void mMiddleCheckBox_stateChanged( bool state );
293 void mMiddleRightCheckBox_stateChanged( bool state );
294 void mLowerLeftCheckBox_stateChanged( bool state );
295 void mLowerMiddleCheckBox_stateChanged( bool state );
296 void mLowerRightCheckBox_stateChanged( bool state );
297
298 void mBlendModeCombo_currentIndexChanged( int index );
299 void opacityChanged( double value );
300
301 void mItemRotationSpinBox_valueChanged( double val );
302 void mExcludeFromPrintsCheckBox_toggled( bool checked );
303
304 void setValuesForGuiElements();
305 //sets the values for all position related (x, y, width, height) elements
306 void setValuesForGuiPositionElements();
307 //sets the values for all non-position related elements
308 void setValuesForGuiNonPositionElements();
309
310 void variablesChanged();
311
312 private:
313 QPointer<QgsLayoutItem> mItem;
314 QgsLayoutConfigObject *mConfigObject = nullptr;
315
316 bool mFreezeXPosSpin = false;
317 bool mFreezeYPosSpin = false;
318 bool mFreezeWidthSpin = false;
319 bool mFreezeHeightSpin = false;
320 bool mFreezePageSpin = false;
321 bool mBlockVariableUpdates = false;
322 // void changeItemTransparency( int value );
323 void changeItemPosition();
324 void changeItemReference( QgsLayoutItem::ReferencePoint point );
325 void changeItemSize();
326};
327
328
329#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