Skip to content
Permalink
Browse files

improve dragging legend layers

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14704 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 17, 2010
1 parent c2a400a commit 23f9055c704a8119f1c48c0c7a777f6292f15478
Showing with 54 additions and 42 deletions.
  1. +3 −1 ms-windows/osgeo4w/package.cmd
  2. +51 −41 src/app/legend/qgslegend.cpp
@@ -147,6 +147,7 @@ touch exclude

tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 ^
--exclude-from exclude ^
--exclude "*.pyc" ^
--exclude "apps/%PACKAGENAME%/themes/classic/grass" ^
--exclude "apps/%PACKAGENAME%/themes/default/grass" ^
--exclude "apps/%PACKAGENAME%/themes/qgis/grass" ^
@@ -162,8 +163,9 @@ tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-%VERSION%-%PACKAGE%.tar.bz2 ^
>>%LOG% 2>&1
if errorlevel 1 goto error

tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-grass-%VERSION%-%PACKAGE%.tar.bz2 ^
tar -C %OSGEO4W_ROOT% -cjf %PACKAGENAME%-grass-plugin-%VERSION%-%PACKAGE%.tar.bz2 ^
--exclude-from exclude ^
--exclude "*.pyc" \
"apps/%PACKAGENAME%/themes/classic/grass" ^
"apps/%PACKAGENAME%/themes/default/grass" ^
"apps/%PACKAGENAME%/themes/gis/grass" ^
@@ -48,11 +48,11 @@ static const char *const ident_ = "$Id$";
const int AUTOSCROLL_MARGIN = 16;

QgsLegend::QgsLegend( QgsMapCanvas *canvas, QWidget * parent, const char *name )
: QTreeWidget( parent )
, mMousePressedFlag( false )
, mMapCanvas( canvas )
, mMinimumIconSize( 20, 20 )
, mChanging( false )
: QTreeWidget( parent )
, mMousePressedFlag( false )
, mMapCanvas( canvas )
, mMinimumIconSize( 20, 20 )
, mChanging( false )
{
setObjectName( name );

@@ -117,7 +117,7 @@ void QgsLegend::showItem( QString msg, QTreeWidgetItem *item )
return;
}

QgsLegendItem *litem = dynamic_cast<QgsLegendGroup *>( item );
QgsLegendItem *litem = dynamic_cast<QgsLegendItem *>( item );
QgsLegendGroup *group = dynamic_cast<QgsLegendGroup *>( item );
QgsLegendLayer *layer = dynamic_cast<QgsLegendLayer *>( item );

@@ -327,54 +327,65 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
{
showItem( "moveMoveEvent" , item );

QgsLegendItem *litem = dynamic_cast<QgsLegendGroup *>( item );
QgsLegendItem *litem = dynamic_cast<QgsLegendItem *>( item );
QgsLegendGroup *group = dynamic_cast<QgsLegendGroup *>( item );
QgsLegendLayer *layer = dynamic_cast<QgsLegendLayer *>( item );

if ( group || layer )
while ( item->parent() && !group && !layer )
{
item = item->parent();
litem = dynamic_cast<QgsLegendItem *>( item );
group = dynamic_cast<QgsLegendGroup *>( item );
layer = dynamic_cast<QgsLegendLayer *>( item );
}

showItem( "layer/group" , item );

int line_x = visualItemRect( item ).left();
int line_y;
if ( layer )
{
QTreeWidgetItem *lastItem = item->childCount() > 0 ? item->child( item->childCount() - 1 ) : item;
int y0 = visualItemRect( item ).top() + 1;
int y1 = visualItemRect( lastItem ).bottom() - 2;

mDropTarget = layer;

if ( e->y() < ( y0 + y1 ) / 2 )
{
QgsDebugMsg( "insert before layer" );
mDropAction = BEFORE;
line_y = y0;
}
else
{
QgsDebugMsg( "insert after layer" );
mDropAction = AFTER;
line_y = y1;
}
}
else if ( group )
{
if ( yCoordAboveCenter( litem, e->y() ) ) //over center of item
{
int line_y = visualItemRect( item ).top() + 1;
int line_left = visualItemRect( item ).left();

QgsDebugMsg( "insert before layer/group" );
showLine( line_y, line_left );
setCursor( QCursor( Qt::SizeVerCursor ) );
QgsDebugMsg( "insert before group" );

line_y = visualItemRect( item ).top() + 1;
mDropTarget = item;
mDropAction = BEFORE;
}
else // below center of item
{
int line_y = visualItemRect( item ).bottom() - 2;
int line_left = visualItemRect( item ).left();

if ( group )
{
QgsDebugMsg( "insert into group" );
showLine( line_y, line_left );
setCursor( QCursor( Qt::SizeVerCursor ) );
QgsDebugMsg( "insert into group" );

mDropTarget = item;
mDropAction = INSERT;
}
else
{
QgsDebugMsg( "insert after layer" );
showLine( line_y, line_left );
setCursor( QCursor( Qt::SizeVerCursor ) );

mDropTarget = item;
mDropAction = AFTER;
}
line_y = visualItemRect( item ).bottom() - 2;
mDropTarget = item;
mDropAction = INSERT;
}
}
else
{
QgsDebugMsg( "no action" );
setCursor( QCursor( Qt::ForbiddenCursor ) );
}

showLine( line_y, line_x );
setCursor( QCursor( Qt::SizeVerCursor ) );
}
else if ( !item
&& e->pos().y() >= 0 && e->pos().y() < viewport()->height()
@@ -383,12 +394,11 @@ void QgsLegend::mouseMoveEvent( QMouseEvent * e )
// Outside the listed items, but check if we are in the empty area
// of the viewport, so we can drop after the last top level item.
mDropTarget = topLevelItem( topLevelItemCount() - 1 );
mDropAction = AFTER;

QgsDebugMsg( "insert after last layer/group" );
showLine( visualItemRect( lastVisibleItem() ).bottom() + 1, 0 );
setCursor( QCursor( Qt::SizeVerCursor ) );

mDropAction = AFTER;
}
else
{

0 comments on commit 23f9055

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