Skip to content
Permalink
Browse files

Replace selectedFeaturesIds by selectedFeatureIds

  • Loading branch information
DelazJ committed Dec 6, 2016
1 parent c558d51 commit f9578bf60b7a2a6359679c74066ebda735783381
Showing with 99 additions and 99 deletions.
  1. +3 −3 python/core/qgsvectorlayer.sip
  2. +1 −1 python/gui/attributetable/qgsifeatureselectionmanager.sip
  3. +1 −1 python/plugins/processing/algs/qgis/SelectByAttributeSum.py
  4. +1 −1 python/plugins/processing/algs/qgis/SelectByExpression.py
  5. +1 −1 python/plugins/processing/algs/qgis/SelectByLocation.py
  6. +7 −7 src/analysis/vector/qgsgeometryanalyzer.cpp
  7. +2 −2 src/analysis/vector/qgsoverlayanalyzer.cpp
  8. +6 −6 src/app/qgisapp.cpp
  9. +1 −1 src/app/qgsattributeactiondialog.cpp
  10. +1 −1 src/app/qgsattributetabledialog.cpp
  11. +1 −1 src/app/qgsfieldcalculator.cpp
  12. +1 −1 src/app/qgsidentifyresultsdialog.cpp
  13. +1 −1 src/app/qgsmaptoolmovefeature.cpp
  14. +1 −1 src/app/qgsmaptooloffsetcurve.cpp
  15. +1 −1 src/app/qgsmaptoolrotatefeature.cpp
  16. +1 −1 src/app/qgsmaptoolselectutils.cpp
  17. +1 −1 src/app/qgsmergeattributesdialog.cpp
  18. +1 −1 src/core/qgsexpression.cpp
  19. +2 −2 src/core/qgsofflineediting.cpp
  20. +2 −2 src/core/qgsvectorfilewriter.cpp
  21. +3 −3 src/core/qgsvectorlayer.cpp
  22. +3 −3 src/core/qgsvectorlayer.h
  23. +1 −1 src/core/qgsvectorlayereditutils.cpp
  24. +1 −1 src/core/qgsvectorlayerimport.cpp
  25. +1 −1 src/core/qgsvectorlayerrenderer.cpp
  26. +3 −3 src/gui/attributetable/qgsattributetablefiltermodel.cpp
  27. +1 −1 src/gui/attributetable/qgsfeatureselectionmodel.cpp
  28. +1 −1 src/gui/attributetable/qgsgenericfeatureselectionmanager.cpp
  29. +1 −1 src/gui/attributetable/qgsgenericfeatureselectionmanager.h
  30. +1 −1 src/gui/attributetable/qgsifeatureselectionmanager.h
  31. +2 −2 src/gui/attributetable/qgsvectorlayerselectionmanager.cpp
  32. +1 −1 src/gui/attributetable/qgsvectorlayerselectionmanager.h
  33. +1 −1 src/gui/qgsattributeform.cpp
  34. +1 −1 src/gui/qgsfeatureselectiondlg.cpp
  35. +4 −4 src/gui/qgsrelationeditorwidget.cpp
  36. +2 −2 src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp
  37. +1 −1 src/plugins/geometry_checker/qgsgeometrychecker.cpp
  38. +1 −1 src/plugins/geometry_checker/ui/qgsgeometrycheckersetuptab.cpp
  39. +2 −2 src/plugins/geometry_checker/utils/qgsfeaturepool.cpp
  40. +1 −1 src/plugins/grass/qgsgrassmoduleparam.cpp
  41. +3 −3 src/plugins/spatialquery/qgsspatialquerydialog.cpp
  42. +1 −1 tests/src/core/testqgsexpression.cpp
  43. +1 −1 tests/src/python/test_provider_shapefile.py
  44. +26 −26 tests/src/python/test_qgsvectorlayer.py
@@ -572,7 +572,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator
*
* @return A list of { @link QgsFeature } 's
*
* @see selectedFeaturesIds()
* @see selectedFeatureIds()
* @see selectedFeaturesIterator() which is more memory friendly when handling large selections
*/
QgsFeatureList selectedFeatures() const;
@@ -585,7 +585,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator
*
* @return Iterator over the selected features
*
* @see selectedFeaturesIds()
* @see selectedFeatureIds()
* @see selectedFeatures()
*/
QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() ) const;
@@ -596,7 +596,7 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator
* @return A list of { @link QgsFeatureId } 's
* @see selectedFeatures()
*/
const QgsFeatureIds &selectedFeaturesIds() const;
const QgsFeatureIds &selectedFeatureIds() const;

/** Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned */
QgsRectangle boundingBoxOfSelected() const;
@@ -63,7 +63,7 @@ class QgsIFeatureSelectionManager : QObject
* @return A list of { @link QgsFeatureId } 's
* @see selectedFeatures()
*/
virtual const QgsFeatureIds &selectedFeaturesIds() const = 0;
virtual const QgsFeatureIds &selectedFeatureIds() const = 0;

signals:
/**
@@ -63,7 +63,7 @@ def processAlgorithm(self, progress):
fieldName = self.getParameterValue(self.FIELD)
value = self.getParameterValue(self.VALUE)

selected = layer.selectedFeaturesIds()
selected = layer.selectedFeatureIds()
if len(selected) == 0:
GeoAlgorithmExecutionException(
self.tr('There is no selection in the input layer. '
@@ -61,7 +61,7 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
filename = self.getParameterValue(self.LAYERNAME)
layer = dataobjects.getObjectFromUri(filename)
oldSelection = set(layer.selectedFeaturesIds())
oldSelection = set(layer.selectedFeatureIds())
method = self.getParameterValue(self.METHOD)

if method == 0:
@@ -87,7 +87,7 @@ def processAlgorithm(self, progress):
predicates = self.getParameterValue(self.PREDICATE)
precision = self.getParameterValue(self.PRECISION)

oldSelection = set(inputLayer.selectedFeaturesIds())
oldSelection = set(inputLayer.selectedFeatureIds())
inputLayer.removeSelection()
index = vector.spatialindex(inputLayer)

@@ -58,7 +58,7 @@ bool QgsGeometryAnalyzer::simplify( QgsVectorLayer* layer,
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
const QgsFeatureIds selection = layer->selectedFeatureIds();
if ( p )
{
p->setMaximum( selection.size() );
@@ -173,7 +173,7 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
const QgsFeatureIds selection = layer->selectedFeatureIds();
if ( p )
{
p->setMaximum( selection.size() );
@@ -396,7 +396,7 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
const QgsFeatureIds selection = layer->selectedFeatureIds();
QgsFeatureIds::const_iterator it = selection.constBegin();
for ( ; it != selection.constEnd(); ++it )
{
@@ -447,7 +447,7 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
const QgsFeatureIds selection = layer->selectedFeatureIds();
if ( p )
{
p->setMaximum( selection.size() );
@@ -594,7 +594,7 @@ bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer* layer, const QString& shapef
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
const QgsFeatureIds selection = layer->selectedFeatureIds();
QgsFeatureIds::const_iterator it = selection.constBegin();
for ( ; it != selection.constEnd(); ++it )
{
@@ -626,7 +626,7 @@ bool QgsGeometryAnalyzer::dissolve( QgsVectorLayer* layer, const QString& shapef
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
const QgsFeatureIds selection = layer->selectedFeatureIds();
if ( p )
{
p->setMaximum( selection.size() );
@@ -744,7 +744,7 @@ bool QgsGeometryAnalyzer::buffer( QgsVectorLayer* layer, const QString& shapefil
if ( onlySelectedFeatures )
{
//use QgsVectorLayer::featureAtId
const QgsFeatureIds selection = layer->selectedFeaturesIds();
const QgsFeatureIds selection = layer->selectedFeatureIds();
if ( p )
{
p->setMaximum( selection.size() );
@@ -58,12 +58,12 @@ bool QgsOverlayAnalyzer::intersection( QgsVectorLayer* layerA, QgsVectorLayer* l
//take only selection
if ( onlySelectedFeatures )
{
QgsFeatureIds selectionB = layerB->selectedFeaturesIds();
QgsFeatureIds selectionB = layerB->selectedFeatureIds();
QgsFeatureRequest req = QgsFeatureRequest().setFilterFids( selectionB ).setSubsetOfAttributes( QgsAttributeList() );
QgsSpatialIndex index = QgsSpatialIndex( layerB->getFeatures( req ) );

//use QgsVectorLayer::featureAtId
const QgsFeatureIds selectionA = layerA->selectedFeaturesIds();
const QgsFeatureIds selectionA = layerA->selectedFeatureIds();
if ( p )
{
p->setMaximum( selectionA.size() );
@@ -6517,7 +6517,7 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget* parent, bool promptCo
}

//validate selection
int numberOfSelectedFeatures = vlayer->selectedFeaturesIds().size();
int numberOfSelectedFeatures = vlayer->selectedFeatureIds().size();
if ( numberOfSelectedFeatures == 0 )
{
messageBar()->pushMessage( tr( "No Features Selected" ),
@@ -7024,7 +7024,7 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
}

//get selected feature ids (as a QSet<int> )
const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
const QgsFeatureIds& featureIdSet = vl->selectedFeatureIds();
if ( featureIdSet.size() < 2 )
{
messageBar()->pushMessage(
@@ -7052,7 +7052,7 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
QSet<int> toSkip = d.skippedAttributeIndexes();

bool firstFeature = true;
Q_FOREACH ( QgsFeatureId fid, vl->selectedFeaturesIds() )
Q_FOREACH ( QgsFeatureId fid, vl->selectedFeatureIds() )
{
for ( int i = 0; i < merged.count(); ++i )
{
@@ -7166,7 +7166,7 @@ void QgisApp::mergeSelectedFeatures()
}

//get selected feature ids (as a QSet<int> )
const QgsFeatureIds& featureIdSet = vl->selectedFeaturesIds();
const QgsFeatureIds& featureIdSet = vl->selectedFeatureIds();
if ( featureIdSet.size() < 2 )
{
messageBar()->pushMessage(
@@ -7177,7 +7177,7 @@ void QgisApp::mergeSelectedFeatures()
}

//get initial selection (may be altered by attribute merge dialog later)
QgsFeatureIds featureIds = vl->selectedFeaturesIds();
QgsFeatureIds featureIds = vl->selectedFeatureIds();
QgsFeatureList featureList = vl->selectedFeatures(); //get QList<QgsFeature>
bool canceled;
QgsGeometry unionGeom = unionGeometries( vl, featureList, canceled );
@@ -7200,7 +7200,7 @@ void QgisApp::mergeSelectedFeatures()
return;
}

QgsFeatureIds featureIdsAfter = vl->selectedFeaturesIds();
QgsFeatureIds featureIdsAfter = vl->selectedFeatureIds();

if ( featureIdsAfter.size() < 2 )
{
@@ -306,7 +306,7 @@ void QgsAttributeActionDialog::addDefaultActions()
insertRow( pos++, QgsAction::GenericPython, tr( "Clicked coordinates (Run feature actions tool)" ), QStringLiteral( "from qgis.PyQt import QtWidgets\n\nQtWidgets.QMessageBox.information(None, \"Clicked coords\", \"layer: [% @layer_id %]\\ncoords: ([% @click_x %],[% @click_y %])\")" ), QLatin1String( "" ), false, tr( "Clicked Coordinate" ), QSet<QString>() << QStringLiteral( "Canvas" ) );
insertRow( pos++, QgsAction::OpenUrl, tr( "Open file" ), QStringLiteral( "[% \"PATH\" %]" ), QLatin1String( "" ), false, tr( "Open file" ), QSet<QString>() << QStringLiteral( "Feature" ) << QStringLiteral( "Canvas" ) );
insertRow( pos++, QgsAction::OpenUrl, tr( "Search on web based on attribute's value" ), QStringLiteral( "http://www.google.com/search?q=[% \"ATTRIBUTE\" %]" ), QLatin1String( "" ), false, tr( "Search Web" ), QSet<QString>() << QStringLiteral( "Field" ) );
insertRow( pos++, QgsAction::GenericPython, tr( "List feature ids" ), QStringLiteral( "from qgis.PyQt import QtWidgets\n\nlayer = QgsMapLayerRegistry.instance().mapLayer('[% @layer_id %]')\nif layer.selectedFeatureCount():\n ids = layer.selectedFeaturesIds()\nelse:\n ids = [f.id() for f in layer.getFeatures()]\n\nQtWidgets.QMessageBox.information(None, \"Feature ids\", ', '.join([str(id) for id in ids]))" ), QLatin1String( "" ), false, tr( "List feature ids" ), QSet<QString>() << QStringLiteral( "Layer" ) );
insertRow( pos++, QgsAction::GenericPython, tr( "List feature ids" ), QStringLiteral( "from qgis.PyQt import QtWidgets\n\nlayer = QgsMapLayerRegistry.instance().mapLayer('[% @layer_id %]')\nif layer.selectedFeatureCount():\n ids = layer.selectedFeatureIds()\nelse:\n ids = [f.id() for f in layer.getFeatures()]\n\nQtWidgets.QMessageBox.information(None, \"Feature ids\", ', '.join([str(id) for id in ids]))" ), QLatin1String( "" ), false, tr( "List feature ids" ), QSet<QString>() << QStringLiteral( "Layer" ) );
}

void QgsAttributeActionDialog::itemDoubleClicked( QTableWidgetItem* item )
@@ -436,7 +436,7 @@ void QgsAttributeTableDialog::updateFieldFromExpression()

void QgsAttributeTableDialog::updateFieldFromExpressionSelected()
{
QgsFeatureIds filteredIds = mLayer->selectedFeaturesIds();
QgsFeatureIds filteredIds = mLayer->selectedFeatureIds();
runFieldCalculation( mLayer, mFieldCombo->currentText(), mUpdateExpressionText->asExpression(), filteredIds );
}

@@ -276,7 +276,7 @@ void QgsFieldCalculator::accept()
QgsFeatureRequest req = QgsFeatureRequest().setFlags( useGeometry ? QgsFeatureRequest::NoFlags : QgsFeatureRequest::NoGeometry );
if ( mOnlyUpdateSelectedCheckBox->isChecked() )
{
req.setFilterFids( mVectorLayer->selectedFeaturesIds() );
req.setFilterFids( mVectorLayer->selectedFeatureIds() );
}
QgsFeatureIterator fit = mVectorLayer->getFeatures( req );
while ( fit.nextFeature( feature ) )
@@ -1915,7 +1915,7 @@ void QgsIdentifyResultsDialog::toggleFeatureSelection()
if ( !vl )
return;

if ( vl->selectedFeaturesIds().contains( item->feature().id() ) )
if ( vl->selectedFeatureIds().contains( item->feature().id() ) )
vl->deselect( item->feature().id() );
else
vl->select( item->feature().id() );
@@ -130,7 +130,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}
else
{
mMovedFeatures = vlayer->selectedFeaturesIds();
mMovedFeatures = vlayer->selectedFeatureIds();

mRubberBand = createRubberBand( vlayer->geometryType() );
QgsFeature feat;
@@ -284,7 +284,7 @@ QgsGeometry QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, con
}

//for background layers, try to merge selected entries together if snapped feature is contained in selection
const QgsFeatureIds& selection = vl->selectedFeaturesIds();
const QgsFeatureIds& selection = vl->selectedFeatureIds();
if ( selection.size() < 1 || !selection.contains( match.featureId() ) )
{
return convertToSingleLine( snappedFeature.geometry(), partVertexNr, mMultiPartGeometry );
@@ -279,7 +279,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent* e )
}
else
{
mRotatedFeatures = vlayer->selectedFeaturesIds();
mRotatedFeatures = vlayer->selectedFeatureIds();

mRubberBand = createRubberBand( vlayer->geometryType() ) ;

@@ -129,7 +129,7 @@ void QgsMapToolSelectUtils::selectSingleFeature( QgsMapCanvas* canvas, const Qgs
if ( e->modifiers() & Qt::ShiftModifier || e->modifiers() & Qt::ControlModifier )
{
QgsFeatureId selectId = *selectedFeatures.constBegin();
QgsFeatureIds layerSelectedFeatures = vlayer->selectedFeaturesIds();
QgsFeatureIds layerSelectedFeatures = vlayer->selectedFeatureIds();
if ( layerSelectedFeatures.contains( selectId ) )
behaviour = QgsVectorLayer::RemoveFromSelection;
else
@@ -464,7 +464,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
selectedRowChanged();

//remove feature from the vector layer selection
QgsFeatureIds selectedIds = mVectorLayer->selectedFeaturesIds();
QgsFeatureIds selectedIds = mVectorLayer->selectedFeatureIds();
selectedIds.remove( featureId );
mVectorLayer->selectByIds( selectedIds );
mMapCanvas->repaint();
@@ -1493,7 +1493,7 @@ static QVariant fcnIsSelected( const QVariantList& values, const QgsExpressionCo
return QVariant( QVariant::Bool );
}

return layer->selectedFeaturesIds().contains( feature.id() );
return layer->selectedFeatureIds().contains( feature.id() );
}

static QVariant fcnNumSelected( const QVariantList& values, const QgsExpressionContext* context, QgsExpression* parent )
@@ -627,7 +627,7 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit

if ( onlySelected )
{
QgsFeatureIds selectedFids = layer->selectedFeaturesIds();
QgsFeatureIds selectedFids = layer->selectedFeatureIds();
if ( !selectedFids.isEmpty() )
req.setFilterFids( selectedFids );
}
@@ -636,7 +636,7 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit

if ( req.filterType() == QgsFeatureRequest::FilterFids )
{
emit progressModeSet( QgsOfflineEditing::CopyFeatures, layer->selectedFeaturesIds().size() );
emit progressModeSet( QgsOfflineEditing::CopyFeatures, layer->selectedFeatureIds().size() );
}
else
{
@@ -2379,7 +2379,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
QgsFeatureRequest req;
if ( options.onlySelectedFeatures )
{
req.setFilterFids( layer->selectedFeaturesIds() );
req.setFilterFids( layer->selectedFeatureIds() );
}
QgsFeatureIterator fit = layer->getFeatures( req );
QgsFeature fet;
@@ -2455,7 +2455,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer* layer,
}
req.setSubsetOfAttributes( attributes );
if ( options.onlySelectedFeatures )
req.setFilterFids( layer->selectedFeaturesIds() );
req.setFilterFids( layer->selectedFeatureIds() );
QgsFeatureIterator fit = layer->getFeatures( req );

//create symbol table if needed
@@ -325,7 +325,7 @@ void QgsVectorLayer::selectByExpression( const QString& expression, QgsVectorLay

if ( behaviour == AddToSelection )
{
newSelection = selectedFeaturesIds();
newSelection = selectedFeatureIds();
}
QgsFeature feat;
while ( features.nextFeature( feat ) )
@@ -339,7 +339,7 @@ void QgsVectorLayer::selectByExpression( const QString& expression, QgsVectorLay
QgsExpression exp( expression );
exp.prepare( &context );

QgsFeatureIds oldSelection = selectedFeaturesIds();
QgsFeatureIds oldSelection = selectedFeatureIds();
QgsFeatureRequest request = QgsFeatureRequest().setFilterFids( oldSelection );

//refine request
@@ -2466,7 +2466,7 @@ int QgsVectorLayer::selectedFeatureCount() const
return mSelectedFeatureIds.size();
}

const QgsFeatureIds& QgsVectorLayer::selectedFeaturesIds() const
const QgsFeatureIds& QgsVectorLayer::selectedFeatureIds() const
{
return mSelectedFeatureIds;
}
@@ -668,7 +668,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*
* @return A list of { @link QgsFeature } 's
*
* @see selectedFeaturesIds()
* @see selectedFeatureIds()
* @see selectedFeaturesIterator() which is more memory friendly when handling large selections
*/
QgsFeatureList selectedFeatures() const;
@@ -681,7 +681,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*
* @return Iterator over the selected features
*
* @see selectedFeaturesIds()
* @see selectedFeatureIds()
* @see selectedFeatures()
*/
QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() ) const;
@@ -692,7 +692,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
* @return A list of { @link QgsFeatureId } 's
* @see selectedFeatures()
*/
const QgsFeatureIds &selectedFeaturesIds() const;
const QgsFeatureIds &selectedFeatureIds() const;

//! Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned
QgsRectangle boundingBoxOfSelected() const;
@@ -304,7 +304,7 @@ int QgsVectorLayerEditUtils::splitFeatures( const QList<QgsPoint>& splitLine, bo
int numberOfSplittedFeatures = 0;

QgsFeatureIterator features;
const QgsFeatureIds selectedIds = L->selectedFeaturesIds();
const QgsFeatureIds selectedIds = L->selectedFeatureIds();

if ( !selectedIds.isEmpty() ) //consider only the selected features if there is a selection
{
@@ -315,7 +315,7 @@ QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,

QgsFeatureIterator fit = layer->getFeatures( req );

const QgsFeatureIds& ids = layer->selectedFeaturesIds();
const QgsFeatureIds& ids = layer->selectedFeatureIds();

// Create our transform
if ( destCRS.isValid() )

0 comments on commit f9578bf

Please sign in to comment.
You can’t perform that action at this time.