Skip to content

Commit 25789d8

Browse files
author
mhugent
committed
better method to check if a canvas redraw is necessary after a drag in the legend
git-svn-id: http://svn.osgeo.org/qgis/trunk@4934 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent dd657c9 commit 25789d8

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/legend/qgslegend.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ void QgsLegend::mouseMoveEvent(QMouseEvent * e)
242242
}
243243
}
244244
}
245-
//QTreeWidget::mouseMoveEvent(e);
246245
}
247246

248247
void QgsLegend::mouseReleaseEvent(QMouseEvent * e)
@@ -325,7 +324,13 @@ void QgsLegend::mouseReleaseEvent(QMouseEvent * e)
325324
origLayer->setLegend((QgsLegend*)(dynamic_cast<QgsLegendItem*>(dest->parent())->nextSibling()));
326325
}
327326
}
328-
emit zOrderChanged(this);
327+
328+
std::deque<QString> layersAfterRelease = layerIDs(); //test if canvas redraw is really necessary
329+
if(layersAfterRelease != mLayersPriorToMove)
330+
{
331+
emit zOrderChanged(this);
332+
}
333+
329334
}
330335
}
331336
mMousePressedFlag = false;
@@ -989,6 +994,7 @@ void QgsLegend::storeInitialPosition(QTreeWidgetItem* li)
989994
mRestoreInformation = YOUNGER_SIBLING;
990995
mRestoreItem = ((QgsLegendItem*)(li))->findYoungerSibling();
991996
}
997+
mLayersPriorToMove = layerIDs();
992998
}
993999

9941000
void QgsLegend::resetToInitialPosition(QTreeWidgetItem* li)

src/legend/qgslegend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ this item may be moved back to the original position with resetToInitialPosition
222222
/**Returns the legend layer to which a map layer gelongs*/
223223
QgsLegendLayer* findLegendLayer(const QString& layerKey);
224224

225+
225226
private slots:
226227

227228
/**Calls 'handleRightClickEvent' on the item*/
@@ -294,6 +295,10 @@ this item may be moved back to the original position with resetToInitialPosition
294295

295296
bool mShowLegendLayerFiles;
296297

298+
/**Stores the layer ordering before a mouse Move. After the move, this is used to
299+
decide if the mapcanvas really has to be refreshed*/
300+
std::deque<QString> mLayersPriorToMove;
301+
297302
/*!
298303
* A fuction sed to determin how far down in the list an item is (starting with one for the first Item.
299304
*If the item is not in the legend, -1 is returned

0 commit comments

Comments
 (0)