Skip to content

Commit

Permalink
Tweak the labeling of the new merge "from largest" button depending
Browse files Browse the repository at this point in the history
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 c8223b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
32 changes: 28 additions & 4 deletions src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -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 );
Expand Down
3 changes: 0 additions & 3 deletions src/ui/qgsmergeattributesdialogbase.ui
Expand Up @@ -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>
Expand Down

0 comments on commit c8223b9

Please sign in to comment.