Skip to content

Commit

Permalink
Show feedback message when using Select by Expression, to match
Browse files Browse the repository at this point in the history
Select by Form behaviour

(cherry picked from commit 098aad5)
  • Loading branch information
nyalldawson committed Jan 11, 2019
1 parent 3376586 commit 0274be4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/gui/qgsexpressionselectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsexpressionselectiondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 0274be4

Please sign in to comment.