QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgslayoutlabelwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutlabelwidget.cpp
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 #include "qgslayoutlabelwidget.h"
19 #include "qgslayoutitemlabel.h"
20 #include "qgslayout.h"
22 #include "qgsguiutils.h"
23 #include "qgslayoutitemmap.h"
24 #include "qgsvectorlayer.h"
25 #include "qgsprojoperation.h"
26 
27 #include <QColorDialog>
28 #include <QFontDialog>
29 #include <QWidget>
30 #include <QAction>
31 #include <QMenu>
32 
34  : QgsLayoutItemBaseWidget( nullptr, label )
35  , mLabel( label )
36 {
37  Q_ASSERT( mLabel );
38 
39  setupUi( this );
40  connect( mHtmlCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutLabelWidget::mHtmlCheckBox_stateChanged );
41  connect( mTextEdit, &QPlainTextEdit::textChanged, this, &QgsLayoutLabelWidget::mTextEdit_textChanged );
42  connect( mInsertExpressionButton, &QPushButton::clicked, this, &QgsLayoutLabelWidget::mInsertExpressionButton_clicked );
43  connect( mMarginXDoubleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutLabelWidget::mMarginXDoubleSpinBox_valueChanged );
44  connect( mMarginYDoubleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutLabelWidget::mMarginYDoubleSpinBox_valueChanged );
45  connect( mCenterRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::mCenterRadioButton_clicked );
46  connect( mLeftRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::mLeftRadioButton_clicked );
47  connect( mRightRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::mRightRadioButton_clicked );
48  connect( mTopRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::mTopRadioButton_clicked );
49  connect( mBottomRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::mBottomRadioButton_clicked );
50  connect( mMiddleRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::mMiddleRadioButton_clicked );
51  setPanelTitle( tr( "Label Properties" ) );
52 
53  mFontButton->setMode( QgsFontButton::ModeTextRenderer );
54  mFontButton->setDialogTitle( tr( "Label Font" ) );
55  mFontButton->registerExpressionContextGenerator( this );
56 
57  //add widget for general composer item properties
58  mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, label );
59  mainLayout->addWidget( mItemPropertiesWidget );
60 
61  mMarginXDoubleSpinBox->setClearValue( 0.0 );
62  mMarginYDoubleSpinBox->setClearValue( 0.0 );
63 
64  setGuiElementValues();
65  connect( mLabel, &QgsLayoutObject::changed, this, &QgsLayoutLabelWidget::setGuiElementValues );
66 
67  connect( mFontButton, &QgsFontButton::changed, this, &QgsLayoutLabelWidget::fontChanged );
68  connect( mJustifyRadioButton, &QRadioButton::clicked, this, &QgsLayoutLabelWidget::justifyClicked );
69 
70  mDynamicTextMenu = new QMenu( this );
71  mDynamicTextButton->setMenu( mDynamicTextMenu );
72 
73  connect( mDynamicTextMenu, &QMenu::aboutToShow, this, [ = ]
74  {
75  mDynamicTextMenu->clear();
76  if ( mLabel->layout() )
77  {
78  // we need to rebuild this on each show, as the content varies depending on other available items...
79  buildInsertDynamicTextMenu( mLabel->layout(), mDynamicTextMenu, [ = ]( const QString & expression )
80  {
81  mLabel->beginCommand( tr( "Insert dynamic text" ) );
82  mTextEdit->insertPlainText( "[%" + expression + "%]" );
83  mLabel->endCommand();
84  } );
85  }
86  } );
87 
88  QMenu *expressionMenu = new QMenu( this );
89  QAction *convertToStaticAction = new QAction( tr( "Convert to Static Text" ), this );
90  expressionMenu->addAction( convertToStaticAction );
91  connect( convertToStaticAction, &QAction::triggered, mLabel, &QgsLayoutItemLabel::convertToStaticText );
92  mInsertExpressionButton->setMenu( expressionMenu );
93 
94  mFontButton->setLayer( coverageLayer() );
95  if ( mLabel->layout() )
96  {
97  connect( &mLabel->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, mFontButton, &QgsFontButton::setLayer );
98  }
99 }
100 
102 {
103  if ( mItemPropertiesWidget )
104  mItemPropertiesWidget->setMasterLayout( masterLayout );
105 }
106 
108 {
109  return mLabel->createExpressionContext();
110 }
111 
112 void QgsLayoutLabelWidget::buildInsertDynamicTextMenu( QgsLayout *layout, QMenu *menu, const std::function<void ( const QString & )> &callback )
113 {
114  Q_ASSERT( layout );
115  auto addExpression = [&callback]( QMenu * menu, const QString & name, const QString & expression )
116  {
117  QAction *action = new QAction( name, menu );
118  connect( action, &QAction::triggered, action, [callback, expression]
119  {
120  callback( expression );
121  } );
122  menu->addAction( action );
123  };
124 
125  QMenu *dateMenu = new QMenu( tr( "Current Date" ), menu );
126  for ( const std::pair< QString, QString > &expression :
127  {
128  std::make_pair( tr( "ISO Format (%1)" ).arg( QDateTime::currentDateTime().toString( QStringLiteral( "yyyy-MM-dd" ) ) ), QStringLiteral( "format_date(now(), 'yyyy-MM-dd')" ) ),
129  std::make_pair( tr( "Day/Month/Year (%1)" ).arg( QDateTime::currentDateTime().toString( QStringLiteral( "dd/MM/yyyy" ) ) ), QStringLiteral( "format_date(now(), 'dd/MM/yyyy')" ) ),
130  std::make_pair( tr( "Month/Day/Year (%1)" ).arg( QDateTime::currentDateTime().toString( QStringLiteral( "MM/dd/yyyy" ) ) ), QStringLiteral( "format_date(now(), 'MM/dd/yyyy')" ) ),
131  } )
132  {
133  addExpression( dateMenu, expression.first, expression.second );
134  }
135  menu->addMenu( dateMenu );
136 
137  QMenu *mapsMenu = new QMenu( tr( "Map Properties" ), menu );
138  QList< QgsLayoutItemMap * > maps;
139  layout->layoutItems( maps );
140  for ( QgsLayoutItemMap *map : std::as_const( maps ) )
141  {
142  // these expressions require the map to have a non-empty ID set
143  if ( map->id().isEmpty() )
144  continue;
145 
146  QMenu *mapMenu = new QMenu( map->displayName(), mapsMenu );
147  for ( const std::pair< QString, QString > &expression :
148  {
149  std::make_pair( tr( "Scale (%1)" ).arg( map->scale() ), QStringLiteral( "item_variables('%1')['map_scale']" ).arg( map->id() ) ),
150  std::make_pair( tr( "Rotation (%1)" ).arg( map->rotation() ), QStringLiteral( "item_variables('%1')['map_rotation']" ).arg( map->id() ) ),
151  } )
152  {
153  addExpression( mapMenu, expression.first, expression.second );
154  }
155  mapMenu->addSeparator();
156  for ( const std::pair< QString, QString > &expression :
157  {
158  std::make_pair( tr( "CRS Identifier (%1)" ).arg( map->crs().authid() ), QStringLiteral( "item_variables('%1')['map_crs']" ).arg( map->id() ) ),
159  std::make_pair( tr( "CRS Name (%1)" ).arg( map->crs().description() ), QStringLiteral( "item_variables('%1')['map_crs_description']" ).arg( map->id() ) ),
160  std::make_pair( tr( "Ellipsoid Name (%1)" ).arg( map->crs().ellipsoidAcronym() ), QStringLiteral( "item_variables('%1')['map_crs_ellipsoid']" ).arg( map->id() ) ),
161  std::make_pair( tr( "Units (%1)" ).arg( QgsUnitTypes::toString( map->crs().mapUnits() ) ), QStringLiteral( "item_variables('%1')['map_units']" ).arg( map->id() ) ),
162  std::make_pair( tr( "Projection (%1)" ).arg( map->crs().operation().description() ), QStringLiteral( "item_variables('%1')['map_crs_projection']" ).arg( map->id() ) ),
163  } )
164  {
165  addExpression( mapMenu, expression.first, expression.second );
166  }
167  mapMenu->addSeparator();
168 
169  const QgsRectangle mapExtent = map->extent();
170  const QgsPointXY center = mapExtent.center();
171  for ( const std::pair< QString, QString > &expression :
172  {
173  std::make_pair( tr( "Center (X) (%1)" ).arg( center.x() ), QStringLiteral( "x(item_variables('%1')['map_extent_center'])" ).arg( map->id() ) ),
174  std::make_pair( tr( "Center (Y) (%1)" ).arg( center.y() ), QStringLiteral( "y(item_variables('%1')['map_extent_center'])" ).arg( map->id() ) ),
175  std::make_pair( tr( "X Minimum (%1)" ).arg( mapExtent.xMinimum() ), QStringLiteral( "x_min(item_variables('%1')['map_extent'])" ).arg( map->id() ) ),
176  std::make_pair( tr( "Y Minimum (%1)" ).arg( mapExtent.yMinimum() ), QStringLiteral( "y_min(item_variables('%1')['map_extent'])" ).arg( map->id() ) ),
177  std::make_pair( tr( "X Maximum (%1)" ).arg( mapExtent.xMaximum() ), QStringLiteral( "x_max(item_variables('%1')['map_extent'])" ).arg( map->id() ) ),
178  std::make_pair( tr( "Y Maximum (%1)" ).arg( mapExtent.yMaximum() ), QStringLiteral( "y_max(item_variables('%1')['map_extent'])" ).arg( map->id() ) ),
179  } )
180  {
181  addExpression( mapMenu, expression.first, expression.second );
182  }
183  mapMenu->addSeparator();
184  for ( const std::pair< QString, QString > &expression :
185  {
186  std::make_pair( tr( "Layer Credits" ), QStringLiteral( "array_to_string(map_credits('%1'))" ).arg( map->id() ) ),
187  } )
188  {
189  addExpression( mapMenu, expression.first, expression.second );
190  }
191  mapsMenu->addMenu( mapMenu );
192  }
193  menu->addMenu( mapsMenu );
194  menu->addSeparator();
195 
196  if ( layout->reportContext().layer() )
197  {
198  const QgsFields fields = layout->reportContext().layer()->fields();
199 
200  QMenu *fieldsMenu = new QMenu( tr( "Field" ), menu );
201  for ( const QgsField &field : fields )
202  {
203  addExpression( fieldsMenu, field.displayName(), QStringLiteral( "\"%1\"" ).arg( field.name() ) );
204  }
205 
206  menu->addMenu( fieldsMenu );
207  menu->addSeparator();
208  }
209 
210  for ( const std::pair< QString, QString > &expression :
211  {
212  std::make_pair( tr( "Layout Name" ), QStringLiteral( "@layout_name" ) ),
213  std::make_pair( tr( "Layout Page Number" ), QStringLiteral( "@layout_page" ) ),
214  std::make_pair( tr( "Layout Page Count" ), QStringLiteral( "@layout_numpages" ) )
215  } )
216  {
217  addExpression( menu, expression.first, expression.second );
218  }
219  menu->addSeparator();
220  for ( const std::pair< QString, QString > &expression :
221  {
222  std::make_pair( tr( "Project Author" ), QStringLiteral( "@project_author" ) ),
223  std::make_pair( tr( "Project Title" ), QStringLiteral( "@project_title" ) ),
224  std::make_pair( tr( "Project Path" ), QStringLiteral( "@project_path" ) )
225  } )
226  {
227  addExpression( menu, expression.first, expression.second );
228  }
229  menu->addSeparator();
230  for ( const std::pair< QString, QString > &expression :
231  {
232  std::make_pair( tr( "Current User Name" ), QStringLiteral( "@user_full_name" ) ),
233  std::make_pair( tr( "Current User Account" ), QStringLiteral( "@user_account_name" ) )
234  } )
235  {
236  addExpression( menu, expression.first, expression.second );
237  }
238 }
239 
241 {
242  if ( item->type() != QgsLayoutItemRegistry::LayoutLabel )
243  return false;
244 
245  if ( mLabel )
246  {
247  disconnect( mLabel, &QgsLayoutObject::changed, this, &QgsLayoutLabelWidget::setGuiElementValues );
248  }
249 
250  mLabel = qobject_cast< QgsLayoutItemLabel * >( item );
251  mItemPropertiesWidget->setItem( mLabel );
252 
253  if ( mLabel )
254  {
255  connect( mLabel, &QgsLayoutObject::changed, this, &QgsLayoutLabelWidget::setGuiElementValues );
256  }
257 
258  setGuiElementValues();
259 
260  return true;
261 }
262 
263 void QgsLayoutLabelWidget::mHtmlCheckBox_stateChanged( int state )
264 {
265  if ( mLabel )
266  {
267  mVerticalAlignementLabel->setDisabled( state );
268  mTopRadioButton->setDisabled( state );
269  mMiddleRadioButton->setDisabled( state );
270  mBottomRadioButton->setDisabled( state );
271 
272  mLabel->beginCommand( tr( "Change Label Mode" ) );
273  mLabel->blockSignals( true );
274  mLabel->setMode( state ? QgsLayoutItemLabel::ModeHtml : QgsLayoutItemLabel::ModeFont );
275  mLabel->setText( mTextEdit->toPlainText() );
276  mLabel->update();
277  mLabel->blockSignals( false );
278  mLabel->endCommand();
279  }
280 }
281 
282 void QgsLayoutLabelWidget::mTextEdit_textChanged()
283 {
284  if ( mLabel )
285  {
286  mLabel->beginCommand( tr( "Change Label Text" ), QgsLayoutItem::UndoLabelText );
287  mLabel->blockSignals( true );
288  mLabel->setText( mTextEdit->toPlainText() );
289  mLabel->update();
290  mLabel->blockSignals( false );
291  mLabel->endCommand();
292  }
293 }
294 
295 void QgsLayoutLabelWidget::fontChanged()
296 {
297  if ( mLabel )
298  {
299  mLabel->beginCommand( tr( "Change Label Font" ), QgsLayoutItem::UndoLabelFont );
300  mLabel->setTextFormat( mFontButton->textFormat() );
301  mLabel->update();
302  mLabel->endCommand();
303  }
304 }
305 
306 void QgsLayoutLabelWidget::justifyClicked()
307 {
308  if ( mLabel )
309  {
310  mLabel->beginCommand( tr( "Change Label Alignment" ) );
311  mLabel->setHAlign( Qt::AlignJustify );
312  mLabel->update();
313  mLabel->endCommand();
314  }
315 }
316 
317 void QgsLayoutLabelWidget::mMarginXDoubleSpinBox_valueChanged( double d )
318 {
319  if ( mLabel )
320  {
321  mLabel->beginCommand( tr( "Change Label Margin" ), QgsLayoutItem::UndoLabelMargin );
322  mLabel->setMarginX( d );
323  mLabel->update();
324  mLabel->endCommand();
325  }
326 }
327 
328 void QgsLayoutLabelWidget::mMarginYDoubleSpinBox_valueChanged( double d )
329 {
330  if ( mLabel )
331  {
332  mLabel->beginCommand( tr( "Change Label Margin" ), QgsLayoutItem::UndoLabelMargin );
333  mLabel->setMarginY( d );
334  mLabel->update();
335  mLabel->endCommand();
336  }
337 }
338 
339 void QgsLayoutLabelWidget::mInsertExpressionButton_clicked()
340 {
341  if ( !mLabel )
342  {
343  return;
344  }
345 
346  QString selText = mTextEdit->textCursor().selectedText();
347 
348  // html editor replaces newlines with Paragraph Separator characters - see https://github.com/qgis/QGIS/issues/27568
349  selText = selText.replace( QChar( 0x2029 ), QChar( '\n' ) );
350 
351  // edit the selected expression if there's one
352  if ( selText.startsWith( QLatin1String( "[%" ) ) && selText.endsWith( QLatin1String( "%]" ) ) )
353  selText = selText.mid( 2, selText.size() - 4 );
354 
355  // use the atlas coverage layer, if any
356  QgsVectorLayer *layer = coverageLayer();
357 
358  QgsExpressionContext context = mLabel->createExpressionContext();
359  QgsExpressionBuilderDialog exprDlg( layer, selText, this, QStringLiteral( "generic" ), context );
360 
361  exprDlg.setWindowTitle( tr( "Insert Expression" ) );
362  if ( exprDlg.exec() == QDialog::Accepted )
363  {
364  QString expression = exprDlg.expressionText();
365  if ( !expression.isEmpty() )
366  {
367  mLabel->beginCommand( tr( "Insert expression" ) );
368  mTextEdit->insertPlainText( "[%" + expression + "%]" );
369  mLabel->endCommand();
370  }
371  }
372 }
373 
374 void QgsLayoutLabelWidget::mCenterRadioButton_clicked()
375 {
376  if ( mLabel )
377  {
378  mLabel->beginCommand( tr( "Change Label Alignment" ) );
379  mLabel->setHAlign( Qt::AlignHCenter );
380  mLabel->update();
381  mLabel->endCommand();
382  }
383 }
384 
385 void QgsLayoutLabelWidget::mRightRadioButton_clicked()
386 {
387  if ( mLabel )
388  {
389  mLabel->beginCommand( tr( "Change Label Alignment" ) );
390  mLabel->setHAlign( Qt::AlignRight );
391  mLabel->update();
392  mLabel->endCommand();
393  }
394 }
395 
396 void QgsLayoutLabelWidget::mLeftRadioButton_clicked()
397 {
398  if ( mLabel )
399  {
400  mLabel->beginCommand( tr( "Change Label Alignment" ) );
401  mLabel->setHAlign( Qt::AlignLeft );
402  mLabel->update();
403  mLabel->endCommand();
404  }
405 }
406 
407 void QgsLayoutLabelWidget::mTopRadioButton_clicked()
408 {
409  if ( mLabel )
410  {
411  mLabel->beginCommand( tr( "Change Label Alignment" ) );
412  mLabel->setVAlign( Qt::AlignTop );
413  mLabel->update();
414  mLabel->endCommand();
415  }
416 }
417 
418 void QgsLayoutLabelWidget::mBottomRadioButton_clicked()
419 {
420  if ( mLabel )
421  {
422  mLabel->beginCommand( tr( "Change Label Alignment" ) );
423  mLabel->setVAlign( Qt::AlignBottom );
424  mLabel->update();
425  mLabel->endCommand();
426  }
427 }
428 
429 void QgsLayoutLabelWidget::mMiddleRadioButton_clicked()
430 {
431  if ( mLabel )
432  {
433  mLabel->beginCommand( tr( "Change Label Alignment" ) );
434  mLabel->setVAlign( Qt::AlignVCenter );
435  mLabel->update();
436  mLabel->endCommand();
437  }
438 }
439 
440 void QgsLayoutLabelWidget::setGuiElementValues()
441 {
442  blockAllSignals( true );
443  mTextEdit->setPlainText( mLabel->text() );
444  mTextEdit->moveCursor( QTextCursor::End, QTextCursor::MoveAnchor );
445  mMarginXDoubleSpinBox->setValue( mLabel->marginX() );
446  mMarginYDoubleSpinBox->setValue( mLabel->marginY() );
447  mHtmlCheckBox->setChecked( mLabel->mode() == QgsLayoutItemLabel::ModeHtml );
448  mTopRadioButton->setChecked( mLabel->vAlign() == Qt::AlignTop );
449  mMiddleRadioButton->setChecked( mLabel->vAlign() == Qt::AlignVCenter );
450  mBottomRadioButton->setChecked( mLabel->vAlign() == Qt::AlignBottom );
451  mLeftRadioButton->setChecked( mLabel->hAlign() == Qt::AlignLeft );
452  mJustifyRadioButton->setChecked( mLabel->hAlign() == Qt::AlignJustify );
453  mCenterRadioButton->setChecked( mLabel->hAlign() == Qt::AlignHCenter );
454  mRightRadioButton->setChecked( mLabel->hAlign() == Qt::AlignRight );
455  mFontButton->setTextFormat( mLabel->textFormat() );
456  mVerticalAlignementLabel->setDisabled( mLabel->mode() == QgsLayoutItemLabel::ModeHtml );
457  mTopRadioButton->setDisabled( mLabel->mode() == QgsLayoutItemLabel::ModeHtml );
458  mMiddleRadioButton->setDisabled( mLabel->mode() == QgsLayoutItemLabel::ModeHtml );
459  mBottomRadioButton->setDisabled( mLabel->mode() == QgsLayoutItemLabel::ModeHtml );
460 
461  blockAllSignals( false );
462 }
463 
464 void QgsLayoutLabelWidget::blockAllSignals( bool block )
465 {
466  mTextEdit->blockSignals( block );
467  mHtmlCheckBox->blockSignals( block );
468  mMarginXDoubleSpinBox->blockSignals( block );
469  mMarginYDoubleSpinBox->blockSignals( block );
470  mTopRadioButton->blockSignals( block );
471  mMiddleRadioButton->blockSignals( block );
472  mBottomRadioButton->blockSignals( block );
473  mLeftRadioButton->blockSignals( block );
474  mCenterRadioButton->blockSignals( block );
475  mRightRadioButton->blockSignals( block );
476  mJustifyRadioButton->blockSignals( block );
477  mFontButton->blockSignals( block );
478 }
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsPointXY::y
double y
Definition: qgspointxy.h:63
QgsLayoutLabelWidget::setMasterLayout
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
Definition: qgslayoutlabelwidget.cpp:101
qgslayoutlabelwidget.h
QgsLayout::layoutItems
void layoutItems(QList< T * > &itemList) const
Returns a list of layout items of a specific type.
Definition: qgslayout.h:122
QgsRectangle::center
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
Definition: qgsrectangle.h:251
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsRectangle::yMinimum
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Definition: qgsrectangle.h:198
QgsLayoutItemLabel::ModeFont
@ ModeFont
Label displays text rendered using a single font.
Definition: qgslayoutitemlabel.h:45
qgsprojoperation.h
qgslayoutitemlabel.h
field
const QgsField & field
Definition: qgsfield.h:463
QgsLayoutObject::changed
void changed()
Emitted when the object's properties change.
QgsField::name
QString name
Definition: qgsfield.h:60
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsLayoutItemPropertiesWidget
A widget for controlling the common properties of layout items (e.g. position and size,...
Definition: qgslayoutitemwidget.h:217
QgsLayoutItemBaseWidget::coverageLayer
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
Definition: qgslayoutitemwidget.cpp:256
QgsLayoutItemPropertiesWidget::setMasterLayout
void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
Definition: qgslayoutitemwidget.cpp:420
QgsLayoutItem::type
int type() const override
Returns a unique graphics item type identifier.
Definition: qgslayoutitem.cpp:124
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition: qgsvectorlayer.cpp:3436
QgsRectangle::xMaximum
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Definition: qgsrectangle.h:183
QgsLayoutItem::UndoLabelText
@ UndoLabelText
Label text.
Definition: qgslayoutitem.h:247
QgsUnitTypes::toString
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
Definition: qgsunittypes.cpp:199
QgsExpressionBuilderDialog
A generic dialog for building expression strings.
Definition: qgsexpressionbuilderdialog.h:30
QgsLayout::reportContext
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
Definition: qgslayout.cpp:369
QgsLayoutItem::UndoLabelMargin
@ UndoLabelMargin
Label margin.
Definition: qgslayoutitem.h:249
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:112
QgsRectangle::xMinimum
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Definition: qgsrectangle.h:188
QgsLayoutLabelWidget::QgsLayoutLabelWidget
QgsLayoutLabelWidget(QgsLayoutItemLabel *label)
constructor
Definition: qgslayoutlabelwidget.cpp:33
QgsLayoutLabelWidget::buildInsertDynamicTextMenu
static void buildInsertDynamicTextMenu(QgsLayout *layout, QMenu *menu, const std::function< void(const QString &expression) > &callback)
Populates the specified menu with actions reflecting dynamic text expressions applicable for a layout...
Definition: qgslayoutlabelwidget.cpp:112
QgsPanelWidget::setPanelTitle
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
Definition: qgspanelwidget.h:44
qgslayout.h
QgsLayoutItemBaseWidget
A base class for property widgets for layout items. All layout item widgets should inherit from this ...
Definition: qgslayoutitemwidget.h:122
QgsLayoutItemLabel::ModeHtml
@ ModeHtml
Label displays rendered HTML content.
Definition: qgslayoutitemlabel.h:46
qgsvectorlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:317
QgsLayoutItemRegistry::LayoutLabel
@ LayoutLabel
Label item.
Definition: qgslayoutitemregistry.h:349
QgsFontButton::ModeTextRenderer
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
Definition: qgsfontbutton.h:61
QgsRectangle::yMaximum
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Definition: qgsrectangle.h:193
QgsLayoutItemLabel::convertToStaticText
void convertToStaticText()
Converts the label's text() to a static string, by evaluating any expressions included in the text an...
Definition: qgslayoutitemlabel.cpp:571
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsLayoutItem::UndoLabelFont
@ UndoLabelFont
Label font.
Definition: qgslayoutitem.h:248
QgsPointXY::x
double x
Definition: qgspointxy.h:62
QgsFontButton::setLayer
void setLayer(QgsVectorLayer *layer)
Sets a layer to associate with the widget.
Definition: qgsfontbutton.cpp:762
QgsField::displayName
QString displayName() const
Returns the name to use when displaying this field.
Definition: qgsfield.cpp:89
QgsLayoutItemLabel
A layout item subclass for text labels.
Definition: qgslayoutitemlabel.h:36
QgsMasterLayoutInterface
Interface for master layout type objects, such as print layouts and reports.
Definition: qgsmasterlayoutinterface.h:42
qgsguiutils.h
QgsLayoutLabelWidget::setNewItem
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
Definition: qgslayoutlabelwidget.cpp:240
QgsLayoutItemPropertiesWidget::setItem
void setItem(QgsLayoutItem *item)
Sets the layout item.
Definition: qgslayoutitemwidget.cpp:401
QgsLayoutReportContext::layerChanged
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
QgsLayoutReportContext::layer
QgsVectorLayer * layer() const
Returns the vector layer associated with the layout's context.
Definition: qgslayoutreportcontext.cpp:66
qgslayoutitemmap.h
qgsexpressionbuilderdialog.h
QgsFontButton::changed
void changed()
Emitted when the widget's text format settings are changed.
QgsField
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:50
QgsLayoutLabelWidget::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgslayoutlabelwidget.cpp:107