Skip to content

Commit

Permalink
QgsVectorLayer::featureAtId() - use the same semantics as QgsVectorDa…
Browse files Browse the repository at this point in the history
…taProvider::featureAtId()

i.e. return true on success


git-svn-id: http://svn.osgeo.org/qgis/trunk@9620 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 11, 2008
1 parent bb63eac commit 9221974
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -166,8 +166,8 @@ public:


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

/** Adds a feature
@param alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents.
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolidentify.cpp
Expand Up @@ -451,7 +451,7 @@ void QgsMapToolIdentify::highlightFeature( int featureId )
mRubberBand = 0;

QgsFeature feat;
if ( layer->featureAtId( featureId, feat, true, false ) != 0 )
if ( ! layer->featureAtId( featureId, feat, true, false ) )
{
return;
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1301,13 +1301,13 @@ bool QgsVectorLayer::nextFeature( QgsFeature &f )
return false;
}

int QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometries, bool fetchAttributes )
bool QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometries, bool fetchAttributes )
{
if ( !mDataProvider )
return 1;
return false;

if ( mDeletedFeatureIds.contains( featureId ) )
return 2;
return false;

if ( fetchGeometries && mChangedGeometries.contains( featureId ) )
{
Expand Down Expand Up @@ -1359,7 +1359,7 @@ int QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometr
if ( fetchAttributes )
f.setAttributeMap( iter->attributeMap() );

return 0;
return true;
}
}

Expand All @@ -1369,17 +1369,17 @@ int QgsVectorLayer::featureAtId( int featureId, QgsFeature& f, bool fetchGeometr
if ( mDataProvider->featureAtId( featureId, f, fetchGeometries, mDataProvider->attributeIndexes() ) )
{
updateFeatureAttributes( f );
return 0;
return true;
}
}
else
{
if ( mDataProvider->featureAtId( featureId, f, fetchGeometries, QgsAttributeList() ) )
{
return 0;
return true;
}
}
return 3;
return false;
}

bool QgsVectorLayer::addFeature( QgsFeature& f, bool alsoUpdateExtent )
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayer.h
Expand Up @@ -225,8 +225,8 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
bool nextFeature( QgsFeature& feature );

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

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

0 comments on commit 9221974

Please sign in to comment.