Skip to content
Permalink
Browse files

Trying to fix the very erratic reordering of layer legend, by only us…

…ing INSERT in lower half of layer group, and also inserting item first in child list

git-svn-id: http://svn.osgeo.org/qgis/trunk@9547 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann
homann committed Oct 25, 2008
1 parent 2435898 commit acdbf8af6f52f8abcf64eeb50b058eeed58cd542
Showing with 38 additions and 21 deletions.
  1. +36 −20 src/app/legend/qgslegend.cpp
  2. +2 −1 src/app/legend/qgslegendgroup.cpp
@@ -233,12 +233,12 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
if ( item && ( item != mItemBeingMoved ) )
{
QgsLegendItem::DRAG_ACTION action = dest->accept( origin );
if ( action == QgsLegendItem::REORDER )
if ( yCoordAboveCenter( dest, e->y() ) ) //over center of item
{
QgsDebugMsg( "mouseMoveEvent::REORDER" );

if ( !yCoordAboveCenter( dest, e->y() ) ) //over bottom of item
if ( action == QgsLegendItem::REORDER || action == QgsLegendItem::INSERT )
{
QgsDebugMsg( "mouseMoveEvent::REORDER/INSERT top half" );
if ( origin->nextSibling() != dest )
{
if ( origin->parent() != dest->parent() )
@@ -251,37 +251,53 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
moveItem( dest, origin );
}
}
setCurrentItem( origin );
}
else //over top of item
else
{
if ( mItemBeingMoved != dest->nextSibling() )
QgsDebugMsg( "mouseMoveEvent::NO_ACTION" );

if ( origin->type() == QgsLegendItem::LEGEND_LAYER_FILE && mItemBeingMovedOrigPos != getItemPos( mItemBeingMoved ) )
{
//origin->moveItem(dest);
moveItem( origin, dest );
resetToInitialPosition( mItemBeingMoved );
}
setCursor( QCursor( Qt::ForbiddenCursor ) );
}
setCurrentItem( origin );
}
else if ( action == QgsLegendItem::INSERT )
else // below center of item
{
QgsDebugMsg( "mouseMoveEvent::INSERT" );

setCursor( QCursor( Qt::PointingHandCursor ) );
if ( origin->parent() != dest )
if ( action == QgsLegendItem::REORDER )
{
insertItem( origin, dest );
QgsDebugMsg( "mouseMoveEvent::REORDER bottom half" );
if ( mItemBeingMoved != dest->nextSibling() )
{
//origin->moveItem(dest);
moveItem( origin, dest );
}
setCurrentItem( origin );
}
}
else//no action
{
QgsDebugMsg( "mouseMoveEvent::NO_ACTION" );
else if ( action == QgsLegendItem::INSERT )
{
QgsDebugMsg( "mouseMoveEvent::INSERT" );

if ( origin->type() == QgsLegendItem::LEGEND_LAYER_FILE && mItemBeingMovedOrigPos != getItemPos( mItemBeingMoved ) )
setCursor( QCursor( Qt::PointingHandCursor ) );
if ( origin->parent() != dest )
{
insertItem( origin, dest );
setCurrentItem( origin );
}
}
else//no action
{
resetToInitialPosition( mItemBeingMoved );
QgsDebugMsg( "mouseMoveEvent::NO_ACTION" );

if ( origin->type() == QgsLegendItem::LEGEND_LAYER_FILE && mItemBeingMovedOrigPos != getItemPos( mItemBeingMoved ) )
{
resetToInitialPosition( mItemBeingMoved );
}
setCursor( QCursor( Qt::ForbiddenCursor ) );
}
setCursor( QCursor( Qt::ForbiddenCursor ) );
}
}
}
@@ -100,7 +100,8 @@ bool QgsLegendGroup::insert( QgsLegendItem* theItem )
{
if ( theItem->type() == LEGEND_LAYER )
{
addChild( theItem );
// Always insert at top of list
insertChild( 0, theItem );
}
// XXX - mloskot - I don't know what to return
// but this function must return a value

0 comments on commit acdbf8a

Please sign in to comment.
You can’t perform that action at this time.