27 mCache.setMaxCost( cacheSize );
31 connect( mLayer, SIGNAL( layerDeleted() ), SLOT( layerDeleted() ) );
37 connect( mLayer, SIGNAL( attributeDeleted(
int ) ), SLOT( attributeDeleted(
int ) ) );
38 connect( mLayer, SIGNAL( updatedFields() ), SLOT( updatedFields() ) );
44 qDeleteAll( mCacheIndices );
45 mCacheIndices.clear();
50 mCache.setMaxCost( cacheSize );
55 return mCache.maxCost();
73 mCachedAttributes = attributes;
78 mFullCache = fullCache;
87 .setSubsetOfAttributes( mCachedAttributes )
96 while ( it.nextFeature( f ) )
100 if ( t.elapsed() > 1000 )
119 mCacheIndices.append( cacheIndex );
124 if ( cacheAddedAttributes )
126 connect( mLayer, SIGNAL( attributeAdded(
int ) ), SLOT( attributeAdded(
int ) ) );
130 disconnect( mLayer, SIGNAL( attributeAdded(
int ) ),
this, SLOT( attributeAdded(
int ) ) );
136 bool featureFound =
false;
142 cachedFeature = mCache[ featureId ];
145 if ( cachedFeature != NULL )
147 feature =
QgsFeature( *cachedFeature->feature() );
151 .setFilterFid( featureId )
152 .setSubsetOfAttributes( mCachedAttributes )
156 cacheFeature( feature );
165 return mCache.remove( fid );
176 if ( fids.count() < mCache.size() )
193 void QgsVectorLayerCache::onAttributeValueChanged(
QgsFeatureId fid,
int field,
const QVariant& value )
197 if ( NULL != cachedFeat )
199 cachedFeat->mFeature->setAttribute( field, value );
205 void QgsVectorLayerCache::featureDeleted(
QgsFeatureId fid )
207 mCache.remove( fid );
210 void QgsVectorLayerCache::onFeatureAdded(
QgsFeatureId fid )
225 void QgsVectorLayerCache::attributeAdded(
int field )
228 mCachedAttributes.append( field );
236 mCache[ fid ]->mFeature->deleteAttribute( field );
244 if ( cachedFeat != NULL )
246 cachedFeat->mFeature->setGeometry( geom );
250 void QgsVectorLayerCache::layerDeleted()
256 void QgsVectorLayerCache::updatedFields()
264 bool requiresWriterIt =
true;
272 requiresWriterIt =
false;
281 requiresWriterIt =
false;
291 requiresWriterIt =
false;
305 QSet<int> attrs = featureRequest.
subsetOfAttributes().toSet() + mCachedAttributes.toSet();
316 return mCache.contains( fid );
333 foreach (
int attr, requestedAttributes )
335 if ( !mCachedAttributes.contains( attr ) )