Skip to content
Permalink
Browse files

Show feedback message when using Select by Expression, to match

Select by Form behaviour
  • Loading branch information
nyalldawson committed Jan 8, 2019
1 parent 500dff1 commit 098aad5c1679142dee97bc298f5b75a40092b6de
Showing with 24 additions and 0 deletions.
  1. +22 −0 src/gui/qgsexpressionselectiondialog.cpp
  2. +2 −0 src/gui/qgsexpressionselectiondialog.h
@@ -104,30 +104,52 @@ void QgsExpressionSelectionDialog::mActionSelect_triggered()
{
mLayer->selectByExpression( mExpressionBuilder->expressionText(),
QgsVectorLayer::SetSelection );
pushSelectedFeaturesMessage();
saveRecent();
}

void QgsExpressionSelectionDialog::mActionAddToSelection_triggered()
{
mLayer->selectByExpression( mExpressionBuilder->expressionText(),
QgsVectorLayer::AddToSelection );
pushSelectedFeaturesMessage();
saveRecent();
}

void QgsExpressionSelectionDialog::mActionSelectIntersect_triggered()
{
mLayer->selectByExpression( mExpressionBuilder->expressionText(),
QgsVectorLayer::IntersectSelection );
pushSelectedFeaturesMessage();
saveRecent();
}

void QgsExpressionSelectionDialog::mActionRemoveFromSelection_triggered()
{
mLayer->selectByExpression( mExpressionBuilder->expressionText(),
QgsVectorLayer::RemoveFromSelection );
pushSelectedFeaturesMessage();
saveRecent();
}

void QgsExpressionSelectionDialog::pushSelectedFeaturesMessage()
{
int count = mLayer->selectedFeatureCount();
if ( count > 0 )
{
mMessageBar->pushMessage( QString(),
tr( "%1 matching %2 selected" ).arg( count )
.arg( count == 1 ? tr( "feature" ) : tr( "features" ) ),
Qgis::Info );
}
else
{
mMessageBar->pushMessage( QString(),
tr( "No matching features found" ),
Qgis::Warning );
}
}

void QgsExpressionSelectionDialog::mButtonZoomToFeatures_clicked()
{
if ( mExpressionBuilder->expressionText().isEmpty() || !mMapCanvas )
@@ -111,9 +111,11 @@ class GUI_EXPORT QgsExpressionSelectionDialog : public QDialog, private Ui::QgsE

private:
void saveRecent();
void pushSelectedFeaturesMessage();
QgsVectorLayer *mLayer = nullptr;
QgsMessageBar *mMessageBar = nullptr;
QgsMapCanvas *mMapCanvas = nullptr;

};

#endif

0 comments on commit 098aad5

Please sign in to comment.
You can’t perform that action at this time.