Browse Source

Enable Combobox editor for the "Mixed" file download priority

Fixes #1544.
PR #16522.
adaptive-webui-19844
Aleksandr Cupacenko 3 years ago committed by GitHub
parent
commit
2e08ae82b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/gui/properties/proplistdelegate.cpp

17
src/gui/properties/proplistdelegate.cpp

@ -60,6 +60,9 @@ void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index) @@ -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 @@ -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 @@ -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, @@ -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…
Cancel
Save