mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
commit
0058abeefa
22 changed files with 711 additions and 543 deletions
|
@ -32,6 +32,6 @@
|
||||||
#define TORRENTFILTERENUM_H
|
#define TORRENTFILTERENUM_H
|
||||||
|
|
||||||
namespace TorrentFilter {
|
namespace TorrentFilter {
|
||||||
enum TorrentFilter {ALL, DOWNLOADING, COMPLETED, PAUSED, RESUMED, ACTIVE, INACTIVE};
|
enum TorrentFilter {ALL, DOWNLOADING, COMPLETED, RESUMED, PAUSED, ACTIVE, INACTIVE};
|
||||||
}
|
}
|
||||||
#endif // TORRENTFILTERENUM_H
|
#endif // TORRENTFILTERENUM_H
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
#include "autoexpandabledialog.h"
|
#include "autoexpandabledialog.h"
|
||||||
#include "torrentfilterenum.h"
|
#include "torrentfilterenum.h"
|
||||||
|
|
||||||
LabelFiltersList::LabelFiltersList(QWidget *parent): QListWidget(parent) {
|
LabelFiltersList::LabelFiltersList(QWidget *parent): QListWidget(parent)
|
||||||
|
{
|
||||||
itemHover = 0;
|
itemHover = 0;
|
||||||
// Accept drop
|
// Accept drop
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
@ -59,7 +60,8 @@ LabelFiltersList::LabelFiltersList(QWidget *parent): QListWidget(parent) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelFiltersList::addItem(QListWidgetItem *it) {
|
void LabelFiltersList::addItem(QListWidgetItem *it)
|
||||||
|
{
|
||||||
Q_ASSERT(count() >= 2);
|
Q_ASSERT(count() >= 2);
|
||||||
for (int i = 2; i<count(); ++i) {
|
for (int i = 2; i<count(); ++i) {
|
||||||
if (item(i)->text().localeAwareCompare(it->text()) >= 0) {
|
if (item(i)->text().localeAwareCompare(it->text()) >= 0) {
|
||||||
|
@ -70,7 +72,8 @@ void LabelFiltersList::addItem(QListWidgetItem *it) {
|
||||||
QListWidget::addItem(it);
|
QListWidget::addItem(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LabelFiltersList::labelFromRow(int row) const {
|
QString LabelFiltersList::labelFromRow(int row) const
|
||||||
|
{
|
||||||
Q_ASSERT(row > 1);
|
Q_ASSERT(row > 1);
|
||||||
const QString &label = item(row)->text();
|
const QString &label = item(row)->text();
|
||||||
QStringList parts = label.split(" ");
|
QStringList parts = label.split(" ");
|
||||||
|
@ -79,15 +82,16 @@ QString LabelFiltersList::labelFromRow(int row) const {
|
||||||
return parts.join(" ");
|
return parts.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
int LabelFiltersList::rowFromLabel(QString label) const {
|
int LabelFiltersList::rowFromLabel(QString label) const
|
||||||
|
{
|
||||||
Q_ASSERT(!label.isEmpty());
|
Q_ASSERT(!label.isEmpty());
|
||||||
for (int i=2; i<count(); ++i) {
|
for (int i = 2; i<count(); ++i)
|
||||||
if (label == labelFromRow(i)) return i;
|
if (label == labelFromRow(i)) return i;
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelFiltersList::dragMoveEvent(QDragMoveEvent *event) {
|
void LabelFiltersList::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
{
|
||||||
if (itemAt(event->pos()) && row(itemAt(event->pos())) > 0) {
|
if (itemAt(event->pos()) && row(itemAt(event->pos())) > 0) {
|
||||||
if (itemHover) {
|
if (itemHover) {
|
||||||
if (itemHover != itemAt(event->pos())) {
|
if (itemHover != itemAt(event->pos())) {
|
||||||
|
@ -95,50 +99,56 @@ void LabelFiltersList::dragMoveEvent(QDragMoveEvent *event) {
|
||||||
itemHover = itemAt(event->pos());
|
itemHover = itemAt(event->pos());
|
||||||
setItemHover(true);
|
setItemHover(true);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
itemHover = itemAt(event->pos());
|
itemHover = itemAt(event->pos());
|
||||||
setItemHover(true);
|
setItemHover(true);
|
||||||
}
|
}
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if (itemHover)
|
if (itemHover)
|
||||||
setItemHover(false);
|
setItemHover(false);
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelFiltersList::dropEvent(QDropEvent *event) {
|
void LabelFiltersList::dropEvent(QDropEvent *event)
|
||||||
|
{
|
||||||
qDebug("Drop Event in labels list");
|
qDebug("Drop Event in labels list");
|
||||||
if (itemAt(event->pos())) {
|
if (itemAt(event->pos()))
|
||||||
emit torrentDropped(row(itemAt(event->pos())));
|
emit torrentDropped(row(itemAt(event->pos())));
|
||||||
}
|
|
||||||
event->ignore();
|
event->ignore();
|
||||||
setItemHover(false);
|
setItemHover(false);
|
||||||
// Select current item again
|
// Select current item again
|
||||||
currentItem()->setSelected(true);
|
currentItem()->setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelFiltersList::dragLeaveEvent(QDragLeaveEvent*) {
|
void LabelFiltersList::dragLeaveEvent(QDragLeaveEvent*)
|
||||||
|
{
|
||||||
if (itemHover)
|
if (itemHover)
|
||||||
setItemHover(false);
|
setItemHover(false);
|
||||||
// Select current item again
|
// Select current item again
|
||||||
currentItem()->setSelected(true);
|
currentItem()->setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelFiltersList::setItemHover(bool hover) {
|
void LabelFiltersList::setItemHover(bool hover)
|
||||||
|
{
|
||||||
Q_ASSERT(itemHover);
|
Q_ASSERT(itemHover);
|
||||||
if (hover) {
|
if (hover) {
|
||||||
itemHover->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("folder-documents.png"));
|
itemHover->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("folder-documents.png"));
|
||||||
itemHover->setSelected(true);
|
itemHover->setSelected(true);
|
||||||
//setCurrentItem(itemHover);
|
//setCurrentItem(itemHover);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
itemHover->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory.png"));
|
itemHover->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory.png"));
|
||||||
//itemHover->setSelected(false);
|
//itemHover->setSelected(false);
|
||||||
itemHover = 0;
|
itemHover = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusFiltersWidget::StatusFiltersWidget(QWidget *parent) : QListWidget(parent), m_shown(false) {
|
StatusFiltersWidget::StatusFiltersWidget(QWidget *parent): QListWidget(parent), m_shown(false)
|
||||||
|
{
|
||||||
setUniformItemSizes(true);
|
setUniformItemSizes(true);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
// Height is fixed (sizeHint().height() is used)
|
// Height is fixed (sizeHint().height() is used)
|
||||||
|
@ -149,14 +159,16 @@ StatusFiltersWidget::StatusFiltersWidget(QWidget *parent) : QListWidget(parent),
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize StatusFiltersWidget::sizeHint() const {
|
QSize StatusFiltersWidget::sizeHint() const
|
||||||
|
{
|
||||||
QSize size = QListWidget::sizeHint();
|
QSize size = QListWidget::sizeHint();
|
||||||
// Height should be exactly the height of the content
|
// Height should be exactly the height of the content
|
||||||
size.setHeight(contentsSize().height() + 2 * frameWidth() + 6);
|
size.setHeight(contentsSize().height() + 2 * frameWidth() + 6);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList): QFrame(parent), transferList(transferList), nb_labeled(0), nb_torrents(0) {
|
TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferListWidget *transferList): QFrame(parent), transferList(transferList), nb_labeled(0), nb_torrents(0)
|
||||||
|
{
|
||||||
// Construct lists
|
// Construct lists
|
||||||
vLayout = new QVBoxLayout();
|
vLayout = new QVBoxLayout();
|
||||||
vLayout->setContentsMargins(0, 4, 0, 0);
|
vLayout->setContentsMargins(0, 4, 0, 0);
|
||||||
|
@ -184,25 +196,25 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
|
||||||
// Add status filters
|
// Add status filters
|
||||||
QListWidgetItem *all = new QListWidgetItem(statusFilters);
|
QListWidgetItem *all = new QListWidgetItem(statusFilters);
|
||||||
all->setData(Qt::DisplayRole, QVariant(tr("All") + " (0)"));
|
all->setData(Qt::DisplayRole, QVariant(tr("All") + " (0)"));
|
||||||
all->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterall.png"));
|
all->setData(Qt::DecorationRole, QIcon(":/Icons/skin/filterall.png"));
|
||||||
QListWidgetItem *downloading = new QListWidgetItem(statusFilters);
|
QListWidgetItem *downloading = new QListWidgetItem(statusFilters);
|
||||||
downloading->setData(Qt::DisplayRole, QVariant(tr("Downloading") + " (0)"));
|
downloading->setData(Qt::DisplayRole, QVariant(tr("Downloading") + " (0)"));
|
||||||
downloading->setData(Qt::DecorationRole, QIcon(":/icons/skin/downloading.png"));
|
downloading->setData(Qt::DecorationRole, QIcon(":/Icons/skin/downloading.png"));
|
||||||
QListWidgetItem *completed = new QListWidgetItem(statusFilters);
|
QListWidgetItem *completed = new QListWidgetItem(statusFilters);
|
||||||
completed->setData(Qt::DisplayRole, QVariant(tr("Completed") + " (0)"));
|
completed->setData(Qt::DisplayRole, QVariant(tr("Completed") + " (0)"));
|
||||||
completed->setData(Qt::DecorationRole, QIcon(":/icons/skin/uploading.png"));
|
completed->setData(Qt::DecorationRole, QIcon(":/Icons/skin/uploading.png"));
|
||||||
QListWidgetItem *paused = new QListWidgetItem(statusFilters);
|
|
||||||
paused->setData(Qt::DisplayRole, QVariant(tr("Paused") + " (0)"));
|
|
||||||
paused->setData(Qt::DecorationRole, QIcon(":/icons/skin/paused.png"));
|
|
||||||
QListWidgetItem *resumed = new QListWidgetItem(statusFilters);
|
QListWidgetItem *resumed = new QListWidgetItem(statusFilters);
|
||||||
resumed->setData(Qt::DisplayRole, QVariant(tr("Resumed") + " (0)"));
|
resumed->setData(Qt::DisplayRole, QVariant(tr("Resumed") + " (0)"));
|
||||||
resumed->setData(Qt::DecorationRole, QIcon(":/icons/skin/resumed.png"));
|
resumed->setData(Qt::DecorationRole, QIcon(":/Icons/skin/resumed.png"));
|
||||||
|
QListWidgetItem *paused = new QListWidgetItem(statusFilters);
|
||||||
|
paused->setData(Qt::DisplayRole, QVariant(tr("Paused") + " (0)"));
|
||||||
|
paused->setData(Qt::DecorationRole, QIcon(":/Icons/skin/paused.png"));
|
||||||
QListWidgetItem *active = new QListWidgetItem(statusFilters);
|
QListWidgetItem *active = new QListWidgetItem(statusFilters);
|
||||||
active->setData(Qt::DisplayRole, QVariant(tr("Active") + " (0)"));
|
active->setData(Qt::DisplayRole, QVariant(tr("Active") + " (0)"));
|
||||||
active->setData(Qt::DecorationRole, QIcon(":/icons/skin/filteractive.png"));
|
active->setData(Qt::DecorationRole, QIcon(":/Icons/skin/filteractive.png"));
|
||||||
QListWidgetItem *inactive = new QListWidgetItem(statusFilters);
|
QListWidgetItem *inactive = new QListWidgetItem(statusFilters);
|
||||||
inactive->setData(Qt::DisplayRole, QVariant(tr("Inactive") + " (0)"));
|
inactive->setData(Qt::DisplayRole, QVariant(tr("Inactive") + " (0)"));
|
||||||
inactive->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterinactive.png"));
|
inactive->setData(Qt::DecorationRole, QIcon(":/Icons/skin/filterinactive.png"));
|
||||||
|
|
||||||
// SIGNAL/SLOT
|
// SIGNAL/SLOT
|
||||||
connect(statusFilters, SIGNAL(currentRowChanged(int)), transferList, SLOT(applyStatusFilter(int)));
|
connect(statusFilters, SIGNAL(currentRowChanged(int)), transferList, SLOT(applyStatusFilter(int)));
|
||||||
|
@ -232,24 +244,28 @@ TransferListFiltersWidget::TransferListFiltersWidget(QWidget *parent, TransferLi
|
||||||
connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint)));
|
connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TransferListFiltersWidget::~TransferListFiltersWidget() {
|
TransferListFiltersWidget::~TransferListFiltersWidget()
|
||||||
|
{
|
||||||
saveSettings();
|
saveSettings();
|
||||||
delete statusFilters;
|
delete statusFilters;
|
||||||
delete labelFilters;
|
delete labelFilters;
|
||||||
delete vLayout;
|
delete vLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusFiltersWidget* TransferListFiltersWidget::getStatusFilters() const {
|
StatusFiltersWidget* TransferListFiltersWidget::getStatusFilters() const
|
||||||
|
{
|
||||||
return statusFilters;
|
return statusFilters;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::saveSettings() const {
|
void TransferListFiltersWidget::saveSettings() const
|
||||||
|
{
|
||||||
Preferences* const pref = Preferences::instance();
|
Preferences* const pref = Preferences::instance();
|
||||||
pref->setTransSelFilter(statusFilters->currentRow());
|
pref->setTransSelFilter(statusFilters->currentRow());
|
||||||
pref->setTorrentLabels(customLabels.keys());
|
pref->setTorrentLabels(customLabels.keys());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::loadSettings() {
|
void TransferListFiltersWidget::loadSettings()
|
||||||
|
{
|
||||||
statusFilters->setCurrentRow(Preferences::instance()->getTransSelFilter());
|
statusFilters->setCurrentRow(Preferences::instance()->getTransSelFilter());
|
||||||
const QStringList label_list = Preferences::instance()->getTorrentLabels();
|
const QStringList label_list = Preferences::instance()->getTorrentLabels();
|
||||||
foreach (const QString &label, label_list) {
|
foreach (const QString &label, label_list) {
|
||||||
|
@ -262,7 +278,8 @@ void TransferListFiltersWidget::loadSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::updateTorrentNumbers() {
|
void TransferListFiltersWidget::updateTorrentNumbers()
|
||||||
|
{
|
||||||
const TorrentStatusReport report = transferList->getSourceModel()->getTorrentStatusReport();
|
const TorrentStatusReport report = transferList->getSourceModel()->getTorrentStatusReport();
|
||||||
statusFilters->item(TorrentFilter::ALL)->setData(Qt::DisplayRole, QVariant(tr("All") + " (" + QString::number(report.nb_active + report.nb_inactive) + ")"));
|
statusFilters->item(TorrentFilter::ALL)->setData(Qt::DisplayRole, QVariant(tr("All") + " (" + QString::number(report.nb_active + report.nb_inactive) + ")"));
|
||||||
statusFilters->item(TorrentFilter::DOWNLOADING)->setData(Qt::DisplayRole, QVariant(tr("Downloading") + " (" + QString::number(report.nb_downloading) + ")"));
|
statusFilters->item(TorrentFilter::DOWNLOADING)->setData(Qt::DisplayRole, QVariant(tr("Downloading") + " (" + QString::number(report.nb_downloading) + ")"));
|
||||||
|
@ -273,16 +290,17 @@ void TransferListFiltersWidget::updateTorrentNumbers() {
|
||||||
statusFilters->item(TorrentFilter::INACTIVE)->setData(Qt::DisplayRole, QVariant(tr("Inactive") + " (" + QString::number(report.nb_inactive) + ")"));
|
statusFilters->item(TorrentFilter::INACTIVE)->setData(Qt::DisplayRole, QVariant(tr("Inactive") + " (" + QString::number(report.nb_inactive) + ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::torrentDropped(int row) {
|
void TransferListFiltersWidget::torrentDropped(int row)
|
||||||
|
{
|
||||||
Q_ASSERT(row > 0);
|
Q_ASSERT(row > 0);
|
||||||
if (row == 1) {
|
if (row == 1)
|
||||||
transferList->setSelectionLabel("");
|
transferList->setSelectionLabel("");
|
||||||
} else {
|
else
|
||||||
transferList->setSelectionLabel(labelFilters->labelFromRow(row));
|
transferList->setSelectionLabel(labelFilters->labelFromRow(row));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void TransferListFiltersWidget::addLabel(QString& label) {
|
void TransferListFiltersWidget::addLabel(QString& label)
|
||||||
|
{
|
||||||
label = fsutils::toValidFileSystemName(label.trimmed());
|
label = fsutils::toValidFileSystemName(label.trimmed());
|
||||||
if (label.isEmpty() || customLabels.contains(label)) return;
|
if (label.isEmpty() || customLabels.contains(label)) return;
|
||||||
QListWidgetItem *newLabel = new QListWidgetItem();
|
QListWidgetItem *newLabel = new QListWidgetItem();
|
||||||
|
@ -293,7 +311,8 @@ void TransferListFiltersWidget::addLabel(QString& label) {
|
||||||
Preferences::instance()->addTorrentLabel(label);
|
Preferences::instance()->addTorrentLabel(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::showLabelMenu(QPoint) {
|
void TransferListFiltersWidget::showLabelMenu(QPoint)
|
||||||
|
{
|
||||||
QMenu labelMenu(labelFilters);
|
QMenu labelMenu(labelFilters);
|
||||||
QAction *addAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add label..."));
|
QAction *addAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add label..."));
|
||||||
QAction *removeAct = 0;
|
QAction *removeAct = 0;
|
||||||
|
@ -339,7 +358,8 @@ void TransferListFiltersWidget::showLabelMenu(QPoint) {
|
||||||
if (ok && !label.isEmpty()) {
|
if (ok && !label.isEmpty()) {
|
||||||
if (fsutils::isValidFileSystemName(label)) {
|
if (fsutils::isValidFileSystemName(label)) {
|
||||||
addLabel(label);
|
addLabel(label);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
QMessageBox::warning(this, tr("Invalid label name"), tr("Please don't use any special characters in the label name."));
|
QMessageBox::warning(this, tr("Invalid label name"), tr("Please don't use any special characters in the label name."));
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +370,8 @@ void TransferListFiltersWidget::showLabelMenu(QPoint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::removeSelectedLabel() {
|
void TransferListFiltersWidget::removeSelectedLabel()
|
||||||
|
{
|
||||||
const int row = labelFilters->row(labelFilters->selectedItems().first());
|
const int row = labelFilters->row(labelFilters->selectedItems().first());
|
||||||
Q_ASSERT(row > 1);
|
Q_ASSERT(row > 1);
|
||||||
const QString &label = labelFilters->labelFromRow(row);
|
const QString &label = labelFilters->labelFromRow(row);
|
||||||
|
@ -367,13 +388,13 @@ void TransferListFiltersWidget::removeSelectedLabel() {
|
||||||
Preferences::instance()->removeTorrentLabel(label);
|
Preferences::instance()->removeTorrentLabel(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::removeUnusedLabels() {
|
void TransferListFiltersWidget::removeUnusedLabels()
|
||||||
|
{
|
||||||
QStringList unusedLabels;
|
QStringList unusedLabels;
|
||||||
QHash<QString, int>::const_iterator i;
|
QHash<QString, int>::const_iterator i;
|
||||||
for (i = customLabels.begin(); i != customLabels.end(); ++i) {
|
for (i = customLabels.begin(); i != customLabels.end(); ++i)
|
||||||
if (i.value() == 0)
|
if (i.value() == 0)
|
||||||
unusedLabels << i.key();
|
unusedLabels << i.key();
|
||||||
}
|
|
||||||
foreach (const QString &label, unusedLabels) {
|
foreach (const QString &label, unusedLabels) {
|
||||||
customLabels.remove(label);
|
customLabels.remove(label);
|
||||||
delete labelFilters->takeItem(labelFilters->rowFromLabel(label));
|
delete labelFilters->takeItem(labelFilters->rowFromLabel(label));
|
||||||
|
@ -381,7 +402,8 @@ void TransferListFiltersWidget::removeUnusedLabels() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::applyLabelFilter(int row) {
|
void TransferListFiltersWidget::applyLabelFilter(int row)
|
||||||
|
{
|
||||||
switch (row) {
|
switch (row) {
|
||||||
case 0:
|
case 0:
|
||||||
transferList->applyLabelFilterAll();
|
transferList->applyLabelFilterAll();
|
||||||
|
@ -394,7 +416,8 @@ void TransferListFiltersWidget::applyLabelFilter(int row) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::torrentChangedLabel(TorrentModelItem *torrentItem, QString old_label, QString new_label) {
|
void TransferListFiltersWidget::torrentChangedLabel(TorrentModelItem *torrentItem, QString old_label, QString new_label)
|
||||||
|
{
|
||||||
Q_UNUSED(torrentItem);
|
Q_UNUSED(torrentItem);
|
||||||
qDebug("Torrent label changed from %s to %s", qPrintable(old_label), qPrintable(new_label));
|
qDebug("Torrent label changed from %s to %s", qPrintable(old_label), qPrintable(new_label));
|
||||||
if (!old_label.isEmpty()) {
|
if (!old_label.isEmpty()) {
|
||||||
|
@ -422,7 +445,8 @@ void TransferListFiltersWidget::torrentChangedLabel(TorrentModelItem *torrentIte
|
||||||
updateStickyLabelCounters();
|
updateStickyLabelCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::handleNewTorrent(TorrentModelItem* torrentItem) {
|
void TransferListFiltersWidget::handleNewTorrent(TorrentModelItem* torrentItem)
|
||||||
|
{
|
||||||
QString label = torrentItem->data(TorrentModelItem::TR_LABEL).toString();
|
QString label = torrentItem->data(TorrentModelItem::TR_LABEL).toString();
|
||||||
qDebug("New torrent was added with label: %s", qPrintable(label));
|
qDebug("New torrent was added with label: %s", qPrintable(label));
|
||||||
if (!label.isEmpty()) {
|
if (!label.isEmpty()) {
|
||||||
|
@ -449,7 +473,8 @@ void TransferListFiltersWidget::handleNewTorrent(TorrentModelItem* torrentItem)
|
||||||
updateStickyLabelCounters();
|
updateStickyLabelCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::torrentAboutToBeDeleted(TorrentModelItem* torrentItem) {
|
void TransferListFiltersWidget::torrentAboutToBeDeleted(TorrentModelItem* torrentItem)
|
||||||
|
{
|
||||||
Q_ASSERT(torrentItem);
|
Q_ASSERT(torrentItem);
|
||||||
QString label = torrentItem->data(TorrentModelItem::TR_LABEL).toString();
|
QString label = torrentItem->data(TorrentModelItem::TR_LABEL).toString();
|
||||||
if (!label.isEmpty()) {
|
if (!label.isEmpty()) {
|
||||||
|
@ -469,7 +494,8 @@ void TransferListFiltersWidget::torrentAboutToBeDeleted(TorrentModelItem* torren
|
||||||
updateStickyLabelCounters();
|
updateStickyLabelCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::updateStickyLabelCounters() {
|
void TransferListFiltersWidget::updateStickyLabelCounters()
|
||||||
|
{
|
||||||
labelFilters->item(0)->setText(tr("All labels") + " (" + QString::number(nb_torrents) + ")");
|
labelFilters->item(0)->setText(tr("All labels") + " (" + QString::number(nb_torrents) + ")");
|
||||||
labelFilters->item(1)->setText(tr("Unlabeled") + " (" + QString::number(nb_torrents - nb_labeled) + ")");
|
labelFilters->item(1)->setText(tr("Unlabeled") + " (" + QString::number(nb_torrents - nb_labeled) + ")");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,8 @@ QT_END_NAMESPACE
|
||||||
class TransferListWidget;
|
class TransferListWidget;
|
||||||
class TorrentModelItem;
|
class TorrentModelItem;
|
||||||
|
|
||||||
class LabelFiltersList: public QListWidget {
|
class LabelFiltersList: public QListWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -68,7 +69,8 @@ protected:
|
||||||
void setItemHover(bool hover);
|
void setItemHover(bool hover);
|
||||||
};
|
};
|
||||||
|
|
||||||
class StatusFiltersWidget : public QListWidget {
|
class StatusFiltersWidget: public QListWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -81,7 +83,8 @@ private:
|
||||||
bool m_shown;
|
bool m_shown;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TransferListFiltersWidget: public QFrame {
|
class TransferListFiltersWidget: public QFrame
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -102,6 +102,7 @@ static const char KEY_TORRENT_STATE[] = "state";
|
||||||
static const char KEY_TORRENT_SEQUENTIAL_DOWNLOAD[] = "seq_dl";
|
static const char KEY_TORRENT_SEQUENTIAL_DOWNLOAD[] = "seq_dl";
|
||||||
static const char KEY_TORRENT_FIRST_LAST_PIECE_PRIO[] = "f_l_piece_prio";
|
static const char KEY_TORRENT_FIRST_LAST_PIECE_PRIO[] = "f_l_piece_prio";
|
||||||
static const char KEY_TORRENT_LABEL[] = "label";
|
static const char KEY_TORRENT_LABEL[] = "label";
|
||||||
|
static const char KEY_TORRENT_SUPER_SEEDING[] = "super_seeding";
|
||||||
|
|
||||||
// Tracker keys
|
// Tracker keys
|
||||||
static const char KEY_TRACKER_URL[] = "url";
|
static const char KEY_TRACKER_URL[] = "url";
|
||||||
|
@ -144,6 +145,11 @@ static const char KEY_TRANSFER_UPRATELIMIT[] = "up_rate_limit";
|
||||||
static const char KEY_TRANSFER_DHT_NODES[] = "dht_nodes";
|
static const char KEY_TRANSFER_DHT_NODES[] = "dht_nodes";
|
||||||
static const char KEY_TRANSFER_CONNECTION_STATUS[] = "connection_status";
|
static const char KEY_TRANSFER_CONNECTION_STATUS[] = "connection_status";
|
||||||
|
|
||||||
|
// Sync main data keys
|
||||||
|
static const char KEY_SYNC_MAINDATA_QUEUEING[] = "queueing";
|
||||||
|
static const char KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS[] = "use_alt_speed_limits";
|
||||||
|
static const char KEY_SYNC_MAINDATA_REFRESH_INTERVAL[] = "refresh_interval";
|
||||||
|
|
||||||
static const char KEY_FULL_UPDATE[] = "full_update";
|
static const char KEY_FULL_UPDATE[] = "full_update";
|
||||||
static const char KEY_RESPONSE_ID[] = "rid";
|
static const char KEY_RESPONSE_ID[] = "rid";
|
||||||
static const char KEY_SUFFIX_REMOVED[] = "_removed";
|
static const char KEY_SUFFIX_REMOVED[] = "_removed";
|
||||||
|
@ -151,7 +157,7 @@ static const char KEY_SUFFIX_REMOVED[] = "_removed";
|
||||||
QVariantMap getTranserInfoMap();
|
QVariantMap getTranserInfoMap();
|
||||||
QVariantMap toMap(const QTorrentHandle& h);
|
QVariantMap toMap(const QTorrentHandle& h);
|
||||||
void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData);
|
void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData);
|
||||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncData, QVariantList &removedItems);
|
void processHash(QVariantHash prevData, QVariantHash data, QVariantMap &syncData, QVariantList &removedItems);
|
||||||
void processList(QVariantList prevData, QVariantList data, QVariantList &syncData, QVariantList &removedItems);
|
void processList(QVariantList prevData, QVariantList data, QVariantList &syncData, QVariantList &removedItems);
|
||||||
QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantMap &lastAcceptedData, QVariantMap &lastData);
|
QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantMap &lastAcceptedData, QVariantMap &lastData);
|
||||||
|
|
||||||
|
@ -274,8 +280,7 @@ QByteArray btjson::getTorrents(QString filter, QString label,
|
||||||
* - "torrents_removed": a list of hashes of removed torrents
|
* - "torrents_removed": a list of hashes of removed torrents
|
||||||
* - "labels": list of labels
|
* - "labels": list of labels
|
||||||
* - "labels_removed": list of removed labels
|
* - "labels_removed": list of removed labels
|
||||||
* - "queueing": priority system usage flag
|
* - "server_state": map contains information about the state of the server
|
||||||
* - "server_state": map contains information about the status of the server
|
|
||||||
* The keys of the 'torrents' dictionary are hashes of torrents.
|
* The keys of the 'torrents' dictionary are hashes of torrents.
|
||||||
* Each value of the 'torrents' dictionary contains map. The map can contain following keys:
|
* Each value of the 'torrents' dictionary contains map. The map can contain following keys:
|
||||||
* - "name": Torrent name
|
* - "name": Torrent name
|
||||||
|
@ -302,6 +307,8 @@ QByteArray btjson::getTorrents(QString filter, QString label,
|
||||||
* - "up_info_data: bytes uploaded
|
* - "up_info_data: bytes uploaded
|
||||||
* - "up_info_speed: upload speed
|
* - "up_info_speed: upload speed
|
||||||
* - "up_rate_limit: upload speed limit
|
* - "up_rate_limit: upload speed limit
|
||||||
|
* - "queueing": priority system usage flag
|
||||||
|
* - "refresh_interval": torrents table refresh interval
|
||||||
*/
|
*/
|
||||||
QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData, QVariantMap &lastAcceptedData)
|
QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData, QVariantMap &lastAcceptedData)
|
||||||
{
|
{
|
||||||
|
@ -321,14 +328,18 @@ QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData
|
||||||
}
|
}
|
||||||
|
|
||||||
data["torrents"] = torrents;
|
data["torrents"] = torrents;
|
||||||
data["queueing"] = QBtSession::instance()->isQueueingEnabled();
|
|
||||||
|
|
||||||
QVariantList labels;
|
QVariantList labels;
|
||||||
foreach (QString s, Preferences::instance()->getTorrentLabels())
|
foreach (QString s, Preferences::instance()->getTorrentLabels())
|
||||||
labels << s;
|
labels << s;
|
||||||
|
|
||||||
data["labels"] = labels;
|
data["labels"] = labels;
|
||||||
data["server_state"] = getTranserInfoMap();
|
|
||||||
|
QVariantMap serverState = getTranserInfoMap();
|
||||||
|
serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled();
|
||||||
|
serverState[KEY_SYNC_MAINDATA_USE_ALT_SPEED_LIMITS] = Preferences::instance()->isAltBandwidthEnabled();
|
||||||
|
serverState[KEY_SYNC_MAINDATA_REFRESH_INTERVAL] = Preferences::instance()->getRefreshInterval();
|
||||||
|
data["server_state"] = serverState;
|
||||||
|
|
||||||
return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData));
|
return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData));
|
||||||
}
|
}
|
||||||
|
@ -528,6 +539,21 @@ QVariantMap getTranserInfoMap()
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray btjson::getTorrentsRatesLimits(QStringList &hashes, bool downloadLimits)
|
||||||
|
{
|
||||||
|
QVariantMap map;
|
||||||
|
|
||||||
|
foreach (const QString &hash, hashes) {
|
||||||
|
int limit = -1;
|
||||||
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
||||||
|
if (h.is_valid())
|
||||||
|
limit = downloadLimits ? h.download_limit() : h.upload_limit();
|
||||||
|
map[hash] = limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
return json::toJson(map);
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap toMap(const QTorrentHandle& h)
|
QVariantMap toMap(const QTorrentHandle& h)
|
||||||
{
|
{
|
||||||
libtorrent::torrent_status status = h.status(torrent_handle::query_accurate_download_counters);
|
libtorrent::torrent_status status = h.status(torrent_handle::query_accurate_download_counters);
|
||||||
|
@ -555,6 +581,7 @@ QVariantMap toMap(const QTorrentHandle& h)
|
||||||
if (h.has_metadata())
|
if (h.has_metadata())
|
||||||
ret[KEY_TORRENT_FIRST_LAST_PIECE_PRIO] = h.first_last_piece_first();
|
ret[KEY_TORRENT_FIRST_LAST_PIECE_PRIO] = h.first_last_piece_first();
|
||||||
ret[KEY_TORRENT_LABEL] = TorrentPersistentData::instance()->getLabel(h.hash());
|
ret[KEY_TORRENT_LABEL] = TorrentPersistentData::instance()->getLabel(h.hash());
|
||||||
|
ret[KEY_TORRENT_SUPER_SEEDING] = status.super_seeding;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -579,10 +606,10 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QVariant::Hash: {
|
case QVariant::Hash: {
|
||||||
QVariantHash hash;
|
QVariantMap map;
|
||||||
processHash(prevData[key].toHash(), data[key].toHash(), hash, removedItems);
|
processHash(prevData[key].toHash(), data[key].toHash(), map, removedItems);
|
||||||
if (!hash.isEmpty())
|
if (!map.isEmpty())
|
||||||
syncData[key] = hash;
|
syncData[key] = map;
|
||||||
if (!removedItems.isEmpty())
|
if (!removedItems.isEmpty())
|
||||||
syncData[key + KEY_SUFFIX_REMOVED] = removedItems;
|
syncData[key + KEY_SUFFIX_REMOVED] = removedItems;
|
||||||
}
|
}
|
||||||
|
@ -603,6 +630,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
|
||||||
case QVariant::Bool:
|
case QVariant::Bool:
|
||||||
case QVariant::Double:
|
case QVariant::Double:
|
||||||
case QVariant::ULongLong:
|
case QVariant::ULongLong:
|
||||||
|
case QVariant::UInt:
|
||||||
if (prevData[key] != data[key])
|
if (prevData[key] != data[key])
|
||||||
syncData[key] = data[key];
|
syncData[key] = data[key];
|
||||||
break;
|
break;
|
||||||
|
@ -615,7 +643,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
|
||||||
// Compare two lists of structures (prevData, data) and calculate difference (syncData, removedItems).
|
// Compare two lists of structures (prevData, data) and calculate difference (syncData, removedItems).
|
||||||
// Structures encoded as map.
|
// Structures encoded as map.
|
||||||
// Lists are encoded as hash table (indexed by structure key value) to improve ease of searching for removed items.
|
// Lists are encoded as hash table (indexed by structure key value) to improve ease of searching for removed items.
|
||||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncData, QVariantList &removedItems)
|
void processHash(QVariantHash prevData, QVariantHash data, QVariantMap &syncData, QVariantList &removedItems)
|
||||||
{
|
{
|
||||||
// initialize output variables
|
// initialize output variables
|
||||||
syncData.clear();
|
syncData.clear();
|
||||||
|
@ -623,7 +651,8 @@ void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncDat
|
||||||
|
|
||||||
if (prevData.isEmpty()) {
|
if (prevData.isEmpty()) {
|
||||||
// If list was empty before, then difference is a whole new list.
|
// If list was empty before, then difference is a whole new list.
|
||||||
syncData = data;
|
foreach (QString key, data.keys())
|
||||||
|
syncData[key] = data[key];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (QString key, data.keys()) {
|
foreach (QString key, data.keys()) {
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
static QByteArray getPropertiesForTorrent(const QString& hash);
|
static QByteArray getPropertiesForTorrent(const QString& hash);
|
||||||
static QByteArray getFilesForTorrent(const QString& hash);
|
static QByteArray getFilesForTorrent(const QString& hash);
|
||||||
static QByteArray getTransferInfo();
|
static QByteArray getTransferInfo();
|
||||||
|
static QByteArray getTorrentsRatesLimits(QStringList& hashes, bool downloadLimits);
|
||||||
}; // class btjson
|
}; // class btjson
|
||||||
|
|
||||||
#endif // BTJSON_H
|
#endif // BTJSON_H
|
||||||
|
|
|
@ -45,9 +45,11 @@ namespace json {
|
||||||
inline QByteArray toJson(const QVariant& var)
|
inline QByteArray toJson(const QVariant& var)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||||
return QJsonDocument::fromVariant(var).toJson();
|
return QJsonDocument::fromVariant(var).toJson(QJsonDocument::Compact);
|
||||||
#else
|
#else
|
||||||
return QJson::Serializer().serialize(var);
|
QJson::Serializer serializer;
|
||||||
|
serializer.setIndentMode(QJson::IndentCompact);
|
||||||
|
return serializer.serialize(var);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@ QTorrentFilter::QTorrentFilter(QString filter, QString label)
|
||||||
type_ = Completed;
|
type_ = Completed;
|
||||||
else if (filter == "paused")
|
else if (filter == "paused")
|
||||||
type_ = Paused;
|
type_ = Paused;
|
||||||
|
else if (filter == "resumed")
|
||||||
|
type_ = Resumed;
|
||||||
else if (filter == "active")
|
else if (filter == "active")
|
||||||
type_ = Active;
|
type_ = Active;
|
||||||
else if (filter == "inactive")
|
else if (filter == "inactive")
|
||||||
|
@ -57,6 +59,8 @@ bool QTorrentFilter::apply(const QTorrentHandle& h) const
|
||||||
return isTorrentCompleted(h);
|
return isTorrentCompleted(h);
|
||||||
case Paused:
|
case Paused:
|
||||||
return isTorrentPaused(h);
|
return isTorrentPaused(h);
|
||||||
|
case Resumed:
|
||||||
|
return isTorrentResumed(h);
|
||||||
case Active:
|
case Active:
|
||||||
return isTorrentActive(h);
|
return isTorrentActive(h);
|
||||||
case Inactive:
|
case Inactive:
|
||||||
|
@ -98,6 +102,14 @@ bool QTorrentFilter::isTorrentPaused(const QTorrentHandle &h) const
|
||||||
|| state == QTorrentState::Error;
|
|| state == QTorrentState::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QTorrentFilter::isTorrentResumed(const QTorrentHandle &h) const
|
||||||
|
{
|
||||||
|
const QTorrentState state = h.torrentState();
|
||||||
|
|
||||||
|
return state != QTorrentState::PausedUploading
|
||||||
|
&& state != QTorrentState::PausedDownloading;
|
||||||
|
}
|
||||||
|
|
||||||
bool QTorrentFilter::isTorrentActive(const QTorrentHandle &h) const
|
bool QTorrentFilter::isTorrentActive(const QTorrentHandle &h) const
|
||||||
{
|
{
|
||||||
const QTorrentState state = h.torrentState();
|
const QTorrentState state = h.torrentState();
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
Downloading,
|
Downloading,
|
||||||
Completed,
|
Completed,
|
||||||
Paused,
|
Paused,
|
||||||
|
Resumed,
|
||||||
Active,
|
Active,
|
||||||
Inactive
|
Inactive
|
||||||
};
|
};
|
||||||
|
@ -55,6 +56,7 @@ private:
|
||||||
bool isTorrentDownloading(const QTorrentHandle &h) const;
|
bool isTorrentDownloading(const QTorrentHandle &h) const;
|
||||||
bool isTorrentCompleted(const QTorrentHandle &h) const;
|
bool isTorrentCompleted(const QTorrentHandle &h) const;
|
||||||
bool isTorrentPaused(const QTorrentHandle &h) const;
|
bool isTorrentPaused(const QTorrentHandle &h) const;
|
||||||
|
bool isTorrentResumed(const QTorrentHandle &h) const;
|
||||||
bool isTorrentActive(const QTorrentHandle &h) const;
|
bool isTorrentActive(const QTorrentHandle &h) const;
|
||||||
bool isTorrentInactive(const QTorrentHandle &h) const;
|
bool isTorrentInactive(const QTorrentHandle &h) const;
|
||||||
bool torrentHasLabel(const QTorrentHandle &h) const;
|
bool torrentHasLabel(const QTorrentHandle &h) const;
|
||||||
|
|
|
@ -94,14 +94,15 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize
|
||||||
ADD_ACTION(command, getGlobalDlLimit);
|
ADD_ACTION(command, getGlobalDlLimit);
|
||||||
ADD_ACTION(command, setGlobalUpLimit);
|
ADD_ACTION(command, setGlobalUpLimit);
|
||||||
ADD_ACTION(command, setGlobalDlLimit);
|
ADD_ACTION(command, setGlobalDlLimit);
|
||||||
ADD_ACTION(command, getTorrentUpLimit);
|
ADD_ACTION(command, getTorrentsUpLimit);
|
||||||
ADD_ACTION(command, getTorrentDlLimit);
|
ADD_ACTION(command, getTorrentsDlLimit);
|
||||||
ADD_ACTION(command, setTorrentUpLimit);
|
ADD_ACTION(command, setTorrentsUpLimit);
|
||||||
ADD_ACTION(command, setTorrentDlLimit);
|
ADD_ACTION(command, setTorrentsDlLimit);
|
||||||
ADD_ACTION(command, alternativeSpeedLimitsEnabled);
|
ADD_ACTION(command, alternativeSpeedLimitsEnabled);
|
||||||
ADD_ACTION(command, toggleAlternativeSpeedLimits);
|
ADD_ACTION(command, toggleAlternativeSpeedLimits);
|
||||||
ADD_ACTION(command, toggleSequentialDownload);
|
ADD_ACTION(command, toggleSequentialDownload);
|
||||||
ADD_ACTION(command, toggleFirstLastPiecePrio);
|
ADD_ACTION(command, toggleFirstLastPiecePrio);
|
||||||
|
ADD_ACTION(command, setSuperSeeding);
|
||||||
ADD_ACTION(command, delete);
|
ADD_ACTION(command, delete);
|
||||||
ADD_ACTION(command, deletePerm);
|
ADD_ACTION(command, deletePerm);
|
||||||
ADD_ACTION(command, increasePrio);
|
ADD_ACTION(command, increasePrio);
|
||||||
|
@ -212,7 +213,7 @@ void WebApplication::action_public_images()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET params:
|
// GET params:
|
||||||
// - filter (string): all, downloading, completed, paused, active, inactive
|
// - filter (string): all, downloading, completed, paused, resumed, active, inactive
|
||||||
// - label (string): torrent label for filtering by it (empty string means "unlabeled"; no "label" param presented means "any label")
|
// - label (string): torrent label for filtering by it (empty string means "unlabeled"; no "label" param presented means "any label")
|
||||||
// - sort (string): name of column for sorting by its value
|
// - sort (string): name of column for sorting by its value
|
||||||
// - reverse (bool): enable reverse sorting
|
// - reverse (bool): enable reverse sorting
|
||||||
|
@ -453,53 +454,55 @@ void WebApplication::action_command_setGlobalDlLimit()
|
||||||
Preferences::instance()->setGlobalDownloadLimit(limit / 1024.);
|
Preferences::instance()->setGlobalDownloadLimit(limit / 1024.);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_getTorrentUpLimit()
|
void WebApplication::action_command_getTorrentsUpLimit()
|
||||||
{
|
{
|
||||||
CHECK_URI(0);
|
CHECK_URI(0);
|
||||||
CHECK_PARAMETERS("hash");
|
CHECK_PARAMETERS("hashes");
|
||||||
QString hash = request().posts["hash"];
|
QStringList hashes = request().posts["hashes"].split("|");
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
print(btjson::getTorrentsRatesLimits(hashes, false), Http::CONTENT_TYPE_JS);
|
||||||
|
|
||||||
if (h.is_valid())
|
|
||||||
print(QByteArray::number(h.upload_limit()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_getTorrentDlLimit()
|
void WebApplication::action_command_getTorrentsDlLimit()
|
||||||
{
|
{
|
||||||
CHECK_URI(0);
|
CHECK_URI(0);
|
||||||
CHECK_PARAMETERS("hash");
|
CHECK_PARAMETERS("hashes");
|
||||||
QString hash = request().posts["hash"];
|
QStringList hashes = request().posts["hashes"].split("|");
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
print(btjson::getTorrentsRatesLimits(hashes, true), Http::CONTENT_TYPE_JS);
|
||||||
|
|
||||||
if (h.is_valid())
|
|
||||||
print(QByteArray::number(h.download_limit()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_setTorrentUpLimit()
|
void WebApplication::action_command_setTorrentsUpLimit()
|
||||||
{
|
{
|
||||||
CHECK_URI(0);
|
CHECK_URI(0);
|
||||||
CHECK_PARAMETERS("hash" << "limit");
|
CHECK_PARAMETERS("hashes" << "limit");
|
||||||
QString hash = request().posts["hash"];
|
|
||||||
qlonglong limit = request().posts["limit"].toLongLong();
|
qlonglong limit = request().posts["limit"].toLongLong();
|
||||||
if (limit == 0) limit = -1;
|
if (limit == 0)
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
limit = -1;
|
||||||
|
|
||||||
|
QStringList hashes = request().posts["hashes"].split("|");
|
||||||
|
foreach (const QString &hash, hashes) {
|
||||||
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
||||||
if (h.is_valid())
|
if (h.is_valid())
|
||||||
h.set_upload_limit(limit);
|
h.set_upload_limit(limit);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_setTorrentDlLimit()
|
void WebApplication::action_command_setTorrentsDlLimit()
|
||||||
{
|
{
|
||||||
CHECK_URI(0);
|
CHECK_URI(0);
|
||||||
CHECK_PARAMETERS("hash" << "limit");
|
CHECK_PARAMETERS("hashes" << "limit");
|
||||||
QString hash = request().posts["hash"];
|
|
||||||
qlonglong limit = request().posts["limit"].toLongLong();
|
|
||||||
if (limit == 0) limit = -1;
|
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
|
||||||
|
|
||||||
|
qlonglong limit = request().posts["limit"].toLongLong();
|
||||||
|
if (limit == 0)
|
||||||
|
limit = -1;
|
||||||
|
|
||||||
|
QStringList hashes = request().posts["hashes"].split("|");
|
||||||
|
foreach (const QString &hash, hashes) {
|
||||||
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
||||||
if (h.is_valid())
|
if (h.is_valid())
|
||||||
h.set_download_limit(limit);
|
h.set_download_limit(limit);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_toggleAlternativeSpeedLimits()
|
void WebApplication::action_command_toggleAlternativeSpeedLimits()
|
||||||
{
|
{
|
||||||
|
@ -541,6 +544,21 @@ void WebApplication::action_command_toggleFirstLastPiecePrio()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebApplication::action_command_setSuperSeeding()
|
||||||
|
{
|
||||||
|
CHECK_URI(0);
|
||||||
|
CHECK_PARAMETERS("hashes" << "value");
|
||||||
|
bool value = request().posts["value"] == "true";
|
||||||
|
QStringList hashes = request().posts["hashes"].split("|");
|
||||||
|
foreach (const QString &hash, hashes) {
|
||||||
|
try {
|
||||||
|
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
||||||
|
h.super_seeding(value);
|
||||||
|
}
|
||||||
|
catch(invalid_handle&) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebApplication::action_command_delete()
|
void WebApplication::action_command_delete()
|
||||||
{
|
{
|
||||||
CHECK_URI(0);
|
CHECK_URI(0);
|
||||||
|
|
|
@ -68,14 +68,15 @@ private:
|
||||||
void action_command_getGlobalDlLimit();
|
void action_command_getGlobalDlLimit();
|
||||||
void action_command_setGlobalUpLimit();
|
void action_command_setGlobalUpLimit();
|
||||||
void action_command_setGlobalDlLimit();
|
void action_command_setGlobalDlLimit();
|
||||||
void action_command_getTorrentUpLimit();
|
void action_command_getTorrentsUpLimit();
|
||||||
void action_command_getTorrentDlLimit();
|
void action_command_getTorrentsDlLimit();
|
||||||
void action_command_setTorrentUpLimit();
|
void action_command_setTorrentsUpLimit();
|
||||||
void action_command_setTorrentDlLimit();
|
void action_command_setTorrentsDlLimit();
|
||||||
void action_command_alternativeSpeedLimitsEnabled();
|
void action_command_alternativeSpeedLimitsEnabled();
|
||||||
void action_command_toggleAlternativeSpeedLimits();
|
void action_command_toggleAlternativeSpeedLimits();
|
||||||
void action_command_toggleSequentialDownload();
|
void action_command_toggleSequentialDownload();
|
||||||
void action_command_toggleFirstLastPiecePrio();
|
void action_command_toggleFirstLastPiecePrio();
|
||||||
|
void action_command_setSuperSeeding();
|
||||||
void action_command_delete();
|
void action_command_delete();
|
||||||
void action_command_deletePerm();
|
void action_command_deletePerm();
|
||||||
void action_command_increasePrio();
|
void action_command_increasePrio();
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
<li><a href="#UploadLimit"><img src="images/skin/seeding.png" alt="QBT_TR(Limit upload rate...)QBT_TR"/> QBT_TR(Limit upload rate...)QBT_TR</a></li>
|
<li><a href="#UploadLimit"><img src="images/skin/seeding.png" alt="QBT_TR(Limit upload rate...)QBT_TR"/> QBT_TR(Limit upload rate...)QBT_TR</a></li>
|
||||||
<li class="separator"><a href="#SequentialDownload"><img src="theme/checked" alt="QBT_TR(Download in sequential order)QBT_TR"/> QBT_TR(Download in sequential order)QBT_TR</a></li>
|
<li class="separator"><a href="#SequentialDownload"><img src="theme/checked" alt="QBT_TR(Download in sequential order)QBT_TR"/> QBT_TR(Download in sequential order)QBT_TR</a></li>
|
||||||
<li><a href="#FirstLastPiecePrio"><img src="theme/checked" alt="QBT_TR(Download first and last piece first)QBT_TR"/> QBT_TR(Download first and last piece first)QBT_TR</a></li>
|
<li><a href="#FirstLastPiecePrio"><img src="theme/checked" alt="QBT_TR(Download first and last piece first)QBT_TR"/> QBT_TR(Download first and last piece first)QBT_TR</a></li>
|
||||||
|
<li class="separator"><a href="#SuperSeeding"><img src="theme/checked" alt="QBT_TR(Super seeding mode)QBT_TR"/> QBT_TR(Super seeding mode)QBT_TR</a></li>
|
||||||
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify" alt="QBT_TR(Force recheck)QBT_TR"/> QBT_TR(Force recheck)QBT_TR</a></li>
|
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify" alt="QBT_TR(Force recheck)QBT_TR"/> QBT_TR(Force recheck)QBT_TR</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="desktopFooterWrapper">
|
<div id="desktopFooterWrapper">
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var hash = new URI().getData('hash');
|
var hashes = new URI().getData('hashes').split('|');
|
||||||
setDlLimit = function() {
|
setDlLimit = function() {
|
||||||
var limit = $("dllimitUpdatevalue").value.toInt() * 1024;
|
var limit = $("dllimitUpdatevalue").value.toInt() * 1024;
|
||||||
if (hash == "global") {
|
if (hashes[0] == "global") {
|
||||||
new Request({
|
new Request({
|
||||||
url: 'command/setGlobalDlLimit',
|
url: 'command/setGlobalDlLimit',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
@ -38,10 +38,10 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new Request({
|
new Request({
|
||||||
url: 'command/setTorrentDlLimit',
|
url: 'command/setTorrentsDlLimit',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
'hash': hash,
|
'hashes': hashes.join('|'),
|
||||||
'limit': limit
|
'limit': limit
|
||||||
},
|
},
|
||||||
onComplete: function() {
|
onComplete: function() {
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
MochaUI.addDlLimitSlider(hash);
|
MochaUI.addDlLimitSlider(hashes);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All)QBT_TR</a></li>
|
<li id="all_filter"><a href="#" onclick="setFilter('all');return false;"><img src="images/skin/filterall.png"/>QBT_TR(All)QBT_TR</a></li>
|
||||||
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading)QBT_TR</a></li>
|
<li id="downloading_filter"><a href="#" onclick="setFilter('downloading');return false;"><img src="images/skin/downloading.png"/>QBT_TR(Downloading)QBT_TR</a></li>
|
||||||
<li id="completed_filter"><a href="#" onclick="setFilter('completed');return false;"><img src="images/skin/uploading.png"/>QBT_TR(Completed)QBT_TR</a></li>
|
<li id="completed_filter"><a href="#" onclick="setFilter('completed');return false;"><img src="images/skin/uploading.png"/>QBT_TR(Completed)QBT_TR</a></li>
|
||||||
|
<li id="resumed_filter"><a href="#" onclick="setFilter('resumed');return false;"><img src="images/skin/resumed.png"/>QBT_TR(Resumed)QBT_TR</a></li>
|
||||||
<li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.png"/>QBT_TR(Paused)QBT_TR</a></li>
|
<li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.png"/>QBT_TR(Paused)QBT_TR</a></li>
|
||||||
<li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.png"/>QBT_TR(Active)QBT_TR</a></li>
|
<li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.png"/>QBT_TR(Active)QBT_TR</a></li>
|
||||||
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.png"/>QBT_TR(Inactive)QBT_TR</a></li>
|
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.png"/>QBT_TR(Inactive)QBT_TR</a></li>
|
||||||
|
|
|
@ -27,6 +27,8 @@ myTable = new dynamicTable();
|
||||||
var updatePropertiesPanel = function(){};
|
var updatePropertiesPanel = function(){};
|
||||||
var updateMainData = function(){};
|
var updateMainData = function(){};
|
||||||
var alternativeSpeedLimits = false;
|
var alternativeSpeedLimits = false;
|
||||||
|
var queueing_enabled = true;
|
||||||
|
var syncMainDataTimerPeriod = 1500;
|
||||||
|
|
||||||
selected_filter = getLocalStorageItem('selected_filter', 'all');
|
selected_filter = getLocalStorageItem('selected_filter', 'all');
|
||||||
selected_label = null;
|
selected_label = null;
|
||||||
|
@ -95,6 +97,7 @@ window.addEvent('load', function () {
|
||||||
$("downloading_filter").removeClass("selectedFilter");
|
$("downloading_filter").removeClass("selectedFilter");
|
||||||
$("completed_filter").removeClass("selectedFilter");
|
$("completed_filter").removeClass("selectedFilter");
|
||||||
$("paused_filter").removeClass("selectedFilter");
|
$("paused_filter").removeClass("selectedFilter");
|
||||||
|
$("resumed_filter").removeClass("selectedFilter");
|
||||||
$("active_filter").removeClass("selectedFilter");
|
$("active_filter").removeClass("selectedFilter");
|
||||||
$("inactive_filter").removeClass("selectedFilter");
|
$("inactive_filter").removeClass("selectedFilter");
|
||||||
$(f + "_filter").addClass("selectedFilter");
|
$(f + "_filter").addClass("selectedFilter");
|
||||||
|
@ -153,19 +156,6 @@ window.addEvent('load', function () {
|
||||||
myTable.rows.erase();
|
myTable.rows.erase();
|
||||||
if (response['rid'])
|
if (response['rid'])
|
||||||
syncMainDataLastResponseId = response['rid'];
|
syncMainDataLastResponseId = response['rid'];
|
||||||
if ('queueing' in response) {
|
|
||||||
var queueing_enabled = response['queueing'];
|
|
||||||
myTable.columns['priority'].force_hide = !queueing_enabled;
|
|
||||||
myTable.updateColumn('priority');
|
|
||||||
if (queueing_enabled) {
|
|
||||||
$('queueingButtons').removeClass('invisible');
|
|
||||||
$('queueingMenuItems').removeClass('invisible');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('queueingButtons').addClass('invisible');
|
|
||||||
$('queueingMenuItems').addClass('invisible');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (response['torrents'])
|
if (response['torrents'])
|
||||||
for (var key in response['torrents']) {
|
for (var key in response['torrents']) {
|
||||||
response['torrents'][key]['hash'] = key;
|
response['torrents'][key]['hash'] = key;
|
||||||
|
@ -185,7 +175,7 @@ window.addEvent('load', function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clearTimeout(syncMainDataTimer);
|
clearTimeout(syncMainDataTimer);
|
||||||
syncMainDataTimer = syncMainData.delay(1500);
|
syncMainDataTimer = syncMainData.delay(syncMainDataTimerPeriod);
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
};
|
};
|
||||||
|
@ -220,6 +210,29 @@ window.addEvent('load', function () {
|
||||||
$('connectionStatus').src = 'images/skin/firewalled.png';
|
$('connectionStatus').src = 'images/skin/firewalled.png';
|
||||||
else
|
else
|
||||||
$('connectionStatus').src = 'images/skin/disconnected.png';
|
$('connectionStatus').src = 'images/skin/disconnected.png';
|
||||||
|
|
||||||
|
if (queueing_enabled != serverState.queueing) {
|
||||||
|
queueing_enabled = serverState.queueing;
|
||||||
|
myTable.columns['priority'].force_hide = !queueing_enabled;
|
||||||
|
myTable.updateColumn('priority');
|
||||||
|
if (queueing_enabled) {
|
||||||
|
$('queueingButtons').removeClass('invisible');
|
||||||
|
$('queueingMenuItems').removeClass('invisible');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('queueingButtons').addClass('invisible');
|
||||||
|
$('queueingMenuItems').addClass('invisible');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alternativeSpeedLimits != serverState.use_alt_speed_limits) {
|
||||||
|
alternativeSpeedLimits = serverState.use_alt_speed_limits;
|
||||||
|
updateAltSpeedIcon(alternativeSpeedLimits);
|
||||||
|
}
|
||||||
|
|
||||||
|
syncMainDataTimerPeriod = serverState.refresh_interval;
|
||||||
|
if (syncMainDataTimerPeriod < 500)
|
||||||
|
syncMainDataTimerPeriod = 500;
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateAltSpeedIcon = function(enabled) {
|
var updateAltSpeedIcon = function(enabled) {
|
||||||
|
@ -229,16 +242,6 @@ window.addEvent('load', function () {
|
||||||
$('alternativeSpeedLimits').src = "images/slow_off.png"
|
$('alternativeSpeedLimits').src = "images/slow_off.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether the alternative speed limits are enabled or not
|
|
||||||
new Request({url: 'command/alternativeSpeedLimitsEnabled',
|
|
||||||
method: 'get',
|
|
||||||
onSuccess : function (isEnabled) {
|
|
||||||
alternativeSpeedLimits = !!parseInt(isEnabled);
|
|
||||||
if (alternativeSpeedLimits)
|
|
||||||
$('alternativeSpeedLimits').src = "images/slow.png"
|
|
||||||
}
|
|
||||||
}).send();
|
|
||||||
|
|
||||||
$('alternativeSpeedLimits').addEvent('click', function() {
|
$('alternativeSpeedLimits').addEvent('click', function() {
|
||||||
// Change icon immediately to give some feedback
|
// Change icon immediately to give some feedback
|
||||||
updateAltSpeedIcon(!alternativeSpeedLimits);
|
updateAltSpeedIcon(!alternativeSpeedLimits);
|
||||||
|
@ -354,11 +357,20 @@ window.addEvent('load', function () {
|
||||||
|
|
||||||
function closeWindows() {
|
function closeWindows() {
|
||||||
MochaUI.closeAll();
|
MochaUI.closeAll();
|
||||||
}
|
};
|
||||||
|
|
||||||
window.addEvent('keydown', function (event) {
|
var keyboardEvents = new Keyboard({
|
||||||
if (event.key == 'a' && event.control) {
|
defaultEventType: 'keydown',
|
||||||
event.stop();
|
events: {
|
||||||
|
'ctrl+a': function(event) {
|
||||||
myTable.selectAll();
|
myTable.selectAll();
|
||||||
|
event.preventDefault();
|
||||||
|
},
|
||||||
|
'delete': function(event) {
|
||||||
|
deleteFN();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
keyboardEvents.activate();
|
||||||
|
|
|
@ -136,6 +136,7 @@ var ContextMenu = new Class({
|
||||||
all_are_downloaded = true;
|
all_are_downloaded = true;
|
||||||
all_are_paused = true;
|
all_are_paused = true;
|
||||||
there_are_paused = false;
|
there_are_paused = false;
|
||||||
|
all_are_super_seeding = true;
|
||||||
|
|
||||||
var h = myTable.selectedIds();
|
var h = myTable.selectedIds();
|
||||||
h.each(function(item, index){
|
h.each(function(item, index){
|
||||||
|
@ -153,6 +154,8 @@ var ContextMenu = new Class({
|
||||||
|
|
||||||
if (data['progress'] != 1.0) // not downloaded
|
if (data['progress'] != 1.0) // not downloaded
|
||||||
all_are_downloaded = false;
|
all_are_downloaded = false;
|
||||||
|
else if (data['super_seeding'] != true)
|
||||||
|
all_are_super_seeding = false;
|
||||||
|
|
||||||
state = data['state'];
|
state = data['state'];
|
||||||
if ((state != 'pausedUP') && (state != 'pausedDL'))
|
if ((state != 'pausedUP') && (state != 'pausedDL'))
|
||||||
|
@ -174,6 +177,8 @@ var ContextMenu = new Class({
|
||||||
if (all_are_downloaded) {
|
if (all_are_downloaded) {
|
||||||
this.hideItem('SequentialDownload');
|
this.hideItem('SequentialDownload');
|
||||||
this.hideItem('FirstLastPiecePrio');
|
this.hideItem('FirstLastPiecePrio');
|
||||||
|
this.showItem('SuperSeeding');
|
||||||
|
this.setItemChecked('SuperSeeding', all_are_super_seeding);
|
||||||
} else {
|
} else {
|
||||||
if (!show_seq_dl && show_f_l_piece_prio)
|
if (!show_seq_dl && show_f_l_piece_prio)
|
||||||
this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.addClass('separator');
|
this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.addClass('separator');
|
||||||
|
@ -192,6 +197,8 @@ var ContextMenu = new Class({
|
||||||
|
|
||||||
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
this.setItemChecked('SequentialDownload', all_are_seq_dl);
|
||||||
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
|
this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio);
|
||||||
|
|
||||||
|
this.hideItem('SuperSeeding');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (all_are_paused) {
|
if (all_are_paused) {
|
||||||
|
@ -234,6 +241,10 @@ var ContextMenu = new Class({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getItemChecked: function(item) {
|
||||||
|
return '0' != this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity;
|
||||||
|
},
|
||||||
|
|
||||||
//hide an item
|
//hide an item
|
||||||
hideItem: function(item) {
|
hideItem: function(item) {
|
||||||
this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible');
|
this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible');
|
||||||
|
|
|
@ -261,6 +261,10 @@ var dynamicTable = new Class({
|
||||||
if (!~state.indexOf('paused'))
|
if (!~state.indexOf('paused'))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
case 'resumed':
|
||||||
|
if (~state.indexOf('paused'))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
case 'active':
|
case 'active':
|
||||||
if ((state != 'uploading') && (state != 'downloading'))
|
if ((state != 'uploading') && (state != 'downloading'))
|
||||||
return false;
|
return false;
|
||||||
|
@ -352,6 +356,17 @@ var dynamicTable = new Class({
|
||||||
myTable.selectRow(this.hash);
|
myTable.selectRow(this.hash);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
tr.addEvent('dblclick', function (e) {
|
||||||
|
e.stop();
|
||||||
|
myTable.selectRow(this.hash);
|
||||||
|
var row = myTable.rows.get(this.hash);
|
||||||
|
var state = row['full_data'].state;
|
||||||
|
if (~state.indexOf('paused'))
|
||||||
|
startFN();
|
||||||
|
else
|
||||||
|
pauseFN();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
tr.addEvent('click', function (e) {
|
tr.addEvent('click', function (e) {
|
||||||
e.stop();
|
e.stop();
|
||||||
if (e.control) {
|
if (e.control) {
|
||||||
|
|
|
@ -38,11 +38,11 @@ function friendlyDuration(seconds) {
|
||||||
if (minutes < 60)
|
if (minutes < 60)
|
||||||
return "QBT_TR(%1m)QBT_TR".replace("%1", parseInt(minutes));
|
return "QBT_TR(%1m)QBT_TR".replace("%1", parseInt(minutes));
|
||||||
var hours = minutes / 60;
|
var hours = minutes / 60;
|
||||||
minutes = minutes - hours * 60;
|
minutes = minutes % 60;
|
||||||
if (hours < 24)
|
if (hours < 24)
|
||||||
return "QBT_TR(%1h %2m)QBT_TR".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes))
|
return "QBT_TR(%1h %2m)QBT_TR".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes))
|
||||||
var days = hours / 24;
|
var days = hours / 24;
|
||||||
hours = hours - days * 24;
|
hours = hours % 24;
|
||||||
if (days < 100)
|
if (days < 100)
|
||||||
return "QBT_TR(%1d %2h)QBT_TR".replace("%1", parseInt(days)).replace("%2", parseInt(hours))
|
return "QBT_TR(%1d %2h)QBT_TR".replace("%1", parseInt(days)).replace("%2", parseInt(hours))
|
||||||
return "∞";
|
return "∞";
|
||||||
|
|
|
@ -29,6 +29,10 @@ function getLocalStorageItem(name, defaultVal) {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deleteFN = function() {};
|
||||||
|
var startFN = function() {};
|
||||||
|
var pauseFN = function() {};
|
||||||
|
|
||||||
initializeWindows = function() {
|
initializeWindows = function() {
|
||||||
|
|
||||||
function addClickEvent(el, fn) {
|
function addClickEvent(el, fn) {
|
||||||
|
@ -103,7 +107,7 @@ initializeWindows = function() {
|
||||||
id: 'uploadLimitPage',
|
id: 'uploadLimitPage',
|
||||||
title: "QBT_TR(Global Upload Speed Limit)QBT_TR",
|
title: "QBT_TR(Global Upload Speed Limit)QBT_TR",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL: 'uploadlimit.html?hash=global',
|
contentURL: 'uploadlimit.html?hashes=global',
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -122,7 +126,7 @@ initializeWindows = function() {
|
||||||
id: 'uploadLimitPage',
|
id: 'uploadLimitPage',
|
||||||
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR",
|
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL: 'uploadlimit.html?hash=' + hash,
|
contentURL: 'uploadlimit.html?hashes=' + h.join("|"),
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -162,12 +166,27 @@ initializeWindows = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setSuperSeedingFN = function(val) {
|
||||||
|
var h = myTable.selectedIds();
|
||||||
|
if (h.length) {
|
||||||
|
new Request({
|
||||||
|
url: 'command/setSuperSeeding',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
value: val,
|
||||||
|
hashes: h.join("|")
|
||||||
|
}
|
||||||
|
}).send();
|
||||||
|
updateMainData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
globalDownloadLimitFN = function() {
|
globalDownloadLimitFN = function() {
|
||||||
new MochaUI.Window({
|
new MochaUI.Window({
|
||||||
id: 'downloadLimitPage',
|
id: 'downloadLimitPage',
|
||||||
title: "QBT_TR(Global Download Speed Limit)QBT_TR",
|
title: "QBT_TR(Global Download Speed Limit)QBT_TR",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL: 'downloadlimit.html?hash=global',
|
contentURL: 'downloadlimit.html?hashes=global',
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -186,7 +205,7 @@ initializeWindows = function() {
|
||||||
id: 'downloadLimitPage',
|
id: 'downloadLimitPage',
|
||||||
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR",
|
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR",
|
||||||
loadMethod: 'iframe',
|
loadMethod: 'iframe',
|
||||||
contentURL: 'downloadlimit.html?hash=' + hash,
|
contentURL: 'downloadlimit.html?hashes=' + h.join("|"),
|
||||||
scrollbars: false,
|
scrollbars: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
maximizable: false,
|
maximizable: false,
|
||||||
|
@ -274,7 +293,7 @@ initializeWindows = function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
['pause', 'resume', 'recheck'].each(function(item) {
|
['pauseAll', 'resumeAll', 'pause', 'resume', 'recheck'].each(function(item) {
|
||||||
addClickEvent(item, function(e) {
|
addClickEvent(item, function(e) {
|
||||||
new Event(e).stop();
|
new Event(e).stop();
|
||||||
var h = myTable.selectedIds();
|
var h = myTable.selectedIds();
|
||||||
|
|
|
@ -14,7 +14,7 @@ Requires:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
MochaUI.extend({
|
MochaUI.extend({
|
||||||
addUpLimitSlider: function(hash) {
|
addUpLimitSlider: function(hashes) {
|
||||||
if ($('uplimitSliderarea')) {
|
if ($('uplimitSliderarea')) {
|
||||||
var windowOptions = MochaUI.Windows.windowOptions;
|
var windowOptions = MochaUI.Windows.windowOptions;
|
||||||
var sliderFirst = true;
|
var sliderFirst = true;
|
||||||
|
@ -31,15 +31,15 @@ MochaUI.extend({
|
||||||
maximum = tmp / 1024.
|
maximum = tmp / 1024.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (hash == "global")
|
if (hashes[0] == "global")
|
||||||
maximum = 10000;
|
maximum = 10000;
|
||||||
else
|
else
|
||||||
maximum = 1000;
|
maximum = 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get torrent upload limit
|
// Get torrents upload limit
|
||||||
// And create slider
|
// And create slider
|
||||||
if (hash == 'global') {
|
if (hashes[0] == 'global') {
|
||||||
var up_limit = maximum;
|
var up_limit = maximum;
|
||||||
if (up_limit < 0) up_limit = 0;
|
if (up_limit < 0) up_limit = 0;
|
||||||
maximum = 10000;
|
maximum = 10000;
|
||||||
|
@ -69,15 +69,21 @@ MochaUI.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var req = new Request({
|
var req = new Request.JSON({
|
||||||
url: 'command/getTorrentUpLimit',
|
url: 'command/getTorrentsUpLimit',
|
||||||
|
noCache : true,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
hash: hash
|
hashes: hashes.join('|')
|
||||||
},
|
},
|
||||||
onSuccess: function(data) {
|
onSuccess: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
var up_limit = data.toInt();
|
var up_limit = data[hashes[0]];
|
||||||
|
for(var key in data)
|
||||||
|
if (up_limit != data[key]) {
|
||||||
|
up_limit = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (up_limit < 0) up_limit = 0;
|
if (up_limit < 0) up_limit = 0;
|
||||||
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
|
||||||
steps: maximum,
|
steps: maximum,
|
||||||
|
@ -112,7 +118,7 @@ MochaUI.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addDlLimitSlider: function(hash) {
|
addDlLimitSlider: function(hashes) {
|
||||||
if ($('dllimitSliderarea')) {
|
if ($('dllimitSliderarea')) {
|
||||||
var windowOptions = MochaUI.Windows.windowOptions;
|
var windowOptions = MochaUI.Windows.windowOptions;
|
||||||
var sliderFirst = true;
|
var sliderFirst = true;
|
||||||
|
@ -129,15 +135,15 @@ MochaUI.extend({
|
||||||
maximum = tmp / 1024.
|
maximum = tmp / 1024.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (hash == "global")
|
if (hashes[0] == "global")
|
||||||
maximum = 10000;
|
maximum = 10000;
|
||||||
else
|
else
|
||||||
maximum = 1000;
|
maximum = 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get torrent download limit
|
// Get torrents download limit
|
||||||
// And create slider
|
// And create slider
|
||||||
if (hash == "global") {
|
if (hashes[0] == 'global') {
|
||||||
var dl_limit = maximum;
|
var dl_limit = maximum;
|
||||||
if (dl_limit < 0) dl_limit = 0;
|
if (dl_limit < 0) dl_limit = 0;
|
||||||
maximum = 10000;
|
maximum = 10000;
|
||||||
|
@ -167,15 +173,21 @@ MochaUI.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var req = new Request({
|
var req = new Request.JSON({
|
||||||
url: 'command/getTorrentDlLimit',
|
url: 'command/getTorrentsDlLimit',
|
||||||
|
noCache : true,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
hash: hash
|
hashes: hashes.join('|')
|
||||||
},
|
},
|
||||||
onSuccess: function(data) {
|
onSuccess: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
var dl_limit = data.toInt();
|
var dl_limit = data[hashes[0]];
|
||||||
|
for(var key in data)
|
||||||
|
if (dl_limit != data[key]) {
|
||||||
|
dl_limit = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (dl_limit < 0) dl_limit = 0;
|
if (dl_limit < 0) dl_limit = 0;
|
||||||
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
|
||||||
steps: maximum,
|
steps: maximum,
|
||||||
|
|
|
@ -37,7 +37,7 @@ var ProgressBar = new Class({
|
||||||
'text-align': 'center',
|
'text-align': 'center',
|
||||||
'left': 0,
|
'left': 0,
|
||||||
'top': 0,
|
'top': 0,
|
||||||
'line-height': vals.height - 2
|
'line-height': vals.height
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
obj.vals.light = new Element('div', {
|
obj.vals.light = new Element('div', {
|
||||||
|
@ -52,7 +52,7 @@ var ProgressBar = new Class({
|
||||||
'text-align': 'center',
|
'text-align': 'center',
|
||||||
'left': 0,
|
'left': 0,
|
||||||
'top': 0,
|
'top': 0,
|
||||||
'line-height': vals.height - 2
|
'line-height': vals.height
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
obj.appendChild(obj.vals.dark);
|
obj.appendChild(obj.vals.dark);
|
||||||
|
|
|
@ -51,6 +51,9 @@
|
||||||
},
|
},
|
||||||
FirstLastPiecePrio : function (element, ref) {
|
FirstLastPiecePrio : function (element, ref) {
|
||||||
toggleFirstLastPiecePrioFN();
|
toggleFirstLastPiecePrioFN();
|
||||||
|
},
|
||||||
|
SuperSeeding : function (element, ref) {
|
||||||
|
setSuperSeedingFN(!ref.getItemChecked('SuperSeeding'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
offsets : {
|
offsets : {
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var hash = new URI().getData('hash');
|
var hashes = new URI().getData('hashes').split('|');
|
||||||
setUpLimit = function() {
|
setUpLimit = function() {
|
||||||
var limit = $("uplimitUpdatevalue").value.toInt() * 1024;
|
var limit = $("uplimitUpdatevalue").value.toInt() * 1024;
|
||||||
if (hash == "global") {
|
if (hashes[0] == "global") {
|
||||||
new Request({
|
new Request({
|
||||||
url: 'command/setGlobalUpLimit',
|
url: 'command/setGlobalUpLimit',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
@ -38,10 +38,10 @@
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new Request({
|
new Request({
|
||||||
url: 'command/setTorrentUpLimit',
|
url: 'command/setTorrentsUpLimit',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
'hash': hash,
|
'hashes': hashes.join('|'),
|
||||||
'limit': limit
|
'limit': limit
|
||||||
},
|
},
|
||||||
onComplete: function() {
|
onComplete: function() {
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
MochaUI.addUpLimitSlider(hash);
|
MochaUI.addUpLimitSlider(hashes);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue