コード例 #1
0
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;
}
コード例 #2
0
/** 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;
  }
}
コード例 #3
0
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;
}