FEATURE: Added filter for paused/error torrents

This commit is contained in:
Christophe Dumez 2010-05-24 15:16:14 +00:00
parent 1a0cc3215c
commit 607bba4625
4 changed files with 35 additions and 19 deletions

View file

@ -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

View file

@ -147,20 +147,20 @@ protected:
class StatusFiltersWidget : public QListWidget {
public:
StatusFiltersWidget(QWidget *parent) : QListWidget(parent) {
setFixedHeight(100);
setFixedHeight(120);
}
protected:
void changeEvent(QEvent *e) {
QListWidget::changeEvent(e);
switch (e->type()) {
case QEvent::StyleChange:
setSpacing(0);
setFixedHeight(100);
break;
default:
break;
void changeEvent(QEvent *e) {
QListWidget::changeEvent(e);
switch (e->type()) {
case QEvent::StyleChange:
setSpacing(0);
setFixedHeight(120);
break;
default:
break;
}
}
}
};
@ -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:
// 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:
}
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)+")"));
}

View file

@ -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) {
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) {
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) {
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) {
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());
}

View file

@ -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:
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);