Skip to content

Commit

Permalink
Remove duplicate QgsFeature::setFeatureId method
Browse files Browse the repository at this point in the history
Leave just QgsFeature::setId and document api break
  • Loading branch information
nyalldawson authored and m-kuhn committed Jan 11, 2017
1 parent 3e2b4fc commit e656c63
Show file tree
Hide file tree
Showing 36 changed files with 58 additions and 86 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ None will need to be modified, as the method will return an empty geometry if th
- The temporary constGeometry() method has been removed. Use geometry() instead.
- setFields( const QgsFields*, bool ) has been removed, use setFields( const QgsFields&, bool ) instead.
- fields() no longer returns a pointer, but instead a QgsFields value.
- The duplicate method setFeatureId() was removed. Use setId() instead.


QgsFeatureRendererV2 {#qgis_api_break_3_0_QgsFeatureRendererV2}
Expand Down
6 changes: 0 additions & 6 deletions python/core/qgsfeature.sip
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ class QgsFeature
*/
QgsFeatureId id() const;

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
*/
void setFeatureId( QgsFeatureId id );

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
Expand Down
17 changes: 1 addition & 16 deletions src/core/qgsfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,6 @@ QgsGeometry QgsFeature::geometry() const
return d->geometry;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests in testqgsfeature.cpp.
* See details in QEP #17
****************************************************************************/

void QgsFeature::setFeatureId( QgsFeatureId id )
{
if ( id == d->fid )
return;

d.detach();
d->fid = id;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests in testqgsfeature.cpp.
Expand Down Expand Up @@ -324,7 +309,7 @@ QDataStream& operator>>( QDataStream& in, QgsFeature& feature )
bool valid;
QgsAttributes attr;
in >> id >> attr >> geometry >> valid;
feature.setFeatureId( id );
feature.setId( id );
feature.setGeometry( geometry );
feature.setAttributes( attr );
feature.setValid( valid );
Expand Down
10 changes: 1 addition & 9 deletions src/core/qgsfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,14 @@ class CORE_EXPORT QgsFeature
*/
bool operator!=( const QgsFeature& other ) const;



virtual ~QgsFeature();

/** Get the feature ID for this feature.
* @returns feature ID
* @see setFeatureId
* @see setId()
*/
QgsFeatureId id() const;

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
*/
void setFeatureId( QgsFeatureId id );

/** Sets the feature ID for this feature.
* @param id feature id
* @see id
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsogrutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QgsFeature QgsOgrUtils::readOgrFeature( OGRFeatureH ogrFet, const QgsFields& fie
return feature;
}

feature.setFeatureId( OGR_F_GetFID( ogrFet ) );
feature.setId( OGR_F_GetFID( ogrFet ) );
feature.setValid( true );

if ( !readOgrFeatureGeometry( ogrFet, feature ) )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerdiagramprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void QgsVectorLayerDiagramProvider::drawLabel( QgsRenderContext& context, pal::L
QgsFeature feature;
feature.setFields( mFields );
feature.setValid( true );
feature.setFeatureId( label->getFeaturePart()->featureId() );
feature.setId( label->getFeaturePart()->featureId() );
feature.setAttributes( dlf->attributes() );

//calculate top-left point for diagram
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorlayerfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextAddedFeature( QgsFeature& f )

void QgsVectorLayerFeatureIterator::useAddedFeature( const QgsFeature& src, QgsFeature& f )
{
f.setFeatureId( src.id() );
f.setId( src.id() );
f.setValid( true );
f.setFields( mSource->mFields );

Expand Down Expand Up @@ -450,7 +450,7 @@ bool QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature( QgsFeature

void QgsVectorLayerFeatureIterator::useChangedAttributeFeature( QgsFeatureId fid, const QgsGeometry& geom, QgsFeature& f )
{
f.setFeatureId( fid );
f.setId( fid );
f.setValid( true );
f.setFields( mSource->mFields );

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerundocommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ QgsVectorLayerUndoCommandAddFeature::QgsVectorLayerUndoCommandAddFeature( QgsVec
// Force a feature ID (to keep other functions in QGIS happy,
// providers will use their own new feature ID when we commit the new feature)
// and add to the known added features.
f.setFeatureId( addedIdLowWaterMark );
f.setId( addedIdLowWaterMark );

mFeature = f;
}
Expand Down
6 changes: 3 additions & 3 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ QgsAttributeTableModel::QgsAttributeTableModel( QgsVectorLayerCache *layerCache,
mFeatureRequest.setFlags( QgsFeatureRequest::NoGeometry );
}

mFeat.setFeatureId( std::numeric_limits<int>::min() );
mFeat.setId( std::numeric_limits<int>::min() );

if ( !layer()->hasGeometryType() )
mFeatureRequest.setFlags( QgsFeatureRequest::NoGeometry );
Expand Down Expand Up @@ -744,7 +744,7 @@ Qt::ItemFlags QgsAttributeTableModel::flags( const QModelIndex &index ) const

void QgsAttributeTableModel::reload( const QModelIndex &index1, const QModelIndex &index2 )
{
mFeat.setFeatureId( std::numeric_limits<int>::min() );
mFeat.setId( std::numeric_limits<int>::min() );
emit dataChanged( index1, index2 );
}

Expand All @@ -765,7 +765,7 @@ QgsFeature QgsAttributeTableModel::feature( const QModelIndex &idx ) const
{
QgsFeature f;
f.initAttributes( mAttributes.size() );
f.setFeatureId( rowToId( idx.row() ) );
f.setId( rowToId( idx.row() ) );
for ( int i = 0; i < mAttributes.size(); i++ )
{
f.setAttribute( mAttributes[i], data( index( idx.row(), i ), Qt::EditRole ) );
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/geometry_checker/utils/qgsfeaturepool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void QgsFeaturePool::addFeature( QgsFeature& feature )
features.append( feature );
mLayerMutex.lock();
mLayer->dataProvider()->addFeatures( features );
feature.setFeatureId( features.front().id() );
feature.setId( features.front().id() );
if ( mSelectedOnly )
{
QgsFeatureIds selectedFeatureIds = mLayer->selectedFeatureIds();
Expand Down
2 changes: 1 addition & 1 deletion src/providers/arcgisrest/qgsafsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ bool QgsAfsProvider::getFeature( QgsFeatureId id, QgsFeature &f, bool fetchGeome
QgsFeature feature;

// Set FID
feature.setFeatureId( startId + i );
feature.setId( startId + i );

// Set attributes
if ( !fetchAttribIdx.isEmpty() )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/db2/qgsdb2featureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ bool QgsDb2FeatureIterator::fetchFeature( QgsFeature& feature )
}
}
// QgsDebugMsg( QString( "Fid: %1; value: %2" ).arg( mSource->mFidColName ).arg( record.value( mSource->mFidColName ).toLongLong() ) );
feature.setFeatureId( mQuery->record().value( mSource->mFidColName ).toLongLong() );
feature.setId( mQuery->record().value( mSource->mFidColName ).toLongLong() );

if ( mSource->isSpatial() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/db2/qgsdb2provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ bool QgsDb2Provider::addFeatures( QgsFeatureList & flist )
return false;
}
}
it->setFeatureId( queryFid.value( 0 ).toLongLong() );
it->setId( queryFid.value( 0 ).toLongLong() );
writeCount++;
// QgsDebugMsg( QString( "count: %1; featureId: %2" ).arg( writeCount ).arg( queryFid.value( 0 ).toLongLong() ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ bool QgsDelimitedTextFeatureIterator::nextFeatureInternal( QgsFeature& feature )

feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.setFeatureId( fid );
feature.setId( fid );
feature.initAttributes( mSource->mFields.count() );
feature.setGeometry( geom );

Expand Down
4 changes: 2 additions & 2 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
if ( buildSpatialIndex )
{
QgsFeature f;
f.setFeatureId( mFile->recordId() );
f.setId( mFile->recordId() );
f.setGeometry( geom );
mSpatialIndex->insertFeature( f );
}
Expand Down Expand Up @@ -528,7 +528,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
if ( buildSpatialIndex && qIsFinite( pt.x() ) && qIsFinite( pt.y() ) )
{
QgsFeature f;
f.setFeatureId( mFile->recordId() );
f.setId( mFile->recordId() );
f.setGeometry( QgsGeometry::fromPoint( pt ) );
mSpatialIndex->insertFeature( f );
}
Expand Down
6 changes: 3 additions & 3 deletions src/providers/gpx/qgsgpxfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool QgsGPXFeatureIterator::readWaypoint( const QgsWaypoint& wpt, QgsFeature& fe
feature.setGeometry( *g );
delete g;
}
feature.setFeatureId( wpt.id );
feature.setId( wpt.id );
feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.initAttributes( mSource->mFields.count() );
Expand Down Expand Up @@ -235,7 +235,7 @@ bool QgsGPXFeatureIterator::readRoute( const QgsRoute& rte, QgsFeature& feature
{
delete theGeometry;
}
feature.setFeatureId( rte.id );
feature.setId( rte.id );
feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.initAttributes( mSource->mFields.count() );
Expand Down Expand Up @@ -278,7 +278,7 @@ bool QgsGPXFeatureIterator::readTrack( const QgsTrack& trk, QgsFeature& feature
{
delete theGeometry;
}
feature.setFeatureId( trk.id );
feature.setId( trk.id );
feature.setValid( true );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
feature.initAttributes( mSource->mFields.count() );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ bool QgsGrassFeatureIterator::fetchFeature( QgsFeature& feature )
}
QgsDebugMsgLevel( QString( "lid = %1 type = %2 cat = %3 featureId = %4" ).arg( lid ).arg( type ).arg( cat ).arg( featureId ), 3 );

feature.setFeatureId( featureId );
feature.setId( featureId );
//feature.initAttributes( mSource->mFields.count() );
QgsDebugMsgLevel( QString( "mSource->mFields.size() = %1" ).arg( mSource->mFields.size() ), 3 );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups
Expand Down
2 changes: 1 addition & 1 deletion src/providers/memory/qgsmemoryprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ bool QgsMemoryProvider::addFeatures( QgsFeatureList & flist )
// TODO: sanity checks of fields and geometries
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
{
it->setFeatureId( mNextFeatureId );
it->setId( mNextFeatureId );
it->setValid( true );

mFeatures.insert( mNextFeatureId, *it );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ bool QgsMssqlFeatureIterator::fetchFeature( QgsFeature& feature )
feature.setAttribute( mAttributesToFetch.at( i ), v );
}

feature.setFeatureId( mQuery->record().value( mSource->mFidColName ).toLongLong() );
feature.setId( mQuery->record().value( mSource->mFidColName ).toLongLong() );

if ( mSource->isSpatial() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
return false;
}
}
it->setFeatureId( query.value( 0 ).toLongLong() );
it->setId( query.value( 0 ).toLongLong() );
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature

bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature& feature ) const
{
feature.setFeatureId( OGR_F_GetFID( fet ) );
feature.setId( OGR_F_GetFID( fet ) );
feature.initAttributes( mSource->mFields.count() );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups

Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
QgsFeatureId id = static_cast<QgsFeatureId>( OGR_F_GetFID( feature ) );
if ( id >= 0 )
{
f.setFeatureId( id );
f.setId( id );

if ( mFirstFieldIsFid && attrs.count() > 0 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/oracle/qgsoraclefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature& feature )
return false;
}

feature.setFeatureId( fid );
feature.setId( fid );
QgsDebugMsgLevel( QString( "fid=%1" ).arg( fid ), 5 );

// iterate attributes
Expand Down
6 changes: 3 additions & 3 deletions src/providers/oracle/qgsoracleprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktRowId )
{
features->setFeatureId( mShared->lookupFid( QList<QVariant>() << QVariant( ins.lastInsertId() ) ) );
features->setId( mShared->lookupFid( QList<QVariant>() << QVariant( ins.lastInsertId() ) ) );
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
else if ( mPrimaryKeyType == pktInt || mPrimaryKeyType == pktFidMap )
Expand Down Expand Up @@ -1448,7 +1448,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktInt )
{
features->setFeatureId( STRING_TO_FID( attributevec[ mPrimaryKeyAttrs[0] ] ) );
features->setId( STRING_TO_FID( attributevec[ mPrimaryKeyAttrs[0] ] ) );
}
else
{
Expand All @@ -1459,7 +1459,7 @@ bool QgsOracleProvider::addFeatures( QgsFeatureList &flist )
primaryKeyVals << attributevec[ idx ];
}

features->setFeatureId( mShared->lookupFid( QVariant( primaryKeyVals ) ) );
features->setId( mShared->lookupFid( QVariant( primaryKeyVals ) ) );
}
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int
return false;
}

feature.setFeatureId( fid );
feature.setId( fid );
QgsDebugMsgLevel( QString( "fid=%1" ).arg( fid ), 4 );

// iterate attributes
Expand Down
8 changes: 4 additions & 4 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktOid )
{
features->setFeatureId( result.PQoidValue() );
features->setId( result.PQoidValue() );
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
}
Expand All @@ -2160,11 +2160,11 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )

if ( mPrimaryKeyType == pktUint64 )
{
features->setFeatureId( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) );
features->setId( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) );
}
else if ( mPrimaryKeyType == pktInt )
{
features->setFeatureId( PKINT2FID( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) ) );
features->setId( PKINT2FID( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) ) );
}
else
{
Expand All @@ -2175,7 +2175,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
primaryKeyVals << attrs.at( idx );
}

features->setFeatureId( mShared->lookupFid( primaryKeyVals ) );
features->setId( mShared->lookupFid( primaryKeyVals ) );
}
QgsDebugMsgLevel( QString( "new fid=%1" ).arg( features->id() ), 4 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/providers/spatialite/qgsspatialitefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,13 @@ bool QgsSpatiaLiteFeatureIterator::getFeature( sqlite3_stmt *stmt, QgsFeature &f
// first column always contains the ROWID (or the primary key)
QgsFeatureId fid = sqlite3_column_int64( stmt, ic );
QgsDebugMsgLevel( QString( "fid=%1" ).arg( fid ), 3 );
feature.setFeatureId( fid );
feature.setId( fid );
}
else
{
// autoincrement a row number
mRowNumber++;
feature.setFeatureId( mRowNumber );
feature.setId( mRowNumber );
}
}
else if ( mFetchGeometry && ic == mGeomColIdx )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3970,7 +3970,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
if ( ret == SQLITE_DONE || ret == SQLITE_ROW )
{
// update feature id
feature->setFeatureId( sqlite3_last_insert_rowid( mSqliteHandle ) );
feature->setId( sqlite3_last_insert_rowid( mSqliteHandle ) );
mNumberFeatures++;
}
else
Expand Down
Loading

0 comments on commit e656c63

Please sign in to comment.