Skip to content
Permalink
Browse files

Tweak the labeling of the new merge "from largest" button depending

on the layer's actual geometry type, and disable the option
for single-point layers
  • Loading branch information
nyalldawson committed Mar 16, 2021
1 parent fd826d7 commit c8223b97cb4ef842014db06f4d1dc0d21dba8351
Showing with 28 additions and 7 deletions.
  1. +28 −4 src/app/qgsmergeattributesdialog.cpp
  2. +0 −3 src/ui/qgsmergeattributesdialogbase.ui
@@ -79,10 +79,34 @@ QgsMergeAttributesDialog::QgsMergeAttributesDialog( const QgsFeatureList &featur
mFromLargestPushButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionFromLargestFeature.svg" ) ) );
mRemoveFeatureFromSelectionButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionRemoveSelectedFeature.svg" ) ) );

mFromLargestPushButton->setEnabled( mVectorLayer->geometryType() == QgsWkbTypes::PointGeometry ||
mVectorLayer->geometryType() == QgsWkbTypes::LineGeometry ||
mVectorLayer->geometryType() == QgsWkbTypes::PolygonGeometry );
mTakeLargestAttributesLabel->setEnabled( mFromLargestPushButton->isEnabled() );
switch ( mVectorLayer->geometryType() )
{
case QgsWkbTypes::PointGeometry:
mTakeLargestAttributesLabel->setText( tr( "Take attributes from feature with the most points" ) );
mFromLargestPushButton->setToolTip( tr( "Take all attributes from the MultiPoint feature with the most parts" ) );
if ( !QgsWkbTypes::isMultiType( mVectorLayer->wkbType() ) )
{
mTakeLargestAttributesLabel->setEnabled( false );
mFromLargestPushButton->setEnabled( false );
}
break;

case QgsWkbTypes::LineGeometry:
mTakeLargestAttributesLabel->setText( tr( "Take attributes from feature with the longest length" ) );
mFromLargestPushButton->setToolTip( tr( "Take all attributes from the Line feature with the longest length" ) );
break;

case QgsWkbTypes::PolygonGeometry:
mTakeLargestAttributesLabel->setText( tr( "Take attributes from feature with the largest area" ) );
mFromLargestPushButton->setToolTip( tr( "Take all attributes from the Polygon feature with the largest area" ) );
break;

case QgsWkbTypes::UnknownGeometry:
case QgsWkbTypes::NullGeometry:
mTakeLargestAttributesLabel->setEnabled( false );
mFromLargestPushButton->setEnabled( false );
break;
}

connect( mSkipAllButton, &QAbstractButton::clicked, this, &QgsMergeAttributesDialog::setAllToSkip );
connect( mTableWidget, &QTableWidget::cellChanged, this, &QgsMergeAttributesDialog::tableWidgetCellChanged );
@@ -64,9 +64,6 @@
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="mFromLargestPushButton">
<property name="toolTip">
<string>Take all attributes from the Polygon with the largest area, Line with the longest length or MultiPoint with the most parts</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>

0 comments on commit c8223b9

Please sign in to comment.