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() );
449 mComposerMapComboBox->setItem( mTable->map() );
450 mMaximumRowsSpinBox->setValue( mTable->maximumNumberOfFeatures() );
451 mMarginSpinBox->setValue( mTable->cellMargin() );
452 mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
453 mGridColorButton->setColor( mTable->gridColor() );
454 mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
455 mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
456 if ( mTable->showGrid() )
458 mShowGridGroupCheckBox->setChecked(
true );
462 mShowGridGroupCheckBox->setChecked(
false );
464 mBackgroundColorButton->setColor( mTable->backgroundColor() );
466 mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
467 mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
469 if ( mTable->displayOnlyVisibleFeatures() && mShowOnlyVisibleFeaturesCheckBox->isEnabled() )
471 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Checked );
472 mComposerMapComboBox->setEnabled(
true );
473 mComposerMapLabel->setEnabled(
true );
477 mShowOnlyVisibleFeaturesCheckBox->setCheckState( Qt::Unchecked );
478 mComposerMapComboBox->setEnabled(
false );
479 mComposerMapLabel->setEnabled(
false );
482 mUniqueOnlyCheckBox->setChecked( mTable->uniqueRowsOnly() );
483 mIntersectAtlasCheckBox->setChecked( mTable->filterToAtlasFeature() );
484 mFeatureFilterEdit->setText( mTable->featureFilter() );
485 mFeatureFilterCheckBox->setCheckState( mTable->filterFeatures() ? Qt::Checked : Qt::Unchecked );
486 mFeatureFilterEdit->setEnabled( mTable->filterFeatures() );
487 mFeatureFilterButton->setEnabled( mTable->filterFeatures() );
488 mUseConditionalStylingCheckBox->setChecked( mTable->useConditionalStyling() );
490 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
491 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
493 mEmptyModeComboBox->setCurrentIndex( mEmptyModeComboBox->findData( mTable->emptyTableBehavior() ) );
494 mEmptyMessageLineEdit->setText( mTable->emptyTableMessage() );
497 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
498 mWrapStringLineEdit->setText( mTable->wrapString() );
499 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
501 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
504 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
505 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
509 toggleSourceControls();
511 blockAllSignals(
false );
514void QgsLayoutAttributeTableWidget::atlasToggled()
521 toggleAtlasSpecificControls( atlasEnabled );
526 whileBlocking( mSourceComboBox )->setCurrentIndex( mSourceComboBox->findData( mTable->source() ) );
528 if ( !atlasEnabled && mTable->filterToAtlasFeature() )
530 mTable->setFilterToAtlasFeature(
false );
534void QgsLayoutAttributeTableWidget::updateRelationsCombo()
536 mRelationsComboBox->blockSignals(
true );
537 mRelationsComboBox->clear();
543 for (
const QgsRelation &relation : relations )
545 mRelationsComboBox->addItem( relation.name(), relation.id() );
549 mRelationsComboBox->setCurrentIndex( mRelationsComboBox->findData( mTable->relationId() ) );
553 mRelationsComboBox->blockSignals(
false );
556void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls(
const bool atlasEnabled )
566 mRelationsComboBox->blockSignals(
true );
567 mRelationsComboBox->setEnabled(
false );
568 mRelationsComboBox->clear();
569 mRelationsComboBox->blockSignals(
false );
570 mIntersectAtlasCheckBox->setEnabled(
false );
586 updateRelationsCombo();
587 mRelationsComboBox->setEnabled(
true );
588 mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() !=
Qgis::GeometryType::Null );
592void QgsLayoutAttributeTableWidget::blockAllSignals(
bool b )
594 mSourceComboBox->blockSignals( b );
595 mLayerComboBox->blockSignals( b );
596 mComposerMapComboBox->blockSignals( b );
597 mMaximumRowsSpinBox->blockSignals( b );
598 mMarginSpinBox->blockSignals( b );
599 mGridColorButton->blockSignals( b );
600 mGridStrokeWidthSpinBox->blockSignals( b );
601 mBackgroundColorButton->blockSignals( b );
602 mDrawHorizontalGrid->blockSignals( b );
603 mDrawVerticalGrid->blockSignals( b );
604 mShowGridGroupCheckBox->blockSignals( b );
605 mShowOnlyVisibleFeaturesCheckBox->blockSignals( b );
606 mUniqueOnlyCheckBox->blockSignals( b );
607 mIntersectAtlasCheckBox->blockSignals( b );
608 mFeatureFilterEdit->blockSignals( b );
609 mFeatureFilterCheckBox->blockSignals( b );
610 mHeaderHAlignmentComboBox->blockSignals( b );
611 mHeaderModeComboBox->blockSignals( b );
612 mResizeModeComboBox->blockSignals( b );
613 mRelationsComboBox->blockSignals( b );
614 mEmptyModeComboBox->blockSignals( b );
615 mEmptyMessageLineEdit->blockSignals( b );
616 mEmptyFrameCheckBox->blockSignals( b );
617 mHideEmptyBgCheckBox->blockSignals( b );
618 mDrawEmptyCheckBox->blockSignals( b );
619 mWrapStringLineEdit->blockSignals( b );
620 mWrapBehaviorComboBox->blockSignals( b );
621 mContentFontToolButton->blockSignals( b );
622 mHeaderFontToolButton->blockSignals( b );
625void QgsLayoutAttributeTableWidget::setMaximumNumberOfFeatures(
int n )
630void QgsLayoutAttributeTableWidget::mShowOnlyVisibleFeaturesCheckBox_stateChanged(
int state )
637 mTable->beginCommand( tr(
"Toggle Visible Features Only" ) );
638 const bool showOnlyVisibleFeatures = ( state == Qt::Checked );
639 mTable->setDisplayOnlyVisibleFeatures( showOnlyVisibleFeatures );
641 mTable->endCommand();
644 mComposerMapComboBox->setEnabled( state == Qt::Checked );
645 mComposerMapLabel->setEnabled( state == Qt::Checked );
648void QgsLayoutAttributeTableWidget::mUniqueOnlyCheckBox_stateChanged(
int state )
655 mTable->beginCommand( tr(
"Toggle Table Filter Duplicates" ) );
656 mTable->setUniqueRowsOnly( state == Qt::Checked );
658 mTable->endCommand();
661void QgsLayoutAttributeTableWidget::mEmptyFrameCheckBox_toggled(
bool checked )
668 mFrame->beginCommand( tr(
"Toggle Empty Frame Mode" ) );
669 mFrame->setHidePageIfEmpty( checked );
670 mFrame->endCommand();
673void QgsLayoutAttributeTableWidget::mHideEmptyBgCheckBox_toggled(
bool checked )
680 mFrame->beginCommand( tr(
"Toggle Background Display" ) );
681 mFrame->setHideBackgroundIfEmpty( checked );
682 mFrame->endCommand();
685void QgsLayoutAttributeTableWidget::mIntersectAtlasCheckBox_stateChanged(
int state )
692 mTable->beginCommand( tr(
"Toggle Table Atlas Filter" ) );
693 const bool filterToAtlas = ( state == Qt::Checked );
694 mTable->setFilterToAtlasFeature( filterToAtlas );
696 mTable->endCommand();
699void QgsLayoutAttributeTableWidget::mFeatureFilterCheckBox_stateChanged(
int state )
706 if ( state == Qt::Checked )
708 mFeatureFilterEdit->setEnabled(
true );
709 mFeatureFilterButton->setEnabled(
true );
713 mFeatureFilterEdit->setEnabled(
false );
714 mFeatureFilterButton->setEnabled(
false );
717 mTable->beginCommand( tr(
"Toggle Table Feature Filter" ) );
718 mTable->setFilterFeatures( state == Qt::Checked );
720 mTable->endCommand();
723void QgsLayoutAttributeTableWidget::mFeatureFilterEdit_editingFinished()
730 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
731 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
733 mTable->endCommand();
736void QgsLayoutAttributeTableWidget::mFeatureFilterButton_clicked()
743 const QgsExpressionContext context = mTable->createExpressionContext();
744 QgsExpressionBuilderDialog exprDlg( mTable->sourceLayer(), mFeatureFilterEdit->text(),
this, u
"generic"_s, context );
745 exprDlg.setWindowTitle( tr(
"Expression Based Filter" ) );
746 if ( exprDlg.exec() == QDialog::Accepted )
748 const QString expression = exprDlg.expressionText();
749 if ( !expression.isEmpty() )
751 mFeatureFilterEdit->setText( expression );
752 mTable->beginCommand( tr(
"Change Table Feature Filter" ) );
753 mTable->setFeatureFilter( mFeatureFilterEdit->text() );
755 mTable->endCommand();
760void QgsLayoutAttributeTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged(
int )
767 mTable->beginCommand( tr(
"Change Table Alignment" ) );
769 mTable->endCommand();
772void QgsLayoutAttributeTableWidget::mHeaderModeComboBox_currentIndexChanged(
int )
779 mTable->beginCommand( tr(
"Change Table Header Mode" ) );
781 mTable->endCommand();
784void QgsLayoutAttributeTableWidget::mWrapStringLineEdit_editingFinished()
791 mTable->beginCommand( tr(
"Change Table Wrap String" ) );
792 mTable->setWrapString( mWrapStringLineEdit->text() );
793 mTable->endCommand();
796void QgsLayoutAttributeTableWidget::changeLayer(
QgsMapLayer *layer )
803 QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
809 mTable->beginCommand( tr(
"Change Table Layer" ) );
810 mTable->setVectorLayer( vl );
812 mTable->endCommand();
814 mContentFontToolButton->setLayer( vl );
815 mHeaderFontToolButton->setLayer( vl );
820 mShowOnlyVisibleFeaturesCheckBox->setChecked(
false );
821 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
false );
822 mComposerMapComboBox->setEnabled(
false );
823 mComposerMapLabel->setEnabled(
false );
824 mIntersectAtlasCheckBox->setEnabled(
false );
828 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
829 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
830 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
835void QgsLayoutAttributeTableWidget::mAddFramePushButton_clicked()
837 if ( !mTable || !mFrame )
843 QPointF pos = mFrame->pos();
845 pos.ry() += mFrame->rect().height() + 10;
847 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
848 mTable->recalculateFrameSizes();
851 if ( QgsLayout *layout = mTable->layout() )
853 layout->setSelectedItem( newFrame );
857void QgsLayoutAttributeTableWidget::mResizeModeComboBox_currentIndexChanged(
int index )
864 mTable->beginCommand( tr(
"Change Resize Mode" ) );
866 mTable->endCommand();
871void QgsLayoutAttributeTableWidget::mSourceComboBox_currentIndexChanged(
int index )
878 mTable->beginCommand( tr(
"Change Table Source" ) );
880 mTable->endCommand();
882 toggleSourceControls();
885void QgsLayoutAttributeTableWidget::mRelationsComboBox_currentIndexChanged(
int index )
892 mTable->beginCommand( tr(
"Change Table Source Relation" ) );
893 mTable->setRelationId( mRelationsComboBox->itemData( index ).toString() );
894 mTable->endCommand();
897void QgsLayoutAttributeTableWidget::mEmptyModeComboBox_currentIndexChanged(
int index )
904 mTable->beginCommand( tr(
"Change Empty Table Behavior" ) );
906 mTable->endCommand();
911void QgsLayoutAttributeTableWidget::mWrapBehaviorComboBox_currentIndexChanged(
int index )
918 mTable->beginCommand( tr(
"Change Table Wrap Mode" ) );
920 mTable->endCommand();
923void QgsLayoutAttributeTableWidget::mAdvancedCustomizationButton_clicked()
930 QgsLayoutTableBackgroundColorsDialog d( mTable,
this );
934void QgsLayoutAttributeTableWidget::useConditionalStylingChanged(
bool checked )
941 mTable->beginCommand( tr(
"Toggle Table Conditional Styling" ) );
942 mTable->setUseConditionalStyling( checked );
944 mTable->endCommand();
947void QgsLayoutAttributeTableWidget::mDrawEmptyCheckBox_toggled(
bool checked )
954 mTable->beginCommand( tr(
"Change Show Empty Rows" ) );
955 mTable->setShowEmptyRows( checked );
956 mTable->endCommand();
959void QgsLayoutAttributeTableWidget::mEmptyMessageLineEdit_editingFinished()
966 mTable->beginCommand( tr(
"Change Empty Table Message" ) );
967 mTable->setEmptyTableMessage( mEmptyMessageLineEdit->text() );
968 mTable->endCommand();
971void QgsLayoutAttributeTableWidget::toggleSourceControls()
973 switch ( mTable->source() )
976 mLayerComboBox->setEnabled(
true );
977 mLayerComboBox->setVisible(
true );
978 mLayerSourceDDBtn->setVisible(
true );
979 mLayerLabel->setVisible(
true );
980 mRelationsComboBox->setEnabled(
false );
981 mRelationsComboBox->setVisible(
false );
982 mRelationLabel->setVisible(
false );
983 mMaximumRowsSpinBox->setEnabled(
true );
984 mMaxNumFeaturesLabel->setEnabled(
true );
985 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null );
986 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
987 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
988 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
992 mLayerComboBox->setEnabled(
false );
993 mLayerComboBox->setVisible(
false );
994 mLayerSourceDDBtn->setVisible(
false );
995 mLayerLabel->setVisible(
false );
996 mRelationsComboBox->setEnabled(
false );
997 mRelationsComboBox->setVisible(
false );
998 mRelationLabel->setVisible(
false );
999 mMaximumRowsSpinBox->setEnabled(
false );
1000 mMaxNumFeaturesLabel->setEnabled(
false );
1001 mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null );
1002 mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() !=
Qgis::GeometryType::Null && mTable->displayOnlyVisibleFeatures() );
1003 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1004 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1005 mIntersectAtlasCheckBox->setEnabled(
false );
1008 mLayerComboBox->setEnabled(
false );
1009 mLayerComboBox->setVisible(
false );
1010 mLayerLabel->setVisible(
false );
1011 mLayerSourceDDBtn->setVisible(
false );
1012 mRelationsComboBox->setEnabled(
true );
1013 mRelationsComboBox->setVisible(
true );
1014 mRelationLabel->setVisible(
true );
1015 mMaximumRowsSpinBox->setEnabled(
true );
1016 mMaxNumFeaturesLabel->setEnabled(
true );
1018 mShowOnlyVisibleFeaturesCheckBox->setEnabled(
true );
1019 mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1020 mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
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.