From 082dce0a66b6feda1122b49520af9b999ba817d6 Mon Sep 17 00:00:00 2001 From: Nick Tiskov Date: Sun, 30 Jun 2013 23:29:48 +0400 Subject: [PATCH] Properly rename torrents, when index is moved out of current filter model or changes position inside filter model while rename window stays open --- src/transferlistwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 4923670c2..a0303c1a4 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -606,7 +606,8 @@ void TransferListWidget::renameSelectedTorrent() { const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); if (selectedIndexes.size() != 1) 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); if (!h.is_valid()) return; // Ask for a new Name @@ -614,7 +615,7 @@ void TransferListWidget::renameSelectedTorrent() { const QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok); if (ok && !name.isEmpty()) { // Rename the torrent - nameFilterModel->setData(selectedIndexes.first(), name, Qt::DisplayRole); + listModel->setData(mi, name, Qt::DisplayRole); } }