[QGIS Commit] r15561 - in trunk/qgis: python/gui src/app/legend src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Mar 22 11:39:10 EDT 2011


Author: mhugent
Date: 2011-03-22 08:39:10 -0700 (Tue, 22 Mar 2011)
New Revision: 15561

Modified:
   trunk/qgis/python/gui/qgslegendinterface.sip
   trunk/qgis/src/app/legend/qgsapplegendinterface.cpp
   trunk/qgis/src/app/legend/qgsapplegendinterface.h
   trunk/qgis/src/app/legend/qgslegend.cpp
   trunk/qgis/src/app/legend/qgslegend.h
   trunk/qgis/src/gui/qgslegendinterface.h
Log:
Apply patch #3263 to fix adding of groups to Legend. Provided by Marco Bernasocchi

Modified: trunk/qgis/python/gui/qgslegendinterface.sip
===================================================================
--- trunk/qgis/python/gui/qgslegendinterface.sip	2011-03-22 08:56:28 UTC (rev 15560)
+++ trunk/qgis/python/gui/qgslegendinterface.sip	2011-03-22 15:39:10 UTC (rev 15561)
@@ -50,7 +50,8 @@
   public slots:
 
     //! Add a new group
-    virtual int addGroup( QString name, bool expand = true ) =0;
+    //! @note added parent parameter in 1.7
+    virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent =0 ) =0;
 
     //! Remove group on index
     virtual void removeGroup( int groupIndex ) =0;

Modified: trunk/qgis/src/app/legend/qgsapplegendinterface.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgsapplegendinterface.cpp	2011-03-22 08:56:28 UTC (rev 15560)
+++ trunk/qgis/src/app/legend/qgsapplegendinterface.cpp	2011-03-22 15:39:10 UTC (rev 15561)
@@ -21,6 +21,7 @@
 #include "qgslegendlayer.h"
 #include "qgsmaplayer.h"
 
+
 QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
     : mLegend( legend )
 {
@@ -31,9 +32,9 @@
 {
 }
 
-int QgsAppLegendInterface::addGroup( QString name, bool expand )
+int QgsAppLegendInterface::addGroup( QString name, bool expand, QTreeWidgetItem* parent )
 {
-  return mLegend->addGroup( name, expand );
+  return mLegend->addGroup( name, expand, parent );
 }
 
 void QgsAppLegendInterface::removeGroup( int groupIndex )

Modified: trunk/qgis/src/app/legend/qgsapplegendinterface.h
===================================================================
--- trunk/qgis/src/app/legend/qgsapplegendinterface.h	2011-03-22 08:56:28 UTC (rev 15560)
+++ trunk/qgis/src/app/legend/qgsapplegendinterface.h	2011-03-22 15:39:10 UTC (rev 15561)
@@ -65,7 +65,7 @@
   public slots:
 
     //! Add a new group
-    int addGroup( QString name, bool expand = true );
+    int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 );
 
     //! Remove all groups with the given name
     void removeGroup( int groupIndex );

Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp	2011-03-22 08:56:28 UTC (rev 15560)
+++ trunk/qgis/src/app/legend/qgslegend.cpp	2011-03-22 15:39:10 UTC (rev 15561)
@@ -151,16 +151,16 @@
   emit currentLayerChanged( layer );
 }
 
-int QgsLegend::addGroup( QString name, bool expand )
+int QgsLegend::addGroup( QString name, bool expand, QTreeWidgetItem* parent )
 {
   if ( name.isEmpty() )
     name = tr( "group" ); // some default name if none specified
 
-  QgsLegendGroup *parent = dynamic_cast<QgsLegendGroup *>( currentItem() );
+  QgsLegendGroup *parentGroup = dynamic_cast<QgsLegendGroup *>( parent );
 
   QgsLegendGroup *group;
-  if ( parent )
-    group = new QgsLegendGroup( parent, name );
+  if ( parentGroup )
+    group = new QgsLegendGroup( parentGroup, name );
   else
     group = new QgsLegendGroup( this, name );
 
@@ -1792,10 +1792,10 @@
     QgsDebugMsg( "Raster units per pixel  : " + QString::number( layer->rasterUnitsPerPixel() ) );
     QgsDebugMsg( "MapUnitsPerPixel before : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );
 
-   layer->setCacheImage( NULL );
-   mMapCanvas->zoomByFactor( qAbs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
-   mMapCanvas->refresh();
-   QgsDebugMsg( "MapUnitsPerPixel after  : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );
+    layer->setCacheImage( NULL );
+    mMapCanvas->zoomByFactor( qAbs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
+    mMapCanvas->refresh();
+    QgsDebugMsg( "MapUnitsPerPixel after  : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );
   }
 }
 

Modified: trunk/qgis/src/app/legend/qgslegend.h
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.h	2011-03-22 08:56:28 UTC (rev 15560)
+++ trunk/qgis/src/app/legend/qgslegend.h	2011-03-22 15:39:10 UTC (rev 15561)
@@ -221,7 +221,7 @@
      * @param expand expand the group
      * @return void
      */
-    int addGroup( QString name = QString(), bool expand = true );
+    int addGroup( QString name = QString(), bool expand = true, QTreeWidgetItem* parent = 0 );
 
     /*!
      * Removes all groups with the given name.

Modified: trunk/qgis/src/gui/qgslegendinterface.h
===================================================================
--- trunk/qgis/src/gui/qgslegendinterface.h	2011-03-22 08:56:28 UTC (rev 15560)
+++ trunk/qgis/src/gui/qgslegendinterface.h	2011-03-22 15:39:10 UTC (rev 15561)
@@ -23,6 +23,7 @@
 #include <QStringList>
 
 class QgsMapLayer;
+class QTreeWidgetItem;
 
 //Information about relationship between groups and layers
 //key: group name (or null strings for single layers without groups)
@@ -80,7 +81,8 @@
   public slots:
 
     //! Add a new group
-    virtual int addGroup( QString name, bool expand = true ) = 0;
+    //! forceAtEnd forces the new group to be created at the end of the legend
+    virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 ) = 0;
 
     //! Remove group on index
     virtual void removeGroup( int groupIndex ) = 0;



More information about the QGIS-commit mailing list