Skip to content

Commit 75e9f01

Browse files
authoredMar 26, 2021
Fix GUI on layout attributetable widget enabling/disabling geometry filter options (#41668)
* uncheck show only visible on map on Current Report Layer source * consider disabling depending map combobox * disable the widgets according to the layers geometry (if nullgeometry - don't provide geometric filters * check for vector layer before accessing the geometryType * allow 'show only features visible within a map' on current report feature but only if it has geometry * enable/disable 'show only features intersecting report feature' according if layer has geometry AND if atlas-layer has geometry
1 parent cf1ffda commit 75e9f01

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed
 

‎src/gui/layout/qgslayoutattributetablewidget.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,16 @@ void QgsLayoutAttributeTableWidget::updateGuiElements()
426426
//layer has no geometry, so uncheck & disable controls which require geometry
427427
mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
428428
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
429+
mComposerMapComboBox->setEnabled( false );
430+
mComposerMapLabel->setEnabled( false );
431+
mIntersectAtlasCheckBox->setEnabled( false );
429432
}
430433
else
431434
{
432435
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
436+
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
437+
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
438+
mIntersectAtlasCheckBox->setEnabled( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
433439
}
434440
}
435441

@@ -572,7 +578,7 @@ void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls( const bool atla
572578
//add relations for coverage layer
573579
updateRelationsCombo();
574580
mRelationsComboBox->setEnabled( true );
575-
mIntersectAtlasCheckBox->setEnabled( true );
581+
mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
576582
}
577583
}
578584

@@ -803,10 +809,16 @@ void QgsLayoutAttributeTableWidget::changeLayer( QgsMapLayer *layer )
803809
//layer has no geometry, so uncheck & disable controls which require geometry
804810
mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
805811
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
812+
mComposerMapComboBox->setEnabled( false );
813+
mComposerMapLabel->setEnabled( false );
814+
mIntersectAtlasCheckBox->setEnabled( false );
806815
}
807816
else
808817
{
809818
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
819+
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
820+
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
821+
mIntersectAtlasCheckBox->setEnabled( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
810822
}
811823
}
812824

@@ -960,9 +972,12 @@ void QgsLayoutAttributeTableWidget::toggleSourceControls()
960972
mRelationLabel->setVisible( false );
961973
mMaximumRowsSpinBox->setEnabled( true );
962974
mMaxNumFeaturesLabel->setEnabled( true );
963-
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
964-
mComposerMapComboBox->setEnabled( mTable->displayOnlyVisibleFeatures() );
965-
mComposerMapLabel->setEnabled( mTable->displayOnlyVisibleFeatures() );
975+
mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != QgsWkbTypes::NullGeometry );
976+
mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != QgsWkbTypes::NullGeometry && mTable->displayOnlyVisibleFeatures() );
977+
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
978+
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
979+
mIntersectAtlasCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != QgsWkbTypes::NullGeometry
980+
&& mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
966981
break;
967982
case QgsLayoutItemAttributeTable::AtlasFeature:
968983
mLayerComboBox->setEnabled( false );
@@ -974,9 +989,11 @@ void QgsLayoutAttributeTableWidget::toggleSourceControls()
974989
mRelationLabel->setVisible( false );
975990
mMaximumRowsSpinBox->setEnabled( false );
976991
mMaxNumFeaturesLabel->setEnabled( false );
977-
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
978-
mComposerMapComboBox->setEnabled( false );
979-
mComposerMapLabel->setEnabled( false );
992+
mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() != QgsWkbTypes::NullGeometry );
993+
mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() != QgsWkbTypes::NullGeometry && mTable->displayOnlyVisibleFeatures() );
994+
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
995+
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
996+
mIntersectAtlasCheckBox->setEnabled( false );
980997
break;
981998
case QgsLayoutItemAttributeTable::RelationChildren:
982999
mLayerComboBox->setEnabled( false );
@@ -988,9 +1005,11 @@ void QgsLayoutAttributeTableWidget::toggleSourceControls()
9881005
mRelationLabel->setVisible( true );
9891006
mMaximumRowsSpinBox->setEnabled( true );
9901007
mMaxNumFeaturesLabel->setEnabled( true );
1008+
//it's missing the check for null geometry of the referencing layer
9911009
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
992-
mComposerMapComboBox->setEnabled( true );
993-
mComposerMapLabel->setEnabled( true );
1010+
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1011+
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
1012+
mIntersectAtlasCheckBox->setEnabled( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
9941013
break;
9951014
}
9961015
}

0 commit comments

Comments
 (0)
Please sign in to comment.