Skip to content

Commit

Permalink
Fix addGroup to return the integer groupIndex other methods expect
Browse files Browse the repository at this point in the history
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 677095f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/app/legend/qgslegend.cpp
Expand Up @@ -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 )
Expand Down

0 comments on commit 677095f

Please sign in to comment.