Skip to content
Permalink
Browse files
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 3072d71114dc238374e496c5a84ba1de83dc02fb
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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>());
@@ -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.
@@ -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
@@ -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;
@@ -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.
@@ -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
@@ -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() ) )
{
@@ -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();
@@ -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
@@ -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 );
@@ -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 )
@@ -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;
}
@@ -88,7 +88,7 @@ void QgsMapToolMoveFeature::canvasPressEvent( QMouseEvent * e )

QgsFeature cf;
QgsFeature f;
while ( vlayer->getNextFeature( f ) )
while ( vlayer->nextFeature( f ) )
{
if ( f.geometry() )
{
@@ -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();
@@ -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() ) )
{
@@ -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;
@@ -93,7 +93,7 @@ bool QgsVectorDataProvider::changeAttributeValues( const QgsChangedAttributesMap
return false;
}

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

QgsAttributeList QgsVectorDataProvider::allAttributesList()
QgsAttributeList QgsVectorDataProvider::attributeIndexes()
{
uint count = fieldCount();
QgsAttributeList list;
@@ -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() ) )
{
@@ -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 )
@@ -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
@@ -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() );
@@ -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.
@@ -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
@@ -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;
@@ -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*/
@@ -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 );
@@ -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;

0 comments on commit 3072d71

Please sign in to comment.