bool QgsAppLegendInterface::groupExists( int groupIndex ) { QTreeWidgetItem * item = getItem (groupIndex); QgsLegendItem* legendItem = dynamic_cast<QgsLegendItem *>( item ); if ( !legendItem ) { return false; } return legendItem->type() == QgsLegendItem::LEGEND_GROUP; }
/** Overloads cmpare function of QListViewItem * @note The symbology group must always be the second in the list */ int QgsLegendSymbologyGroup::compare( QTreeWidgetItem * i, int col, bool ascending ) { Q_UNUSED( col ); Q_UNUSED( ascending ); QgsLegendItem * myItem = dynamic_cast<QgsLegendItem *>( i ) ; if ( myItem->type() == QgsLegendItem::LEGEND_PROPERTY_GROUP ) { return 1; } else { return -1; } }
QTreeWidgetItem *QgsAppLegendInterface::getItem(int itemIndex) { int itemCount = 0; for (QTreeWidgetItem* theItem = mLegend->firstItem(); theItem; theItem = mLegend->nextItem( theItem ) ) { QgsLegendItem* legendItem = dynamic_cast<QgsLegendItem *>( theItem ); if (legendItem->type() == QgsLegendItem::LEGEND_GROUP) { if (itemCount == itemIndex) { return theItem; } else { itemCount = itemCount + 1; } } } return NULL; }