示例#1
0
	QVariant MediaModel::data(const QModelIndex & index, int role) const
	{
		if (index.column() != 0 || index.row() < 0 || index.row() >= items.count())
			return QVariant();
		
		MediaFile::Ptr mf = items.at(index.row());
		switch (role)
		{
			case Qt::ToolTipRole:
				{
					QString preview = mf->previewAvailable() ? i18n("Available") : i18n("Pending");
					return i18n("<b>%1</b><br/>Preview: %2<br/>Downloaded: %3 %",
							mf->name(),preview,mf->downloadPercentage());
				}
				break;
			case Qt::DisplayRole:
				return mf->name();
			case Qt::DecorationRole:
				return KIcon(KMimeType::findByPath(mf->path())->iconName());
			case Qt::UserRole: // user role is for finding out if a torrent is complete
				return mf->fullyAvailable();
			case Qt::UserRole + 1:
				return QFileInfo(mf->path()).lastModified().toTime_t();
			default:
				return QVariant();
		}
		
		return QVariant();
	}
示例#2
0
    bool MediaViewFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
    {
        if (show_incomplete)
            return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);

        MediaModel* model = (MediaModel*)sourceModel();
        MediaFileRef ref = model->fileForIndex(model->index(source_row));
        MediaFile::Ptr file = ref.mediaFile();
        if (file->fullyAvailable())
            return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
        else
            return false;
    }
示例#3
0
    void VideoChunkBar::setMediaFile(const kt::MediaFileRef& mf)
    {
        mfile = mf;
        MediaFile::Ptr file = mfile.mediaFile();
        if (file && !file->fullyAvailable())
        {
            bt::TorrentFileStream::Ptr stream = file->stream().toStrongRef();
            if (stream)
                connect(stream.data(), SIGNAL(readyRead()), this, SLOT(updateChunkBar()));

            updateBitSet();
            updateChunkBar();
        }
    }