19#include "moc_qgslayoutattributetablewidget.cpp"
41 connect( mRefreshPushButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked );
42 connect( mAttributesPushButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked );
43 connect( mMaximumRowsSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged );
44 connect( mMarginSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged );
45 connect( mGridStrokeWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged );
47 connect( mBackgroundColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged );
48 connect( mDrawHorizontalGrid, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled );
49 connect( mDrawVerticalGrid, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled );
50 connect( mShowGridGroupCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled );
51 connect( mShowOnlyVisibleFeaturesCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged );
52 connect( mFeatureFilterCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged );
53 connect( mFeatureFilterEdit, &QLineEdit::editingFinished,
this, &QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished );
54 connect( mFeatureFilterButton, &QToolButton::clicked,
this, &QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked );
55 connect( mHeaderHAlignmentComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged );
56 connect( mHeaderModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged );
57 connect( mWrapStringLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished );
58 connect( mAddFramePushButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked );
59 connect( mResizeModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged );
60 connect( mSourceComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged );
61 connect( mRelationsComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged );
62 connect( mEmptyModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged );
63 connect( mDrawEmptyCheckBox, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled );
64 connect( mEmptyMessageLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished );
65 connect( mIntersectAtlasCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged );
66 connect( mUniqueOnlyCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged );
67 connect( mEmptyFrameCheckBox, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled );
68 connect( mHideEmptyBgCheckBox, &QCheckBox::toggled,
this, &QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled );
69 connect( mWrapBehaviorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged );
70 connect( mAdvancedCustomizationButton, &QPushButton::clicked,
this, &QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked );
71 connect( mUseConditionalStylingCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutAttributeTableWidget::useConditionalStylingChanged );
77 mContentFontToolButton->registerExpressionContextGenerator(
this );
78 mContentFontToolButton->setLayer( mTable->sourceLayer() );
79 mHeaderFontToolButton->registerExpressionContextGenerator(
this );
80 mHeaderFontToolButton->setLayer( mTable->sourceLayer() );
82 blockAllSignals(
true );
105 toggleAtlasSpecificControls(
static_cast< bool >(
coverageLayer() ) );
113 mComposerMapComboBox->setCurrentLayout( mTable->layout() );
117 mGridColorButton->setColorDialogTitle( tr(
"Select Grid Color" ) );
118 mGridColorButton->setAllowOpacity(
true );
119 mGridColorButton->setContext( QStringLiteral(
"composer" ) );
120 mGridColorButton->setDefaultColor( Qt::black );
121 mBackgroundColorButton->setColorDialogTitle( tr(
"Select Background Color" ) );
122 mBackgroundColorButton->setAllowOpacity(
true );
123 mBackgroundColorButton->setContext( QStringLiteral(
"composer" ) );
124 mBackgroundColorButton->setShowNoColor(
true );
125 mBackgroundColorButton->setNoColorString( tr(
"No Background" ) );
135 this, &QgsLayoutAttributeTableWidget::atlasToggled );
143 mLayerSourceDDBtn->registerExpressionContextGenerator( mTable );
153 mainLayout->addWidget( mItemPropertiesWidget );
156 connect( mHeaderFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::headerFontChanged );
157 connect( mContentFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutAttributeTableWidget::contentFontChanged );
162 mIntersectAtlasCheckBox->setText( tr(
"Show only features intersecting %1 feature" ).arg(
string ) );
164 if ( atlasFeatureIndex != -1 )
166 mSourceComboBox->setItemText( atlasFeatureIndex, tr(
"Current %1 Feature" ).arg(
string ) );
172 if ( mItemPropertiesWidget )
182 context = mFrame->createExpressionContext();
184 context = mTable->createExpressionContext();
186 std::unique_ptr< QgsExpressionContextScope > cellScope = std::make_unique< QgsExpressionContextScope >();
187 cellScope->setVariable( QStringLiteral(
"row_number" ), 1,
true );
188 cellScope->setVariable( QStringLiteral(
"column_number" ), 1,
true );
192 QStringLiteral(
"column_number" )} );
215 mTable = qobject_cast< QgsLayoutItemAttributeTable * >( multiFrame );
217 mItemPropertiesWidget->
setItem( frame );
230void QgsLayoutAttributeTableWidget::mRefreshPushButton_clicked()
237 mTable->refreshAttributes();
240void QgsLayoutAttributeTableWidget::mAttributesPushButton_clicked()
248 QVector<QgsLayoutTableColumn> currentColumns = mTable->columns();
249 QVector<QgsLayoutTableColumn> currentSortColumns = mTable->sortColumns();
251 mTable->beginCommand( tr(
"Change Table Attributes" ) );
254 window()->setUpdatesEnabled(
false );
257 if ( d.exec() == QDialog::Accepted )
259 mTable->refreshAttributes();
261 window()->setUpdatesEnabled(
true );
263 mTable->endCommand();
266 currentColumns.clear();
267 currentSortColumns.clear();
272 mTable->setColumns( currentColumns );
273 mTable->setSortColumns( currentSortColumns );
274 window()->setUpdatesEnabled(
true );
275 mTable->cancelCommand();
279void QgsLayoutAttributeTableWidget::composerMapChanged(
QgsLayoutItem *item )
286 mTable->beginCommand( tr(
"Change Table Map" ) );
287 mTable->setMap( qobject_cast< QgsLayoutItemMap * >( item ) );
289 mTable->endCommand();
292void QgsLayoutAttributeTableWidget::mMaximumRowsSpinBox_valueChanged(
int i )
300 mTable->setMaximumNumberOfFeatures( i );
302 mTable->endCommand();
305void QgsLayoutAttributeTableWidget::mMarginSpinBox_valueChanged(
double d )
313 mTable->setCellMargin( d );
314 mTable->endCommand();
317void QgsLayoutAttributeTableWidget::headerFontChanged()
322 mTable->beginCommand( tr(
"Change Table Text Format" ) );
323 mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
324 mTable->endCommand();
327void QgsLayoutAttributeTableWidget::contentFontChanged()
334 mTable->beginCommand( tr(
"Change Table Text Format" ) );
335 mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
336 mTable->endCommand();
339void QgsLayoutAttributeTableWidget::mGridStrokeWidthSpinBox_valueChanged(
double d )
347 mTable->setGridStrokeWidth( d );
348 mTable->endCommand();
351void QgsLayoutAttributeTableWidget::mGridColorButton_colorChanged(
const QColor &newColor )
359 mTable->setGridColor( newColor );
360 mTable->endCommand();
363void QgsLayoutAttributeTableWidget::mDrawHorizontalGrid_toggled(
bool state )
370 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
371 mTable->setHorizontalGrid( state );
372 mTable->endCommand();
375void QgsLayoutAttributeTableWidget::mDrawVerticalGrid_toggled(
bool state )
382 mTable->beginCommand( tr(
"Toggled Table Grid" ) );
383 mTable->setVerticalGrid( state );
384 mTable->endCommand();
387void QgsLayoutAttributeTableWidget::mShowGridGroupCheckBox_toggled(
bool state )
394 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
395 mTable->setShowGrid( state );
396 mTable->endCommand();
399void QgsLayoutAttributeTableWidget::mBackgroundColorButton_colorChanged(
const QColor &newColor )
407 mTable->setBackgroundColor( newColor );
408 mTable->endCommand();
411void QgsLayoutAttributeTableWidget::updateGuiElements()
413 if ( !mTable || !mFrame )
418 blockAllSignals(
true );
420 mSourceComboBox->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
421 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
424 if ( mTable->vectorLayer() )
426 mLayerComboBox->setLayer( mTable->vectorLayer() );
430 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
431 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
432 mComposerMapComboBox->setEnabled(
false );
433 mComposerMapLabel->setEnabled(
false );
434 mIntersectAtlasCheckBox->setEnabled(
false );
438 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
439 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
440 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
445 mComposerMapComboBox->setItem( mTable->map() );
446 mMaximumRowsSpinBox->setValue( mTable->maximumNumberOfFeatures() );
447 mMarginSpinBox->setValue( mTable->cellMargin() );
448 mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
449 mGridColorButton->setColor( mTable->gridColor() );
450 mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
451 mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
452 if ( mTable->showGrid() )
454 mShowGridGroupCheckBox->setChecked(
true );
458 mShowGridGroupCheckBox->setChecked(
false );
460 mBackgroundColorButton->setColor( mTable->backgroundColor() );
462 mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
463 mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
465 if ( mTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
467 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
468 mComposerMapComboBox->setEnabled(
true );
469 mComposerMapLabel->setEnabled(
true );
473 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
474 mComposerMapComboBox->setEnabled(
false );
475 mComposerMapLabel->setEnabled(
false );
478 mUniqueOnlyCheckBox->setChecked( mTable->uniqueRowsOnly() );
479 mIntersectAtlasCheckBox->setChecked( mTable->filterToAtlasFeature() );
480 mFeatureFilterEdit->setText( mTable->featureFilter() );
481 mFeatureFilterCheckBox->setCheckState( mTable->filterFeatures() ? Qt::Checked : Qt::Unchecked );
482 mFeatureFilterEdit->setEnabled( mTable->filterFeatures() );
483 mFeatureFilterButton->setEnabled( mTable->filterFeatures() );
484 mUseConditionalStylingCheckBox->setChecked( mTable->useConditionalStyling() );
486 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
487 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
489 mEmptyModeComboBox->setCurrentIndex( mEmptyModeComboBox->findData( mTable->emptyTableBehavior() ) );
490 mEmptyMessageLineEdit->setText( mTable->emptyTableMessage() );
493 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
494 mWrapStringLineEdit->setText( mTable->wrapString() );
495 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
497 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
500 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
501 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
505 toggleSourceControls();
507 blockAllSignals(
false );
510void QgsLayoutAttributeTableWidget::atlasToggled()
517 toggleAtlasSpecificControls( atlasEnabled );
522 whileBlocking( mSourceComboBox )->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
524 if ( !atlasEnabled && mTable->filterToAtlasFeature() )
526 mTable->setFilterToAtlasFeature(
false );
530void QgsLayoutAttributeTableWidget::updateRelationsCombo()
532 mRelationsComboBox->blockSignals(
true );
533 mRelationsComboBox->clear();
541 mRelationsComboBox->addItem( relation.name(), relation.id() );
545 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
549 mRelationsComboBox->blockSignals(
false );
552void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls(
const bool atlasEnabled )
562 mRelationsComboBox->blockSignals(
true );
563 mRelationsComboBox->setEnabled(
false );
564 mRelationsComboBox->clear();
565 mRelationsComboBox->blockSignals(
false );
566 mIntersectAtlasCheckBox->setEnabled(
false );
582 updateRelationsCombo();
583 mRelationsComboBox->setEnabled(
true );
584 mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() !=
Qgis::GeometryType::Null );
588void QgsLayoutAttributeTableWidget::blockAllSignals(
bool b )
590 mSourceComboBox->blockSignals( b );
591 mLayerComboBox->blockSignals( b );
592 mComposerMapComboBox->blockSignals( b );
593 mMaximumRowsSpinBox->blockSignals( b );
594 mMarginSpinBox->blockSignals( b );
595 mGridColorButton->blockSignals( b );
596 mGridStrokeWidthSpinBox->blockSignals( b );
597 mBackgroundColorButton->blockSignals( b );
598 mDrawHorizontalGrid->blockSignals( b );
599 mDrawVerticalGrid->blockSignals( b );
600 mShowGridGroupCheckBox->blockSignals( b );
601 mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
602 mUniqueOnlyCheckBox->blockSignals( b );
603 mIntersectAtlasCheckBox->blockSignals( b );
604 mFeatureFilterEdit->blockSignals( b );
605 mFeatureFilterCheckBox->blockSignals( b );
606 mHeaderHAlignmentComboBox->blockSignals( b );
607 mHeaderModeComboBox->blockSignals( b );
608 mResizeModeComboBox->blockSignals( b );
609 mRelationsComboBox->blockSignals( b );
610 mEmptyModeComboBox->blockSignals( b );
611 mEmptyMessageLineEdit->blockSignals( b );
612 mEmptyFrameCheckBox->blockSignals( b );
613 mHideEmptyBgCheckBox->blockSignals( b );
614 mDrawEmptyCheckBox->blockSignals( b );
615 mWrapStringLineEdit->blockSignals( b );
616 mWrapBehaviorComboBox->blockSignals( b );
617 mContentFontToolButton->blockSignals( b );
618 mHeaderFontToolButton->blockSignals( b );
621void QgsLayoutAttributeTableWidget::setMaximumNumberOfFeatures(
int n )
626void QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged(
int state )
633 mTable->beginCommand( tr(
"Toggle Visible Features Only" ) );
634 const bool showOnlyVisibleFeatures = ( state == Qt::Checked );
635 mTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
637 mTable->endCommand();
640 mComposerMapComboBox->setEnabled( state == Qt::Checked );
641 mComposerMapLabel->setEnabled( state == Qt::Checked );
644void QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged(
int state )
651 mTable->beginCommand( tr(
"Toggle Table Filter Duplicates" ) );
652 mTable->setUniqueRowsOnly( state == Qt::Checked );
654 mTable->endCommand();
657void QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled(
bool checked )
664 mFrame->beginCommand( tr(
"Toggle Empty Frame Mode" ) );
665 mFrame->setHidePageIfEmpty( checked );
666 mFrame->endCommand();
669void QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled(
bool checked )
676 mFrame->beginCommand( tr(
"Toggle Background Display" ) );
677 mFrame->setHideBackgroundIfEmpty( checked );
678 mFrame->endCommand();
681void QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged(
int state )
688 mTable->beginCommand( tr(
"Toggle Table Atlas Filter" ) );
689 const bool filterToAtlas = ( state == Qt::Checked );
690 mTable->setFilterToAtlasFeature( filterToAtlas );
692 mTable->endCommand();
695void QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged(
int state )
702 if ( state == Qt::Checked )
704 mFeatureFilterEdit->setEnabled(
true );
705 mFeatureFilterButton->setEnabled(
true );
709 mFeatureFilterEdit->setEnabled(
false );
710 mFeatureFilterButton->setEnabled(
false );
713 mTable->beginCommand( tr(
"Toggle Table Feature Filter" ) );
714 mTable->setFilterFeatures( state == Qt::Checked );
716 mTable->endCommand();
719void QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished()
726 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
727 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
729 mTable->endCommand();
732void QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked()
740 QgsExpressionBuilderDialog exprDlg( mTable->sourceLayer(), mFeatureFilterEdit->text(),
this, QStringLiteral(
"generic" ), context );
741 exprDlg.setWindowTitle( tr(
"Expression Based Filter" ) );
742 if ( exprDlg.exec() == QDialog::Accepted )
744 const QString expression = exprDlg.expressionText();
745 if ( !expression.isEmpty() )
747 mFeatureFilterEdit->setText( expression );
748 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
749 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
751 mTable->endCommand();
756void QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged(
int )
763 mTable->beginCommand( tr(
"Change Table Alignment" ) );
765 mTable->endCommand();
768void QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged(
int )
775 mTable->beginCommand( tr(
"Change Table Header Mode" ) );
777 mTable->endCommand();
780void QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished()
787 mTable->beginCommand( tr(
"Change Table Wrap String" ) );
788 mTable->setWrapString( mWrapStringLineEdit->text() );
789 mTable->endCommand();
792void QgsLayoutAttributeTableWidget::changeLayer(
QgsMapLayer *layer )
805 mTable->beginCommand( tr(
"Change Table Layer" ) );
806 mTable->setVectorLayer( vl );
808 mTable->endCommand();
810 mContentFontToolButton->setLayer( vl );
811 mHeaderFontToolButton->setLayer( vl );
816 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
817 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
818 mComposerMapComboBox->setEnabled(
false );
819 mComposerMapLabel->setEnabled(
false );
820 mIntersectAtlasCheckBox->setEnabled(
false );
824 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
825 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
826 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
831void QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked()
833 if ( !mTable || !mFrame )
839 QPointF pos = mFrame->pos();
841 pos.ry() += mFrame->rect().height() + 10;
843 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
844 mTable->recalculateFrameSizes();
847 if (
QgsLayout *layout = mTable->layout() )
849 layout->setSelectedItem( newFrame );
853void QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged(
int index )
860 mTable->beginCommand( tr(
"Change Resize Mode" ) );
862 mTable->endCommand();
867void QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged(
int index )
874 mTable->beginCommand( tr(
"Change Table Source" ) );
876 mTable->endCommand();
878 toggleSourceControls();
881void QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged(
int index )
888 mTable->beginCommand( tr(
"Change Table Source Relation" ) );
889 mTable->setRelationId( mRelationsComboBox->itemData( index ).toString() );
890 mTable->endCommand();
893void QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged(
int index )
900 mTable->beginCommand( tr(
"Change Empty Table Behavior" ) );
902 mTable->endCommand();
907void QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged(
int index )
914 mTable->beginCommand( tr(
"Change Table Wrap Mode" ) );
916 mTable->endCommand();
919void QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked()
930void QgsLayoutAttributeTableWidget::useConditionalStylingChanged(
bool checked )
937 mTable->beginCommand( tr(
"Toggle Table Conditional Styling" ) );
938 mTable->setUseConditionalStyling( checked );
940 mTable->endCommand();
943void QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled(
bool checked )
950 mTable->beginCommand( tr(
"Change Show Empty Rows" ) );
951 mTable->setShowEmptyRows( checked );
952 mTable->endCommand();
955void QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished()
962 mTable->beginCommand( tr(
"Change Empty Table Message" ) );
963 mTable->setEmptyTableMessage( mEmptyMessageLineEdit->text() );
964 mTable->endCommand();
967void QgsLayoutAttributeTableWidget::toggleSourceControls()
969 switch ( mTable->source() )
972 mLayerComboBox->setEnabled(
true );
973 mLayerComboBox->setVisible(
true );
974 mLayerSourceDDBtn->setVisible(
true );
975 mLayerLabel->setVisible(
true );
976 mRelationsComboBox->setEnabled(
false );
977 mRelationsComboBox->setVisible(
false );
978 mRelationLabel->setVisible(
false );
979 mMaximumRowsSpinBox->setEnabled(
true );
980 mMaxNumFeaturesLabel->setEnabled(
true );
981 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null );
982 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
983 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
984 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
985 mIntersectAtlasCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null
989 mLayerComboBox->setEnabled(
false );
990 mLayerComboBox->setVisible(
false );
991 mLayerSourceDDBtn->setVisible(
false );
992 mLayerLabel->setVisible(
false );
993 mRelationsComboBox->setEnabled(
false );
994 mRelationsComboBox->setVisible(
false );
995 mRelationLabel->setVisible(
false );
996 mMaximumRowsSpinBox->setEnabled(
false );
997 mMaxNumFeaturesLabel->setEnabled(
false );
998 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null );
999 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
1000 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1001 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1002 mIntersectAtlasCheckBox->setEnabled(
false );
1005 mLayerComboBox->setEnabled(
false );
1006 mLayerComboBox->setVisible(
false );
1007 mLayerLabel->setVisible(
false );
1008 mLayerSourceDDBtn->setVisible(
false );
1009 mRelationsComboBox->setEnabled(
true );
1010 mRelationsComboBox->setVisible(
true );
1011 mRelationLabel->setVisible(
true );
1012 mMaximumRowsSpinBox->setEnabled(
true );
1013 mMaxNumFeaturesLabel->setEnabled(
true );
1015 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
1016 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1017 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.