Skip to content

Commit

Permalink
fix #3109
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14377 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 13, 2010
1 parent ec7117f commit 1684936
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
37 changes: 18 additions & 19 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ void QgsLegend::selectAll( bool select )

// Turn off rendering to improve speed.
bool renderFlagState = mMapCanvas->renderFlag();
mMapCanvas->setRenderFlag( false );
if ( renderFlagState )
mMapCanvas->setRenderFlag( false );

for ( QTreeWidgetItem* theItem = firstItem(); theItem; theItem = nextItem( theItem ) )
{
Expand All @@ -168,7 +169,8 @@ void QgsLegend::selectAll( bool select )
}

// Turn on rendering (if it was on previously)
mMapCanvas->setRenderFlag( renderFlagState );
if ( renderFlagState )
mMapCanvas->setRenderFlag( true );

QgsProject::instance()->dirty( true );
}
Expand Down Expand Up @@ -1483,8 +1485,6 @@ void QgsLegend::handleItemChange( QTreeWidgetItem* item, int row )
return;
}

bool renderFlagState = mMapCanvas->renderFlag();

//if the text of a QgsLegendLayer has changed, change the display names of all its maplayers
// TODO: is this still necessary?
QgsLegendLayer* theLegendLayer = dynamic_cast<QgsLegendLayer *>( item ); //item is a legend layer
Expand All @@ -1497,13 +1497,16 @@ void QgsLegend::handleItemChange( QTreeWidgetItem* item, int row )
if ( item->data( 0, Qt::UserRole ).toInt() == item->checkState( 0 ) )
return;

bool renderFlagState = mMapCanvas->renderFlag();
if ( renderFlagState )
mMapCanvas->setRenderFlag( false );

QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup *>( item ); //item is a legend group
if ( lg )
{
//set all the child layer files to the new check state
std::list<QgsLegendLayer*> subfiles = lg->legendLayers();
bool renderFlagState = mMapCanvas->renderFlag();
mMapCanvas->setRenderFlag( false );

for ( std::list<QgsLegendLayer*>::iterator iter = subfiles.begin(); iter != subfiles.end(); ++iter )
{
#ifdef QGISDEBUG
Expand All @@ -1530,10 +1533,6 @@ void QgsLegend::handleItemChange( QTreeWidgetItem* item, int row )
}
}

// If it was on, turn it back on, otherwise leave it
// off, as turning it on causes a refresh.
if ( renderFlagState )
mMapCanvas->setRenderFlag( true );
item->setData( 0, Qt::UserRole, item->checkState( 0 ) );
}

Expand All @@ -1554,19 +1553,17 @@ void QgsLegend::handleItemChange( QTreeWidgetItem* item, int row )
static_cast<QgsLegendGroup*>( ll->parent() )->updateCheckState();
ll->parent()->setData( 0, Qt::UserRole, ll->parent()->checkState( 0 ) );
}
// If it was on, turn it back on, otherwise leave it
// off, as turning it on causes a refresh.
if ( renderFlagState )
{
mMapCanvas->setRenderFlag( true );
}
mMapCanvas->freeze( false );
//update check state of the legend group
item->setData( 0, Qt::UserRole, item->checkState( 0 ) );
}

// update layer set
updateMapCanvasLayerSet();

// If it was on, turn it back on, otherwise leave it
// off, as turning it on causes a refresh.
if ( renderFlagState )
mMapCanvas->setRenderFlag( true );
}

void QgsLegend::openEditor()
Expand Down Expand Up @@ -1770,7 +1767,8 @@ void QgsLegend::removeSelectedLayers()
{
// Turn off rendering to improve speed.
bool renderFlagState = mMapCanvas->renderFlag();
mMapCanvas->setRenderFlag( false );
if ( renderFlagState )
mMapCanvas->setRenderFlag( false );

foreach( QTreeWidgetItem *item, selectedItems() )
{
Expand All @@ -1790,5 +1788,6 @@ void QgsLegend::removeSelectedLayers()
}

// Turn on rendering (if it was on previously)
mMapCanvas->setRenderFlag( renderFlagState );
if ( renderFlagState )
mMapCanvas->setRenderFlag( true );
}
14 changes: 9 additions & 5 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3544,7 +3544,7 @@ void QgisApp::showComposerManager()

void QgisApp::saveMapAsImage()
{
QPair< QString,QString> myFileNameAndFilter = QgisGui::getSaveAsImageName( this, tr( "Choose a file name to save the map image as" ) );
QPair< QString, QString> myFileNameAndFilter = QgisGui::getSaveAsImageName( this, tr( "Choose a file name to save the map image as" ) );
if ( myFileNameAndFilter.first != "" )
{
//save the mapview to the selected file
Expand Down Expand Up @@ -3606,10 +3606,12 @@ void QgisApp::toggleFullScreen()
// would otherwise cause two re-renders of the map, which can take a
// long time.
bool renderFlag = mapCanvas()->renderFlag();
mapCanvas()->setRenderFlag( false );
if ( renderFlag )
mapCanvas()->setRenderFlag( false );
showNormal();
showMaximized();
mapCanvas()->setRenderFlag( renderFlag );
if ( renderFlag )
mapCanvas()->setRenderFlag( true );
mPrevScreenModeMaximized = false;
}
else
Expand Down Expand Up @@ -4413,7 +4415,8 @@ void QgisApp::deselectAll()

// Turn off rendering to improve speed.
bool renderFlagState = mMapCanvas->renderFlag();
mMapCanvas->setRenderFlag( false );
if ( renderFlagState )
mMapCanvas->setRenderFlag( false );

QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin(); it != layers.end(); it++ )
Expand All @@ -4426,7 +4429,8 @@ void QgisApp::deselectAll()
}

// Turn on rendering (if it was on previously)
mMapCanvas->setRenderFlag( renderFlagState );
if ( renderFlagState )
mMapCanvas->setRenderFlag( true );
}

void QgisApp::addVertex()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
refresh();
}

} // addLayer
} // setLayerSet

void QgsMapCanvas::enableOverviewMode( QgsMapOverviewCanvas* overview )
{
Expand Down

0 comments on commit 1684936

Please sign in to comment.