Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/base/bittorrent/downloadpriority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ namespace BitTorrent
{
case DownloadPriority::Ignored:
case DownloadPriority::Normal:
case DownloadPriority::Normal2:
case DownloadPriority::Normal3:
case DownloadPriority::Normal4:
case DownloadPriority::Normal5:
case DownloadPriority::High:
case DownloadPriority::Maximum:
case DownloadPriority::Mixed:
Expand Down
4 changes: 4 additions & 0 deletions src/base/bittorrent/downloadpriority.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ namespace BitTorrent
{
Ignored = 0,
Normal = 1,
Normal2 = 2,
Normal3 = 3,
Normal4 = 4,
Normal5 = 5,
High = 6,
Maximum = 7,
Comment on lines 35 to 42
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the naming here, but not sure if we can change the defaults.
Probably makes more sense to shift default Normal level to 4 (as libtorrent implies internally) and then introduce low/normal/high levels.
That should not break backward compatibility in theory, files in old torrents will just appear as "low" priority, which is not a big deal.


Expand Down
50 changes: 42 additions & 8 deletions src/gui/torrentcontentitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,30 @@ void TorrentContentItemDelegate::setEditorData(QWidget *editor, const QModelInde
case BitTorrent::DownloadPriority::Ignored:
combobox->setCurrentIndex(0);
break;
case BitTorrent::DownloadPriority::High:
case BitTorrent::DownloadPriority::Normal:
combobox->setCurrentIndex(1);
break;
case BitTorrent::DownloadPriority::Normal2:
combobox->setCurrentIndex(2);
break;
case BitTorrent::DownloadPriority::Maximum:
case BitTorrent::DownloadPriority::Normal3:
combobox->setCurrentIndex(3);
break;
case BitTorrent::DownloadPriority::Mixed:
case BitTorrent::DownloadPriority::Normal4:
combobox->setCurrentIndex(4);
break;
case BitTorrent::DownloadPriority::Normal5:
combobox->setCurrentIndex(5);
break;
case BitTorrent::DownloadPriority::High:
combobox->setCurrentIndex(6);
break;
case BitTorrent::DownloadPriority::Maximum:
combobox->setCurrentIndex(7);
break;
case BitTorrent::DownloadPriority::Mixed:
combobox->setCurrentIndex(8);
break;
default:
combobox->setCurrentIndex(1);
break;
Expand All @@ -76,9 +91,13 @@ QWidget *TorrentContentItemDelegate::createEditor(QWidget *parent, const QStyleO
auto *editor = new QComboBox(parent);
editor->setFocusPolicy(Qt::StrongFocus);
editor->addItem(tr("Do not download", "Do not download (priority)"));
editor->addItem(tr("Normal", "Normal (priority)"));
editor->addItem(tr("High", "High (priority)"));
editor->addItem(tr("Maximum", "Maximum (priority)"));
editor->addItem(tr("Normal (1)", "Normal (1) (priority)"));
editor->addItem(tr("Normal (2)", "Normal (2) (priority)"));
editor->addItem(tr("Normal (3)", "Normal (3) (priority)"));
editor->addItem(tr("Normal (4)", "Normal (4) (priority)"));
editor->addItem(tr("Normal (5)", "Normal (5) (priority)"));
editor->addItem(tr("High (6)", "High (6) (priority)"));
editor->addItem(tr("Maximum (7)", "Maximum (7) (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());
Expand All @@ -105,13 +124,28 @@ void TorrentContentItemDelegate::setModelData(QWidget *editor, QAbstractItemMode
case 0:
prio = BitTorrent::DownloadPriority::Ignored; // IGNORED
break;
case 1:
prio = BitTorrent::DownloadPriority::Normal; // NORMAL (1)
break;
case 2:
prio = BitTorrent::DownloadPriority::High; // HIGH
prio = BitTorrent::DownloadPriority::Normal2; // NORMAL (2)
break;
case 3:
prio = BitTorrent::DownloadPriority::Maximum; // MAX
prio = BitTorrent::DownloadPriority::Normal3; // NORMAL (3)
break;
case 4:
prio = BitTorrent::DownloadPriority::Normal4; // NORMAL (4)
break;
case 5:
prio = BitTorrent::DownloadPriority::Normal5; // NORMAL (5)
break;
case 6:
prio = BitTorrent::DownloadPriority::High; // HIGH
break;
case 7:
prio = BitTorrent::DownloadPriority::Maximum; // MAX
break;
case 8:
prio = BitTorrent::DownloadPriority::Mixed; // MIXED
break;
}
Expand Down
17 changes: 13 additions & 4 deletions src/gui/torrentcontentmodelitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,22 @@ QString TorrentContentModelItem::displayData(const int column) const
return tr("Mixed", "Mixed (priorities");
case BitTorrent::DownloadPriority::Ignored:
return tr("Do not download", "Do not download (priority)");
case BitTorrent::DownloadPriority::Normal:
return tr("Normal (1)", "Normal (1) (priority)");
case BitTorrent::DownloadPriority::Normal2:
return tr("Normal (2)", "Normal (2) (priority)");
case BitTorrent::DownloadPriority::Normal3:
return tr("Normal (3)", "Normal (3) (priority)");
case BitTorrent::DownloadPriority::Normal4:
return tr("Normal (4)", "Normal (4) (priority)");
case BitTorrent::DownloadPriority::Normal5:
return tr("Normal (5)", "Normal (5) (priority)");
case BitTorrent::DownloadPriority::High:
return tr("High", "High (priority)");
return tr("High (6)", "High (6) (priority)");
case BitTorrent::DownloadPriority::Maximum:
return tr("Maximum", "Maximum (priority)");
default:
return tr("Normal", "Normal (priority)");
return tr("Maximum (7)", "Maximum (7) (priority)");
}
return u""_s;
case COL_PROGRESS:
return (m_progress >= 1)
? u"100%"_s
Expand Down
35 changes: 31 additions & 4 deletions src/gui/torrentcontentwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,19 @@ void TorrentContentWidget::applyPrioritiesByOrder()
case 1:
priority = BitTorrent::DownloadPriority::High;
break;
default:
case 2:
priority = BitTorrent::DownloadPriority::Normal5;
break;
case 3:
priority = BitTorrent::DownloadPriority::Normal4;
break;
case 4:
priority = BitTorrent::DownloadPriority::Normal3;
break;
case 5:
priority = BitTorrent::DownloadPriority::Normal2;
break;
default:
priority = BitTorrent::DownloadPriority::Normal;
break;
}
Expand Down Expand Up @@ -435,15 +446,31 @@ void TorrentContentWidget::displayContextMenu()
{
applyPriorities(BitTorrent::DownloadPriority::Ignored);
});
subMenu->addAction(tr("Normal"), this, [this]
subMenu->addAction(tr("Normal (1)"), this, [this]
{
applyPriorities(BitTorrent::DownloadPriority::Normal);
});
subMenu->addAction(tr("High"), this, [this]
subMenu->addAction(tr("Normal (2)"), this, [this]
{
applyPriorities(BitTorrent::DownloadPriority::Normal2);
});
subMenu->addAction(tr("Normal (3)"), this, [this]
{
applyPriorities(BitTorrent::DownloadPriority::Normal3);
});
subMenu->addAction(tr("Normal (4)"), this, [this]
{
applyPriorities(BitTorrent::DownloadPriority::Normal4);
});
subMenu->addAction(tr("Normal (5)"), this, [this]
{
applyPriorities(BitTorrent::DownloadPriority::Normal5);
});
subMenu->addAction(tr("High (6)"), this, [this]
{
applyPriorities(BitTorrent::DownloadPriority::High);
});
subMenu->addAction(tr("Maximum"), this, [this]
subMenu->addAction(tr("Maximum (7)"), this, [this]
{
applyPriorities(BitTorrent::DownloadPriority::Maximum);
});
Expand Down
Loading