mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[quick] add utility method to select feature using their IDs from QML (#32735)
* [quick] add utility method to select feature using their IDs from QML * Update qgsquickutils.cpp
This commit is contained in:
parent
129165a100
commit
f1e6745fe7
@ -375,6 +375,14 @@ QString QgsQuickUtils::evaluateExpression( const QgsQuickFeatureLayerPair &pair,
|
||||
return expr.evaluate( &context ).toString();
|
||||
}
|
||||
|
||||
void QgsQuickUtils::selectFeaturesInLayer( QgsVectorLayer *layer, const QList<int> &fids, QgsVectorLayer::SelectBehavior behavior )
|
||||
{
|
||||
QgsFeatureIds qgsFids;
|
||||
for ( const int &fid : fids )
|
||||
qgsFids << fid;
|
||||
layer->selectByIds( qgsFids, behavior );
|
||||
}
|
||||
|
||||
qreal QgsQuickUtils::screenDensity() const
|
||||
{
|
||||
return mScreenDensity;
|
||||
|
@ -253,6 +253,17 @@ class QUICK_EXPORT QgsQuickUtils: public QObject
|
||||
*/
|
||||
Q_INVOKABLE static QString evaluateExpression( const QgsQuickFeatureLayerPair &pair, QgsProject *activeProject, const QString &expression );
|
||||
|
||||
/**
|
||||
* Selects features in a layer
|
||||
* This method is required since QML cannot perform the conversion of a feature ID to a QgsFeatureId (i.e. a qint64)
|
||||
* \param layer the vector layer
|
||||
* \param fids the list of feature IDs
|
||||
* \param behavior the selection behavior
|
||||
*
|
||||
* \since QGIS 3.12
|
||||
*/
|
||||
Q_INVOKABLE static void selectFeaturesInLayer( QgsVectorLayer *layer, const QList<int> &fids, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
|
||||
|
||||
private:
|
||||
static void formatToMetricDistance( double srcDistance,
|
||||
QgsUnitTypes::DistanceUnit srcUnits,
|
||||
|
Loading…
x
Reference in New Issue
Block a user