Skip to content

Commit

Permalink
Possibility to adapt composer table rect to content size before painting
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13326 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 19, 2010
1 parent 38e0d17 commit 57ed537
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/composer/qgscomposertable.cpp
Expand Up @@ -110,6 +110,22 @@ void QgsComposerTable::paint( QPainter* painter, const QStyleOptionGraphicsItem*
}
}

void QgsComposerTable::adjustFrameToSize()
{
QList<QgsAttributeMap> attributes;
if ( !getFeatureAttributes( attributes ) )
{
return;
}

QMap<int, double> maxWidthMap;
if ( !calculateMaxColumnWidths( maxWidthMap, attributes ) )
{
return;
}
adaptItemFrame( maxWidthMap, attributes );
}

bool QgsComposerTable::tableWriteXML( QDomElement& elem, QDomDocument & doc ) const
{
elem.setAttribute( "lineTextDist", mLineTextDistance );
Expand Down
4 changes: 4 additions & 0 deletions src/core/composer/qgscomposertable.h
Expand Up @@ -55,6 +55,10 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
void setGridColor( const QColor& c ) { mGridColor = c; }
QColor gridColor() const { return mGridColor; }

/**Adapts the size of the frame to match the content. This is normally done in the paint method, but sometimes \
it needs to be done before the first render*/
void adjustFrameToSize();

protected:
/**Distance between table lines and text*/
double mLineTextDistance;
Expand Down

0 comments on commit 57ed537

Please sign in to comment.