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 @@
- FEATURE: Added "No action" setting for double-click action - FEATURE: Added "No action" setting for double-click action
- FEATURE: Several torrents can be moved at once - FEATURE: Several torrents can be moved at once
- FEATURE: Added error state for torrents (error is displayed in a tooltip) - 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 peers country name in tooltip
- COSMETIC: Display number of torrents in transfers tab label - COSMETIC: Display number of torrents in transfers tab label

16
src/transferlistfilterswidget.h

@ -147,20 +147,20 @@ protected:
class StatusFiltersWidget : public QListWidget { class StatusFiltersWidget : public QListWidget {
public: public:
StatusFiltersWidget(QWidget *parent) : QListWidget(parent) { StatusFiltersWidget(QWidget *parent) : QListWidget(parent) {
setFixedHeight(100); setFixedHeight(120);
} }
protected: protected:
void changeEvent(QEvent *e) { void changeEvent(QEvent *e) {
QListWidget::changeEvent(e); QListWidget::changeEvent(e);
switch (e->type()) { switch (e->type()) {
case QEvent::StyleChange: case QEvent::StyleChange:
setSpacing(0); setSpacing(0);
setFixedHeight(100); setFixedHeight(120);
break; break;
default: default:
break; break;
} }
} }
}; };
@ -200,6 +200,9 @@ public:
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 *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"));
@ -209,7 +212,7 @@ public:
// SIGNAL/SLOT // SIGNAL/SLOT
connect(statusFilters, SIGNAL(currentRowChanged(int)), transferList, SLOT(applyStatusFilter(int))); 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(currentRowChanged(int)), this, SLOT(applyLabelFilter(int)));
connect(labelFilters, SIGNAL(torrentDropped(int)), this, SLOT(torrentDropped(int))); connect(labelFilters, SIGNAL(torrentDropped(int)), this, SLOT(torrentDropped(int)));
connect(transferList, SIGNAL(torrentAdded(QModelIndex)), this, SLOT(torrentAdded(QModelIndex))); connect(transferList, SIGNAL(torrentAdded(QModelIndex)), this, SLOT(torrentAdded(QModelIndex)));
@ -276,10 +279,11 @@ public:
} }
protected slots: 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_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_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_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_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)+")")); 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) {
setUpdatesEnabled(false); setUpdatesEnabled(false);
// Refresh only if displayed // Refresh only if displayed
if(!force && main_window->getCurrentTabIndex() != TAB_TRANSFER) return; 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()) { if(BTSession->getSession()->get_torrents().size() != (uint)listModel->rowCount()) {
// Oups, we have torrents that are not displayed, fix this // Oups, we have torrents that are not displayed, fix this
std::vector<torrent_handle> torrents = BTSession->getSession()->get_torrents(); std::vector<torrent_handle> torrents = BTSession->getSession()->get_torrents();
@ -509,10 +509,14 @@ void TransferListWidget::refreshList(bool force) {
case STATE_STALLED_DL: case STATE_STALLED_DL:
case STATE_CHECKING_DL: case STATE_CHECKING_DL:
case STATE_PAUSED_DL: case STATE_PAUSED_DL:
case STATE_QUEUED_DL: case STATE_QUEUED_DL: {
if(s == STATE_PAUSED_DL) {
++nb_paused;
}
++nb_inactive; ++nb_inactive;
++nb_downloading; ++nb_downloading;
break; break;
}
case STATE_SEEDING: case STATE_SEEDING:
++nb_active; ++nb_active;
++nb_seeding; ++nb_seeding;
@ -520,10 +524,14 @@ void TransferListWidget::refreshList(bool force) {
case STATE_STALLED_UP: case STATE_STALLED_UP:
case STATE_CHECKING_UP: case STATE_CHECKING_UP:
case STATE_PAUSED_UP: case STATE_PAUSED_UP:
case STATE_QUEUED_UP: case STATE_QUEUED_UP: {
if(s == STATE_PAUSED_UP) {
++nb_paused;
}
++nb_seeding; ++nb_seeding;
++nb_inactive; ++nb_inactive;
break; break;
}
case STATE_INVALID: case STATE_INVALID:
bad_hashes << getHashFromRow(i); bad_hashes << getHashFromRow(i);
break; break;
@ -538,7 +546,7 @@ void TransferListWidget::refreshList(bool force) {
deleteTorrent(row, false); deleteTorrent(row, false);
} }
// Update status filters counters // 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 // Start updating the display
setUpdatesEnabled(true); setUpdatesEnabled(true);
} }
@ -1358,6 +1366,9 @@ void TransferListWidget::applyStatusFilter(int f) {
case FILTER_INACTIVE: case FILTER_INACTIVE:
proxyModel->setFilterRegExp(QRegExp("[^"+QString::number(STATE_DOWNLOADING)+QString::number(STATE_SEEDING)+"]", Qt::CaseSensitive)); proxyModel->setFilterRegExp(QRegExp("[^"+QString::number(STATE_DOWNLOADING)+QString::number(STATE_SEEDING)+"]", Qt::CaseSensitive));
break; break;
case FILTER_PAUSED:
proxyModel->setFilterRegExp(QRegExp(QString::number(STATE_PAUSED_UP)+"|"+QString::number(STATE_PAUSED_DL)));
break;
default: default:
proxyModel->setFilterRegExp(QRegExp()); proxyModel->setFilterRegExp(QRegExp());
} }

4
src/transferlistwidget.h

@ -41,7 +41,7 @@ class QTimer;
class TransferListDelegate; class TransferListDelegate;
class GUI; 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 { class TransferListWidget: public QTreeView {
Q_OBJECT Q_OBJECT
@ -116,7 +116,7 @@ protected slots:
signals: signals:
void currentTorrentChanged(QTorrentHandle &h); 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 torrentAdded(QModelIndex index);
void torrentAboutToBeRemoved(QModelIndex index); void torrentAboutToBeRemoved(QModelIndex index);
void torrentChangedLabel(QString old_label, QString new_label); void torrentChangedLabel(QString old_label, QString new_label);

Loading…
Cancel
Save