Fixes after rebase

This commit is contained in:
Martin Dobias 2012-10-09 20:57:35 +02:00
parent e110855e6c
commit f217a7fb19
4 changed files with 20 additions and 50 deletions

View File

@ -14,6 +14,8 @@ typedef QMap<int, QString> QgsFieldNameMap;
typedef QList<QgsFeature> QgsFeatureList;
typedef QMap<int, QgsField> QgsFieldMap;
class QgsFeature
{

View File

@ -49,17 +49,16 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual QString storageType() const;
/** 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
* @param useIntersect true if an accurate intersection test should be used,
* false if a test based on bounding box is sufficient
/**
* Query the provider for features specified in request.
*/
virtual void select( QList<int> fetchAttributes = QList<int>(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
bool useIntersect = false ) = 0;
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() ) = 0;
// temporary
QgsFeatureIterator select( QList<int> fetchAttributes = QList<int>(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
bool useIntersect = false ) /Deprecated/;
/**
* This function does nothing useful, it's kept only for compatibility.
@ -67,29 +66,6 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual long updateFeatureCount() /Deprecated/;
/**
* Gets the feature at the given feature ID.
* @param featureId id of the feature
* @param feature feature which will receive the data
* @param fetchGeometry if true, geometry will be fetched from the provider
* @param fetchAttributes a list containing the indexes of the attribute fields to copy
* @return True when feature was found, otherwise false
*
* 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 featureAtId( qint64 featureId,
QgsFeature& feature,
bool fetchGeometry = true,
QList<int> fetchAttributes = QList<int>());
/**
* Get the next feature resulting from a select operation.
* @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 nextFeature( QgsFeature& feature ) = 0;
/**
* Get feature type.
* @return int representing the feature type
@ -120,9 +96,6 @@ class QgsVectorDataProvider : QgsDataProvider
*/
virtual QString dataComment() const;
/** Restart reading features from previous select operation */
virtual void rewind() = 0;
/**
* Returns the minimum value of an attribute
* @param index the index of the attribute

View File

@ -69,9 +69,7 @@ void QgsAtlasComposition::beginRender()
mTransform.setSourceCrs( coverage_crs );
mTransform.setDestCRS( destination_crs );
QgsVectorDataProvider* provider = mCoverageLayer->dataProvider();
QgsFieldMap fieldmap = provider->fields();
QgsFieldMap fieldmap = mCoverageLayer->pendingFields();
if ( mFilenamePattern.size() > 0 )
{
@ -88,12 +86,12 @@ void QgsAtlasComposition::beginRender()
}
// select all features with all attributes
provider->select( provider->attributeIndexes() );
mCoverageLayer->select( mCoverageLayer->pendingAllAttributesList() );
// We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process
// We thus store the feature ids for future extraction
QgsFeature feat;
while ( provider->nextFeature( feat ) )
while ( mCoverageLayer->nextFeature( feat ) )
{
mFeatureIds.push_back( feat.id() );
}
@ -115,7 +113,7 @@ void QgsAtlasComposition::beginRender()
// special columns for expressions
QgsExpression::setSpecialColumn( "$numpages", QVariant( mComposition->numPages() ) );
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )provider->featureCount() ) );
QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )mCoverageLayer->pendingFeatureCount() ) );
}
void QgsAtlasComposition::endRender()
@ -161,9 +159,8 @@ void QgsAtlasComposition::prepareForFeature( size_t featureI )
return;
}
QgsVectorDataProvider* provider = mCoverageLayer->dataProvider();
// retrieve the next feature, based on its id
provider->featureAtId( mFeatureIds[ featureI ], mCurrentFeature, /* fetchGeometry = */ true, provider->attributeIndexes() );
mCoverageLayer->featureAtId( mFeatureIds[ featureI ], mCurrentFeature, /* fetchGeometry = */ true, /* fetchAttributes = */ true );
if ( mFilenamePattern.size() > 0 )
{

View File

@ -125,13 +125,11 @@ void TestQgsComposerLabel::evaluation()
void TestQgsComposerLabel::feature_evaluation()
{
QgsVectorDataProvider* provider = mVectorLayer->dataProvider();
QgsAttributeList allAttrs = provider->attributeIndexes();
provider->select( allAttrs );
QgsAttributeList allAttrs = mVectorLayer->pendingAllAttributesList();
mVectorLayer->select( allAttrs );
QgsFeature feat;
provider->nextFeature( feat );
mVectorLayer->nextFeature( feat );
{
// evaluation with a feature
mComposerLabel->setExpressionContext( &feat, mVectorLayer );
@ -140,7 +138,7 @@ void TestQgsComposerLabel::feature_evaluation()
QString expected = "Basse-Normandie_ok";
QCOMPARE( evaluated, expected );
}
provider->nextFeature( feat );
mVectorLayer->nextFeature( feat );
{
// evaluation with a feature
mComposerLabel->setExpressionContext( &feat, mVectorLayer );