Skip to content

Commit 42e6a11

Browse files
author
wonder
committed
QgsVectorLayer::featureAtId() - use the same semantics as QgsVectorDataProvider::featureAtId()
i.e. return true on success git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9620 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2c0c939 commit 42e6a11

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

python/core/qgsvectorlayer.sip

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ public:
166166

167167

168168
/**Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
169-
@return 0 in case of success*/
170-
int featureAtId(int featureId, QgsFeature& f, bool fetchGeometries = true, bool fetchAttributes = true);
169+
@return true in case of success*/
170+
bool featureAtId(int featureId, QgsFeature& f, bool fetchGeometries = true, bool fetchAttributes = true);
171171

172172
/** Adds a feature
173173
@param alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents.

src/app/qgsmaptoolidentify.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void QgsMapToolIdentify::highlightFeature( int featureId )
451451
mRubberBand = 0;
452452

453453
QgsFeature feat;
454-
if ( layer->featureAtId( featureId, feat, true, false ) != 0 )
454+
if ( ! layer->featureAtId( featureId, feat, true, false ) )
455455
{
456456
return;
457457
}

src/core/qgsvectorlayer.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1301,13 +1301,13 @@ bool QgsVectorLayer::nextFeature( QgsFeature &f )
13011301
return false;
13021302
}
13031303

1304-
int QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometries, bool fetchAttributes )
1304+
bool QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometries, bool fetchAttributes )
13051305
{
13061306
if ( !mDataProvider )
1307-
return 1;
1307+
return false;
13081308

13091309
if ( mDeletedFeatureIds.contains( featureId ) )
1310-
return 2;
1310+
return false;
13111311

13121312
if ( fetchGeometries && mChangedGeometries.contains( featureId ) )
13131313
{
@@ -1359,7 +1359,7 @@ int QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometr
13591359
if ( fetchAttributes )
13601360
f.setAttributeMap( iter->attributeMap() );
13611361

1362-
return 0;
1362+
return true;
13631363
}
13641364
}
13651365

@@ -1369,17 +1369,17 @@ int QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometr
13691369
if ( mDataProvider->featureAtId( featureId, f, fetchGeometries, mDataProvider->attributeIndexes() ) )
13701370
{
13711371
updateFeatureAttributes( f );
1372-
return 0;
1372+
return true;
13731373
}
13741374
}
13751375
else
13761376
{
13771377
if ( mDataProvider->featureAtId( featureId, f, fetchGeometries, QgsAttributeList() ) )
13781378
{
1379-
return 0;
1379+
return true;
13801380
}
13811381
}
1382-
return 3;
1382+
return false;
13831383
}
13841384

13851385
bool QgsVectorLayer::addFeature( QgsFeature& f, bool alsoUpdateExtent )

src/core/qgsvectorlayer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
225225
bool nextFeature( QgsFeature& feature );
226226

227227
/**Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
228-
@return 0 in case of success*/
229-
int featureAtId( int featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true );
228+
@return true in case of success*/
229+
bool featureAtId( int featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true );
230230

231231
/** Adds a feature
232232
@param lastFeatureInBatch If True, will also go to the effort of e.g. updating the extents.

0 commit comments

Comments
 (0)