mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Enable Combobox editor for the "Mixed" file download priority
Fixes #1544. PR #16522.
This commit is contained in:
parent
2652c73a4f
commit
2e08ae82b1
@ -60,6 +60,9 @@ void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
|
|||||||
case BitTorrent::DownloadPriority::Maximum:
|
case BitTorrent::DownloadPriority::Maximum:
|
||||||
combobox->setCurrentIndex(3);
|
combobox->setCurrentIndex(3);
|
||||||
break;
|
break;
|
||||||
|
case BitTorrent::DownloadPriority::Mixed:
|
||||||
|
combobox->setCurrentIndex(4);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
combobox->setCurrentIndex(1);
|
combobox->setCurrentIndex(1);
|
||||||
break;
|
break;
|
||||||
@ -78,10 +81,6 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
|||||||
return nullptr;
|
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);
|
auto *editor = new QComboBox(parent);
|
||||||
editor->setFocusPolicy(Qt::StrongFocus);
|
editor->setFocusPolicy(Qt::StrongFocus);
|
||||||
editor->addItem(tr("Do not download", "Do not download (priority)"));
|
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("High", "High (priority)"));
|
||||||
editor->addItem(tr("Maximum", "Maximum (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]()
|
connect(editor, qOverload<int>(&QComboBox::currentIndexChanged), this, [this, editor]()
|
||||||
{
|
{
|
||||||
emit const_cast<PropListDelegate *>(this)->commitData(editor);
|
emit const_cast<PropListDelegate *>(this)->commitData(editor);
|
||||||
@ -113,6 +119,9 @@ void PropListDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
|||||||
case 3:
|
case 3:
|
||||||
prio = BitTorrent::DownloadPriority::Maximum; // MAX
|
prio = BitTorrent::DownloadPriority::Maximum; // MAX
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
prio = BitTorrent::DownloadPriority::Mixed; // MIXED
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int newPriority = static_cast<int>(prio);
|
const int newPriority = static_cast<int>(prio);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user