diff --git a/src/gui/properties/proplistdelegate.cpp b/src/gui/properties/proplistdelegate.cpp index ef288ceb2..41e4adc8f 100644 --- a/src/gui/properties/proplistdelegate.cpp +++ b/src/gui/properties/proplistdelegate.cpp @@ -68,7 +68,8 @@ void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index) QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const { - if (index.column() != PRIORITY) return nullptr; + if (index.column() != PRIORITY) + return nullptr; if (m_properties) { @@ -87,16 +88,21 @@ QWidget *PropListDelegate::createEditor(QWidget *parent, const QStyleOptionViewI editor->addItem(tr("Normal", "Normal (priority)")); editor->addItem(tr("High", "High (priority)")); editor->addItem(tr("Maximum", "Maximum (priority)")); + + connect(editor, qOverload(&QComboBox::currentIndexChanged), this, [this, editor]() + { + emit const_cast(this)->commitData(editor); + }); + return editor; } void PropListDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { const auto *combobox = static_cast(editor); - const int value = combobox->currentIndex(); BitTorrent::DownloadPriority prio = BitTorrent::DownloadPriority::Normal; // NORMAL - switch (value) + switch (combobox->currentIndex()) { case 0: prio = BitTorrent::DownloadPriority::Ignored; // IGNORED @@ -109,8 +115,14 @@ void PropListDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, break; } - model->setData(index, static_cast(prio)); - emit filteredFilesChanged(); + const int newPriority = static_cast(prio); + const int previousPriority = index.data(TorrentContentModel::UnderlyingDataRole).toInt(); + + if (newPriority != previousPriority) + { + model->setData(index, newPriority); + emit filteredFilesChanged(); + } } void PropListDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const