Skip to content
Permalink
Browse files
Fix addGroup to return the integer groupIndex other methods expect
This commit fixes #6591, although doesn't make the existing
interface any better than it is, and it is really bad :)
No plugin should need any adaption with the changes.
  • Loading branch information
Sandro Santilli committed Dec 14, 2012
1 parent 49102e2 commit 677095f7911cb0e2af91004cf37dfc988d75eded
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/app/legend/qgslegend.cpp
@@ -230,7 +230,18 @@ int QgsLegend::addGroup( QString name, bool expand, QTreeWidgetItem* parent )

emit itemAdded( groupIndex );

return groupIndex.row();
// TODO: use QModelIndex::iternalId for an identifier instead of this mess ?
int itemCount = 0;
for ( QTreeWidgetItem* theItem = firstItem(); theItem; theItem = nextItem( theItem ) )
{
QgsLegendItem* legendItem = dynamic_cast<QgsLegendItem *>( theItem );
if ( legendItem->type() == QgsLegendItem::LEGEND_GROUP )
{
if ( legendItem == group ) return itemCount;
else itemCount++;
}
}
return itemCount; // bogus return
}

int QgsLegend::addGroup( QString name, bool expand, int groupIndex )

0 comments on commit 677095f

Please sign in to comment.