bug3263fix.diff
python/gui/qgslegendinterface.sip (working copy) | ||
---|---|---|
50 | 50 |
public slots: |
51 | 51 | |
52 | 52 |
//! Add a new group |
53 |
virtual int addGroup( QString name, bool expand = true ) =0; |
|
53 |
//! @note added parent parameter in 1.7 |
|
54 |
virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent =0 ) =0; |
|
54 | 55 | |
55 | 56 |
//! Remove group on index |
56 | 57 |
virtual void removeGroup( int groupIndex ) =0; |
src/app/legend/qgsapplegendinterface.h (working copy) | ||
---|---|---|
65 | 65 |
public slots: |
66 | 66 | |
67 | 67 |
//! Add a new group |
68 |
int addGroup( QString name, bool expand = true ); |
|
68 |
int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 );
|
|
69 | 69 | |
70 | 70 |
//! Remove all groups with the given name |
71 | 71 |
void removeGroup( int groupIndex ); |
src/app/legend/qgslegend.cpp (working copy) | ||
---|---|---|
151 | 151 |
emit currentLayerChanged( layer ); |
152 | 152 |
} |
153 | 153 | |
154 |
int QgsLegend::addGroup( QString name, bool expand ) |
|
154 |
int QgsLegend::addGroupToCurrentItem( QString name, bool expand )
|
|
155 | 155 |
{ |
156 |
QTreeWidgetItem *parent = currentItem(); |
|
157 |
addGroup(name, expand, parent); |
|
158 |
} |
|
159 | ||
160 |
int QgsLegend::addGroup( QString name, bool expand, QTreeWidgetItem* parent ) |
|
161 |
{ |
|
156 | 162 |
if ( name.isEmpty() ) |
157 | 163 |
name = tr( "group" ); // some default name if none specified |
164 |
|
|
165 |
QgsLegendGroup *parentGroup = dynamic_cast<QgsLegendGroup *>( parent ); |
|
158 | 166 | |
159 |
QgsLegendGroup *parent = dynamic_cast<QgsLegendGroup *>( currentItem() ); |
|
160 | ||
161 | 167 |
QgsLegendGroup *group; |
162 |
if ( parent ) |
|
163 |
group = new QgsLegendGroup( parent, name );
|
|
168 |
if ( parentGroup )
|
|
169 |
group = new QgsLegendGroup( parentGroup, name );
|
|
164 | 170 |
else |
165 | 171 |
group = new QgsLegendGroup( this, name ); |
166 | 172 | |
... | ... | |
577 | 583 |
} |
578 | 584 |
} |
579 | 585 | |
580 |
theMenu.addAction( QgisApp::getThemeIcon( "/folder_new.png" ), tr( "&Add group" ), this, SLOT( addGroup() ) ); |
|
586 |
theMenu.addAction( QgisApp::getThemeIcon( "/folder_new.png" ), tr( "&Add group" ), this, SLOT( addGroupToCurrentItem() ) );
|
|
581 | 587 |
theMenu.addAction( QgisApp::getThemeIcon( "/mActionExpandTree.png" ), tr( "&Expand all" ), this, SLOT( expandAll() ) ); |
582 | 588 |
theMenu.addAction( QgisApp::getThemeIcon( "/mActionCollapseTree.png" ), tr( "&Collapse all" ), this, SLOT( collapseAll() ) ); |
583 | 589 |
src/app/legend/qgslegend.h (working copy) | ||
---|---|---|
213 | 213 |
* @return void |
214 | 214 |
*/ |
215 | 215 |
void selectAll( bool select ); |
216 | ||
216 |
|
|
217 | 217 |
/*! |
218 | 218 |
* Slot called when user wishes to add a new empty layer group to the legend. |
219 |
* If a the legend has a currentItem() then the new group will be nested into it |
|
219 | 220 |
* The user will be prompted for the name of the newly added group. |
220 | 221 |
* @param name name of the new group |
221 | 222 |
* @param expand expand the group |
222 | 223 |
* @return void |
223 | 224 |
*/ |
224 |
int addGroup( QString name = QString(), bool expand = true );
|
|
225 |
int addGroupToCurrentItem( QString name = QString(), bool expand = true);
|
|
225 | 226 | |
226 | 227 |
/*! |
228 |
* Slot called when user wishes to add a new empty layer group to the legend. |
|
229 |
* The user will be prompted for the name of the newly added group. |
|
230 |
* @param name name of the new group |
|
231 |
* @param expand expand the group |
|
232 |
* @return void |
|
233 |
*/ |
|
234 |
int addGroup( QString name = QString(), bool expand = true, QTreeWidgetItem* parent = 0 ); |
|
235 |
|
|
236 |
/*! |
|
227 | 237 |
* Removes all groups with the given name. |
228 | 238 |
* @param name name of the groups to remove |
229 | 239 |
* @return void |
src/app/legend/qgsapplegendinterface.cpp (working copy) | ||
---|---|---|
21 | 21 |
#include "qgslegendlayer.h" |
22 | 22 |
#include "qgsmaplayer.h" |
23 | 23 | |
24 | ||
24 | 25 |
QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend ) |
25 | 26 |
: mLegend( legend ) |
26 | 27 |
{ |
... | ... | |
31 | 32 |
{ |
32 | 33 |
} |
33 | 34 | |
34 |
int QgsAppLegendInterface::addGroup( QString name, bool expand ) |
|
35 |
int QgsAppLegendInterface::addGroup( QString name, bool expand, QTreeWidgetItem* parent )
|
|
35 | 36 |
{ |
36 |
return mLegend->addGroup( name, expand ); |
|
37 |
return mLegend->addGroup( name, expand, parent );
|
|
37 | 38 |
} |
38 | 39 | |
39 | 40 |
void QgsAppLegendInterface::removeGroup( int groupIndex ) |
src/gui/qgslegendinterface.h (working copy) | ||
---|---|---|
23 | 23 |
#include <QStringList> |
24 | 24 | |
25 | 25 |
class QgsMapLayer; |
26 |
class QTreeWidgetItem; |
|
26 | 27 | |
27 | 28 |
//Information about relationship between groups and layers |
28 | 29 |
//key: group name (or null strings for single layers without groups) |
... | ... | |
80 | 81 |
public slots: |
81 | 82 | |
82 | 83 |
//! Add a new group |
83 |
virtual int addGroup( QString name, bool expand = true ) = 0; |
|
84 |
//! forceAtEnd forces the new group to be created at the end of the legend |
|
85 |
virtual int addGroup( QString name, bool expand = true, QTreeWidgetItem* parent = 0 ) = 0; |
|
84 | 86 | |
85 | 87 |
//! Remove group on index |
86 | 88 |
virtual void removeGroup( int groupIndex ) = 0; |