Skip to content

Commit

Permalink
Patch that provides incremental screen update
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7846 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 5, 2008
1 parent c37b5f0 commit 5f2d993
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 91 deletions.
2 changes: 0 additions & 2 deletions python/gui/qgsmapcanvas.sip
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ class QgsMapCanvas : QGraphicsView
/**Sets dirty=true and calls render()*/
void refresh();

virtual void render();

//! Save the convtents of the map canvas to disk as an image
void saveAsImage(QString theFileName,QPixmap * QPixmap=0, QString="PNG" );

Expand Down
65 changes: 55 additions & 10 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ void QgsLegend::removeAll()

void QgsLegend::selectAll(bool select)
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

QTreeWidgetItem* theItem = firstItem();

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

void QgsLegend::removeLayer(QString layer_key)
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

QTreeWidgetItem* theItem = firstItem();
#ifdef QGISDEBUG
qWarning("in QgsLegend::removeLayer");
Expand Down Expand Up @@ -371,20 +381,24 @@ void QgsLegend::mouseReleaseEvent(QMouseEvent * e)

void QgsLegend::mouseDoubleClickEvent(QMouseEvent* e)
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}
legendLayerShowProperties();
}

void QgsLegend::handleRightClickEvent(QTreeWidgetItem* item, const QPoint& position)
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

QMenu theMenu;

QString iconsPath = QgsApplication::themePath();

if(mMapCanvas->isDrawing())
{
return;
}

QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(item);
if (li)
{
Expand Down Expand Up @@ -446,6 +460,11 @@ int QgsLegend::getItemPos(QTreeWidgetItem* item)

void QgsLegend::addLayer( QgsMapLayer * layer )
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

QgsLegendLayer * llayer = new QgsLegendLayer(layer->name());//generate entry for mStateOfCheckBoxes below
QgsLegendLayerFileGroup * llfgroup = new QgsLegendLayerFileGroup(llayer,QString("Files"));
QgsLegendLayerFile * llfile = new QgsLegendLayerFile(llfgroup, QgsLegendLayerFile::nameFromLayer(layer), layer);
Expand Down Expand Up @@ -535,6 +554,11 @@ QgsMapLayer* QgsLegend::currentLayer()

void QgsLegend::legendGroupRemove()
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

QgsLegendGroup* lg = dynamic_cast<QgsLegendGroup*>(currentItem());
if(lg)
{
Expand All @@ -553,6 +577,11 @@ void QgsLegend::legendGroupRemove()

void QgsLegend::legendLayerRemove()
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

//if the current item is a legend layer: remove all layers of the current legendLayer
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(currentItem());
if(ll)
Expand All @@ -572,14 +601,12 @@ void QgsLegend::legendLayerRemove()
//remove the layer
if(*it)
{
//the map layer registry emits a signal an this will remove the legend layer
//from the legend and from memory by calling QgsLegend::removeLayer(QString layer key)
QgsMapLayerRegistry::instance()->removeMapLayer((*it)->getLayerID());
}
}

if(maplayers.size()>0)
{
mMapCanvas->refresh();
}
removeItem(ll);
delete ll;
adjustIconSize();
Expand All @@ -604,6 +631,11 @@ void QgsLegend::legendLayerRemove()

void QgsLegend::legendLayerShowProperties()
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(currentItem());
QgsLegendLayerFile* llf = 0;

Expand Down Expand Up @@ -679,6 +711,11 @@ void QgsLegend::legendLayerShowProperties()

void QgsLegend::legendLayerShowInOverview()
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

QgsLegendItem* li = dynamic_cast<QgsLegendItem*>(currentItem());
if(!li)
return;
Expand Down Expand Up @@ -1585,6 +1622,7 @@ void QgsLegend::handleItemChange(QTreeWidgetItem* item, int row)
//set all the child layer files to the new check state
subfiles = ll->legendLayerFiles();
bool renderFlagState = mMapCanvas->renderFlag();
mMapCanvas->freeze(true);
mMapCanvas->setRenderFlag(false);
for(std::list<QgsLegendLayerFile*>::iterator iter = subfiles.begin(); iter != subfiles.end(); ++iter)
{
Expand All @@ -1605,7 +1643,10 @@ 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);
{
mMapCanvas->setRenderFlag(true);
}
mMapCanvas->freeze(false);
//update check state of the legend group
mStateOfCheckBoxes[item] = item->checkState(0);
}
Expand Down Expand Up @@ -1752,6 +1793,10 @@ void QgsLegend::legendLayerZoomNative()

void QgsLegend::legendLayerAttributeTable()
{
if(!mMapCanvas || mMapCanvas->isDrawing())
{
return;
}

// try whether it's a legend layer
QgsLegendLayer* ll = dynamic_cast<QgsLegendLayer*>(currentItem());
Expand Down
1 change: 1 addition & 0 deletions src/app/legend/qgslegendlayerfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ void QgsLegendLayerFile::table()
// but be can get it using this ugly hack. [jef]
// TODO: do this cleanly
QgisApp *app = NULL;

QList<QWidget *> list = QApplication::topLevelWidgets();

int i;
Expand Down
Loading

0 comments on commit 5f2d993

Please sign in to comment.