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" ) );
148 mLayerSourceDDBtn->registerExpressionContextGenerator( mTable );
158 mainLayout->addWidget( mItemPropertiesWidget );
161 connect( mHeaderFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::headerFontChanged );
162 connect( mContentFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::contentFontChanged );
167 mIntersectAtlasCheckBox->setText( tr(
"Show only features intersecting %1 feature" ).arg(
string ) );
169 if ( atlasFeatureIndex != -1 )
171 mSourceComboBox->setItemText( atlasFeatureIndex, tr(
"Current %1 Feature" ).arg(
string ) );
177 if ( mItemPropertiesWidget )
178 mItemPropertiesWidget->setMasterLayout( masterLayout );
187 context = mFrame->createExpressionContext();
189 context = mTable->createExpressionContext();
191 auto cellScope = std::make_unique<QgsExpressionContextScope>();
192 cellScope->setVariable( u
"row_number"_s, 1,
true );
193 cellScope->setVariable( u
"column_number"_s, 1,
true );
219 mTable = qobject_cast<QgsLayoutItemAttributeTable *>( multiFrame );
221 mItemPropertiesWidget->setItem( frame );
234void QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked()
241 mTable->refreshAttributes();
244void QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked()
252 QVector<QgsLayoutTableColumn> currentColumns = mTable->columns();
253 QVector<QgsLayoutTableColumn> currentSortColumns = mTable->sortColumns();
255 mTable->beginCommand( tr(
"Change Table Attributes" ) );
258 window()->setUpdatesEnabled(
false );
260 QgsLayoutAttributeSelectionDialog d( mTable, mTable->sourceLayer(),
this );
261 if ( d.exec() == QDialog::Accepted )
263 mTable->refreshAttributes();
265 window()->setUpdatesEnabled(
true );
267 mTable->endCommand();
270 currentColumns.clear();
271 currentSortColumns.clear();
276 mTable->setColumns( currentColumns );
277 mTable->setSortColumns( currentSortColumns );
278 window()->setUpdatesEnabled(
true );
279 mTable->cancelCommand();
283void QgsLayoutAttributeTableWidget::composerMapChanged(
QgsLayoutItem *item )
290 mTable->beginCommand( tr(
"Change Table Map" ) );
291 mTable->setMap( qobject_cast<QgsLayoutItemMap *>( item ) );
293 mTable->endCommand();
296void QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged(
int i )
304 mTable->setMaximumNumberOfFeatures( i );
306 mTable->endCommand();
309void QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged(
double d )
317 mTable->setCellMargin( d );
318 mTable->endCommand();
321void QgsLayoutAttributeTableWidget::headerFontChanged()
326 mTable->beginCommand( tr(
"Change Table Text Format" ) );
327 mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
328 mTable->endCommand();
331void QgsLayoutAttributeTableWidget::contentFontChanged()
338 mTable->beginCommand( tr(
"Change Table Text Format" ) );
339 mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
340 mTable->endCommand();
343void QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged(
double d )
351 mTable->setGridStrokeWidth( d );
352 mTable->endCommand();
355void QgsLayoutAttributeTableWidget::mGridColorButton_colorChanged(
const QColor &newColor )
363 mTable->setGridColor( newColor );
364 mTable->endCommand();
367void QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled(
bool state )
374 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
375 mTable->setHorizontalGrid( state );
376 mTable->endCommand();
379void QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled(
bool state )
386 mTable->beginCommand( tr(
"Toggled Table Grid" ) );
387 mTable->setVerticalGrid( state );
388 mTable->endCommand();
391void QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled(
bool state )
398 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
399 mTable->setShowGrid( state );
400 mTable->endCommand();
403void QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged(
const QColor &newColor )
411 mTable->setBackgroundColor( newColor );
412 mTable->endCommand();
415void QgsLayoutAttributeTableWidget::updateGuiElements()
417 if ( !mTable || !mFrame )
422 blockAllSignals(
true );
424 mSourceComboBox->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
425 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
428 if ( mTable->vectorLayer() )
430 mLayerComboBox->setLayer( mTable->vectorLayer() );
434 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
435 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
436 mComposerMapComboBox->setEnabled(
false );
437 mComposerMapLabel->setEnabled(
false );
438 mIntersectAtlasCheckBox->setEnabled(
false );
442 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
443 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
444 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
445 mIntersectAtlasCheckBox->setEnabled(
447 && mTable->layout()->reportContext().layer()
453 mComposerMapComboBox->setItem( mTable->map() );
454 mMaximumRowsSpinBox->setValue( mTable->maximumNumberOfFeatures() );
455 mMarginSpinBox->setValue( mTable->cellMargin() );
456 mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
457 mGridColorButton->setColor( mTable->gridColor() );
458 mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
459 mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
460 if ( mTable->showGrid() )
462 mShowGridGroupCheckBox->setChecked(
true );
466 mShowGridGroupCheckBox->setChecked(
false );
468 mBackgroundColorButton->setColor( mTable->backgroundColor() );
470 mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
471 mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
473 if ( mTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
475 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
476 mComposerMapComboBox->setEnabled(
true );
477 mComposerMapLabel->setEnabled(
true );
481 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
482 mComposerMapComboBox->setEnabled(
false );
483 mComposerMapLabel->setEnabled(
false );
486 mUniqueOnlyCheckBox->setChecked( mTable->uniqueRowsOnly() );
487 mIntersectAtlasCheckBox->setChecked( mTable->filterToAtlasFeature() );
488 mFeatureFilterEdit->setText( mTable->featureFilter() );
489 mFeatureFilterCheckBox->setCheckState( mTable->filterFeatures() ? Qt::Checked : Qt::Unchecked );
490 mFeatureFilterEdit->setEnabled( mTable->filterFeatures() );
491 mFeatureFilterButton->setEnabled( mTable->filterFeatures() );
492 mUseConditionalStylingCheckBox->setChecked( mTable->useConditionalStyling() );
494 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
495 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
497 mEmptyModeComboBox->setCurrentIndex( mEmptyModeComboBox->findData( mTable->emptyTableBehavior() ) );
498 mEmptyMessageLineEdit->setText( mTable->emptyTableMessage() );
501 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
502 mWrapStringLineEdit->setText( mTable->wrapString() );
503 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
505 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
508 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
509 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
513 toggleSourceControls();
515 blockAllSignals(
false );
518void QgsLayoutAttributeTableWidget::atlasToggled()
525 toggleAtlasSpecificControls( atlasEnabled );
530 whileBlocking( mSourceComboBox )->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
532 if ( !atlasEnabled && mTable->filterToAtlasFeature() )
534 mTable->setFilterToAtlasFeature(
false );
538void QgsLayoutAttributeTableWidget::updateRelationsCombo()
540 mRelationsComboBox->blockSignals(
true );
541 mRelationsComboBox->clear();
547 for (
const QgsRelation &relation : relations )
549 mRelationsComboBox->addItem( relation.name(), relation.id() );
553 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
557 mRelationsComboBox->blockSignals(
false );
560void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls(
const bool atlasEnabled )
570 mRelationsComboBox->blockSignals(
true );
571 mRelationsComboBox->setEnabled(
false );
572 mRelationsComboBox->clear();
573 mRelationsComboBox->blockSignals(
false );
574 mIntersectAtlasCheckBox->setEnabled(
false );
590 updateRelationsCombo();
591 mRelationsComboBox->setEnabled(
true );
592 mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() !=
Qgis::GeometryType::Null );
596void QgsLayoutAttributeTableWidget::blockAllSignals(
bool b )
598 mSourceComboBox->blockSignals( b );
599 mLayerComboBox->blockSignals( b );
600 mComposerMapComboBox->blockSignals( b );
601 mMaximumRowsSpinBox->blockSignals( b );
602 mMarginSpinBox->blockSignals( b );
603 mGridColorButton->blockSignals( b );
604 mGridStrokeWidthSpinBox->blockSignals( b );
605 mBackgroundColorButton->blockSignals( b );
606 mDrawHorizontalGrid->blockSignals( b );
607 mDrawVerticalGrid->blockSignals( b );
608 mShowGridGroupCheckBox->blockSignals( b );
609 mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
610 mUniqueOnlyCheckBox->blockSignals( b );
611 mIntersectAtlasCheckBox->blockSignals( b );
612 mFeatureFilterEdit->blockSignals( b );
613 mFeatureFilterCheckBox->blockSignals( b );
614 mHeaderHAlignmentComboBox->blockSignals( b );
615 mHeaderModeComboBox->blockSignals( b );
616 mResizeModeComboBox->blockSignals( b );
617 mRelationsComboBox->blockSignals( b );
618 mEmptyModeComboBox->blockSignals( b );
619 mEmptyMessageLineEdit->blockSignals( b );
620 mEmptyFrameCheckBox->blockSignals( b );
621 mHideEmptyBgCheckBox->blockSignals( b );
622 mDrawEmptyCheckBox->blockSignals( b );
623 mWrapStringLineEdit->blockSignals( b );
624 mWrapBehaviorComboBox->blockSignals( b );
625 mContentFontToolButton->blockSignals( b );
626 mHeaderFontToolButton->blockSignals( b );
629void QgsLayoutAttributeTableWidget::setMaximumNumberOfFeatures(
int n )
634void QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged(
int state )
641 mTable->beginCommand( tr(
"Toggle Visible Features Only" ) );
642 const bool showOnlyVisibleFeatures = ( state == Qt::Checked );
643 mTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
645 mTable->endCommand();
648 mComposerMapComboBox->setEnabled( state == Qt::Checked );
649 mComposerMapLabel->setEnabled( state == Qt::Checked );
652void QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged(
int state )
659 mTable->beginCommand( tr(
"Toggle Table Filter Duplicates" ) );
660 mTable->setUniqueRowsOnly( state == Qt::Checked );
662 mTable->endCommand();
665void QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled(
bool checked )
672 mFrame->beginCommand( tr(
"Toggle Empty Frame Mode" ) );
673 mFrame->setHidePageIfEmpty( checked );
674 mFrame->endCommand();
677void QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled(
bool checked )
684 mFrame->beginCommand( tr(
"Toggle Background Display" ) );
685 mFrame->setHideBackgroundIfEmpty( checked );
686 mFrame->endCommand();
689void QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged(
int state )
696 mTable->beginCommand( tr(
"Toggle Table Atlas Filter" ) );
697 const bool filterToAtlas = ( state == Qt::Checked );
698 mTable->setFilterToAtlasFeature( filterToAtlas );
700 mTable->endCommand();
703void QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged(
int state )
710 if ( state == Qt::Checked )
712 mFeatureFilterEdit->setEnabled(
true );
713 mFeatureFilterButton->setEnabled(
true );
717 mFeatureFilterEdit->setEnabled(
false );
718 mFeatureFilterButton->setEnabled(
false );
721 mTable->beginCommand( tr(
"Toggle Table Feature Filter" ) );
722 mTable->setFilterFeatures( state == Qt::Checked );
724 mTable->endCommand();
727void QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished()
734 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
735 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
737 mTable->endCommand();
740void QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked()
747 const QgsExpressionContext context = mTable->createExpressionContext();
748 QgsExpressionBuilderDialog exprDlg( mTable->sourceLayer(), mFeatureFilterEdit->text(),
this, u
"generic"_s, context );
749 exprDlg.setWindowTitle( tr(
"Expression Based Filter" ) );
750 if ( exprDlg.exec() == QDialog::Accepted )
752 const QString expression = exprDlg.expressionText();
753 if ( !expression.isEmpty() )
755 mFeatureFilterEdit->setText( expression );
756 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
757 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
759 mTable->endCommand();
764void QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged(
int )
771 mTable->beginCommand( tr(
"Change Table Alignment" ) );
773 mTable->endCommand();
776void QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged(
int )
783 mTable->beginCommand( tr(
"Change Table Header Mode" ) );
785 mTable->endCommand();
788void QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished()
795 mTable->beginCommand( tr(
"Change Table Wrap String" ) );
796 mTable->setWrapString( mWrapStringLineEdit->text() );
797 mTable->endCommand();
800void QgsLayoutAttributeTableWidget::changeLayer(
QgsMapLayer *layer )
807 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
813 mTable->beginCommand( tr(
"Change Table Layer" ) );
814 mTable->setVectorLayer( vl );
816 mTable->endCommand();
818 mContentFontToolButton->setLayer( vl );
819 mHeaderFontToolButton->setLayer( vl );
824 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
825 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
826 mComposerMapComboBox->setEnabled(
false );
827 mComposerMapLabel->setEnabled(
false );
828 mIntersectAtlasCheckBox->setEnabled(
false );
832 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
833 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
834 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
835 mIntersectAtlasCheckBox->setEnabled(
837 && mTable->layout()->reportContext().layer()
843void QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked()
845 if ( !mTable || !mFrame )
851 QPointF pos = mFrame->pos();
853 pos.ry() += mFrame->rect().height() + 10;
855 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
856 mTable->recalculateFrameSizes();
859 if ( QgsLayout *layout = mTable->layout() )
861 layout->setSelectedItem( newFrame );
865void QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged(
int index )
872 mTable->beginCommand( tr(
"Change Resize Mode" ) );
874 mTable->endCommand();
879void QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged(
int index )
886 mTable->beginCommand( tr(
"Change Table Source" ) );
888 mTable->endCommand();
890 toggleSourceControls();
893void QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged(
int index )
900 mTable->beginCommand( tr(
"Change Table Source Relation" ) );
901 mTable->setRelationId( mRelationsComboBox->itemData( index ).toString() );
902 mTable->endCommand();
905void QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged(
int index )
912 mTable->beginCommand( tr(
"Change Empty Table Behavior" ) );
914 mTable->endCommand();
919void QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged(
int index )
926 mTable->beginCommand( tr(
"Change Table Wrap Mode" ) );
928 mTable->endCommand();
931void QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked()
938 QgsLayoutTableBackgroundColorsDialog d( mTable,
this );
942void QgsLayoutAttributeTableWidget::useConditionalStylingChanged(
bool checked )
949 mTable->beginCommand( tr(
"Toggle Table Conditional Styling" ) );
950 mTable->setUseConditionalStyling( checked );
952 mTable->endCommand();
955void QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled(
bool checked )
962 mTable->beginCommand( tr(
"Change Show Empty Rows" ) );
963 mTable->setShowEmptyRows( checked );
964 mTable->endCommand();
967void QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished()
974 mTable->beginCommand( tr(
"Change Empty Table Message" ) );
975 mTable->setEmptyTableMessage( mEmptyMessageLineEdit->text() );
976 mTable->endCommand();
979void QgsLayoutAttributeTableWidget::toggleSourceControls()
981 switch ( mTable->source() )
984 mLayerComboBox->setEnabled(
true );
985 mLayerComboBox->setVisible(
true );
986 mLayerSourceDDBtn->setVisible(
true );
987 mLayerLabel->setVisible(
true );
988 mRelationsComboBox->setEnabled(
false );
989 mRelationsComboBox->setVisible(
false );
990 mRelationLabel->setVisible(
false );
991 mMaximumRowsSpinBox->setEnabled(
true );
992 mMaxNumFeaturesLabel->setEnabled(
true );
993 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null );
994 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
995 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
996 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
997 mIntersectAtlasCheckBox->setEnabled(
998 mTable->vectorLayer()
1001 && mTable->layout()->reportContext().layer()
1006 mLayerComboBox->setEnabled(
false );
1007 mLayerComboBox->setVisible(
false );
1008 mLayerSourceDDBtn->setVisible(
false );
1009 mLayerLabel->setVisible(
false );
1010 mRelationsComboBox->setEnabled(
false );
1011 mRelationsComboBox->setVisible(
false );
1012 mRelationLabel->setVisible(
false );
1013 mMaximumRowsSpinBox->setEnabled(
false );
1014 mMaxNumFeaturesLabel->setEnabled(
false );
1015 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null );
1016 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
1017 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1018 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1019 mIntersectAtlasCheckBox->setEnabled(
false );
1022 mLayerComboBox->setEnabled(
false );
1023 mLayerComboBox->setVisible(
false );
1024 mLayerLabel->setVisible(
false );
1025 mLayerSourceDDBtn->setVisible(
false );
1026 mRelationsComboBox->setEnabled(
true );
1027 mRelationsComboBox->setVisible(
true );
1028 mRelationLabel->setVisible(
true );
1029 mMaximumRowsSpinBox->setEnabled(
true );
1030 mMaxNumFeaturesLabel->setEnabled(
true );
1032 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
1033 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1034 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1035 mIntersectAtlasCheckBox->setEnabled(
1037 && 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.