[QGIS Commit] r14704 - in trunk/qgis: ms-windows/osgeo4w src/app/legend

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Nov 17 16:05:02 EST 2010


Author: jef
Date: 2010-11-17 13:05:02 -0800 (Wed, 17 Nov 2010)
New Revision: 14704

Modified:
   trunk/qgis/ms-windows/osgeo4w/package.cmd
   trunk/qgis/src/app/legend/qgslegend.cpp
Log:
improve dragging legend layers

Modified: trunk/qgis/ms-windows/osgeo4w/package.cmd
===================================================================
--- trunk/qgis/ms-windows/osgeo4w/package.cmd	2010-11-17 20:40:23 UTC (rev 14703)
+++ trunk/qgis/ms-windows/osgeo4w/package.cmd	2010-11-17 21:05:02 UTC (rev 14704)
@@ -147,6 +147,7 @@
 
 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 @@
 	>>%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" ^

Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp	2010-11-17 20:40:23 UTC (rev 14703)
+++ trunk/qgis/src/app/legend/qgslegend.cpp	2010-11-17 21:05:02 UTC (rev 14704)
@@ -48,11 +48,11 @@
 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 @@
     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 @@
   {
     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 group" );
 
-        QgsDebugMsg( "insert before layer/group" );
-        showLine( line_y, line_left );
-        setCursor( QCursor( Qt::SizeVerCursor ) );
-
+        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();
+        QgsDebugMsg( "insert into group" );
 
-        if ( group )
-        {
-          QgsDebugMsg( "insert into group" );
-          showLine( line_y, line_left );
-          setCursor( QCursor( Qt::SizeVerCursor ) );
-
-          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 @@
     // 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
   {



More information about the QGIS-commit mailing list