mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Use enums instead of values when dealing with file priorities
Manually backported commit 10880e10f1
from v3_2_x branch.
This commit is contained in:
parent
c17a56cb8b
commit
f21fbff1a8
1 changed files with 10 additions and 9 deletions
|
@ -49,6 +49,7 @@
|
||||||
#include "core/utils/string.h"
|
#include "core/utils/string.h"
|
||||||
#include "propertieswidget.h"
|
#include "propertieswidget.h"
|
||||||
#include "proplistdelegate.h"
|
#include "proplistdelegate.h"
|
||||||
|
#include "torrentcontentmodelitem.h"
|
||||||
|
|
||||||
PropListDelegate::PropListDelegate(PropertiesWidget *properties, QObject *parent)
|
PropListDelegate::PropListDelegate(PropertiesWidget *properties, QObject *parent)
|
||||||
: QItemDelegate(parent)
|
: QItemDelegate(parent)
|
||||||
|
@ -98,16 +99,16 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
||||||
QItemDelegate::drawBackground(painter, opt, index);
|
QItemDelegate::drawBackground(painter, opt, index);
|
||||||
QString text = "";
|
QString text = "";
|
||||||
switch (index.data().toInt()) {
|
switch (index.data().toInt()) {
|
||||||
case -1:
|
case prio::MIXED:
|
||||||
text = tr("Mixed", "Mixed (priorities");
|
text = tr("Mixed", "Mixed (priorities");
|
||||||
break;
|
break;
|
||||||
case 0:
|
case prio::IGNORED:
|
||||||
text = tr("Not downloaded");
|
text = tr("Not downloaded");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case prio::HIGH:
|
||||||
text = tr("High", "High (priority)");
|
text = tr("High", "High (priority)");
|
||||||
break;
|
break;
|
||||||
case 7:
|
case prio::MAXIMUM:
|
||||||
text = tr("Maximum", "Maximum (priority)");
|
text = tr("Maximum", "Maximum (priority)");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -129,10 +130,10 @@ void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
|
||||||
QComboBox *combobox = static_cast<QComboBox*>(editor);
|
QComboBox *combobox = static_cast<QComboBox*>(editor);
|
||||||
// Set combobox index
|
// Set combobox index
|
||||||
switch(index.data().toInt()) {
|
switch(index.data().toInt()) {
|
||||||
case 2:
|
case prio::HIGH:
|
||||||
combobox->setCurrentIndex(1);
|
combobox->setCurrentIndex(1);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case prio::MAXIMUM:
|
||||||
combobox->setCurrentIndex(2);
|
combobox->setCurrentIndex(2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -172,13 +173,13 @@ void PropListDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
|
|
||||||
switch(value) {
|
switch(value) {
|
||||||
case 1:
|
case 1:
|
||||||
model->setData(index, 2); // HIGH
|
model->setData(index, prio::HIGH); // HIGH
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
model->setData(index, 7); // MAX
|
model->setData(index, prio::MAXIMUM); // MAX
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
model->setData(index, 1); // NORMAL
|
model->setData(index, prio::NORMAL); // NORMAL
|
||||||
}
|
}
|
||||||
|
|
||||||
emit filteredFilesChanged();
|
emit filteredFilesChanged();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue