mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
Enable Combobox editor for the "Mixed" file download priority
Fixes #1544. PR #16522.
This commit is contained in:
parent
2652c73a4f
commit
2e08ae82b1
1 changed files with 13 additions and 4 deletions
|
@ -60,6 +60,9 @@ void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
|
|||
case BitTorrent::DownloadPriority::Maximum:
|
||||
combobox->setCurrentIndex(3);
|
||||
break;
|
||||
case BitTorrent::DownloadPriority::Mixed:
|
||||
combobox->setCurrentIndex(4);
|
||||
break;
|
||||
default:
|
||||
combobox->setCurrentIndex(1);
|
||||
break;
|
||||
|
@ -78,10 +81,6 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const int priority = index.data(TorrentContentModel::UnderlyingDataRole).toInt();
|
||||
if (static_cast<BitTorrent::DownloadPriority>(priority) == BitTorrent::DownloadPriority::Mixed)
|
||||
return nullptr;
|
||||
|
||||
auto *editor = new QComboBox(parent);
|
||||
editor->setFocusPolicy(Qt::StrongFocus);
|
||||
editor->addItem(tr("Do not download", "Do not download (priority)"));
|
||||
|
@ -89,6 +88,13 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
|||
editor->addItem(tr("High", "High (priority)"));
|
||||
editor->addItem(tr("Maximum", "Maximum (priority)"));
|
||||
|
||||
// add Mixed priority item to the new combobox only for those items with Mixed priority
|
||||
const auto priority = static_cast<BitTorrent::DownloadPriority>(index.data(TorrentContentModel::UnderlyingDataRole).toInt());
|
||||
if (priority == BitTorrent::DownloadPriority::Mixed)
|
||||
{
|
||||
editor->addItem(tr("Mixed", "Mixed (priorities)"));
|
||||
}
|
||||
|
||||
connect(editor, qOverload<int>(&QComboBox::currentIndexChanged), this, [this, editor]()
|
||||
{
|
||||
emit const_cast<PropListDelegate *>(this)->commitData(editor);
|
||||
|
@ -113,6 +119,9 @@ void PropListDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
|||
case 3:
|
||||
prio = BitTorrent::DownloadPriority::Maximum; // MAX
|
||||
break;
|
||||
case 4:
|
||||
prio = BitTorrent::DownloadPriority::Mixed; // MIXED
|
||||
break;
|
||||
}
|
||||
|
||||
const int newPriority = static_cast<int>(prio);
|
||||
|
|
Loading…
Reference in a new issue