Skip to content
Permalink
Browse files

Fix loading of composer map preview states after template read. Ticket

  • Loading branch information
mhugent committed Jul 12, 2012
1 parent f3edf04 commit 3869a6c707fefb43c5dc1bc30a87f30e253981d4
Showing with 37 additions and 17 deletions.
  1. +29 −17 src/app/composer/qgscomposer.cpp
  2. +8 −0 src/app/composer/qgscomposer.h
@@ -1094,23 +1094,8 @@ void QgsComposer::showEvent( QShowEvent* event )
{
if ( event->spontaneous() ) //event from the window system
{
//go through maps and restore original preview modes (show on demand after loading from project file)
QMap< QgsComposerMap*, int >::iterator mapIt = mMapsToRestore.begin();
for ( ; mapIt != mMapsToRestore.end(); ++mapIt )
{
mapIt.key()->setPreviewMode(( QgsComposerMap::PreviewMode )( mapIt.value() ) );
mapIt.key()->cache();
mapIt.key()->update();
}
mMapsToRestore.clear();

//create composer picture widget previews
QList< QgsComposerPictureWidget* >::iterator picIt = mPicturePreviews.begin();
for ( ; picIt != mPicturePreviews.end(); ++picIt )
{
( *picIt )->addStandardDirectoriesToPreview();
}
mPicturePreviews.clear();
restoreComposerMapStates();
initialiseComposerPicturePreviews();
}

#ifdef Q_WS_MAC
@@ -1505,6 +1490,9 @@ void QgsComposer::cleanupAfterTemplateRead()
}
}
}

restoreComposerMapStates();
initialiseComposerPicturePreviews();
}

void QgsComposer::on_mActionPageSetup_triggered()
@@ -1517,3 +1505,27 @@ void QgsComposer::on_mActionPageSetup_triggered()
QPageSetupDialog pageSetupDialog( &mPrinter, this );
pageSetupDialog.exec();
}

void QgsComposer::restoreComposerMapStates()
{
//go through maps and restore original preview modes (show on demand after loading from project file)
QMap< QgsComposerMap*, int >::iterator mapIt = mMapsToRestore.begin();
for ( ; mapIt != mMapsToRestore.end(); ++mapIt )
{
mapIt.key()->setPreviewMode(( QgsComposerMap::PreviewMode )( mapIt.value() ) );
mapIt.key()->cache();
mapIt.key()->update();
}
mMapsToRestore.clear();
}

void QgsComposer::initialiseComposerPicturePreviews()
{
//create composer picture widget previews
QList< QgsComposerPictureWidget* >::iterator picIt = mPicturePreviews.begin();
for ( ; picIt != mPicturePreviews.end(); ++picIt )
{
( *picIt )->addStandardDirectoriesToPreview();
}
mPicturePreviews.clear();
}
@@ -289,6 +289,14 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! Removes all the item from the graphics scene and deletes them
void deleteItems();

//! Restores composer map preview states.
//! Initially after reading from xml, states are set to rectangle to achieve faster project loading.
void restoreComposerMapStates();

//! Fills icons into composer picture widgets
//! To make loading from project faster, the previews are generated when the composer becomes visible.
void initialiseComposerPicturePreviews();

/**Composer title*/
QString mTitle;

0 comments on commit 3869a6c

Please sign in to comment.
You can’t perform that action at this time.