Skip to content
Permalink
Browse files
Commited patch for #3263 with small modifications
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15766 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 19, 2011
1 parent 1509957 commit d241c01bd20426e77c4624c32b7e13de1745d5d5
Showing with 20 additions and 4 deletions.
  1. +8 −2 src/app/legend/qgslegend.cpp
  2. +12 −2 src/app/legend/qgslegend.h
@@ -151,14 +151,20 @@ void QgsLegend::handleCurrentItemChanged( QTreeWidgetItem* current, QTreeWidgetI
emit currentLayerChanged( layer );
}

int QgsLegend::addGroupToCurrentItem( QString name, bool expand )
{
QTreeWidgetItem *parent = currentItem();
return addGroup( name, expand, parent );
}

int QgsLegend::addGroup( QString name, bool expand, QTreeWidgetItem* parent )
{
if ( name.isEmpty() )
name = tr( "group" ); // some default name if none specified

QgsLegendGroup *parentGroup = dynamic_cast<QgsLegendGroup *>( parent );

QgsLegendGroup *group;

if ( parentGroup )
group = new QgsLegendGroup( parentGroup, name );
else
@@ -577,7 +583,7 @@ void QgsLegend::handleRightClickEvent( QTreeWidgetItem* item, const QPoint& posi
}
}

theMenu.addAction( QgisApp::getThemeIcon( "/folder_new.png" ), tr( "&Add group" ), this, SLOT( addGroup() ) );
theMenu.addAction( QgisApp::getThemeIcon( "/folder_new.png" ), tr( "&Add group" ), this, SLOT( addGroupToCurrentItem() ) );
theMenu.addAction( QgisApp::getThemeIcon( "/mActionExpandTree.png" ), tr( "&Expand all" ), this, SLOT( expandAll() ) );
theMenu.addAction( QgisApp::getThemeIcon( "/mActionCollapseTree.png" ), tr( "&Collapse all" ), this, SLOT( collapseAll() ) );

@@ -220,10 +220,20 @@ class QgsLegend : public QTreeWidget

/*!
* Slot called when user wishes to add a new empty layer group to the legend.
* If a the legend has a currentItem() then the new group will be nested into it
* The user will be prompted for the name of the newly added group.
* @param name name of the new group
* @param expand expand the group
* @return void
* @return index of inserted group
*/
int addGroupToCurrentItem( QString name = QString(), bool expand = true );

/*!
* Slot called when user wishes to add a new empty layer group to the legend.
* The user will be prompted for the name of the newly added group.
* @param name name of the new group
* @param expand expand the group
* @return index of inserted group
*/
int addGroup( QString name = QString(), bool expand = true, QTreeWidgetItem* parent = 0 );

@@ -414,7 +424,7 @@ class QgsLegend : public QTreeWidget

/**Pointer to the main canvas. Used for requiring repaints in case of legend changes*/
QgsMapCanvas* mMapCanvas;

/**Stores the width values of the LegendSymbologyItem pixmaps. The purpose of this is that the legend may automatically change
the global IconWidth when items are added or removed*/
std::multiset<int> mPixmapWidthValues;

0 comments on commit d241c01

Please sign in to comment.