Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show cached content of composer maps in screen resolution after loadi…
…ng from project file

git-svn-id: http://svn.osgeo.org/qgis/trunk@11715 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Sep 26, 2009
1 parent 9d80e9d commit 5e51be2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/app/composer/qgscomposer.cpp
Expand Up @@ -65,7 +65,7 @@
#include <QSizeGrip>
#include "qgslogger.h"

QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow()
QgsComposer::QgsComposer( QgisApp *qgis ): QMainWindow(), mFirstPaint( true )
{
setupUi( this );
setupTheme();
Expand Down Expand Up @@ -300,6 +300,27 @@ void QgsComposer::open( void )
}
}

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();
Expand Down Expand Up @@ -1352,3 +1373,5 @@ void QgsComposer::cleanupAfterTemplateRead()
}
}
}


7 changes: 7 additions & 0 deletions src/app/composer/qgscomposer.h
Expand Up @@ -224,6 +224,10 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase

void setSelectionTool();

protected:

void paintEvent( QPaintEvent* event );

private slots:

//! Raise, unminimize and activate this window
Expand Down Expand Up @@ -283,6 +287,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
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;

Expand Down

0 comments on commit 5e51be2

Please sign in to comment.