38 connect( mActionSelect, &QAction::triggered,
this, &QgsExpressionSelectionDialog::mActionSelect_triggered );
39 connect( mActionAddToSelection, &QAction::triggered,
this, &QgsExpressionSelectionDialog::mActionAddToSelection_triggered );
40 connect( mActionRemoveFromSelection, &QAction::triggered,
this, &QgsExpressionSelectionDialog::mActionRemoveFromSelection_triggered );
41 connect( mActionSelectIntersect, &QAction::triggered,
this, &QgsExpressionSelectionDialog::mActionSelectIntersect_triggered );
42 connect( mButtonZoomToFeatures, &QToolButton::clicked,
this, &QgsExpressionSelectionDialog::mButtonZoomToFeatures_clicked );
43 connect( mPbnClose, &QPushButton::clicked,
this, &QgsExpressionSelectionDialog::mPbnClose_clicked );
46 setWindowTitle( tr(
"%1 — Select by Expression" ).arg( layer->
name() ) );
53 mButtonSelect->addAction( mActionSelect );
54 mButtonSelect->addAction( mActionAddToSelection );
55 mButtonSelect->addAction( mActionRemoveFromSelection );
56 mButtonSelect->addAction( mActionSelectIntersect );
57 mButtonSelect->setDefaultAction( mActionSelect );
60 mExpressionBuilder->initWithLayer( layer, context, QStringLiteral(
"selection" ) );
61 mExpressionBuilder->setExpressionText( startText );
64 mButtonZoomToFeatures->setVisible(
false );
66 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsExpressionSelectionDialog::showHelp );
71 return mExpressionBuilder;
76 mExpressionBuilder->setExpressionText( text );
81 return mExpressionBuilder->expressionText();
87 mExpressionBuilder->setGeomCalculator( da );
92 mMessageBar = messageBar;
98 mButtonZoomToFeatures->setVisible(
true );
101 void QgsExpressionSelectionDialog::mActionSelect_triggered()
105 pushSelectedFeaturesMessage();
109 void QgsExpressionSelectionDialog::mActionAddToSelection_triggered()
113 pushSelectedFeaturesMessage();
117 void QgsExpressionSelectionDialog::mActionSelectIntersect_triggered()
121 pushSelectedFeaturesMessage();
125 void QgsExpressionSelectionDialog::mActionRemoveFromSelection_triggered()
129 pushSelectedFeaturesMessage();
133 void QgsExpressionSelectionDialog::pushSelectedFeaturesMessage()
142 tr(
"%n matching feature(s) selected",
"matching features", count ),
143 Qgis::MessageLevel::Info );
148 tr(
"No matching features found" ),
149 Qgis::MessageLevel::Info );
153 void QgsExpressionSelectionDialog::mButtonZoomToFeatures_clicked()
155 if ( mExpressionBuilder->expressionText().isEmpty() || !mMapCanvas )
169 int featureCount = 0;
182 if ( featureCount > 0 )
188 tr(
"Zoomed to %n matching feature(s)",
"number of matching features", featureCount ),
189 Qgis::MessageLevel::Info );
192 else if ( mMessageBar )
195 tr(
"No matching features found" ),
196 Qgis::MessageLevel::Info );
206 void QgsExpressionSelectionDialog::mPbnClose_clicked()
217 void QgsExpressionSelectionDialog::saveRecent()
219 mExpressionBuilder->expressionTree()->saveToRecent( mExpressionBuilder->expressionText(), QStringLiteral(
"selection" ) );
222 void QgsExpressionSelectionDialog::showHelp()
224 QgsHelp::openHelp( QStringLiteral(
"introduction/general_tools.html#automatic-selection" ) );