Skip to content

Commit

Permalink
Fix display of features in composer table if map is projected (ticket #…
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Sep 15, 2012
1 parent c0ee7f0 commit 1880db0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/core/composer/qgscomposerattributetable.cpp
Expand Up @@ -129,6 +129,20 @@ bool QgsComposerAttributeTable::getFeatureAttributes( QList<QgsAttributeMap>& at
if ( mComposerMap && mShowOnlyVisibleFeatures )
{
selectionRect = mComposerMap->extent();
if ( mVectorLayer && mComposerMap->mapRenderer()
&& mComposerMap->mapRenderer()->hasCrsTransformEnabled() )
{
//transform back to layer CRS
QgsCoordinateTransform coordTransform( mVectorLayer->crs(), mComposerMap->mapRenderer()->destinationCrs() );
try
{
selectionRect = coordTransform.transformBoundingBox( selectionRect, QgsCoordinateTransform::ReverseTransform );
}
catch ( QgsCsException &cse )
{
return false;
}
}
}

if ( mDisplayAttributes.size() < 1 )
Expand Down Expand Up @@ -221,6 +235,7 @@ bool QgsComposerAttributeTable::writeXML( QDomElement& elem, QDomDocument & doc
{
QDomElement composerTableElem = doc.createElement( "ComposerAttributeTable" );
composerTableElem.setAttribute( "showOnlyVisibleFeatures", mShowOnlyVisibleFeatures );
composerTableElem.setAttribute( "maxFeatures", mMaximumNumberOfFeatures );

if ( mComposerMap )
{
Expand Down Expand Up @@ -281,7 +296,6 @@ bool QgsComposerAttributeTable::readXML( const QDomElement& itemElem, const QDom
return false;
}

mMaximumNumberOfFeatures = itemElem.attribute( "maxFeatures", "5" ).toInt();
mShowOnlyVisibleFeatures = itemElem.attribute( "showOnlyVisibleFeatures", "1" ).toInt();

//composer map
Expand Down Expand Up @@ -364,6 +378,10 @@ bool QgsComposerAttributeTable::readXML( const QDomElement& itemElem, const QDom
}
}
bool success = tableReadXML( itemElem, doc );

//must be done here because tableReadXML->setSceneRect changes mMaximumNumberOfFeatures
mMaximumNumberOfFeatures = itemElem.attribute( "maxFeatures", "5" ).toInt();

emit itemChanged();
return success;
}

0 comments on commit 1880db0

Please sign in to comment.