Browse Source

FEATURE: Added filter for paused/error torrents

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
607bba4625
  1. 1
      Changelog
  2. 16
      src/transferlistfilterswidget.h
  3. 19
      src/transferlistwidget.cpp
  4. 4
      src/transferlistwidget.h

1
Changelog

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
- FEATURE: Added "No action" setting for double-click action
- FEATURE: Several torrents can be moved at once
- FEATURE: Added error state for torrents (error is displayed in a tooltip)
- FEATURE: Added filter for paused/error torrents
- COSMETIC: Display peers country name in tooltip
- COSMETIC: Display number of torrents in transfers tab label

16
src/transferlistfilterswidget.h

@ -147,20 +147,20 @@ protected: @@ -147,20 +147,20 @@ protected:
class StatusFiltersWidget : public QListWidget {
public:
StatusFiltersWidget(QWidget *parent) : QListWidget(parent) {
setFixedHeight(100);
setFixedHeight(120);
}
protected:
void changeEvent(QEvent *e) {
void changeEvent(QEvent *e) {
QListWidget::changeEvent(e);
switch (e->type()) {
case QEvent::StyleChange:
setSpacing(0);
setFixedHeight(100);
setFixedHeight(120);
break;
default:
break;
}
}
}
};
@ -200,6 +200,9 @@ public: @@ -200,6 +200,9 @@ public:
QListWidgetItem *completed = new QListWidgetItem(statusFilters);
completed->setData(Qt::DisplayRole, QVariant(tr("Completed") + " (0)"));
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 *active = new QListWidgetItem(statusFilters);
active->setData(Qt::DisplayRole, QVariant(tr("Active") + " (0)"));
active->setData(Qt::DecorationRole, QIcon(":/Icons/skin/filteractive.png"));
@ -209,7 +212,7 @@ public: @@ -209,7 +212,7 @@ public:
// SIGNAL/SLOT
connect(statusFilters, SIGNAL(currentRowChanged(int)), transferList, SLOT(applyStatusFilter(int)));
connect(transferList, SIGNAL(torrentStatusUpdate(uint,uint,uint,uint)), this, SLOT(updateTorrentNumbers(uint, uint, uint, uint)));
connect(transferList, SIGNAL(torrentStatusUpdate(uint,uint,uint,uint,uint)), this, SLOT(updateTorrentNumbers(uint, uint, uint, uint, uint)));
connect(labelFilters, SIGNAL(currentRowChanged(int)), this, SLOT(applyLabelFilter(int)));
connect(labelFilters, SIGNAL(torrentDropped(int)), this, SLOT(torrentDropped(int)));
connect(transferList, SIGNAL(torrentAdded(QModelIndex)), this, SLOT(torrentAdded(QModelIndex)));
@ -276,10 +279,11 @@ public: @@ -276,10 +279,11 @@ public:
}
protected slots:
void updateTorrentNumbers(uint nb_downloading, uint nb_seeding, uint nb_active, uint nb_inactive) {
void updateTorrentNumbers(uint nb_downloading, uint nb_seeding, uint nb_active, uint nb_inactive, uint nb_paused) {
statusFilters->item(FILTER_ALL)->setData(Qt::DisplayRole, QVariant(tr("All")+" ("+QString::number(nb_active+nb_inactive)+")"));
statusFilters->item(FILTER_DOWNLOADING)->setData(Qt::DisplayRole, QVariant(tr("Downloading")+" ("+QString::number(nb_downloading)+")"));
statusFilters->item(FILTER_COMPLETED)->setData(Qt::DisplayRole, QVariant(tr("Completed")+" ("+QString::number(nb_seeding)+")"));
statusFilters->item(FILTER_PAUSED)->setData(Qt::DisplayRole, QVariant(tr("Paused")+" ("+QString::number(nb_paused)+")"));
statusFilters->item(FILTER_ACTIVE)->setData(Qt::DisplayRole, QVariant(tr("Active")+" ("+QString::number(nb_active)+")"));
statusFilters->item(FILTER_INACTIVE)->setData(Qt::DisplayRole, QVariant(tr("Inactive")+" ("+QString::number(nb_inactive)+")"));
}

19
src/transferlistwidget.cpp

@ -485,7 +485,7 @@ void TransferListWidget::refreshList(bool force) { @@ -485,7 +485,7 @@ void TransferListWidget::refreshList(bool force) {
setUpdatesEnabled(false);
// Refresh only if displayed
if(!force && main_window->getCurrentTabIndex() != TAB_TRANSFER) return;
unsigned int nb_downloading = 0, nb_seeding=0, nb_active=0, nb_inactive = 0;
unsigned int nb_downloading = 0, nb_seeding=0, nb_active=0, nb_inactive = 0, nb_paused = 0;
if(BTSession->getSession()->get_torrents().size() != (uint)listModel->rowCount()) {
// Oups, we have torrents that are not displayed, fix this
std::vector<torrent_handle> torrents = BTSession->getSession()->get_torrents();
@ -509,10 +509,14 @@ void TransferListWidget::refreshList(bool force) { @@ -509,10 +509,14 @@ void TransferListWidget::refreshList(bool force) {
case STATE_STALLED_DL:
case STATE_CHECKING_DL:
case STATE_PAUSED_DL:
case STATE_QUEUED_DL:
case STATE_QUEUED_DL: {
if(s == STATE_PAUSED_DL) {
++nb_paused;
}
++nb_inactive;
++nb_downloading;
break;
}
case STATE_SEEDING:
++nb_active;
++nb_seeding;
@ -520,10 +524,14 @@ void TransferListWidget::refreshList(bool force) { @@ -520,10 +524,14 @@ void TransferListWidget::refreshList(bool force) {
case STATE_STALLED_UP:
case STATE_CHECKING_UP:
case STATE_PAUSED_UP:
case STATE_QUEUED_UP:
case STATE_QUEUED_UP: {
if(s == STATE_PAUSED_UP) {
++nb_paused;
}
++nb_seeding;
++nb_inactive;
break;
}
case STATE_INVALID:
bad_hashes << getHashFromRow(i);
break;
@ -538,7 +546,7 @@ void TransferListWidget::refreshList(bool force) { @@ -538,7 +546,7 @@ void TransferListWidget::refreshList(bool force) {
deleteTorrent(row, false);
}
// Update status filters counters
emit torrentStatusUpdate(nb_downloading, nb_seeding, nb_active, nb_inactive);
emit torrentStatusUpdate(nb_downloading, nb_seeding, nb_active, nb_inactive, nb_paused);
// Start updating the display
setUpdatesEnabled(true);
}
@ -1358,6 +1366,9 @@ void TransferListWidget::applyStatusFilter(int f) { @@ -1358,6 +1366,9 @@ void TransferListWidget::applyStatusFilter(int f) {
case FILTER_INACTIVE:
proxyModel->setFilterRegExp(QRegExp("[^"+QString::number(STATE_DOWNLOADING)+QString::number(STATE_SEEDING)+"]", Qt::CaseSensitive));
break;
case FILTER_PAUSED:
proxyModel->setFilterRegExp(QRegExp(QString::number(STATE_PAUSED_UP)+"|"+QString::number(STATE_PAUSED_DL)));
break;
default:
proxyModel->setFilterRegExp(QRegExp());
}

4
src/transferlistwidget.h

@ -41,7 +41,7 @@ class QTimer; @@ -41,7 +41,7 @@ class QTimer;
class TransferListDelegate;
class GUI;
enum TorrentFilter {FILTER_ALL, FILTER_DOWNLOADING, FILTER_COMPLETED, FILTER_ACTIVE, FILTER_INACTIVE};
enum TorrentFilter {FILTER_ALL, FILTER_DOWNLOADING, FILTER_COMPLETED, FILTER_PAUSED, FILTER_ACTIVE, FILTER_INACTIVE};
class TransferListWidget: public QTreeView {
Q_OBJECT
@ -116,7 +116,7 @@ protected slots: @@ -116,7 +116,7 @@ protected slots:
signals:
void currentTorrentChanged(QTorrentHandle &h);
void torrentStatusUpdate(unsigned int nb_downloading, unsigned int nb_seeding, unsigned int nb_active, unsigned int nb_inactive);
void torrentStatusUpdate(uint nb_downloading, uint nb_seeding, uint nb_active, uint nb_inactive, uint nb_paused);
void torrentAdded(QModelIndex index);
void torrentAboutToBeRemoved(QModelIndex index);
void torrentChangedLabel(QString old_label, QString new_label);

Loading…
Cancel
Save