Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix GUI on layout attributetable widget enabling/disabling geometry f…
…ilter 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
  • Loading branch information
signedav committed Mar 26, 2021
1 parent cf1ffda commit 75e9f01
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/gui/layout/qgslayoutattributetablewidget.cpp
Expand Up @@ -426,10 +426,16 @@ void QgsLayoutAttributeTableWidget::updateGuiElements()
//layer has no geometry, so uncheck & disable controls which require geometry
mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
mComposerMapComboBox->setEnabled( false );
mComposerMapLabel->setEnabled( false );
mIntersectAtlasCheckBox->setEnabled( false );
}
else
{
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mIntersectAtlasCheckBox->setEnabled( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
}
}

Expand Down Expand Up @@ -572,7 +578,7 @@ void QgsLayoutAttributeTableWidget::toggleAtlasSpecificControls( const bool atla
//add relations for coverage layer
updateRelationsCombo();
mRelationsComboBox->setEnabled( true );
mIntersectAtlasCheckBox->setEnabled( true );
mIntersectAtlasCheckBox->setEnabled( mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
}
}

Expand Down Expand Up @@ -803,10 +809,16 @@ void QgsLayoutAttributeTableWidget::changeLayer( QgsMapLayer *layer )
//layer has no geometry, so uncheck & disable controls which require geometry
mShowOnlyVisibleFeaturesCheckBox->setChecked( false );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
mComposerMapComboBox->setEnabled( false );
mComposerMapLabel->setEnabled( false );
mIntersectAtlasCheckBox->setEnabled( false );
}
else
{
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mIntersectAtlasCheckBox->setEnabled( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
}
}

Expand Down Expand Up @@ -960,9 +972,12 @@ void QgsLayoutAttributeTableWidget::toggleSourceControls()
mRelationLabel->setVisible( false );
mMaximumRowsSpinBox->setEnabled( true );
mMaxNumFeaturesLabel->setEnabled( true );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
mComposerMapComboBox->setEnabled( mTable->displayOnlyVisibleFeatures() );
mComposerMapLabel->setEnabled( mTable->displayOnlyVisibleFeatures() );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != QgsWkbTypes::NullGeometry );
mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != QgsWkbTypes::NullGeometry && mTable->displayOnlyVisibleFeatures() );
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mIntersectAtlasCheckBox->setEnabled( mTable->vectorLayer() && mTable->vectorLayer()->geometryType() != QgsWkbTypes::NullGeometry
&& mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
break;
case QgsLayoutItemAttributeTable::AtlasFeature:
mLayerComboBox->setEnabled( false );
Expand All @@ -974,9 +989,11 @@ void QgsLayoutAttributeTableWidget::toggleSourceControls()
mRelationLabel->setVisible( false );
mMaximumRowsSpinBox->setEnabled( false );
mMaxNumFeaturesLabel->setEnabled( false );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( false );
mComposerMapComboBox->setEnabled( false );
mComposerMapLabel->setEnabled( false );
mShowOnlyVisibleFeaturesCheckBox->setEnabled( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() != QgsWkbTypes::NullGeometry );
mShowOnlyVisibleFeaturesCheckBox->setChecked( mTable->sourceLayer() && mTable->sourceLayer()->geometryType() != QgsWkbTypes::NullGeometry && mTable->displayOnlyVisibleFeatures() );
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mIntersectAtlasCheckBox->setEnabled( false );
break;
case QgsLayoutItemAttributeTable::RelationChildren:
mLayerComboBox->setEnabled( false );
Expand All @@ -988,9 +1005,11 @@ void QgsLayoutAttributeTableWidget::toggleSourceControls()
mRelationLabel->setVisible( true );
mMaximumRowsSpinBox->setEnabled( true );
mMaxNumFeaturesLabel->setEnabled( true );
//it's missing the check for null geometry of the referencing layer
mShowOnlyVisibleFeaturesCheckBox->setEnabled( true );
mComposerMapComboBox->setEnabled( true );
mComposerMapLabel->setEnabled( true );
mComposerMapComboBox->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mComposerMapLabel->setEnabled( mShowOnlyVisibleFeaturesCheckBox->isChecked() );
mIntersectAtlasCheckBox->setEnabled( mSourceComboBox->findData( QgsLayoutItemAttributeTable::AtlasFeature ) != -1 && mTable->layout()->reportContext().layer() && mTable->layout()->reportContext().layer()->geometryType() != QgsWkbTypes::NullGeometry );
break;
}
}

0 comments on commit 75e9f01

Please sign in to comment.