Skip to content

Commit 5e51be2

Browse files
author
mhugent
committedSep 26, 2009
Show cached content of composer maps in screen resolution after loading from project file
git-svn-id: http://svn.osgeo.org/qgis/trunk@11715 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9d80e9d commit 5e51be2

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
 

‎src/app/composer/qgscomposer.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
#include <QSizeGrip>
6666
#include "qgslogger.h"
6767

68-
QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
68+
QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow(), mFirstPaint( true )
6969
{
7070
setupUi( this );
7171
setupTheme();
@@ -300,6 +300,27 @@ void QgsComposer::open( void )
300300
}
301301
}
302302

303+
void QgsComposer::paintEvent( QPaintEvent* event )
304+
{
305+
QMainWindow::paintEvent( event );
306+
//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.
307+
//Otherwise the resolution of the composer map is not suitable for screen
308+
if ( mFirstPaint )
309+
{
310+
QMap<QgsComposerItem*, QWidget*>::iterator it = mItemWidgetMap.begin();
311+
for ( ; it != mItemWidgetMap.constEnd(); ++it )
312+
{
313+
QgsComposerMap* cm = dynamic_cast<QgsComposerMap*>( it.key() );
314+
if ( cm )
315+
{
316+
cm->cache();
317+
cm->update();
318+
}
319+
}
320+
mFirstPaint = false;
321+
}
322+
}
323+
303324
void QgsComposer::activate()
304325
{
305326
raise();
@@ -1352,3 +1373,5 @@ void QgsComposer::cleanupAfterTemplateRead()
13521373
}
13531374
}
13541375
}
1376+
1377+

‎src/app/composer/qgscomposer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
224224

225225
void setSelectionTool();
226226

227+
protected:
228+
229+
void paintEvent( QPaintEvent* event );
230+
227231
private slots:
228232

229233
//! Raise, unminimize and activate this window
@@ -283,6 +287,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
283287
QAction *mWindowAction;
284288
#endif
285289

290+
/**False if first paint already happened (used to create cache of composer maps for screen resolution after reading from project files)*/
291+
bool mFirstPaint;
292+
286293
//! Help context id
287294
static const int context_id = 985715179;
288295

0 commit comments

Comments
 (0)
Please sign in to comment.