mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
Merge pull request #727 from Gelmir/rename_on_index_changes
Properly rename torrent which changes position in filter model
This commit is contained in:
commit
a4085ef68c
@ -617,7 +617,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
|
||||
@ -625,7 +626,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user