Skip to content
Permalink
Browse files

show filled attribute table again (partly reverts 779e166)

  • Loading branch information
jef-n committed Nov 1, 2012
1 parent 0dc01f5 commit 42104d7f3d8f54362c2c36a6b35b31b35d53338d
@@ -194,7 +194,7 @@ bool QgsMapToolIdentify::identifyLayer( QgsMapLayer *layer, int x, int y )

bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int y )
{
if ( !layer || !layer->rendererV2() )
if ( !layer )
return false;

if ( layer->hasScaleBasedVisibility() &&
@@ -205,8 +205,6 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
return false;
}

QgsFeatureRendererV2* renderer = layer->rendererV2();

QMap< QString, QString > attributes, derivedAttributes;

QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y );
@@ -263,18 +261,22 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
}
QgsFeatureList::iterator f_it = featureList.begin();

if ( renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
bool filter = false;

QgsFeatureRendererV2* renderer = layer->rendererV2();
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
// setup scale for scale dependent visibility (rule based)
renderer->startRender( *( mCanvas->mapRenderer()->rendererContext() ), layer );
filter = renderer->capabilities() & QgsFeatureRendererV2::Filter;
}
bool filter = renderer->capabilities() & QgsFeatureRendererV2::Filter;

for ( ; f_it != featureList.end(); ++f_it )
{
QgsFeatureId fid = f_it->id();

if ( filter && !renderer->willRenderFeature( *f_it ) ) continue;
if ( filter && !renderer->willRenderFeature( *f_it ) )
continue;

featureCount++;

@@ -328,7 +330,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
results()->addFeature( layer, *f_it, derivedAttributes );
}

if ( renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
renderer->stopRender( *( mCanvas->mapRenderer()->rendererContext() ) );
}
@@ -285,42 +285,44 @@ void QgsAttributeTableModel::loadLayer()
}
else
{
bool filter = false;
QgsRectangle rect;
QgsAttributeList attributeList;
QgsRenderContext renderContext;
QgsFeatureRendererV2* renderer = mLayer->rendererV2();
if ( behaviour == 2 )
{
// current canvas only
rect = mCurrentExtent;
}

QgsFeatureRendererV2* renderer = mLayer->rendererV2();
if ( !renderer )
{
QgsDebugMsg( "Cannot get renderer" );
}
else if ( mLayer->hasScaleBasedVisibility() &&
( mLayer->minimumScale() > mCanvas->mapRenderer()->scale() ||
mLayer->maximumScale() <= mCanvas->mapRenderer()->scale() ) )
{
QgsDebugMsg( "Out of scale limits" );
}
else
{
QgsRenderContext renderContext;
if ( renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
if ( !renderer )
{
// setup scale
// mapRenderer()->renderContext()->scale is not automaticaly updated when
// render extent changes (because it's scale is used to identify if changed
// since last render) -> use local context
renderContext.setExtent( mCanvas->mapRenderer()->rendererContext()->extent() );
renderContext.setMapToPixel( mCanvas->mapRenderer()->rendererContext()->mapToPixel() );
renderContext.setRendererScale( mCanvas->mapRenderer()->scale() );
renderer->startRender( renderContext, mLayer );
QgsDebugMsg( "Cannot get renderer" );
}

bool filter = renderer->capabilities() & QgsFeatureRendererV2::Filter;
if ( mLayer->hasScaleBasedVisibility() &&
( mLayer->minimumScale() > mCanvas->mapRenderer()->scale() ||
mLayer->maximumScale() <= mCanvas->mapRenderer()->scale() ) )
{
QgsDebugMsg( "Out of scale limits" );
}
else
{
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
// setup scale
// mapRenderer()->renderContext()->scale is not automaticaly updated when
// render extent changes (because it's scale is used to identify if changed
// since last render) -> use local context
renderContext.setExtent( mCanvas->mapRenderer()->rendererContext()->extent() );
renderContext.setMapToPixel( mCanvas->mapRenderer()->rendererContext()->mapToPixel() );
renderContext.setRendererScale( mCanvas->mapRenderer()->scale() );
renderer->startRender( renderContext, mLayer );
}

filter = renderer && renderer->capabilities() & QgsFeatureRendererV2::Filter;
}

QgsAttributeList attributeList = QgsAttributeList();
if ( filter )
{
QList<QString> attributeNameList = renderer->usedAttributes();
@@ -329,31 +331,34 @@ void QgsAttributeTableModel::loadLayer()
attributeList.append( mLayer->fieldNameIndex( attributeName ) );
}
}
mLayer->select( attributeList, rect, false );

QgsFeature f;
for ( i = 0; mLayer->nextFeature( f ); ++i )
{
if ( !filter || renderer->willRenderFeature( f ) )
{
featureAdded( f.id() );
}
}

if ( t.elapsed() > 5000 )
{
bool cancel = false;
emit progress( i, cancel );
if ( cancel )
break;
mLayer->select( attributeList, rect, false );

t.restart();
}
QgsFeature f;
for ( i = 0; mLayer->nextFeature( f ); ++i )
{
if ( !filter || renderer->willRenderFeature( f ) )
{
featureAdded( f.id() );
}
if ( renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )

if ( t.elapsed() > 5000 )
{
renderer->stopRender( renderContext );
bool cancel = false;
emit progress( i, cancel );
if ( cancel )
break;

t.restart();
}
}

if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
renderer->stopRender( renderContext );
}

emit finished();
}

@@ -1230,8 +1230,7 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
"has_table_privilege(%1,'DELETE'),"
"has_any_column_privilege(%1,'UPDATE'),"
"%2"
"has_table_privilege(%1,'INSERT'),"
"current_schema()" )
"has_table_privilege(%1,'INSERT')" )
.arg( quotedValue( mQuery ) )
.arg( mGeometryColumn.isNull()
? QString( "'f'," )
@@ -1246,8 +1245,7 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
"has_table_privilege(%1,'DELETE'),"
"has_table_privilege(%1,'UPDATE'),"
"has_table_privilege(%1,'UPDATE'),"
"has_table_privilege(%1,'INSERT'),"
"current_schema()" )
"has_table_privilege(%1,'INSERT')" )
.arg( quotedValue( mQuery ) );
}

0 comments on commit 42104d7

Please sign in to comment.
You can’t perform that action at this time.