Exemplo n.º 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();
	}
Exemplo n.º 2
0
		foreach (MediaFile::Ptr mf,items)
		{
			if (mf->path() == path)
				return MediaFileRef(mf);
		}