From f21fbff1a8aa997c99f4000902cb58c2bed02bf4 Mon Sep 17 00:00:00 2001 From: Gabriele Date: Mon, 29 Jun 2015 01:57:50 +0300 Subject: [PATCH] Use enums instead of values when dealing with file priorities Manually backported commit 10880e10f16a421a5 from v3_2_x branch. --- src/gui/properties/proplistdelegate.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gui/properties/proplistdelegate.cpp b/src/gui/properties/proplistdelegate.cpp index 26f16c3c3..dbd18ecda 100644 --- a/src/gui/properties/proplistdelegate.cpp +++ b/src/gui/properties/proplistdelegate.cpp @@ -49,6 +49,7 @@ #include "core/utils/string.h" #include "propertieswidget.h" #include "proplistdelegate.h" +#include "torrentcontentmodelitem.h" PropListDelegate::PropListDelegate(PropertiesWidget *properties, QObject *parent) : QItemDelegate(parent) @@ -98,16 +99,16 @@ void PropListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti QItemDelegate::drawBackground(painter, opt, index); QString text = ""; switch (index.data().toInt()) { - case -1: + case prio::MIXED: text = tr("Mixed", "Mixed (priorities"); break; - case 0: + case prio::IGNORED: text = tr("Not downloaded"); break; - case 2: + case prio::HIGH: text = tr("High", "High (priority)"); break; - case 7: + case prio::MAXIMUM: text = tr("Maximum", "Maximum (priority)"); break; default: @@ -129,10 +130,10 @@ void PropListDelegate::setEditorData(QWidget *editor, const QModelIndex &index) QComboBox *combobox = static_cast(editor); // Set combobox index switch(index.data().toInt()) { - case 2: + case prio::HIGH: combobox->setCurrentIndex(1); break; - case 7: + case prio::MAXIMUM: combobox->setCurrentIndex(2); break; default: @@ -172,13 +173,13 @@ void PropListDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, switch(value) { case 1: - model->setData(index, 2); // HIGH + model->setData(index, prio::HIGH); // HIGH break; case 2: - model->setData(index, 7); // MAX + model->setData(index, prio::MAXIMUM); // MAX break; default: - model->setData(index, 1); // NORMAL + model->setData(index, prio::NORMAL); // NORMAL } emit filteredFilesChanged();