void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) { const QString hash = index.model()->data(index.model()->index(index.row(), TorrentModelItem::TR_HASH)).toString();//mapToSource(index).row(); Transfer h = BTSession->getTransfer(hash); if (!h.is_valid()) return; int action; if (h.is_seed()) { action = Preferences().getActionOnDblClOnTorrentFn(); } else { action = Preferences().getActionOnDblClOnTorrentDl(); } switch(action) { case TOGGLE_PAUSE: if (h.is_paused()) { h.resume(); } else { h.pause(); } break; case OPEN_DEST: QString link = h.num_files() == 1 ? h.absolute_files_path().at(0) : h.save_path(); QDesktopServices::openUrl(QUrl::fromLocalFile(link)); break; } }
bool Session::playMedia(Transfer t, int fileIndex) { if (t.is_valid() && t.has_metadata() && misc::isPreviewable(misc::file_extension(t.filename_at(fileIndex)))) { TransferBitfield pieces = t.pieces(); const std::vector<int> extremity_pieces = t.file_extremity_pieces_at(fileIndex); // check we have all boundary pieces for the file foreach (int p, extremity_pieces) if (!pieces[p]) return false; t.set_sequential_download(true); return QDesktopServices::openUrl(QUrl::fromLocalFile(t.absolute_files_path().at(fileIndex))); }