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

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

    if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::DecorationRole)) {
        if (item->itemType() == TorrentContentModelItem::FolderType)
            return getDirectoryIcon();
        else
            return getFileIcon();
    }

    if ((index.column() == TorrentContentModelItem::COL_NAME) && (role == Qt::CheckStateRole)) {
        if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::IGNORED)
            return Qt::Unchecked;
        if (item->data(TorrentContentModelItem::COL_PRIO).toInt() == prio::MIXED)
            return Qt::PartiallyChecked;
        return Qt::Checked;
    }

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

    return QVariant();
}