Navigation Menu

Skip to content

Commit

Permalink
Replace selectedFeaturesIds by selectedFeatureIds
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ committed Dec 6, 2016
1 parent c558d51 commit f9578bf
Show file tree
Hide file tree
Showing 44 changed files with 99 additions and 99 deletions.
6 changes: 3 additions & 3 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion python/gui/attributetable/qgsifeatureselectionmanager.sip
Expand Up @@ -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:
/**
Expand Down
Expand Up @@ -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. '
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/SelectByExpression.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/SelectByLocation.py
Expand Up @@ -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)

Expand Down
14 changes: 7 additions & 7 deletions src/analysis/vector/qgsgeometryanalyzer.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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() );
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/qgsoverlayanalyzer.cpp
Expand Up @@ -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() );
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -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" ),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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(
Expand All @@ -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 );
Expand All @@ -7200,7 +7200,7 @@ void QgisApp::mergeSelectedFeatures()
return;
}

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

if ( featureIdsAfter.size() < 2 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributeactiondialog.cpp
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributetabledialog.cpp
Expand Up @@ -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 );
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfieldcalculator.cpp
Expand Up @@ -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 ) )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolmovefeature.cpp
Expand Up @@ -130,7 +130,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent* e )
}
else
{
mMovedFeatures = vlayer->selectedFeaturesIds();
mMovedFeatures = vlayer->selectedFeatureIds();

mRubberBand = createRubberBand( vlayer->geometryType() );
QgsFeature feat;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptooloffsetcurve.cpp
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolrotatefeature.cpp
Expand Up @@ -279,7 +279,7 @@ void QgsMapToolRotateFeature::canvasReleaseEvent( QgsMapMouseEvent* e )
}
else
{
mRotatedFeatures = vlayer->selectedFeaturesIds();
mRotatedFeatures = vlayer->selectedFeatureIds();

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

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolselectutils.cpp
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -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 );
}
Expand All @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -325,7 +325,7 @@ void QgsVectorLayer::selectByExpression( const QString& expression, QgsVectorLay

if ( behaviour == AddToSelection )
{
newSelection = selectedFeaturesIds();
newSelection = selectedFeatureIds();
}
QgsFeature feat;
while ( features.nextFeature( feat ) )
Expand All @@ -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
Expand Down Expand Up @@ -2466,7 +2466,7 @@ int QgsVectorLayer::selectedFeatureCount() const
return mSelectedFeatureIds.size();
}

const QgsFeatureIds& QgsVectorLayer::selectedFeaturesIds() const
const QgsFeatureIds& QgsVectorLayer::selectedFeatureIds() const
{
return mSelectedFeatureIds;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgsvectorlayer.h
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayereditutils.cpp
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerimport.cpp
Expand Up @@ -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() )
Expand Down

0 comments on commit f9578bf

Please sign in to comment.