[QGIS Commit] r9547 - trunk/qgis/src/app/legend
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Oct 25 14:37:06 EDT 2008
Author: homann
Date: 2008-10-25 14:37:06 -0400 (Sat, 25 Oct 2008)
New Revision: 9547
Modified:
trunk/qgis/src/app/legend/qgslegend.cpp
trunk/qgis/src/app/legend/qgslegendgroup.cpp
Log:
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
Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp 2008-10-25 14:19:58 UTC (rev 9546)
+++ trunk/qgis/src/app/legend/qgslegend.cpp 2008-10-25 18:37:06 UTC (rev 9547)
@@ -233,12 +233,12 @@
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 @@
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 ) );
}
}
}
Modified: trunk/qgis/src/app/legend/qgslegendgroup.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegendgroup.cpp 2008-10-25 14:19:58 UTC (rev 9546)
+++ trunk/qgis/src/app/legend/qgslegendgroup.cpp 2008-10-25 18:37:06 UTC (rev 9547)
@@ -100,7 +100,8 @@
{
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
More information about the QGIS-commit
mailing list