Skip to content

Commit 7a34e77

Browse files
author
mhugent
committed
Possibility to adapt composer table rect to content size before painting
git-svn-id: http://svn.osgeo.org/qgis/trunk@13326 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9b4e8c0 commit 7a34e77

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/core/composer/qgscomposertable.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ void QgsComposerTable::paint( QPainter* painter, const QStyleOptionGraphicsItem*
110110
}
111111
}
112112

113+
void QgsComposerTable::adjustFrameToSize()
114+
{
115+
QList<QgsAttributeMap> attributes;
116+
if ( !getFeatureAttributes( attributes ) )
117+
{
118+
return;
119+
}
120+
121+
QMap<int, double> maxWidthMap;
122+
if ( !calculateMaxColumnWidths( maxWidthMap, attributes ) )
123+
{
124+
return;
125+
}
126+
adaptItemFrame( maxWidthMap, attributes );
127+
}
128+
113129
bool QgsComposerTable::tableWriteXML( QDomElement& elem, QDomDocument & doc ) const
114130
{
115131
elem.setAttribute( "lineTextDist", mLineTextDistance );

src/core/composer/qgscomposertable.h

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ class CORE_EXPORT QgsComposerTable: public QgsComposerItem
5555
void setGridColor( const QColor& c ) { mGridColor = c; }
5656
QColor gridColor() const { return mGridColor; }
5757

58+
/**Adapts the size of the frame to match the content. This is normally done in the paint method, but sometimes \
59+
it needs to be done before the first render*/
60+
void adjustFrameToSize();
61+
5862
protected:
5963
/**Distance between table lines and text*/
6064
double mLineTextDistance;

0 commit comments

Comments
 (0)