mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Apply patch #3263 to fix adding of groups to Legend. Provided by Marco Bernasocchi
git-svn-id: http://svn.osgeo.org/qgis/trunk@15561 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
272bbddb0e
commit
855601c3d6
@ -50,7 +50,8 @@ class QgsLegendInterface : QObject
|
||||
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;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "qgslegendlayer.h"
|
||||
#include "qgsmaplayer.h"
|
||||
|
||||
|
||||
QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
|
||||
: mLegend( legend )
|
||||
{
|
||||
@ -31,9 +32,9 @@ QgsAppLegendInterface::~QgsAppLegendInterface()
|
||||
{
|
||||
}
|
||||
|
||||
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 )
|
||||
|
@ -65,7 +65,7 @@ class QgsAppLegendInterface : public QgsLegendInterface
|
||||
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 );
|
||||
|
@ -151,16 +151,16 @@ void QgsLegend::handleCurrentItemChanged( QTreeWidgetItem* current, QTreeWidgetI
|
||||
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 @@ void QgsLegend::legendLayerZoomNative()
|
||||
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() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ class QgsLegend : public QTreeWidget
|
||||
* @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.
|
||||
|
@ -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 @@ class GUI_EXPORT QgsLegendInterface : public QObject
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user