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