1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-02-03 02:14:16 +00:00

Properly rename torrents, when index is moved out of current filter model or changes position inside filter model while rename window stays open

This commit is contained in:
Nick Tiskov 2013-06-30 23:29:48 +04:00
parent 3d9b4988d9
commit 0e09717a02

View File

@ -617,7 +617,8 @@ void TransferListWidget::renameSelectedTorrent() {
const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
if (selectedIndexes.size() != 1) return; if (selectedIndexes.size() != 1) return;
if (!selectedIndexes.first().isValid()) return; if (!selectedIndexes.first().isValid()) return;
const QString hash = getHashFromRow(mapToSource(selectedIndexes.first()).row()); QModelIndex mi = mapToSource(selectedIndexes.first());
const QString hash = getHashFromRow(mi.row());
const QTorrentHandle h = BTSession->getTorrentHandle(hash); const QTorrentHandle h = BTSession->getTorrentHandle(hash);
if (!h.is_valid()) return; if (!h.is_valid()) return;
// Ask for a new Name // Ask for a new Name
@ -625,7 +626,7 @@ void TransferListWidget::renameSelectedTorrent() {
const QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok); const QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok);
if (ok && !name.isEmpty()) { if (ok && !name.isEmpty()) {
// Rename the torrent // Rename the torrent
nameFilterModel->setData(selectedIndexes.first(), name, Qt::DisplayRole); listModel->setData(mi, name, Qt::DisplayRole);
} }
} }