Browse Source

Use enums instead of values when dealing with file priorities

Manually backported commit 10880e10f16a421a5 from v3_2_x branch.
adaptive-webui-19844
Gabriele 10 years ago committed by sledgehammer999
parent
commit
f21fbff1a8
  1. 19
      src/gui/properties/proplistdelegate.cpp

19
src/gui/properties/proplistdelegate.cpp

@ -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…
Cancel
Save