40 connect( mRefreshPushButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked );
41 connect( mAttributesPushButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked );
42 connect( mMaximumRowsSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged );
43 connect( mMarginSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged );
44 connect( mGridStrokeWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged );
46 connect( mBackgroundColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged );
47 connect( mDrawHorizontalGrid, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled );
48 connect( mDrawVerticalGrid, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled );
49 connect( mShowGridGroupCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled );
50 connect( mShowOnlyVisibleFeaturesCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged );
51 connect( mFeatureFilterCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged );
52 connect( mFeatureFilterEdit, &QLineEdit::editingFinished,
this, &QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished );
53 connect( mFeatureFilterButton, &QToolButton::clicked,
this, &QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked );
54 connect( mHeaderHAlignmentComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged );
55 connect( mHeaderModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged );
56 connect( mWrapStringLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished );
57 connect( mAddFramePushButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked );
58 connect( mResizeModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged );
59 connect( mSourceComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged );
60 connect( mRelationsComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged );
61 connect( mEmptyModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged );
62 connect( mDrawEmptyCheckBox, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled );
63 connect( mEmptyMessageLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished );
64 connect( mIntersectAtlasCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged );
65 connect( mUniqueOnlyCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged );
66 connect( mEmptyFrameCheckBox, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled );
67 connect( mHideEmptyBgCheckBox, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled );
68 connect( mWrapBehaviorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged );
69 connect( mAdvancedCustomizationButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked );
70 connect( mUseConditionalStylingCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::useConditionalStylingChanged );
76 mContentFontToolButton->registerExpressionContextGenerator(
this );
77 mContentFontToolButton->setLayer( mTable->sourceLayer() );
78 mHeaderFontToolButton->registerExpressionContextGenerator(
this );
79 mHeaderFontToolButton->setLayer( mTable->sourceLayer() );
81 blockAllSignals(
true );
104 toggleAtlasSpecificControls(
static_cast< bool >(
coverageLayer() ) );
112 mComposerMapComboBox->setCurrentLayout( mTable->layout() );
116 mGridColorButton->setColorDialogTitle( tr(
"Select Grid Color" ) );
117 mGridColorButton->setAllowOpacity(
true );
118 mGridColorButton->setContext( QStringLiteral(
"composer" ) );
119 mGridColorButton->setDefaultColor( Qt::black );
120 mBackgroundColorButton->setColorDialogTitle( tr(
"Select Background Color" ) );
121 mBackgroundColorButton->setAllowOpacity(
true );
122 mBackgroundColorButton->setContext( QStringLiteral(
"composer" ) );
123 mBackgroundColorButton->setShowNoColor(
true );
124 mBackgroundColorButton->setNoColorString( tr(
"No Background" ) );
134 this, &QgsLayoutAttributeTableWidget::atlasToggled );
142 mLayerSourceDDBtn->registerExpressionContextGenerator( mTable );
152 mainLayout->addWidget( mItemPropertiesWidget );
155 connect( mHeaderFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::headerFontChanged );
156 connect( mContentFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::contentFontChanged );
161 mIntersectAtlasCheckBox->setText( tr(
"Show only features intersecting %1 feature" ).arg(
string ) );
163 if ( atlasFeatureIndex != -1 )
165 mSourceComboBox->setItemText( atlasFeatureIndex, tr(
"Current %1 Feature" ).arg(
string ) );
171 if ( mItemPropertiesWidget )
181 context = mFrame->createExpressionContext();
183 context = mTable->createExpressionContext();
185 std::unique_ptr< QgsExpressionContextScope > cellScope = std::make_unique< QgsExpressionContextScope >();
186 cellScope->setVariable( QStringLiteral(
"row_number" ), 1,
true );
187 cellScope->setVariable( QStringLiteral(
"column_number" ), 1,
true );
191 QStringLiteral(
"column_number" )} );
214 mTable = qobject_cast< QgsLayoutItemAttributeTable * >( multiFrame );
216 mItemPropertiesWidget->
setItem( frame );
229void QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked()
236 mTable->refreshAttributes();
239void QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked()
247 QVector<QgsLayoutTableColumn> currentColumns = mTable->columns();
248 QVector<QgsLayoutTableColumn> currentSortColumns = mTable->sortColumns();
250 mTable->beginCommand( tr(
"Change Table Attributes" ) );
253 window()->setUpdatesEnabled(
false );
256 if ( d.exec() == QDialog::Accepted )
258 mTable->refreshAttributes();
260 window()->setUpdatesEnabled(
true );
262 mTable->endCommand();
265 currentColumns.clear();
266 currentSortColumns.clear();
271 mTable->setColumns( currentColumns );
272 mTable->setSortColumns( currentSortColumns );
273 window()->setUpdatesEnabled(
true );
274 mTable->cancelCommand();
278void QgsLayoutAttributeTableWidget::composerMapChanged(
QgsLayoutItem *item )
285 mTable->beginCommand( tr(
"Change Table Map" ) );
286 mTable->setMap( qobject_cast< QgsLayoutItemMap * >( item ) );
288 mTable->endCommand();
291void QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged(
int i )
299 mTable->setMaximumNumberOfFeatures( i );
301 mTable->endCommand();
304void QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged(
double d )
312 mTable->setCellMargin( d );
313 mTable->endCommand();
316void QgsLayoutAttributeTableWidget::headerFontChanged()
321 mTable->beginCommand( tr(
"Change Table Text Format" ) );
322 mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
323 mTable->endCommand();
326void QgsLayoutAttributeTableWidget::contentFontChanged()
333 mTable->beginCommand( tr(
"Change Table Text Format" ) );
334 mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
335 mTable->endCommand();
338void QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged(
double d )
346 mTable->setGridStrokeWidth( d );
347 mTable->endCommand();
350void QgsLayoutAttributeTableWidget::mGridColorButton_colorChanged(
const QColor &newColor )
358 mTable->setGridColor( newColor );
359 mTable->endCommand();
362void QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled(
bool state )
369 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
370 mTable->setHorizontalGrid( state );
371 mTable->endCommand();
374void QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled(
bool state )
381 mTable->beginCommand( tr(
"Toggled Table Grid" ) );
382 mTable->setVerticalGrid( state );
383 mTable->endCommand();
386void QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled(
bool state )
393 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
394 mTable->setShowGrid( state );
395 mTable->endCommand();
398void QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged(
const QColor &newColor )
406 mTable->setBackgroundColor( newColor );
407 mTable->endCommand();
410void QgsLayoutAttributeTableWidget::updateGuiElements()
412 if ( !mTable || !mFrame )
417 blockAllSignals(
true );
419 mSourceComboBox->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
420 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
423 if ( mTable->vectorLayer() )
425 mLayerComboBox->setLayer( mTable->vectorLayer() );
429 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
430 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
431 mComposerMapComboBox->setEnabled(
false );
432 mComposerMapLabel->setEnabled(
false );
433 mIntersectAtlasCheckBox->setEnabled(
false );
437 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
438 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
439 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
444 mComposerMapComboBox->setItem( mTable->map() );
445 mMaximumRowsSpinBox->setValue( mTable->maximumNumberOfFeatures() );
446 mMarginSpinBox->setValue( mTable->cellMargin() );
447 mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
448 mGridColorButton->setColor( mTable->gridColor() );
449 mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
450 mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
451 if ( mTable->showGrid() )
453 mShowGridGroupCheckBox->setChecked(
true );
457 mShowGridGroupCheckBox->setChecked(
false );
459 mBackgroundColorButton->setColor( mTable->backgroundColor() );
461 mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
462 mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
464 if ( mTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
466 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
467 mComposerMapComboBox->setEnabled(
true );
468 mComposerMapLabel->setEnabled(
true );
472 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
473 mComposerMapComboBox->setEnabled(
false );
474 mComposerMapLabel->setEnabled(
false );
477 mUniqueOnlyCheckBox->setChecked( mTable->uniqueRowsOnly() );
478 mIntersectAtlasCheckBox->setChecked( mTable->filterToAtlasFeature() );
479 mFeatureFilterEdit->setText( mTable->featureFilter() );
480 mFeatureFilterCheckBox->setCheckState( mTable->filterFeatures() ? Qt::Checked : Qt::Unchecked );
481 mFeatureFilterEdit->setEnabled( mTable->filterFeatures() );
482 mFeatureFilterButton->setEnabled( mTable->filterFeatures() );
483 mUseConditionalStylingCheckBox->setChecked( mTable->useConditionalStyling() );
485 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
486 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
488 mEmptyModeComboBox->setCurrentIndex( mEmptyModeComboBox->findData( mTable->emptyTableBehavior() ) );
489 mEmptyMessageLineEdit->setText( mTable->emptyTableMessage() );
492 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
493 mWrapStringLineEdit->setText( mTable->wrapString() );
494 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
496 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
499 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
500 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
504 toggleSourceControls();
506 blockAllSignals(
false );
509void QgsLayoutAttributeTableWidget::atlasToggled()
516 toggleAtlasSpecificControls( atlasEnabled );
521 whileBlocking( mSourceComboBox )->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
523 if ( !atlasEnabled && mTable->filterToAtlasFeature() )
525 mTable->setFilterToAtlasFeature(
false );
529void QgsLayoutAttributeTableWidget::updateRelationsCombo()
531 mRelationsComboBox->blockSignals(
true );
532 mRelationsComboBox->clear();
540 mRelationsComboBox->addItem( relation.name(), relation.id() );
544 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
548 mRelationsComboBox->blockSignals(
false );
551void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls(
const bool atlasEnabled )
561 mRelationsComboBox->blockSignals(
true );
562 mRelationsComboBox->setEnabled(
false );
563 mRelationsComboBox->clear();
564 mRelationsComboBox->blockSignals(
false );
565 mIntersectAtlasCheckBox->setEnabled(
false );
581 updateRelationsCombo();
582 mRelationsComboBox->setEnabled(
true );
583 mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() !=
Qgis::GeometryType::Null );
587void QgsLayoutAttributeTableWidget::blockAllSignals(
bool b )
589 mSourceComboBox->blockSignals( b );
590 mLayerComboBox->blockSignals( b );
591 mComposerMapComboBox->blockSignals( b );
592 mMaximumRowsSpinBox->blockSignals( b );
593 mMarginSpinBox->blockSignals( b );
594 mGridColorButton->blockSignals( b );
595 mGridStrokeWidthSpinBox->blockSignals( b );
596 mBackgroundColorButton->blockSignals( b );
597 mDrawHorizontalGrid->blockSignals( b );
598 mDrawVerticalGrid->blockSignals( b );
599 mShowGridGroupCheckBox->blockSignals( b );
600 mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
601 mUniqueOnlyCheckBox->blockSignals( b );
602 mIntersectAtlasCheckBox->blockSignals( b );
603 mFeatureFilterEdit->blockSignals( b );
604 mFeatureFilterCheckBox->blockSignals( b );
605 mHeaderHAlignmentComboBox->blockSignals( b );
606 mHeaderModeComboBox->blockSignals( b );
607 mResizeModeComboBox->blockSignals( b );
608 mRelationsComboBox->blockSignals( b );
609 mEmptyModeComboBox->blockSignals( b );
610 mEmptyMessageLineEdit->blockSignals( b );
611 mEmptyFrameCheckBox->blockSignals( b );
612 mHideEmptyBgCheckBox->blockSignals( b );
613 mDrawEmptyCheckBox->blockSignals( b );
614 mWrapStringLineEdit->blockSignals( b );
615 mWrapBehaviorComboBox->blockSignals( b );
616 mContentFontToolButton->blockSignals( b );
617 mHeaderFontToolButton->blockSignals( b );
620void QgsLayoutAttributeTableWidget::setMaximumNumberOfFeatures(
int n )
625void QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged(
int state )
632 mTable->beginCommand( tr(
"Toggle Visible Features Only" ) );
633 const bool showOnlyVisibleFeatures = ( state == Qt::Checked );
634 mTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
636 mTable->endCommand();
639 mComposerMapComboBox->setEnabled( state == Qt::Checked );
640 mComposerMapLabel->setEnabled( state == Qt::Checked );
643void QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged(
int state )
650 mTable->beginCommand( tr(
"Toggle Table Filter Duplicates" ) );
651 mTable->setUniqueRowsOnly( state == Qt::Checked );
653 mTable->endCommand();
656void QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled(
bool checked )
663 mFrame->beginCommand( tr(
"Toggle Empty Frame Mode" ) );
664 mFrame->setHidePageIfEmpty( checked );
665 mFrame->endCommand();
668void QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled(
bool checked )
675 mFrame->beginCommand( tr(
"Toggle Background Display" ) );
676 mFrame->setHideBackgroundIfEmpty( checked );
677 mFrame->endCommand();
680void QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged(
int state )
687 mTable->beginCommand( tr(
"Toggle Table Atlas Filter" ) );
688 const bool filterToAtlas = ( state == Qt::Checked );
689 mTable->setFilterToAtlasFeature( filterToAtlas );
691 mTable->endCommand();
694void QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged(
int state )
701 if ( state == Qt::Checked )
703 mFeatureFilterEdit->setEnabled(
true );
704 mFeatureFilterButton->setEnabled(
true );
708 mFeatureFilterEdit->setEnabled(
false );
709 mFeatureFilterButton->setEnabled(
false );
712 mTable->beginCommand( tr(
"Toggle Table Feature Filter" ) );
713 mTable->setFilterFeatures( state == Qt::Checked );
715 mTable->endCommand();
718void QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished()
725 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
726 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
728 mTable->endCommand();
731void QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked()
739 QgsExpressionBuilderDialog exprDlg( mTable->sourceLayer(), mFeatureFilterEdit->text(),
this, QStringLiteral(
"generic" ), context );
740 exprDlg.setWindowTitle( tr(
"Expression Based Filter" ) );
741 if ( exprDlg.exec() == QDialog::Accepted )
743 const QString expression = exprDlg.expressionText();
744 if ( !expression.isEmpty() )
746 mFeatureFilterEdit->setText( expression );
747 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
748 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
750 mTable->endCommand();
755void QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged(
int )
762 mTable->beginCommand( tr(
"Change Table Alignment" ) );
764 mTable->endCommand();
767void QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged(
int )
774 mTable->beginCommand( tr(
"Change Table Header Mode" ) );
776 mTable->endCommand();
779void QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished()
786 mTable->beginCommand( tr(
"Change Table Wrap String" ) );
787 mTable->setWrapString( mWrapStringLineEdit->text() );
788 mTable->endCommand();
791void QgsLayoutAttributeTableWidget::changeLayer(
QgsMapLayer *layer )
804 mTable->beginCommand( tr(
"Change Table Layer" ) );
805 mTable->setVectorLayer( vl );
807 mTable->endCommand();
809 mContentFontToolButton->setLayer( vl );
810 mHeaderFontToolButton->setLayer( vl );
815 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
816 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
817 mComposerMapComboBox->setEnabled(
false );
818 mComposerMapLabel->setEnabled(
false );
819 mIntersectAtlasCheckBox->setEnabled(
false );
823 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
824 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
825 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
830void QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked()
832 if ( !mTable || !mFrame )
838 QPointF pos = mFrame->pos();
840 pos.ry() += mFrame->rect().height() + 10;
842 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
843 mTable->recalculateFrameSizes();
846 if (
QgsLayout *layout = mTable->layout() )
848 layout->setSelectedItem( newFrame );
852void QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged(
int index )
859 mTable->beginCommand( tr(
"Change Resize Mode" ) );
861 mTable->endCommand();
866void QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged(
int index )
873 mTable->beginCommand( tr(
"Change Table Source" ) );
875 mTable->endCommand();
877 toggleSourceControls();
880void QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged(
int index )
887 mTable->beginCommand( tr(
"Change Table Source Relation" ) );
888 mTable->setRelationId( mRelationsComboBox->itemData( index ).toString() );
889 mTable->endCommand();
892void QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged(
int index )
899 mTable->beginCommand( tr(
"Change Empty Table Behavior" ) );
901 mTable->endCommand();
906void QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged(
int index )
913 mTable->beginCommand( tr(
"Change Table Wrap Mode" ) );
915 mTable->endCommand();
918void QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked()
929void QgsLayoutAttributeTableWidget::useConditionalStylingChanged(
bool checked )
936 mTable->beginCommand( tr(
"Toggle Table Conditional Styling" ) );
937 mTable->setUseConditionalStyling( checked );
939 mTable->endCommand();
942void QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled(
bool checked )
949 mTable->beginCommand( tr(
"Change Show Empty Rows" ) );
950 mTable->setShowEmptyRows( checked );
951 mTable->endCommand();
954void QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished()
961 mTable->beginCommand( tr(
"Change Empty Table Message" ) );
962 mTable->setEmptyTableMessage( mEmptyMessageLineEdit->text() );
963 mTable->endCommand();
966void QgsLayoutAttributeTableWidget::toggleSourceControls()
968 switch ( mTable->source() )
971 mLayerComboBox->setEnabled(
true );
972 mLayerComboBox->setVisible(
true );
973 mLayerSourceDDBtn->setVisible(
true );
974 mLayerLabel->setVisible(
true );
975 mRelationsComboBox->setEnabled(
false );
976 mRelationsComboBox->setVisible(
false );
977 mRelationLabel->setVisible(
false );
978 mMaximumRowsSpinBox->setEnabled(
true );
979 mMaxNumFeaturesLabel->setEnabled(
true );
980 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null );
981 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
982 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
983 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
984 mIntersectAtlasCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null
988 mLayerComboBox->setEnabled(
false );
989 mLayerComboBox->setVisible(
false );
990 mLayerSourceDDBtn->setVisible(
false );
991 mLayerLabel->setVisible(
false );
992 mRelationsComboBox->setEnabled(
false );
993 mRelationsComboBox->setVisible(
false );
994 mRelationLabel->setVisible(
false );
995 mMaximumRowsSpinBox->setEnabled(
false );
996 mMaxNumFeaturesLabel->setEnabled(
false );
997 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null );
998 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
999 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1000 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1001 mIntersectAtlasCheckBox->setEnabled(
false );
1004 mLayerComboBox->setEnabled(
false );
1005 mLayerComboBox->setVisible(
false );
1006 mLayerLabel->setVisible(
false );
1007 mLayerSourceDDBtn->setVisible(
false );
1008 mRelationsComboBox->setEnabled(
true );
1009 mRelationsComboBox->setVisible(
true );
1010 mRelationLabel->setVisible(
true );
1011 mMaximumRowsSpinBox->setEnabled(
true );
1012 mMaxNumFeaturesLabel->setEnabled(
true );
1014 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
1015 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1016 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
A generic dialog for building expression strings.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
void toggled(bool enabled)
Emitted when atlas is enabled or disabled.
bool enabled() const
Returns whether the atlas generation is enabled.
A dialog to select what attributes to display (in the table item), set the column properties and spec...
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.
A dialog for customization of the cell background colors for a QgsLayoutTable.
HeaderMode
Controls where headers are shown in the table.
@ FirstFrame
Header shown on first frame only.
@ AllFrames
Headers shown on all frames.
@ NoHeaders
No headers shown for table.
WrapBehavior
Controls how long strings in the table are handled.
@ WrapText
Text which doesn't fit inside the cell is wrapped. Note that this only applies to text in columns wit...
@ TruncateText
Text which doesn't fit inside the cell is truncated.
HeaderHAlignment
Controls how headers are horizontally aligned in a table.
@ HeaderRight
Align headers right.
@ HeaderLeft
Align headers left.
@ HeaderCenter
Align headers to center.
@ FollowColumn
Header uses the same alignment as the column.
EmptyTableMode
Controls how empty tables are displayed.
@ HideTable
Hides entire table if empty.
@ ShowMessage
Shows preset message instead of table contents.
@ HeadersOnly
Show header rows only.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
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.
Represents a relationship between two vector layers.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.