Skip to content

Commit 28c5599

Browse files
author
mhugent
committed
Patch that provides incremental screen update
git-svn-id: http://svn.osgeo.org/qgis/trunk@7846 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9b3cdb2 commit 28c5599

12 files changed

+326
-91
lines changed

python/gui/qgsmapcanvas.sip

-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ class QgsMapCanvas : QGraphicsView
182182
/**Sets dirty=true and calls render()*/
183183
void refresh();
184184

185-
virtual void render();
186-
187185
//! Save the convtents of the map canvas to disk as an image
188186
void saveAsImage(QString theFileName,QPixmap * QPixmap=0, QString="PNG" );
189187

src/app/legend/qgslegend.cpp

+55-10
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ void QgsLegend::removeAll()
124124

125125
void QgsLegend::selectAll(bool select)
126126
{
127+
if(!mMapCanvas || mMapCanvas->isDrawing())
128+
{
129+
return;
130+
}
131+
127132
QTreeWidgetItem* theItem = firstItem();
128133

129134
while (theItem)
@@ -140,6 +145,11 @@ void QgsLegend::selectAll(bool select)
140145

141146
void QgsLegend::removeLayer(QString layer_key)
142147
{
148+
if(!mMapCanvas || mMapCanvas->isDrawing())
149+
{
150+
return;
151+
}
152+
143153
QTreeWidgetItem* theItem = firstItem();
144154
#ifdef QGISDEBUG
145155
qWarning("in QgsLegend::removeLayer");
@@ -371,20 +381,24 @@ void QgsLegend::mouseReleaseEvent(QMouseEvent * e)
371381

372382
void QgsLegend::mouseDoubleClickEvent(QMouseEvent* e)
373383
{
384+
if(!mMapCanvas || mMapCanvas->isDrawing())
385+
{
386+
return;
387+
}
374388
legendLayerShowProperties();
375389
}
376390

377391
void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& position)
378392
{
393+
if(!mMapCanvas || mMapCanvas->isDrawing())
394+
{
395+
return;
396+
}
397+
379398
QMenu theMenu;
380399

381400
QString iconsPath = QgsApplication::themePath();
382401

383-
if(mMapCanvas->isDrawing())
384-
{
385-
return;
386-
}
387-
388402
QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(item);
389403
if (li)
390404
{
@@ -446,6 +460,11 @@ int QgsLegend::getItemPos(QTreeWidgetItem* item)
446460

447461
void QgsLegend::addLayer( QgsMapLayer * layer )
448462
{
463+
if(!mMapCanvas || mMapCanvas->isDrawing())
464+
{
465+
return;
466+
}
467+
449468
QgsLegendLayer * llayer = new QgsLegendLayer(layer->name());//generate entry for mStateOfCheckBoxes below
450469
QgsLegendLayerFileGroup * llfgroup = new QgsLegendLayerFileGroup(llayer,QString("Files"));
451470
QgsLegendLayerFile * llfile = new QgsLegendLayerFile(llfgroup, QgsLegendLayerFile::nameFromLayer(layer), layer);
@@ -535,6 +554,11 @@ QgsMapLayer* QgsLegend::currentLayer()
535554

536555
void QgsLegend::legendGroupRemove()
537556
{
557+
if(!mMapCanvas || mMapCanvas->isDrawing())
558+
{
559+
return;
560+
}
561+
538562
QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup*>(currentItem());
539563
if(lg)
540564
{
@@ -553,6 +577,11 @@ void QgsLegend::legendGroupRemove()
553577

554578
void QgsLegend::legendLayerRemove()
555579
{
580+
if(!mMapCanvas || mMapCanvas->isDrawing())
581+
{
582+
return;
583+
}
584+
556585
//if the current item is a legend layer: remove all layers of the current legendLayer
557586
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(currentItem());
558587
if(ll)
@@ -572,14 +601,12 @@ void QgsLegend::legendLayerRemove()
572601
//remove the layer
573602
if(*it)
574603
{
604+
//the map layer registry emits a signal an this will remove the legend layer
605+
//from the legend and from memory by calling QgsLegend::removeLayer(QString layer key)
575606
QgsMapLayerRegistry::instance()->removeMapLayer((*it)->getLayerID());
576607
}
577608
}
578609

579-
if(maplayers.size()>0)
580-
{
581-
mMapCanvas->refresh();
582-
}
583610
removeItem(ll);
584611
delete ll;
585612
adjustIconSize();
@@ -604,6 +631,11 @@ void QgsLegend::legendLayerRemove()
604631

605632
void QgsLegend::legendLayerShowProperties()
606633
{
634+
if(!mMapCanvas || mMapCanvas->isDrawing())
635+
{
636+
return;
637+
}
638+
607639
QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(currentItem());
608640
QgsLegendLayerFile* llf = 0;
609641

@@ -679,6 +711,11 @@ void QgsLegend::legendLayerShowProperties()
679711

680712
void QgsLegend::legendLayerShowInOverview()
681713
{
714+
if(!mMapCanvas || mMapCanvas->isDrawing())
715+
{
716+
return;
717+
}
718+
682719
QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(currentItem());
683720
if(!li)
684721
return;
@@ -1585,6 +1622,7 @@ void QgsLegend::handleItemChange(QTreeWidgetItem* item, int row)
15851622
//set all the child layer files to the new check state
15861623
subfiles = ll->legendLayerFiles();
15871624
bool renderFlagState = mMapCanvas->renderFlag();
1625+
mMapCanvas->freeze(true);
15881626
mMapCanvas->setRenderFlag(false);
15891627
for(std::list<QgsLegendLayerFile*>::iterator iter = subfiles.begin(); iter != subfiles.end(); ++iter)
15901628
{
@@ -1605,7 +1643,10 @@ void QgsLegend::handleItemChange(QTreeWidgetItem* item, int row)
16051643
// If it was on, turn it back on, otherwise leave it
16061644
// off, as turning it on causes a refresh.
16071645
if (renderFlagState)
1608-
mMapCanvas->setRenderFlag(true);
1646+
{
1647+
mMapCanvas->setRenderFlag(true);
1648+
}
1649+
mMapCanvas->freeze(false);
16091650
//update check state of the legend group
16101651
mStateOfCheckBoxes[item] = item->checkState(0);
16111652
}
@@ -1752,6 +1793,10 @@ void QgsLegend::legendLayerZoomNative()
17521793

17531794
void QgsLegend::legendLayerAttributeTable()
17541795
{
1796+
if(!mMapCanvas || mMapCanvas->isDrawing())
1797+
{
1798+
return;
1799+
}
17551800

17561801
// try whether it's a legend layer
17571802
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(currentItem());

src/app/legend/qgslegendlayerfile.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ void QgsLegendLayerFile::table()
249249
// but be can get it using this ugly hack. [jef]
250250
// TODO: do this cleanly
251251
QgisApp *app = NULL;
252+
252253
QList<QWidget *> list = QApplication::topLevelWidgets();
253254

254255
int i;

0 commit comments

Comments
 (0)