mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
call contentsMousePressEvent() of parent object after setting QgsLegendView specific vars rather than before. When hiding a layer contentsMouseReleaseEvent() was being called before contentsMousePressEvent() had returned. This was causing layers to enter drag mode after being hidden/unhidden. This fixes that.
git-svn-id: http://svn.osgeo.org/qgis/trunk@563 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
5b506c2319
commit
0d982e47d4
@ -15,6 +15,7 @@
|
||||
#include <qlistview.h>
|
||||
#include <qpoint.h>
|
||||
#include <qrect.h>
|
||||
//#include <iostream>
|
||||
|
||||
#include "qgslegendview.h"
|
||||
|
||||
@ -26,28 +27,36 @@ QgsLegendView::QgsLegendView( QWidget *parent, const char *name ):QListView( par
|
||||
|
||||
void QgsLegendView::contentsMousePressEvent( QMouseEvent* e )
|
||||
{
|
||||
QListView::contentsMousePressEvent( e );
|
||||
//std::cout << "contentsMousePressEvent" << std::endl;
|
||||
if (e->button() == LeftButton) {
|
||||
//std::cout << "leftButton" << std::endl;
|
||||
QPoint p( contentsToViewport( e->pos() ) );
|
||||
QListViewItem *i = itemAt( p );
|
||||
if ( i ) {
|
||||
presspos = e->pos();
|
||||
mousePressed = TRUE;
|
||||
//std::cout << "mousePressed = TRUE" << std::endl;
|
||||
}
|
||||
}
|
||||
QListView::contentsMousePressEvent( e );
|
||||
}
|
||||
|
||||
void QgsLegendView::contentsMouseMoveEvent( QMouseEvent* e )
|
||||
{
|
||||
//std::cout << "contentsMouseMoveEvent" << std::endl;
|
||||
if ( mousePressed ) {
|
||||
//std::cout << "mousePressed" << std::endl;
|
||||
mousePressed = FALSE;
|
||||
//std::cout << "mousePressed = FALSE" << std::endl;
|
||||
// remember item we've pressed as the one being moved
|
||||
QListViewItem *item = itemAt( contentsToViewport(presspos) );
|
||||
if ( item ) {
|
||||
movingItem = item;
|
||||
setCursor( SizeVerCursor );
|
||||
//std::cout << "movingItem = item" << std::endl;
|
||||
}
|
||||
} else if ( movingItem ) {
|
||||
//std::cout << "movingItem" << std::endl;
|
||||
// move item in list if we're dragging over another item
|
||||
QListViewItem *item = itemAt( e->pos() );
|
||||
if ( item && ( item != movingItem ) ) {
|
||||
@ -75,12 +84,17 @@ void QgsLegendView::contentsMouseMoveEvent( QMouseEvent* e )
|
||||
|
||||
void QgsLegendView::contentsMouseReleaseEvent( QMouseEvent* e)
|
||||
{
|
||||
//std::cout << "contentsMouseReleaseEvent" << std::endl;
|
||||
QListView::contentsMouseReleaseEvent( e );
|
||||
if (e->button() == LeftButton) {
|
||||
//std::cout << "leftButton" << std::endl;
|
||||
mousePressed = FALSE;
|
||||
//std::cout << "mousePressed = FALSE" << std::endl;
|
||||
unsetCursor();
|
||||
if ( movingItem ) {
|
||||
//std::cout << "movingItem" << std::endl;
|
||||
movingItem = NULL;
|
||||
//std::cout << "movingItem = NULL" << std::endl;
|
||||
// tell qgsmapcanvas to reset layer order using the legend order
|
||||
emit zOrderChanged(this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user