QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
qgslayoutattributetablewidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutattributetablewidget.cpp
3 ---------------------------------
4 begin : November 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
19
21#include "qgslayout.h"
22#include "qgslayoutatlas.h"
24#include "qgslayoutframe.h"
26#include "qgslayoutitemmap.h"
27#include "qgslayoutitemwidget.h"
31#include "qgsproject.h"
32#include "qgsrelationmanager.h"
33#include "qgsvectorlayer.h"
34
35#include <QString>
36
37#include "moc_qgslayoutattributetablewidget.cpp"
38
39using namespace Qt::StringLiterals;
40
42 : QgsLayoutItemBaseWidget( nullptr, frame ? qobject_cast<QgsLayoutItemAttributeTable *>( frame->multiFrame() ) : nullptr )
43 , mTable( frame ? qobject_cast<QgsLayoutItemAttributeTable *>( frame->multiFrame() ) : nullptr )
44 , mFrame( frame )
45{
46 setupUi( this );
47 connect( mRefreshPushButton, &QPushButton::clicked, this, &QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked );
48 connect( mAttributesPushButton, &QPushButton::clicked, this, &QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked );
49 connect( mMaximumRowsSpinBox, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged );
50 connect( mMarginSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged );
51 connect( mGridStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged );
52 connect( mGridColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutAttributeTableWidget::mGridColorButton_colorChanged );
53 connect( mBackgroundColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged );
54 connect( mDrawHorizontalGrid, &QCheckBox::toggled, this, &QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled );
55 connect( mDrawVerticalGrid, &QCheckBox::toggled, this, &QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled );
56 connect( mShowGridGroupCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, this, &QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled );
57 connect( mShowOnlyVisibleFeaturesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged );
58 connect( mFeatureFilterCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged );
59 connect( mFeatureFilterEdit, &QLineEdit::editingFinished, this, &QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished );
60 connect( mFeatureFilterButton, &QToolButton::clicked, this, &QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked );
61 connect( mHeaderHAlignmentComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged );
62 connect( mHeaderModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged );
63 connect( mWrapStringLineEdit, &QLineEdit::editingFinished, this, &QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished );
64 connect( mAddFramePushButton, &QPushButton::clicked, this, &QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked );
65 connect( mResizeModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged );
66 connect( mSourceComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged );
67 connect( mRelationsComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged );
68 connect( mEmptyModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged );
69 connect( mDrawEmptyCheckBox, &QCheckBox::toggled, this, &QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled );
70 connect( mEmptyMessageLineEdit, &QLineEdit::editingFinished, this, &QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished );
71 connect( mIntersectAtlasCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged );
72 connect( mUniqueOnlyCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged );
73 connect( mEmptyFrameCheckBox, &QCheckBox::toggled, this, &QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled );
74 connect( mHideEmptyBgCheckBox, &QCheckBox::toggled, this, &QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled );
75 connect( mWrapBehaviorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged );
76 connect( mAdvancedCustomizationButton, &QPushButton::clicked, this, &QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked );
77 connect( mUseConditionalStylingCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutAttributeTableWidget::useConditionalStylingChanged );
78 setPanelTitle( tr( "Table Properties" ) );
79
80 mContentFontToolButton->setMode( QgsFontButton::ModeTextRenderer );
81 mHeaderFontToolButton->setMode( QgsFontButton::ModeTextRenderer );
82
83 mContentFontToolButton->registerExpressionContextGenerator( this );
84 mContentFontToolButton->setLayer( mTable->sourceLayer() );
85 mHeaderFontToolButton->registerExpressionContextGenerator( this );
86 mHeaderFontToolButton->setLayer( mTable->sourceLayer() );
87
88 blockAllSignals( true );
89
90 mResizeModeComboBox->addItem( tr( "Use Existing Frames" ), QgsLayoutMultiFrame::UseExistingFrames );
91 mResizeModeComboBox->addItem( tr( "Extend to Next Page" ), QgsLayoutMultiFrame::ExtendToNextPage );
92 mResizeModeComboBox->addItem( tr( "Repeat Until Finished" ), QgsLayoutMultiFrame::RepeatUntilFinished );
93
94 mEmptyModeComboBox->addItem( tr( "Draw Headers Only" ), QgsLayoutTable::HeadersOnly );
95 mEmptyModeComboBox->addItem( tr( "Hide Entire Table" ), QgsLayoutTable::HideTable );
96 mEmptyModeComboBox->addItem( tr( "Show Set Message" ), QgsLayoutTable::ShowMessage );
97
98 mWrapBehaviorComboBox->addItem( tr( "Truncate Text" ), QgsLayoutTable::TruncateText );
99 mWrapBehaviorComboBox->addItem( tr( "Wrap Text" ), QgsLayoutTable::WrapText );
100
101 mHeaderModeComboBox->addItem( tr( "On First Frame" ), QgsLayoutTable::FirstFrame );
102 mHeaderModeComboBox->addItem( tr( "On All Frames" ), QgsLayoutTable::AllFrames );
103 mHeaderModeComboBox->addItem( tr( "No Header" ), QgsLayoutTable::NoHeaders );
104
105 mHeaderHAlignmentComboBox->addItem( tr( "Follow Column Alignment" ), QgsLayoutTable::FollowColumn );
106 mHeaderHAlignmentComboBox->addItem( tr( "Left" ), QgsLayoutTable::HeaderLeft );
107 mHeaderHAlignmentComboBox->addItem( tr( "Center" ), QgsLayoutTable::HeaderCenter );
108 mHeaderHAlignmentComboBox->addItem( tr( "Right" ), QgsLayoutTable::HeaderRight );
109
110 mSourceComboBox->addItem( tr( "Layer Features" ), QgsLayoutItemAttributeTable::LayerAttributes );
111 toggleAtlasSpecificControls( static_cast<bool>( coverageLayer() ) );
112
113 //update relations combo when relations modified in project
114 connect( QgsProject::instance()->relationManager(), &QgsRelationManager::changed, this, &QgsLayoutAttributeTableWidget::updateRelationsCombo );
115
116 mLayerComboBox->setFilters( Qgis::LayerFilter::VectorLayer );
117 connect( mLayerComboBox, &QgsMapLayerComboBox::layerChanged, this, &QgsLayoutAttributeTableWidget::changeLayer );
118
119 mComposerMapComboBox->setCurrentLayout( mTable->layout() );
120 mComposerMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
121 connect( mComposerMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutAttributeTableWidget::composerMapChanged );
122
123 mGridColorButton->setColorDialogTitle( tr( "Select Grid Color" ) );
124 mGridColorButton->setAllowOpacity( true );
125 mGridColorButton->setContext( u"composer"_s );
126 mGridColorButton->setDefaultColor( Qt::black );
127 mBackgroundColorButton->setColorDialogTitle( tr( "Select Background Color" ) );
128 mBackgroundColorButton->setAllowOpacity( true );
129 mBackgroundColorButton->setContext( u"composer"_s );
130 mBackgroundColorButton->setShowNoColor( true );
131 mBackgroundColorButton->setNoColorString( tr( "No Background" ) );
132
133 updateGuiElements();
134
135 if ( mTable )
136 {
137 connect( mTable, &QgsLayoutMultiFrame::changed, this, &QgsLayoutAttributeTableWidget::updateGuiElements );
138
139 // repopulate relations combo box if atlas layer changes
140 connect( &mTable->layout()->reportContext(), &QgsLayoutReportContext::layerChanged, this, &QgsLayoutAttributeTableWidget::atlasToggled );
141
142 if ( QgsLayoutAtlas *atlas = layoutAtlas() )
143 {
144 connect( atlas, &QgsLayoutAtlas::toggled, this, &QgsLayoutAttributeTableWidget::atlasToggled );
145 atlasToggled();
146 }
147
148 mLayerSourceDDBtn->registerExpressionContextGenerator( mTable );
149 }
150
152
153 //embed widget for general options
154 if ( mFrame )
155 {
156 //add widget for general composer item properties
157 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, mFrame );
158 mainLayout->addWidget( mItemPropertiesWidget );
159 }
160
161 connect( mHeaderFontToolButton, &QgsFontButton::changed, this, &QgsLayoutAttributeTableWidget::headerFontChanged );
162 connect( mContentFontToolButton, &QgsFontButton::changed, this, &QgsLayoutAttributeTableWidget::contentFontChanged );
163}
164
166{
167 mIntersectAtlasCheckBox->setText( tr( "Show only features intersecting %1 feature" ).arg( string ) );
168 const int atlasFeatureIndex = mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature );
169 if ( atlasFeatureIndex != -1 )
170 {
171 mSourceComboBox->setItemText( atlasFeatureIndex, tr( "Current %1 Feature" ).arg( string ) );
172 }
173}
174
176{
177 if ( mItemPropertiesWidget )
178 mItemPropertiesWidget->setMasterLayout( masterLayout );
179}
180
182{
183 QgsExpressionContext context;
184
185 // frames include their parent multiframe's context, so prefer that if possible
186 if ( mFrame )
187 context = mFrame->createExpressionContext();
188 else if ( mTable )
189 context = mTable->createExpressionContext();
190
191 auto cellScope = std::make_unique<QgsExpressionContextScope>();
192 cellScope->setVariable( u"row_number"_s, 1, true );
193 cellScope->setVariable( u"column_number"_s, 1, true );
194 context.appendScope( cellScope.release() );
195
196 context.setHighlightedVariables( { u"row_number"_s, u"column_number"_s } );
197
198 return context;
199}
200
202{
203 QgsLayoutFrame *frame = qobject_cast<QgsLayoutFrame *>( item );
204 if ( !frame )
205 return false;
206
207 QgsLayoutMultiFrame *multiFrame = frame->multiFrame();
208 if ( !multiFrame )
209 return false;
210
212 return false;
213
214 if ( mTable )
215 {
216 disconnect( mTable, &QgsLayoutObject::changed, this, &QgsLayoutAttributeTableWidget::updateGuiElements );
217 }
218
219 mTable = qobject_cast<QgsLayoutItemAttributeTable *>( multiFrame );
220 mFrame = frame;
221 mItemPropertiesWidget->setItem( frame );
222
223 if ( mTable )
224 {
225 connect( mTable, &QgsLayoutObject::changed, this, &QgsLayoutAttributeTableWidget::updateGuiElements );
226 }
227
228 updateGuiElements();
229
230 return true;
231}
232
233
234void QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked()
235{
236 if ( !mTable )
237 {
238 return;
239 }
240
241 mTable->refreshAttributes();
242}
243
244void QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked()
245{
246 if ( !mTable )
247 {
248 return;
249 }
250
251 //make deep copy of current columns, so we can restore them in case of cancellation
252 QVector<QgsLayoutTableColumn> currentColumns = mTable->columns();
253 QVector<QgsLayoutTableColumn> currentSortColumns = mTable->sortColumns();
254
255 mTable->beginCommand( tr( "Change Table Attributes" ) );
256
257 //temporarily block updates for the window, to stop table trying to repaint under windows (#11462)
258 window()->setUpdatesEnabled( false );
259
260 QgsLayoutAttributeSelectionDialog d( mTable, mTable->sourceLayer(), this );
261 if ( d.exec() == QDialog::Accepted )
262 {
263 mTable->refreshAttributes();
264 //safe to unblock updates
265 window()->setUpdatesEnabled( true );
266 mTable->update();
267 mTable->endCommand();
268
269 //clear currentColumns to free memory
270 currentColumns.clear();
271 currentSortColumns.clear();
272 }
273 else
274 {
275 //undo changes
276 mTable->setColumns( currentColumns );
277 mTable->setSortColumns( currentSortColumns );
278 window()->setUpdatesEnabled( true );
279 mTable->cancelCommand();
280 }
281}
282
283void QgsLayoutAttributeTableWidget::composerMapChanged( QgsLayoutItem *item )
284{
285 if ( !mTable )
286 {
287 return;
288 }
289
290 mTable->beginCommand( tr( "Change Table Map" ) );
291 mTable->setMap( qobject_cast<QgsLayoutItemMap *>( item ) );
292 mTable->update();
293 mTable->endCommand();
294}
295
296void QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged( int i )
297{
298 if ( !mTable )
299 {
300 return;
301 }
302
303 mTable->beginCommand( tr( "Change Table Rows" ), QgsLayoutMultiFrame::UndoTableMaximumFeatures );
304 mTable->setMaximumNumberOfFeatures( i );
305 mTable->update();
306 mTable->endCommand();
307}
308
309void QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged( double d )
310{
311 if ( !mTable )
312 {
313 return;
314 }
315
316 mTable->beginCommand( tr( "Change Table Margin" ), QgsLayoutMultiFrame::UndoTableMargin );
317 mTable->setCellMargin( d );
318 mTable->endCommand();
319}
320
321void QgsLayoutAttributeTableWidget::headerFontChanged()
322{
323 if ( !mTable )
324 return;
325
326 mTable->beginCommand( tr( "Change Table Text Format" ) );
327 mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
328 mTable->endCommand();
329}
330
331void QgsLayoutAttributeTableWidget::contentFontChanged()
332{
333 if ( !mTable )
334 {
335 return;
336 }
337
338 mTable->beginCommand( tr( "Change Table Text Format" ) );
339 mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
340 mTable->endCommand();
341}
342
343void QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged( double d )
344{
345 if ( !mTable )
346 {
347 return;
348 }
349
350 mTable->beginCommand( tr( "Change Table Line Width" ), QgsLayoutMultiFrame::UndoTableGridStrokeWidth );
351 mTable->setGridStrokeWidth( d );
352 mTable->endCommand();
353}
354
355void QgsLayoutAttributeTableWidget::mGridColorButton_colorChanged( const QColor &newColor )
356{
357 if ( !mTable )
358 {
359 return;
360 }
361
362 mTable->beginCommand( tr( "Change Table Grid Color" ), QgsLayoutMultiFrame::UndoTableGridColor );
363 mTable->setGridColor( newColor );
364 mTable->endCommand();
365}
366
367void QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled( bool state )
368{
369 if ( !mTable )
370 {
371 return;
372 }
373
374 mTable->beginCommand( tr( "Toggle Table Grid" ) );
375 mTable->setHorizontalGrid( state );
376 mTable->endCommand();
377}
378
379void QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled( bool state )
380{
381 if ( !mTable )
382 {
383 return;
384 }
385
386 mTable->beginCommand( tr( "Toggled Table Grid" ) );
387 mTable->setVerticalGrid( state );
388 mTable->endCommand();
389}
390
391void QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled( bool state )
392{
393 if ( !mTable )
394 {
395 return;
396 }
397
398 mTable->beginCommand( tr( "Toggle Table Grid" ) );
399 mTable->setShowGrid( state );
400 mTable->endCommand();
401}
402
403void QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged( const QColor &newColor )
404{
405 if ( !mTable )
406 {
407 return;
408 }
409
410 mTable->beginCommand( tr( "Change Table Color" ), QgsLayoutMultiFrame::UndoTableBackgroundColor );
411 mTable->setBackgroundColor( newColor );
412 mTable->endCommand();
413}
414
415void QgsLayoutAttributeTableWidget::updateGuiElements()
416{
417 if ( !mTable || !mFrame )
418 {
419 return;
420 }
421
422 blockAllSignals( true );
423
424 mSourceComboBox->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
425 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
426
427 //layer combo box
428 if ( mTable->vectorLayer() )
429 {
430 mLayerComboBox->setLayer( mTable->vectorLayer() );
431 if ( mTable->vectorLayer()->geometryType() == Qgis::GeometryType::Null )
432 {
433 //layer has no geometry, so uncheck & disable controls which require geometry
434 mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
435 mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
436 mComposerMapComboBox->setEnabled( false );
437 mComposerMapLabel->setEnabled( false );
438 mIntersectAtlasCheckBox->setEnabled( false );
439 }
440 else
441 {
442 mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
443 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
444 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
445 mIntersectAtlasCheckBox->setEnabled(
446 mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1
447 && mTable->layout()->reportContext().layer()
448 && mTable->layout()->reportContext().layer()->geometryType() != Qgis::GeometryType::Null
449 );
450 }
451 }
452
453 mComposerMapComboBox->setItem( mTable->map() );
454 mMaximumRowsSpinBox->setValue( mTable->maximumNumberOfFeatures() );
455 mMarginSpinBox->setValue( mTable->cellMargin() );
456 mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
457 mGridColorButton->setColor( mTable->gridColor() );
458 mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
459 mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
460 if ( mTable->showGrid() )
461 {
462 mShowGridGroupCheckBox->setChecked( true );
463 }
464 else
465 {
466 mShowGridGroupCheckBox->setChecked( false );
467 }
468 mBackgroundColorButton->setColor( mTable->backgroundColor() );
469
470 mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
471 mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
472
473 if ( mTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
474 {
475 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
476 mComposerMapComboBox->setEnabled( true );
477 mComposerMapLabel->setEnabled( true );
478 }
479 else
480 {
481 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
482 mComposerMapComboBox->setEnabled( false );
483 mComposerMapLabel->setEnabled( false );
484 }
485
486 mUniqueOnlyCheckBox->setChecked( mTable->uniqueRowsOnly() );
487 mIntersectAtlasCheckBox->setChecked( mTable->filterToAtlasFeature() );
488 mFeatureFilterEdit->setText( mTable->featureFilter() );
489 mFeatureFilterCheckBox->setCheckState( mTable->filterFeatures() ? Qt::Checked : Qt::Unchecked );
490 mFeatureFilterEdit->setEnabled( mTable->filterFeatures() );
491 mFeatureFilterButton->setEnabled( mTable->filterFeatures() );
492 mUseConditionalStylingCheckBox->setChecked( mTable->useConditionalStyling() );
493
494 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
495 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
496
497 mEmptyModeComboBox->setCurrentIndex( mEmptyModeComboBox->findData( mTable->emptyTableBehavior() ) );
498 mEmptyMessageLineEdit->setText( mTable->emptyTableMessage() );
499 mEmptyMessageLineEdit->setEnabled( mTable->emptyTableBehavior() == QgsLayoutTable::ShowMessage );
500 mEmptyMessageLabel->setEnabled( mTable->emptyTableBehavior() == QgsLayoutTable::ShowMessage );
501 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
502 mWrapStringLineEdit->setText( mTable->wrapString() );
503 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
504
505 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
506 mAddFramePushButton->setEnabled( mTable->resizeMode() == QgsLayoutMultiFrame::UseExistingFrames );
507
508 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
509 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
510
511 updateDataDefinedButton( mLayerSourceDDBtn );
512
513 toggleSourceControls();
514
515 blockAllSignals( false );
516}
517
518void QgsLayoutAttributeTableWidget::atlasToggled()
519{
520 // display/hide atlas options in source combobox depending on atlas status
521 // if there's no atlas but there IS a coverageLayer, it's a report export and we should enable the controls
522 const bool atlasEnabled = ( layoutAtlas() && layoutAtlas()->enabled() ) || ( !layoutAtlas() && coverageLayer() );
523
524
525 toggleAtlasSpecificControls( atlasEnabled );
526
527 if ( !mTable )
528 return;
529
530 whileBlocking( mSourceComboBox )->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
531
532 if ( !atlasEnabled && mTable->filterToAtlasFeature() )
533 {
534 mTable->setFilterToAtlasFeature( false );
535 }
536}
537
538void QgsLayoutAttributeTableWidget::updateRelationsCombo()
539{
540 mRelationsComboBox->blockSignals( true );
541 mRelationsComboBox->clear();
542
543 QgsVectorLayer *atlasLayer = coverageLayer();
544 if ( atlasLayer )
545 {
546 const QList<QgsRelation> relations = QgsProject::instance()->relationManager()->referencedRelations( atlasLayer );
547 for ( const QgsRelation &relation : relations )
548 {
549 mRelationsComboBox->addItem( relation.name(), relation.id() );
550 }
551 if ( mTable )
552 {
553 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
554 }
555 }
556
557 mRelationsComboBox->blockSignals( false );
558}
559
560void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls( const bool atlasEnabled )
561{
562 if ( !atlasEnabled )
563 {
564 if ( mTable->source() == QgsLayoutItemAttributeTable::AtlasFeature )
565 {
567 }
568 mSourceComboBox->removeItem( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) );
569 mSourceComboBox->removeItem( mSourceComboBox->findData( QgsLayoutItemAttributeTable::RelationChildren ) );
570 mRelationsComboBox->blockSignals( true );
571 mRelationsComboBox->setEnabled( false );
572 mRelationsComboBox->clear();
573 mRelationsComboBox->blockSignals( false );
574 mIntersectAtlasCheckBox->setEnabled( false );
575 }
576 else
577 {
578 if ( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) == -1 )
579 {
580 //add missing atlasfeature option to combobox
581 mSourceComboBox->addItem( tr( "Current Atlas Feature" ), QgsLayoutItemAttributeTable::AtlasFeature );
582 }
583 if ( mSourceComboBox->findData( QgsLayoutItemAttributeTable::RelationChildren ) == -1 )
584 {
585 //add missing relation children option to combobox
586 mSourceComboBox->addItem( tr( "Relation Children" ), QgsLayoutItemAttributeTable::RelationChildren );
587 }
588
589 //add relations for coverage layer
590 updateRelationsCombo();
591 mRelationsComboBox->setEnabled( true );
592 mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != Qgis::GeometryType::Null );
593 }
594}
595
596void QgsLayoutAttributeTableWidget::blockAllSignals( bool b )
597{
598 mSourceComboBox->blockSignals( b );
599 mLayerComboBox->blockSignals( b );
600 mComposerMapComboBox->blockSignals( b );
601 mMaximumRowsSpinBox->blockSignals( b );
602 mMarginSpinBox->blockSignals( b );
603 mGridColorButton->blockSignals( b );
604 mGridStrokeWidthSpinBox->blockSignals( b );
605 mBackgroundColorButton->blockSignals( b );
606 mDrawHorizontalGrid->blockSignals( b );
607 mDrawVerticalGrid->blockSignals( b );
608 mShowGridGroupCheckBox->blockSignals( b );
609 mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
610 mUniqueOnlyCheckBox->blockSignals( b );
611 mIntersectAtlasCheckBox->blockSignals( b );
612 mFeatureFilterEdit->blockSignals( b );
613 mFeatureFilterCheckBox->blockSignals( b );
614 mHeaderHAlignmentComboBox->blockSignals( b );
615 mHeaderModeComboBox->blockSignals( b );
616 mResizeModeComboBox->blockSignals( b );
617 mRelationsComboBox->blockSignals( b );
618 mEmptyModeComboBox->blockSignals( b );
619 mEmptyMessageLineEdit->blockSignals( b );
620 mEmptyFrameCheckBox->blockSignals( b );
621 mHideEmptyBgCheckBox->blockSignals( b );
622 mDrawEmptyCheckBox->blockSignals( b );
623 mWrapStringLineEdit->blockSignals( b );
624 mWrapBehaviorComboBox->blockSignals( b );
625 mContentFontToolButton->blockSignals( b );
626 mHeaderFontToolButton->blockSignals( b );
627}
628
629void QgsLayoutAttributeTableWidget::setMaximumNumberOfFeatures( int n )
630{
631 whileBlocking( mMaximumRowsSpinBox )->setValue( n );
632}
633
634void QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged( int state )
635{
636 if ( !mTable )
637 {
638 return;
639 }
640
641 mTable->beginCommand( tr( "Toggle Visible Features Only" ) );
642 const bool showOnlyVisibleFeatures = ( state == Qt::Checked );
643 mTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
644 mTable->update();
645 mTable->endCommand();
646
647 //enable/disable map combobox based on state of checkbox
648 mComposerMapComboBox->setEnabled( state == Qt::Checked );
649 mComposerMapLabel->setEnabled( state == Qt::Checked );
650}
651
652void QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged( int state )
653{
654 if ( !mTable )
655 {
656 return;
657 }
658
659 mTable->beginCommand( tr( "Toggle Table Filter Duplicates" ) );
660 mTable->setUniqueRowsOnly( state == Qt::Checked );
661 mTable->update();
662 mTable->endCommand();
663}
664
665void QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled( bool checked )
666{
667 if ( !mFrame )
668 {
669 return;
670 }
671
672 mFrame->beginCommand( tr( "Toggle Empty Frame Mode" ) );
673 mFrame->setHidePageIfEmpty( checked );
674 mFrame->endCommand();
675}
676
677void QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled( bool checked )
678{
679 if ( !mFrame )
680 {
681 return;
682 }
683
684 mFrame->beginCommand( tr( "Toggle Background Display" ) );
685 mFrame->setHideBackgroundIfEmpty( checked );
686 mFrame->endCommand();
687}
688
689void QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged( int state )
690{
691 if ( !mTable )
692 {
693 return;
694 }
695
696 mTable->beginCommand( tr( "Toggle Table Atlas Filter" ) );
697 const bool filterToAtlas = ( state == Qt::Checked );
698 mTable->setFilterToAtlasFeature( filterToAtlas );
699 mTable->update();
700 mTable->endCommand();
701}
702
703void QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged( int state )
704{
705 if ( !mTable )
706 {
707 return;
708 }
709
710 if ( state == Qt::Checked )
711 {
712 mFeatureFilterEdit->setEnabled( true );
713 mFeatureFilterButton->setEnabled( true );
714 }
715 else
716 {
717 mFeatureFilterEdit->setEnabled( false );
718 mFeatureFilterButton->setEnabled( false );
719 }
720
721 mTable->beginCommand( tr( "Toggle Table Feature Filter" ) );
722 mTable->setFilterFeatures( state == Qt::Checked );
723 mTable->update();
724 mTable->endCommand();
725}
726
727void QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished()
728{
729 if ( !mTable )
730 {
731 return;
732 }
733
734 mTable->beginCommand( tr( "Change Table Feature Filter" ) );
735 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
736 mTable->update();
737 mTable->endCommand();
738}
739
740void QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked()
741{
742 if ( !mTable )
743 {
744 return;
745 }
746
747 const QgsExpressionContext context = mTable->createExpressionContext();
748 QgsExpressionBuilderDialog exprDlg( mTable->sourceLayer(), mFeatureFilterEdit->text(), this, u"generic"_s, context );
749 exprDlg.setWindowTitle( tr( "Expression Based Filter" ) );
750 if ( exprDlg.exec() == QDialog::Accepted )
751 {
752 const QString expression = exprDlg.expressionText();
753 if ( !expression.isEmpty() )
754 {
755 mFeatureFilterEdit->setText( expression );
756 mTable->beginCommand( tr( "Change Table Feature Filter" ) );
757 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
758 mTable->update();
759 mTable->endCommand();
760 }
761 }
762}
763
764void QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged( int )
765{
766 if ( !mTable )
767 {
768 return;
769 }
770
771 mTable->beginCommand( tr( "Change Table Alignment" ) );
772 mTable->setHeaderHAlignment( static_cast<QgsLayoutTable::HeaderHAlignment>( mHeaderHAlignmentComboBox->currentData().toInt() ) );
773 mTable->endCommand();
774}
775
776void QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged( int )
777{
778 if ( !mTable )
779 {
780 return;
781 }
782
783 mTable->beginCommand( tr( "Change Table Header Mode" ) );
784 mTable->setHeaderMode( static_cast<QgsLayoutTable::HeaderMode>( mHeaderModeComboBox->currentData().toInt() ) );
785 mTable->endCommand();
786}
787
788void QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished()
789{
790 if ( !mTable )
791 {
792 return;
793 }
794
795 mTable->beginCommand( tr( "Change Table Wrap String" ) );
796 mTable->setWrapString( mWrapStringLineEdit->text() );
797 mTable->endCommand();
798}
799
800void QgsLayoutAttributeTableWidget::changeLayer( QgsMapLayer *layer )
801{
802 if ( !mTable )
803 {
804 return;
805 }
806
807 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
808 if ( !vl )
809 {
810 return;
811 }
812
813 mTable->beginCommand( tr( "Change Table Layer" ) );
814 mTable->setVectorLayer( vl );
815 mTable->update();
816 mTable->endCommand();
817
818 mContentFontToolButton->setLayer( vl );
819 mHeaderFontToolButton->setLayer( vl );
820
822 {
823 //layer has no geometry, so uncheck & disable controls which require geometry
824 mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
825 mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
826 mComposerMapComboBox->setEnabled( false );
827 mComposerMapLabel->setEnabled( false );
828 mIntersectAtlasCheckBox->setEnabled( false );
829 }
830 else
831 {
832 mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
833 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
834 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
835 mIntersectAtlasCheckBox->setEnabled(
836 mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1
837 && mTable->layout()->reportContext().layer()
838 && mTable->layout()->reportContext().layer()->geometryType() != Qgis::GeometryType::Null
839 );
840 }
841}
842
843void QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked()
844{
845 if ( !mTable || !mFrame )
846 {
847 return;
848 }
849
850 //create a new frame based on the current frame
851 QPointF pos = mFrame->pos();
852 //shift new frame so that it sits 10 units below current frame
853 pos.ry() += mFrame->rect().height() + 10;
854
855 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
856 mTable->recalculateFrameSizes();
857
858 //set new frame as selection
859 if ( QgsLayout *layout = mTable->layout() )
860 {
861 layout->setSelectedItem( newFrame );
862 }
863}
864
865void QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged( int index )
866{
867 if ( !mTable )
868 {
869 return;
870 }
871
872 mTable->beginCommand( tr( "Change Resize Mode" ) );
873 mTable->setResizeMode( static_cast<QgsLayoutMultiFrame::ResizeMode>( mResizeModeComboBox->itemData( index ).toInt() ) );
874 mTable->endCommand();
875
876 mAddFramePushButton->setEnabled( mTable->resizeMode() == QgsLayoutMultiFrame::UseExistingFrames );
877}
878
879void QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged( int index )
880{
881 if ( !mTable )
882 {
883 return;
884 }
885
886 mTable->beginCommand( tr( "Change Table Source" ) );
887 mTable->setSource( static_cast<QgsLayoutItemAttributeTable::ContentSource>( mSourceComboBox->itemData( index ).toInt() ) );
888 mTable->endCommand();
889
890 toggleSourceControls();
891}
892
893void QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged( int index )
894{
895 if ( !mTable )
896 {
897 return;
898 }
899
900 mTable->beginCommand( tr( "Change Table Source Relation" ) );
901 mTable->setRelationId( mRelationsComboBox->itemData( index ).toString() );
902 mTable->endCommand();
903}
904
905void QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged( int index )
906{
907 if ( !mTable )
908 {
909 return;
910 }
911
912 mTable->beginCommand( tr( "Change Empty Table Behavior" ) );
913 mTable->setEmptyTableBehavior( static_cast<QgsLayoutTable::EmptyTableMode>( mEmptyModeComboBox->itemData( index ).toInt() ) );
914 mTable->endCommand();
915 mEmptyMessageLineEdit->setEnabled( mTable->emptyTableBehavior() == QgsLayoutTable::ShowMessage );
916 mEmptyMessageLabel->setEnabled( mTable->emptyTableBehavior() == QgsLayoutTable::ShowMessage );
917}
918
919void QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged( int index )
920{
921 if ( !mTable )
922 {
923 return;
924 }
925
926 mTable->beginCommand( tr( "Change Table Wrap Mode" ) );
927 mTable->setWrapBehavior( static_cast<QgsLayoutTable::WrapBehavior>( mWrapBehaviorComboBox->itemData( index ).toInt() ) );
928 mTable->endCommand();
929}
930
931void QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked()
932{
933 if ( !mTable )
934 {
935 return;
936 }
937
938 QgsLayoutTableBackgroundColorsDialog d( mTable, this );
939 d.exec();
940}
941
942void QgsLayoutAttributeTableWidget::useConditionalStylingChanged( bool checked )
943{
944 if ( !mTable )
945 {
946 return;
947 }
948
949 mTable->beginCommand( tr( "Toggle Table Conditional Styling" ) );
950 mTable->setUseConditionalStyling( checked );
951 mTable->update();
952 mTable->endCommand();
953}
954
955void QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled( bool checked )
956{
957 if ( !mTable )
958 {
959 return;
960 }
961
962 mTable->beginCommand( tr( "Change Show Empty Rows" ) );
963 mTable->setShowEmptyRows( checked );
964 mTable->endCommand();
965}
966
967void QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished()
968{
969 if ( !mTable )
970 {
971 return;
972 }
973
974 mTable->beginCommand( tr( "Change Empty Table Message" ) );
975 mTable->setEmptyTableMessage( mEmptyMessageLineEdit->text() );
976 mTable->endCommand();
977}
978
979void QgsLayoutAttributeTableWidget::toggleSourceControls()
980{
981 switch ( mTable->source() )
982 {
984 mLayerComboBox->setEnabled( true );
985 mLayerComboBox->setVisible( true );
986 mLayerSourceDDBtn->setVisible( true );
987 mLayerLabel->setVisible( true );
988 mRelationsComboBox->setEnabled( false );
989 mRelationsComboBox->setVisible( false );
990 mRelationLabel->setVisible( false );
991 mMaximumRowsSpinBox->setEnabled( true );
992 mMaxNumFeaturesLabel->setEnabled( true );
993 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != Qgis::GeometryType::Null );
994 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
995 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
996 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
997 mIntersectAtlasCheckBox->setEnabled(
998 mTable->vectorLayer()
999 && mTable->vectorLayer()->geometryType() != Qgis::GeometryType::Null
1000 && mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1
1001 && mTable->layout()->reportContext().layer()
1002 && mTable->layout()->reportContext().layer()->geometryType() != Qgis::GeometryType::Null
1003 );
1004 break;
1006 mLayerComboBox->setEnabled( false );
1007 mLayerComboBox->setVisible( false );
1008 mLayerSourceDDBtn->setVisible( false );
1009 mLayerLabel->setVisible( false );
1010 mRelationsComboBox->setEnabled( false );
1011 mRelationsComboBox->setVisible( false );
1012 mRelationLabel->setVisible( false );
1013 mMaximumRowsSpinBox->setEnabled( false );
1014 mMaxNumFeaturesLabel->setEnabled( false );
1015 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() != Qgis::GeometryType::Null );
1016 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() != Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
1017 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1018 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1019 mIntersectAtlasCheckBox->setEnabled( false );
1020 break;
1022 mLayerComboBox->setEnabled( false );
1023 mLayerComboBox->setVisible( false );
1024 mLayerLabel->setVisible( false );
1025 mLayerSourceDDBtn->setVisible( false );
1026 mRelationsComboBox->setEnabled( true );
1027 mRelationsComboBox->setVisible( true );
1028 mRelationLabel->setVisible( true );
1029 mMaximumRowsSpinBox->setEnabled( true );
1030 mMaxNumFeaturesLabel->setEnabled( true );
1031 //it's missing the check for null geometry of the referencing layer
1032 mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
1033 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1034 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1035 mIntersectAtlasCheckBox->setEnabled(
1036 mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1
1037 && mTable->layout()->reportContext().layer()
1038 && mTable->layout()->reportContext().layer()->geometryType() != Qgis::GeometryType::Null
1039 );
1040 break;
1041 }
1042}
@ Null
No geometry.
Definition qgis.h:384
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
void changed()
Emitted when the widget's text format settings are changed.
Used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.
void toggled(bool enabled)
Emitted when atlas is enabled or disabled.
bool enabled() const
Returns whether the atlas generation is enabled.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void setReportTypeString(const QString &string) override
Sets the string to use to describe the current report type (e.g.
QgsLayoutAttributeTableWidget(QgsLayoutFrame *frame)
constructor
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
Base class for frame items, which form a layout multiframe item.
QgsLayoutMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
A layout table subclass that displays attributes from a vector layer.
ContentSource
Specifies the content source for the attribute table.
@ AtlasFeature
Table shows attributes from the current atlas feature.
@ RelationChildren
Table shows attributes from related child features.
@ LayerAttributes
Table shows attributes from features in a vector layer.
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a previously registered data defined button to reflect the item's current properties.
QgsVectorLayer * coverageLayer() const
Returns the current layout context coverage layer (if set).
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property)
Registers a data defined button, setting up its initial value, connections and description.
QgsLayoutAtlas * layoutAtlas() const
Returns the atlas for the layout (if available).
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
A widget for controlling the common properties of layout items (e.g.
@ LayoutAttributeTable
Attribute table.
Base class for graphical items within a QgsLayout.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
virtual int type() const =0
Returns unique multiframe type id.
ResizeMode
Specifies the behavior for creating new frames to fit the multiframe's content.
@ UseExistingFrames
Don't automatically create new frames, just use existing frames.
@ ExtendToNextPage
Creates new full page frames on the following page(s) until the entire multiframe content is visible.
@ UndoTableMaximumFeatures
Maximum features in table.
@ UndoTableBackgroundColor
Table background color.
@ UndoTableGridStrokeWidth
Table grid stroke width.
@ UndoTableGridColor
Table grid color.
@ UndoTableMargin
Table margins.
void changed()
Emitted when the object's properties change.
@ AttributeTableSourceLayer
Attribute table source layer.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
HeaderMode
Controls where headers are shown in the table.
@ FirstFrame
Header shown on first frame only.
@ AllFrames
Headers shown on all frames.
@ NoHeaders
No headers shown for table.
WrapBehavior
Controls how long strings in the table are handled.
@ WrapText
Text which doesn't fit inside the cell is wrapped. Note that this only applies to text in columns wit...
@ TruncateText
Text which doesn't fit inside the cell is truncated.
HeaderHAlignment
Controls how headers are horizontally aligned in a table.
@ HeaderRight
Align headers right.
@ HeaderLeft
Align headers left.
@ HeaderCenter
Align headers to center.
@ FollowColumn
Header uses the same alignment as the column.
EmptyTableMode
Controls how empty tables are displayed.
@ HideTable
Hides entire table if empty.
@ ShowMessage
Shows preset message instead of table contents.
@ HeadersOnly
Show header rows only.
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Interface for master layout type objects, such as print layouts and reports.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
QgsRelationManager * relationManager
Definition qgsproject.h:124
static QgsProject * instance()
Returns the QgsProject singleton instance.
QList< QgsRelation > referencedRelations(const QgsVectorLayer *layer=nullptr) const
Gets all relations where this layer is the referenced part (i.e.
void changed()
Emitted when relations are added or removed to the manager.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition qgis.h:6880