Esempio n. 1
0
	void MediaModel::onTorrentRemoved(bt::TorrentInterface* tc)
	{
		int start = -1;
		int cnt = 0;
		for (QList<MediaFile::Ptr>::iterator i = items.begin();i != items.end();i++)
		{
			MediaFile::Ptr p = *i;
			if (p->torrent() == tc)
			{
				if (start == -1)
				{
					// start of the range
					start = i - items.begin();
					cnt = 1;
				}
				else
					cnt++; // Still in the middle of the media files of this torrent
			}
			else if (start != -1)
			{
				// We have found the end
				break;
			}
		}
		
		if (cnt > 0)
			removeRows(start,cnt,QModelIndex());
	}