28 setWindowTitle( QString(
"Select by expression - %1" ).arg( layer->
name() ) );
35 mButtonSelect->addAction( mActionSelect );
36 mButtonSelect->addAction( mActionAddToSelection );
37 mButtonSelect->addAction( mActionRemoveFromSelection );
38 mButtonSelect->addAction( mActionSelectInstersect );
39 mButtonSelect->setDefaultAction( mActionSelect );
41 mExpressionBuilder->setLayer( layer );
42 mExpressionBuilder->setExpressionText( startText );
43 mExpressionBuilder->loadFieldNames();
44 mExpressionBuilder->loadRecent(
"Selection" );
47 restoreGeometry( settings.value(
"/Windows/ExpressionSelectionDialog/geometry" ).toByteArray() );
52 return mExpressionBuilder;
57 mExpressionBuilder->setExpressionText( text );
62 return mExpressionBuilder->expressionText();
68 mExpressionBuilder->setGeomCalculator( da );
85 if ( expression->
evaluate( &feat, fields ).toBool() )
87 newSelection << feat.
id();
113 if ( expression->
evaluate( &feat, fields ).toBool() )
115 newSelection << feat.
id();
145 if ( expression->
evaluate( &feat, fields ).toBool() )
147 newSelection << feat.
id();
182 if ( expression->
evaluate( &feat, fields ).toBool() )
184 newSelection.remove( feat.
id() );
204 QDialog::closeEvent( closeEvent );
207 settings.setValue(
"/Windows/ExpressionSelectionDialog/geometry", saveGeometry() );
221 void QgsExpressionSelectionDialog::saveRecent()
223 mExpressionBuilder->saveToRecent(
"Selection" );
QgsFeatureId id() const
Get the feature id for this feature.
QgsExpressionSelectionDialog(QgsVectorLayer *layer, QString startText=QString(), QWidget *parent=0)
Creates a new selection dialog.
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
QSet< QgsFeatureId > QgsFeatureIds
QString expressionText()
Returns the current expression text.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
static QIcon getThemeIcon(const QString &theName)
Helper to get a theme icon.
Container of fields for a vector layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void on_mActionRemoveFromSelection_triggered()
const QString & name() const
Get the display name of the layer.
void on_mActionAddToSelection_triggered()
const QgsFeatureIds & selectedFeaturesIds() const
Return reference to identifiers of selected features.
void setGeomCalculator(const QgsDistanceArea &da)
Sets geometry calculator used in distance/area calculations.
void on_mActionSelectInstersect_triggered()
virtual void closeEvent(QCloseEvent *closeEvent) override
Implementation for closeEvent Saves the window geometry.
virtual void done(int r) override
Implementation for done (default behavior when pressing esc) Calls close, so the window geometry gets...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsExpressionBuilderWidget * expressionBuilder()
The builder widget that is used by the dialog.
void setExpressionText(const QString &text)
Sets the current expression text.
void on_mPbnClose_clicked()
General purpose distance and area calculator.
void on_mActionSelect_triggered()
void setSelectedFeatures(const QgsFeatureIds &ids)
Change selection to the new set of features.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.