[QGIS Commit] r13326 - trunk/qgis/src/core/composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Apr 19 09:04:05 EDT 2010


Author: mhugent
Date: 2010-04-19 09:04:03 -0400 (Mon, 19 Apr 2010)
New Revision: 13326

Modified:
   trunk/qgis/src/core/composer/qgscomposertable.cpp
   trunk/qgis/src/core/composer/qgscomposertable.h
Log:
Possibility to adapt composer table rect to content size before painting

Modified: trunk/qgis/src/core/composer/qgscomposertable.cpp
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertable.cpp	2010-04-18 19:25:19 UTC (rev 13325)
+++ trunk/qgis/src/core/composer/qgscomposertable.cpp	2010-04-19 13:04:03 UTC (rev 13326)
@@ -110,6 +110,22 @@
   }
 }
 
+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 );

Modified: trunk/qgis/src/core/composer/qgscomposertable.h
===================================================================
--- trunk/qgis/src/core/composer/qgscomposertable.h	2010-04-18 19:25:19 UTC (rev 13325)
+++ trunk/qgis/src/core/composer/qgscomposertable.h	2010-04-19 13:04:03 UTC (rev 13326)
@@ -55,6 +55,10 @@
     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;



More information about the QGIS-commit mailing list