bug3263_addGroupNesting.diff

patch to add nesting on gui - Marco Bernasocchi, 2011-04-19 06:31 AM

Download (2.47 KB)

View differences:

src/app/legend/qgslegend.cpp (working copy)
151 151
  emit currentLayerChanged( layer );
152 152
}
153 153

  
154
int QgsLegend::addGroupToCurrentItem( QString name, bool expand )
155
 {
156
	QgsDebugMsg( "calledsdsss." );
157
	QTreeWidgetItem *parent = currentItem();
158
	addGroup(name, expand, parent);
159
	
160
}
161

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

  
164
   if ( name.isEmpty() )
165
     name = tr( "group" ); // some default name if none specified
166
      
159 167
  QgsLegendGroup *parentGroup = dynamic_cast<QgsLegendGroup *>( parent );
168
  QgsLegendGroup *group;
160 169

  
161
  QgsLegendGroup *group;
162 170
  if ( parentGroup )
163 171
    group = new QgsLegendGroup( parentGroup, name );
164 172
  else
......
577 585
    }
578 586
  }
579 587

  
580
  theMenu.addAction( QgisApp::getThemeIcon( "/folder_new.png" ), tr( "&Add group" ), this, SLOT( addGroup() ) );
588
  theMenu.addAction( QgisApp::getThemeIcon( "/folder_new.png" ), tr( "&Add group" ), this, SLOT( addGroupToCurrentItem() ) );
581 589
  theMenu.addAction( QgisApp::getThemeIcon( "/mActionExpandTree.png" ), tr( "&Expand all" ), this, SLOT( expandAll() ) );
582 590
  theMenu.addAction( QgisApp::getThemeIcon( "/mActionCollapseTree.png" ), tr( "&Collapse all" ), this, SLOT( collapseAll() ) );
583 591

  
src/app/legend/qgslegend.h (working copy)
220 220

  
221 221
    /*!
222 222
     * Slot called when user wishes to add a new empty layer group to the legend.
223
     * If a the legend has a currentItem() then the new group will be nested into it 
223 224
     * The user will be prompted for the name of the newly added group.
224 225
     * @param name name of the new group
225 226
     * @param expand expand the group
226 227
     * @return void
227 228
     */
229
    int addGroupToCurrentItem( QString name = QString(), bool expand = true);  
230
 
231
    /*! 
232
     * Slot called when user wishes to add a new empty layer group to the legend. 
233
     * The user will be prompted for the name of the newly added group. 
234
     * @param name name of the new group 
235
     * @param expand expand the group 
236
     * @return void 
237
     */ 
228 238
    int addGroup( QString name = QString(), bool expand = true, QTreeWidgetItem* parent = 0 );
229 239

  
230 240
    /*!