[QGIS Commit] r11715 - trunk/qgis/src/app/composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Sep 26 11:40:24 EDT 2009


Author: mhugent
Date: 2009-09-26 11:40:24 -0400 (Sat, 26 Sep 2009)
New Revision: 11715

Modified:
   trunk/qgis/src/app/composer/qgscomposer.cpp
   trunk/qgis/src/app/composer/qgscomposer.h
Log:
Show cached content of composer maps in screen resolution after loading from project file

Modified: trunk/qgis/src/app/composer/qgscomposer.cpp
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.cpp	2009-09-26 09:34:17 UTC (rev 11714)
+++ trunk/qgis/src/app/composer/qgscomposer.cpp	2009-09-26 15:40:24 UTC (rev 11715)
@@ -65,7 +65,7 @@
 #include <QSizeGrip>
 #include "qgslogger.h"
 
-QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
+QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow(), mFirstPaint( true )
 {
   setupUi( this );
   setupTheme();
@@ -300,6 +300,27 @@
   }
 }
 
+void QgsComposer::paintEvent( QPaintEvent* event )
+{
+  QMainWindow::paintEvent( event );
+  //The cached content of the composer maps need to be recreated it is the first paint event of the composer after reading from XML file.
+  //Otherwise the resolution of the composer map is not suitable for screen
+  if ( mFirstPaint )
+  {
+    QMap<QgsComposerItem*, QWidget*>::iterator it = mItemWidgetMap.begin();
+    for ( ; it != mItemWidgetMap.constEnd(); ++it )
+    {
+      QgsComposerMap* cm = dynamic_cast<QgsComposerMap*>( it.key() );
+      if ( cm )
+      {
+        cm->cache();
+        cm->update();
+      }
+    }
+    mFirstPaint = false;
+  }
+}
+
 void QgsComposer::activate()
 {
   raise();
@@ -1352,3 +1373,5 @@
     }
   }
 }
+
+

Modified: trunk/qgis/src/app/composer/qgscomposer.h
===================================================================
--- trunk/qgis/src/app/composer/qgscomposer.h	2009-09-26 09:34:17 UTC (rev 11714)
+++ trunk/qgis/src/app/composer/qgscomposer.h	2009-09-26 15:40:24 UTC (rev 11715)
@@ -224,6 +224,10 @@
 
     void setSelectionTool();
 
+  protected:
+
+    void paintEvent( QPaintEvent* event );
+
   private slots:
 
     //! Raise, unminimize and activate this window
@@ -283,6 +287,9 @@
     QAction *mWindowAction;
 #endif
 
+    /**False if first paint already happened (used to create cache of composer maps for screen resolution after reading from project files)*/
+    bool mFirstPaint;
+
     //! Help context id
     static const int context_id = 985715179;
 



More information about the QGIS-commit mailing list