Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
API cleanups: getNextFeature becomes nextFeature, getFeatureAtId beco…
…mes featureAtId, getDefaultValue becomes defaultValue, allAttributeList becomes attributeIndexes and reset becomes begin on data provider api.

git-svn-id: http://svn.osgeo.org/qgis/trunk@9449 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 7, 2008
1 parent 9038cde commit 3072d71
Show file tree
Hide file tree
Showing 32 changed files with 112 additions and 112 deletions.
6 changes: 3 additions & 3 deletions ChangeLog
Expand Up @@ -281,7 +281,7 @@ of layers and tweak their symbology etc without having delays
caused by rerendering everything after each change you make.

2004-11-16 [larsl] 0.5.0devel24
** Reimplemented getNextFeature() so features are visible again
** Reimplemented nextFeature() so features are visible again

2004-11-13 [larsl] 0.5.0devel23
** Changed QgsIdentifyResults and QgsVectorLayer to show all attributes
Expand Down Expand Up @@ -312,7 +312,7 @@ qgis to crash.
a QgsFeature, fixed it

2004-10-29 [larsl] 0.5.0devel16
** Added getDefaultValue() in QgsVectorLayer and QgsVectorDataProvider,
** Added defaultValue() in QgsVectorLayer and QgsVectorDataProvider,
implemented it in the GPX provider

2004-10-29 [stevehalasz] 0.5.0devel15
Expand Down Expand Up @@ -911,7 +911,7 @@ will hopefully speed up compile times for folks building on p133's. Changed
splash image to the fluffball ready for 0.3 release.

2004-05-19 [larsl] 0.2.0devel27
** Implemented getNextFeature(list<int>&) in the GPX provider
** Implemented nextFeature(list<int>&) in the GPX provider

2004-05-18 [gsherman] 0.2.0devel26
** Saved the qgsappbase.ui and the qgsprojectpropertiesbase.ui files (modified
Expand Down
12 changes: 6 additions & 6 deletions python/core/qgsvectordataprovider.sip
Expand Up @@ -44,7 +44,7 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual QString storageType() const;

/** Select features based on a bounding rectangle. Features can be retrieved with calls to getNextFeature.
/** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
* @param fetchAttributes list of attributes which should be fetched
* @param rect spatial filter
* @param fetchGeometry true if the feature geometry should be fetched
Expand All @@ -70,7 +70,7 @@ class QgsVectorDataProvider : QgsDataProvider
* @param fetchAttributes a list containing the indexes of the attribute fields to copy
* @return True when feature was found, otherwise false
*/
virtual bool getFeatureAtId(int featureId,
virtual bool featureAtId(int featureId,
QgsFeature& feature,
bool fetchGeometry = true,
QList<int> fetchAttributes = QList<int>());
Expand All @@ -80,7 +80,7 @@ class QgsVectorDataProvider : QgsDataProvider
* @param feature feature which will receive data from the provider
* @return true when there was a feature to fetch, false when end was hit
*/
virtual bool getNextFeature(QgsFeature& feature) = 0;
virtual bool nextFeature(QgsFeature& feature) = 0;

/**
* Get feature type.
Expand Down Expand Up @@ -180,7 +180,7 @@ class QgsVectorDataProvider : QgsDataProvider
/**
* Returns the default value for field specified by @c fieldId
*/
virtual QVariant getDefaultValue(int fieldId);
virtual QVariant defaultValue(int fieldId);

/**
* Changes geometries of existing features
Expand Down Expand Up @@ -224,9 +224,9 @@ class QgsVectorDataProvider : QgsDataProvider
int fieldNameIndex(const QString& fieldName) const;

/**
* Return list of indexes to fetch all attributes in getNextFeature()
* Return list of indexes to fetch all attributes in nextFeature()
*/
QList<int> allAttributesList();
QList<int> attributeIndexes();

/**Returns the names of the numerical types*/
const QMap<QString,QVariant::Type> &supportedNativeTypes() const;
Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -162,12 +162,12 @@ public:
bool fetchGeometry = true,
bool useIntersect = false);

bool getNextFeature(QgsFeature& feature);
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 getFeatureAtId(int featureId, QgsFeature& f, bool fetchGeometries = true, bool fetchAttributes = true);
int 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/qgsattributetable.cpp
Expand Up @@ -469,7 +469,7 @@ void QgsAttributeTable::fillTable( QgsVectorLayer *layer )
layer->select( layer->pendingAllAttributesList(), QgsRect(), false );

QgsFeature f;
while ( layer->getNextFeature( f ) )
while ( layer->nextFeature( f ) )
features << f;
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributetabledisplay.cpp
Expand Up @@ -375,7 +375,7 @@ void QgsAttributeTableDisplay::doSearch( QString searchString )
mLayer->select( mLayer->pendingAllAttributesList(), QgsRect(), false );

QgsFeature f;
while ( mLayer->getNextFeature( f ) )
while ( mLayer->nextFeature( f ) )
{
if ( searchTree->checkAgainst( mLayer->pendingFields(), f.attributeMap() ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsgraduatedsymboldialog.cpp
Expand Up @@ -466,7 +466,7 @@ int QgsGraduatedSymbolDialog::quantilesFromVectorLayer( std::list<double>& resul
int index = 0;

provider->select( attList, QgsRect(), false );
while ( provider->getNextFeature( currentFeature ) )
while ( provider->nextFeature( currentFeature ) )
{
currentAttributeMap = currentFeature.attributeMap();
currentValue = currentAttributeMap[attributeIndex].toDouble();
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptooladdfeature.cpp
Expand Up @@ -171,7 +171,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
const QgsFieldMap fields = vlayer->pendingFields();
for ( QgsFieldMap::const_iterator it = fields.constBegin(); it != fields.constEnd(); ++it )
{
f->addAttribute( it.key(), provider->getDefaultValue( it.key() ) );
f->addAttribute( it.key(), provider->defaultValue( it.key() ) );
}

// show the dialog to enter attribute values
Expand Down Expand Up @@ -441,7 +441,7 @@ void QgsMapToolAddFeature::canvasReleaseEvent( QMouseEvent * e )
const QgsFieldMap fields = vlayer->pendingFields();
for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
{
f->addAttribute( it.key(), provider->getDefaultValue( it.key() ) );
f->addAttribute( it.key(), provider->defaultValue( it.key() ) );
}

QgsAttributeDialog * mypDialog = new QgsAttributeDialog( vlayer, f );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoolidentify.cpp
Expand Up @@ -268,7 +268,7 @@ void QgsMapToolIdentify::identifyVectorLayer( const QgsPoint& point )

layer->select( layer->pendingAllAttributesList(), r, true, true );
QgsFeature f;
while ( layer->getNextFeature( f ) )
while ( layer->nextFeature( f ) )
mFeatureList << QgsFeature( f );
}
catch ( QgsCsException & cse )
Expand Down Expand Up @@ -451,7 +451,7 @@ void QgsMapToolIdentify::highlightFeature( int featureId )
mRubberBand = 0;

QgsFeature feat;
if ( layer->getFeatureAtId( featureId, feat, true, false ) != 0 )
if ( layer->featureAtId( featureId, feat, true, false ) != 0 )
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolmovefeature.cpp
Expand Up @@ -88,7 +88,7 @@ void QgsMapToolMoveFeature::canvasPressEvent( QMouseEvent * e )

QgsFeature cf;
QgsFeature f;
while ( vlayer->getNextFeature( f ) )
while ( vlayer->nextFeature( f ) )
{
if ( f.geometry() )
{
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgssearchquerybuilder.cpp
Expand Up @@ -115,7 +115,7 @@ void QgsSearchQueryBuilder::getFieldValues( int limit )
mModelValues->blockSignals( true );
lstValues->setUpdatesEnabled( false );

while ( provider->getNextFeature( feat ) &&
while ( provider->nextFeature( feat ) &&
( limit == 0 || mModelValues->rowCount() != limit ) )
{
const QgsAttributeMap& attributes = feat.attributeMap();
Expand Down Expand Up @@ -193,11 +193,11 @@ long QgsSearchQueryBuilder::countRecords( QString searchString )
QgsFeature feat;
QgsVectorDataProvider* provider = mLayer->dataProvider();
const QgsFieldMap& fields = provider->fields();
QgsAttributeList allAttributes = provider->allAttributesList();
QgsAttributeList allAttributes = provider->attributeIndexes();

provider->select( allAttributes, QgsRect(), false );

while ( provider->getNextFeature( feat ) )
while ( provider->nextFeature( feat ) )
{
if ( searchTree->checkAgainst( fields, feat.attributeMap() ) )
{
Expand Down
12 changes: 6 additions & 6 deletions src/core/qgsvectordataprovider.cpp
Expand Up @@ -47,14 +47,14 @@ long QgsVectorDataProvider::updateFeatureCount()
return -1;
}

bool QgsVectorDataProvider::getFeatureAtId( int featureId,
bool QgsVectorDataProvider::featureAtId( int featureId,
QgsFeature& feature,
bool fetchGeometry,
QgsAttributeList fetchAttributes )
{
select( fetchAttributes, QgsRect(), fetchGeometry );

while ( getNextFeature( feature ) )
while ( nextFeature( feature ) )
{
if ( feature.featureId() == featureId )
return TRUE;
Expand Down Expand Up @@ -93,7 +93,7 @@ bool QgsVectorDataProvider::changeAttributeValues( const QgsChangedAttributesMap
return false;
}

QVariant QgsVectorDataProvider::getDefaultValue( int fieldId )
QVariant QgsVectorDataProvider::defaultValue( int fieldId )
{
return QVariant();
}
Expand Down Expand Up @@ -246,7 +246,7 @@ QMap<QString, int> QgsVectorDataProvider::fieldNameMap() const
return resultMap;
}

QgsAttributeList QgsVectorDataProvider::allAttributesList()
QgsAttributeList QgsVectorDataProvider::attributeIndexes()
{
uint count = fieldCount();
QgsAttributeList list;
Expand Down Expand Up @@ -316,7 +316,7 @@ void QgsVectorDataProvider::uniqueValues( int index, QList<QVariant> &values )
QSet<QString> set;
values.clear();

while ( getNextFeature( f ) )
while ( nextFeature( f ) )
{
if ( !set.contains( f.attributeMap()[index].toString() ) )
{
Expand Down Expand Up @@ -347,7 +347,7 @@ void QgsVectorDataProvider::fillMinMaxCache()
QgsAttributeList keys = mCacheMinValues.keys();
select( keys, QgsRect(), false );

while ( getNextFeature( f ) )
while ( nextFeature( f ) )
{
QgsAttributeMap attrMap = f.attributeMap();
for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it )
Expand Down
16 changes: 8 additions & 8 deletions src/core/qgsvectordataprovider.h
Expand Up @@ -81,7 +81,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
*/
virtual QString storageType() const;

/** Select features based on a bounding rectangle. Features can be retrieved with calls to getNextFeature.
/** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
* @param fetchAttributes list of attributes which should be fetched
* @param rect spatial filter
* @param fetchGeometry true if the feature geometry should be fetched
Expand Down Expand Up @@ -110,7 +110,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
* Default implementation traverses all features until it finds the one with correct ID.
* In case the provider supports reading the feature directly, override this function.
*/
virtual bool getFeatureAtId( int featureId,
virtual bool featureAtId( int featureId,
QgsFeature& feature,
bool fetchGeometry = true,
QgsAttributeList fetchAttributes = QgsAttributeList() );
Expand All @@ -120,7 +120,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
* @param feature feature which will receive data from the provider
* @return true when there was a feature to fetch, false when end was hit
*/
virtual bool getNextFeature( QgsFeature& feature ) = 0;
virtual bool nextFeature( QgsFeature& feature ) = 0;

/**
* Get feature type.
Expand Down Expand Up @@ -223,7 +223,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
/**
* Returns the default value for field specified by @c fieldId
*/
virtual QVariant getDefaultValue( int fieldId );
virtual QVariant defaultValue( int fieldId );

/**
* Changes geometries of existing features
Expand Down Expand Up @@ -271,9 +271,9 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
QMap<QString, int> fieldNameMap() const;

/**
* Return list of indexes to fetch all attributes in getNextFeature()
* Return list of indexes to fetch all attributes in nextFeature()
*/
virtual QgsAttributeList allAttributesList();
virtual QgsAttributeList attributeIndexes();

/**Returns the names of the numerical types*/
const QgsNativeTypeMap &supportedNativeTypes() const;
Expand All @@ -298,10 +298,10 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
/** should provider fetch also features that don't have geometry? */
bool mFetchFeaturesWithoutGeom;

/**True if geometry should be added to the features in getNextFeature calls*/
/**True if geometry should be added to the features in nextFeature calls*/
bool mFetchGeom;

/**List of attribute indices to fetch with getNextFeature calls*/
/**List of attribute indices to fetch with nextFeature calls*/
QgsAttributeList mAttributesToFetch;

/**The names of the providers native types*/
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -326,7 +326,7 @@ QgsVectorFileWriter::writeAsShapefile( QgsVectorLayer* layer,
return err;
}

QgsAttributeList allAttr = provider->allAttributesList();
QgsAttributeList allAttr = provider->attributeIndexes();
QgsFeature fet;

provider->select( allAttr, QgsRect(), true );
Expand All @@ -346,7 +346,7 @@ QgsVectorFileWriter::writeAsShapefile( QgsVectorLayer* layer,
}

// write all features
while ( provider->getNextFeature( fet ) )
while ( provider->nextFeature( fet ) )
{
if ( onlySelected && !ids.contains( fet.featureId() ) )
continue;
Expand Down

0 comments on commit 3072d71

Please sign in to comment.