37#include "moc_qgslayoutattributetablewidget.cpp"
39using namespace Qt::StringLiterals;
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 );
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 );
83 mContentFontToolButton->registerExpressionContextGenerator(
this );
84 mContentFontToolButton->setLayer( mTable->sourceLayer() );
85 mHeaderFontToolButton->registerExpressionContextGenerator(
this );
86 mHeaderFontToolButton->setLayer( mTable->sourceLayer() );
88 blockAllSignals(
true );
111 toggleAtlasSpecificControls(
static_cast<bool>(
coverageLayer() ) );
119 mComposerMapComboBox->setCurrentLayout( mTable->layout() );
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" ) );
149 mLayerSourceDDBtn->registerExpressionContextGenerator( mTable );
159 mainLayout->addWidget( mItemPropertiesWidget );
162 connect( mHeaderFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::headerFontChanged );
163 connect( mContentFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::contentFontChanged );
168 mIntersectAtlasCheckBox->setText( tr(
"Show only features intersecting %1 feature" ).arg(
string ) );
170 if ( atlasFeatureIndex != -1 )
172 mSourceComboBox->setItemText( atlasFeatureIndex, tr(
"Current %1 Feature" ).arg(
string ) );
178 if ( mItemPropertiesWidget )
179 mItemPropertiesWidget->setMasterLayout( masterLayout );
188 context = mFrame->createExpressionContext();
190 context = mTable->createExpressionContext();
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 );
220 mTable = qobject_cast<QgsLayoutItemAttributeTable *>( multiFrame );
222 mItemPropertiesWidget->setItem( frame );
235void QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked()
242 mTable->refreshAttributes();
245void QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked()
253 QVector<QgsLayoutTableColumn> currentColumns = mTable->columns();
254 QVector<QgsLayoutTableColumn> currentSortColumns = mTable->sortColumns();
256 mTable->beginCommand( tr(
"Change Table Attributes" ) );
259 window()->setUpdatesEnabled(
false );
261 QgsLayoutAttributeSelectionDialog d( mTable, mTable->sourceLayer(),
this );
262 if ( d.exec() == QDialog::Accepted )
264 mTable->refreshAttributes();
266 window()->setUpdatesEnabled(
true );
268 mTable->endCommand();
271 currentColumns.clear();
272 currentSortColumns.clear();
277 mTable->setColumns( currentColumns );
278 mTable->setSortColumns( currentSortColumns );
279 window()->setUpdatesEnabled(
true );
280 mTable->cancelCommand();
284void QgsLayoutAttributeTableWidget::composerMapChanged(
QgsLayoutItem *item )
291 mTable->beginCommand( tr(
"Change Table Map" ) );
292 mTable->setMap( qobject_cast<QgsLayoutItemMap *>( item ) );
294 mTable->endCommand();
297void QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged(
int i )
305 mTable->setMaximumNumberOfFeatures( i );
307 mTable->endCommand();
310void QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged(
double d )
318 mTable->setCellMargin( d );
319 mTable->endCommand();
322void QgsLayoutAttributeTableWidget::headerFontChanged()
327 mTable->beginCommand( tr(
"Change Table Text Format" ) );
328 mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
329 mTable->endCommand();
332void QgsLayoutAttributeTableWidget::contentFontChanged()
339 mTable->beginCommand( tr(
"Change Table Text Format" ) );
340 mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
341 mTable->endCommand();
344void QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged(
double d )
352 mTable->setGridStrokeWidth( d );
353 mTable->endCommand();
356void QgsLayoutAttributeTableWidget::mGridColorButton_colorChanged(
const QColor &newColor )
364 mTable->setGridColor( newColor );
365 mTable->endCommand();
368void QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled(
bool state )
375 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
376 mTable->setHorizontalGrid( state );
377 mTable->endCommand();
380void QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled(
bool state )
387 mTable->beginCommand( tr(
"Toggled Table Grid" ) );
388 mTable->setVerticalGrid( state );
389 mTable->endCommand();
392void QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled(
bool state )
399 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
400 mTable->setShowGrid( state );
401 mTable->endCommand();
404void QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged(
const QColor &newColor )
412 mTable->setBackgroundColor( newColor );
413 mTable->endCommand();
416void QgsLayoutAttributeTableWidget::updateGuiElements()
418 if ( !mTable || !mFrame )
423 blockAllSignals(
true );
425 mSourceComboBox->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
426 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
429 if ( mTable->vectorLayer() )
431 mLayerComboBox->setLayer( mTable->vectorLayer() );
435 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
436 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
437 mComposerMapComboBox->setEnabled(
false );
438 mComposerMapLabel->setEnabled(
false );
439 mIntersectAtlasCheckBox->setEnabled(
false );
443 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
444 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
445 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
446 mIntersectAtlasCheckBox->setEnabled(
448 && mTable->layout()->reportContext().layer()
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() )
463 mShowGridGroupCheckBox->setChecked(
true );
467 mShowGridGroupCheckBox->setChecked(
false );
469 mBackgroundColorButton->setColor( mTable->backgroundColor() );
471 mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
472 mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
474 if ( mTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
476 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
477 mComposerMapComboBox->setEnabled(
true );
478 mComposerMapLabel->setEnabled(
true );
482 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
483 mComposerMapComboBox->setEnabled(
false );
484 mComposerMapLabel->setEnabled(
false );
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() );
495 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
496 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
498 mEmptyModeComboBox->setCurrentIndex( mEmptyModeComboBox->findData( mTable->emptyTableBehavior() ) );
499 mEmptyMessageLineEdit->setText( mTable->emptyTableMessage() );
502 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
503 mWrapStringLineEdit->setText( mTable->wrapString() );
504 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
506 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
509 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
510 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
514 toggleSourceControls();
516 blockAllSignals(
false );
519void QgsLayoutAttributeTableWidget::atlasToggled()
526 toggleAtlasSpecificControls( atlasEnabled );
531 whileBlocking( mSourceComboBox )->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
533 if ( !atlasEnabled && mTable->filterToAtlasFeature() )
535 mTable->setFilterToAtlasFeature(
false );
539void QgsLayoutAttributeTableWidget::updateRelationsCombo()
541 mRelationsComboBox->blockSignals(
true );
542 mRelationsComboBox->clear();
548 for (
const QgsRelation &relation : relations )
550 mRelationsComboBox->addItem( relation.name(), relation.id() );
554 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
558 mRelationsComboBox->blockSignals(
false );
561void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls(
const bool atlasEnabled )
571 mRelationsComboBox->blockSignals(
true );
572 mRelationsComboBox->setEnabled(
false );
573 mRelationsComboBox->clear();
574 mRelationsComboBox->blockSignals(
false );
575 mIntersectAtlasCheckBox->setEnabled(
false );
591 updateRelationsCombo();
592 mRelationsComboBox->setEnabled(
true );
593 mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() !=
Qgis::GeometryType::Null );
597void QgsLayoutAttributeTableWidget::blockAllSignals(
bool b )
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 );
630void QgsLayoutAttributeTableWidget::setMaximumNumberOfFeatures(
int n )
635void QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged(
int state )
642 mTable->beginCommand( tr(
"Toggle Visible Features Only" ) );
643 const bool showOnlyVisibleFeatures = ( state == Qt::Checked );
644 mTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
646 mTable->endCommand();
649 mComposerMapComboBox->setEnabled( state == Qt::Checked );
650 mComposerMapLabel->setEnabled( state == Qt::Checked );
653void QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged(
int state )
660 mTable->beginCommand( tr(
"Toggle Table Filter Duplicates" ) );
661 mTable->setUniqueRowsOnly( state == Qt::Checked );
663 mTable->endCommand();
666void QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled(
bool checked )
673 mFrame->beginCommand( tr(
"Toggle Empty Frame Mode" ) );
674 mFrame->setHidePageIfEmpty( checked );
675 mFrame->endCommand();
678void QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled(
bool checked )
685 mFrame->beginCommand( tr(
"Toggle Background Display" ) );
686 mFrame->setHideBackgroundIfEmpty( checked );
687 mFrame->endCommand();
690void QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged(
int state )
697 mTable->beginCommand( tr(
"Toggle Table Atlas Filter" ) );
698 const bool filterToAtlas = ( state == Qt::Checked );
699 mTable->setFilterToAtlasFeature( filterToAtlas );
701 mTable->endCommand();
704void QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged(
int state )
711 if ( state == Qt::Checked )
713 mFeatureFilterEdit->setEnabled(
true );
714 mFeatureFilterButton->setEnabled(
true );
718 mFeatureFilterEdit->setEnabled(
false );
719 mFeatureFilterButton->setEnabled(
false );
722 mTable->beginCommand( tr(
"Toggle Table Feature Filter" ) );
723 mTable->setFilterFeatures( state == Qt::Checked );
725 mTable->endCommand();
728void QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished()
735 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
736 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
738 mTable->endCommand();
741void QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked()
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 )
753 const QString expression = exprDlg.expressionText();
754 if ( !expression.isEmpty() )
756 mFeatureFilterEdit->setText( expression );
757 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
758 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
760 mTable->endCommand();
765void QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged(
int )
772 mTable->beginCommand( tr(
"Change Table Alignment" ) );
774 mTable->endCommand();
777void QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged(
int )
784 mTable->beginCommand( tr(
"Change Table Header Mode" ) );
786 mTable->endCommand();
789void QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished()
796 mTable->beginCommand( tr(
"Change Table Wrap String" ) );
797 mTable->setWrapString( mWrapStringLineEdit->text() );
798 mTable->endCommand();
801void QgsLayoutAttributeTableWidget::changeLayer(
QgsMapLayer *layer )
808 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
814 mTable->beginCommand( tr(
"Change Table Layer" ) );
815 mTable->setVectorLayer( vl );
817 mTable->endCommand();
819 mContentFontToolButton->setLayer( vl );
820 mHeaderFontToolButton->setLayer( vl );
825 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
826 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
827 mComposerMapComboBox->setEnabled(
false );
828 mComposerMapLabel->setEnabled(
false );
829 mIntersectAtlasCheckBox->setEnabled(
false );
833 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
834 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
835 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
836 mIntersectAtlasCheckBox->setEnabled(
838 && mTable->layout()->reportContext().layer()
844void QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked()
846 if ( !mTable || !mFrame )
852 QPointF pos = mFrame->pos();
854 pos.ry() += mFrame->rect().height() + 10;
856 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
857 mTable->recalculateFrameSizes();
860 if ( QgsLayout *layout = mTable->layout() )
862 layout->setSelectedItem( newFrame );
866void QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged(
int index )
873 mTable->beginCommand( tr(
"Change Resize Mode" ) );
875 mTable->endCommand();
880void QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged(
int index )
887 mTable->beginCommand( tr(
"Change Table Source" ) );
889 mTable->endCommand();
891 toggleSourceControls();
894void QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged(
int index )
901 mTable->beginCommand( tr(
"Change Table Source Relation" ) );
902 mTable->setRelationId( mRelationsComboBox->itemData( index ).toString() );
903 mTable->endCommand();
906void QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged(
int index )
913 mTable->beginCommand( tr(
"Change Empty Table Behavior" ) );
915 mTable->endCommand();
920void QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged(
int index )
927 mTable->beginCommand( tr(
"Change Table Wrap Mode" ) );
929 mTable->endCommand();
932void QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked()
939 QgsLayoutTableBackgroundColorsDialog d( mTable,
this );
943void QgsLayoutAttributeTableWidget::useConditionalStylingChanged(
bool checked )
950 mTable->beginCommand( tr(
"Toggle Table Conditional Styling" ) );
951 mTable->setUseConditionalStyling( checked );
953 mTable->endCommand();
956void QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled(
bool checked )
963 mTable->beginCommand( tr(
"Change Show Empty Rows" ) );
964 mTable->setShowEmptyRows( checked );
965 mTable->endCommand();
968void QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished()
975 mTable->beginCommand( tr(
"Change Empty Table Message" ) );
976 mTable->setEmptyTableMessage( mEmptyMessageLineEdit->text() );
977 mTable->endCommand();
980void QgsLayoutAttributeTableWidget::toggleSourceControls()
982 switch ( mTable->source() )
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()
1002 && mTable->layout()->reportContext().layer()
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 );
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 );
1033 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
1034 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1035 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1036 mIntersectAtlasCheckBox->setEnabled(
1038 && mTable->layout()->reportContext().layer()
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.
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.
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 itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
@ 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.
Interface for master layout type objects, such as print layouts and reports.
QgsRelationManager * relationManager
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.