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