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 );
45 setWindowTitle( tr(
"%1 — Select by Expression" ).arg( layer->
name() ) );
52 mButtonSelect->addAction( mActionSelect );
53 mButtonSelect->addAction( mActionAddToSelection );
54 mButtonSelect->addAction( mActionRemoveFromSelection );
55 mButtonSelect->addAction( mActionSelectIntersect );
56 mButtonSelect->setDefaultAction( mActionSelect );
59 mExpressionBuilder->initWithLayer( layer, context, QStringLiteral(
"selection" ) );
60 mExpressionBuilder->setExpressionText( startText );
63 mButtonZoomToFeatures->setVisible(
false );
65 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsExpressionSelectionDialog::showHelp );
70 return mExpressionBuilder;
75 mExpressionBuilder->setExpressionText( text );
80 return mExpressionBuilder->expressionText();
86 mExpressionBuilder->setGeomCalculator( da );
91 mMessageBar = messageBar;
97 mButtonZoomToFeatures->setVisible(
true );
100 void QgsExpressionSelectionDialog::mActionSelect_triggered()
104 pushSelectedFeaturesMessage();
108 void QgsExpressionSelectionDialog::mActionAddToSelection_triggered()
112 pushSelectedFeaturesMessage();
116 void QgsExpressionSelectionDialog::mActionSelectIntersect_triggered()
120 pushSelectedFeaturesMessage();
124 void QgsExpressionSelectionDialog::mActionRemoveFromSelection_triggered()
128 pushSelectedFeaturesMessage();
132 void QgsExpressionSelectionDialog::pushSelectedFeaturesMessage()
137 const int timeout =
QgsSettings().
value( QStringLiteral(
"qgis/messageTimeout" ), 5 ).toInt();
142 tr(
"%n matching feature(s) selected",
"matching features", count ),
148 tr(
"No matching features found" ),
153 void QgsExpressionSelectionDialog::mButtonZoomToFeatures_clicked()
155 if ( mExpressionBuilder->expressionText().isEmpty() || !mMapCanvas )
169 int featureCount = 0;
183 int timeout = settings.
value( QStringLiteral(
"qgis/messageTimeout" ), 5 ).toInt();
184 if ( featureCount > 0 )
190 tr(
"Zoomed to %n matching feature(s)",
"number of matching features", featureCount ),
195 else if ( mMessageBar )
198 tr(
"No matching features found" ),
210 void QgsExpressionSelectionDialog::mPbnClose_clicked()
221 void QgsExpressionSelectionDialog::saveRecent()
223 mExpressionBuilder->expressionTree()->saveToRecent( mExpressionBuilder->expressionText(), QStringLiteral(
"selection" ) );
226 void QgsExpressionSelectionDialog::showHelp()
228 QgsHelp::openHelp( QStringLiteral(
"introduction/general_tools.html#automatic-selection" ) );