mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-17 00:09:36 -04:00
Trying to fix the very erratic reordering of layer legend, by only using 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
This commit is contained in:
parent
243589896e
commit
acdbf8af6f
@ -233,12 +233,12 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
|
|||||||
if ( item && ( item != mItemBeingMoved ) )
|
if ( item && ( item != mItemBeingMoved ) )
|
||||||
{
|
{
|
||||||
QgsLegendItem::DRAG_ACTION action = dest->accept( origin );
|
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->nextSibling() != dest )
|
||||||
{
|
{
|
||||||
if ( origin->parent() != dest->parent() )
|
if ( origin->parent() != dest->parent() )
|
||||||
@ -251,37 +251,53 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
|
|||||||
moveItem( dest, origin );
|
moveItem( dest, origin );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setCurrentItem( origin );
|
||||||
}
|
}
|
||||||
else //over top of item
|
else
|
||||||
{
|
{
|
||||||
|
QgsDebugMsg( "mouseMoveEvent::NO_ACTION" );
|
||||||
|
|
||||||
|
if ( origin->type() == QgsLegendItem::LEGEND_LAYER_FILE && mItemBeingMovedOrigPos != getItemPos( mItemBeingMoved ) )
|
||||||
|
{
|
||||||
|
resetToInitialPosition( mItemBeingMoved );
|
||||||
|
}
|
||||||
|
setCursor( QCursor( Qt::ForbiddenCursor ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // below center of item
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( action == QgsLegendItem::REORDER )
|
||||||
|
{
|
||||||
|
QgsDebugMsg( "mouseMoveEvent::REORDER bottom half" );
|
||||||
if ( mItemBeingMoved != dest->nextSibling() )
|
if ( mItemBeingMoved != dest->nextSibling() )
|
||||||
{
|
{
|
||||||
//origin->moveItem(dest);
|
//origin->moveItem(dest);
|
||||||
moveItem( origin, dest );
|
moveItem( origin, dest );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
setCurrentItem( origin );
|
|
||||||
}
|
|
||||||
else if ( action == QgsLegendItem::INSERT )
|
|
||||||
{
|
|
||||||
QgsDebugMsg( "mouseMoveEvent::INSERT" );
|
|
||||||
|
|
||||||
setCursor( QCursor( Qt::PointingHandCursor ) );
|
|
||||||
if ( origin->parent() != dest )
|
|
||||||
{
|
|
||||||
insertItem( origin, dest );
|
|
||||||
setCurrentItem( origin );
|
setCurrentItem( origin );
|
||||||
}
|
}
|
||||||
}
|
else if ( action == QgsLegendItem::INSERT )
|
||||||
else//no action
|
|
||||||
{
|
|
||||||
QgsDebugMsg( "mouseMoveEvent::NO_ACTION" );
|
|
||||||
|
|
||||||
if ( origin->type() == QgsLegendItem::LEGEND_LAYER_FILE && mItemBeingMovedOrigPos != getItemPos( mItemBeingMoved ) )
|
|
||||||
{
|
{
|
||||||
resetToInitialPosition( mItemBeingMoved );
|
QgsDebugMsg( "mouseMoveEvent::INSERT" );
|
||||||
|
|
||||||
|
setCursor( QCursor( Qt::PointingHandCursor ) );
|
||||||
|
if ( origin->parent() != dest )
|
||||||
|
{
|
||||||
|
insertItem( origin, dest );
|
||||||
|
setCurrentItem( origin );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else//no action
|
||||||
|
{
|
||||||
|
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 )
|
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
|
// XXX - mloskot - I don't know what to return
|
||||||
// but this function must return a value
|
// but this function must return a value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user