QVariant SearchTreeModel::data(const QModelIndex& index, int role) const
{
	if(!index.isValid())
	{
		return QVariant();
	}

	SearchTreeItem* item = static_cast<SearchTreeItem*>(index.internalPointer());

	if(role == Qt::DecorationRole)
	{
		if(index.column() == 0)
		{
			return item->HitData.iNetwork;
		}

		if(index.column() == 8)
		{
			return item->HitData.iCountry;
		}
	}

	if(role == Qt::DisplayRole)
	{
		return item->data(index.column());
	}

	return QVariant();
}
示例#2
0
QVariant SearchTreeModel::data( const QModelIndex& index, int role ) const
{
	if ( !index.isValid() )
	{
		return QVariant();
	}

	SearchTreeItem* item = static_cast<SearchTreeItem*>( index.internalPointer() );

	if ( role == Qt::DecorationRole )
	{
		if ( index.column() == 0 ) // Index CAN be a negative value.
		{
			if ( item->parent() == m_pRootItem )
			{
				return m_pIconProvider->icon( item->data( 1 ).toString().prepend( "." ) );
			}
			else
			{
				return item->m_oHitData.iNetwork;
			}
		}

		if ( index.column() == 8 )
		{
			return item->m_oHitData.iCountry;
		}
	}

	if ( role == Qt::DisplayRole )
	{
		return item->data( index.column() );
	}

	return QVariant();
}