Browse Source

Add a "Moving" status filter

Because sometime (when your save and download path are on different drives, when your disk drive is super busy, ...) move operations can stack up, I add this "Moving" status filter so you can see in a blink of the eye which torrents are in a move state.

PR #17810.
adaptive-webui-19844
tristanleboss 2 years ago committed by GitHub
parent
commit
e028d8085b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/base/bittorrent/torrent.h
  2. 5
      src/base/bittorrent/torrentimpl.cpp
  3. 1
      src/base/bittorrent/torrentimpl.h
  4. 5
      src/base/torrentfilter.cpp
  5. 2
      src/base/torrentfilter.h
  6. 7
      src/gui/transferlistfilterswidget.cpp
  7. 1
      src/gui/transferlistfilterswidget.h

1
src/base/bittorrent/torrent.h

@ -222,6 +222,7 @@ namespace BitTorrent
virtual bool isForced() const = 0; virtual bool isForced() const = 0;
virtual bool isChecking() const = 0; virtual bool isChecking() const = 0;
virtual bool isDownloading() const = 0; virtual bool isDownloading() const = 0;
virtual bool isMoving() const = 0;
virtual bool isUploading() const = 0; virtual bool isUploading() const = 0;
virtual bool isCompleted() const = 0; virtual bool isCompleted() const = 0;
virtual bool isActive() const = 0; virtual bool isActive() const = 0;

5
src/base/bittorrent/torrentimpl.cpp

@ -873,6 +873,11 @@ bool TorrentImpl::isDownloading() const
return false; return false;
} }
bool TorrentImpl::isMoving() const
{
return m_state == TorrentState::Moving;
}
bool TorrentImpl::isUploading() const bool TorrentImpl::isUploading() const
{ {
switch (m_state) switch (m_state)

1
src/base/bittorrent/torrentimpl.h

@ -145,6 +145,7 @@ namespace BitTorrent
bool isForced() const override; bool isForced() const override;
bool isChecking() const override; bool isChecking() const override;
bool isDownloading() const override; bool isDownloading() const override;
bool isMoving() const override;
bool isUploading() const override; bool isUploading() const override;
bool isCompleted() const override; bool isCompleted() const override;
bool isActive() const override; bool isActive() const override;

5
src/base/torrentfilter.cpp

@ -46,6 +46,7 @@ const TorrentFilter TorrentFilter::StalledTorrent(TorrentFilter::Stalled);
const TorrentFilter TorrentFilter::StalledUploadingTorrent(TorrentFilter::StalledUploading); const TorrentFilter TorrentFilter::StalledUploadingTorrent(TorrentFilter::StalledUploading);
const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::StalledDownloading); const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::StalledDownloading);
const TorrentFilter TorrentFilter::CheckingTorrent(TorrentFilter::Checking); const TorrentFilter TorrentFilter::CheckingTorrent(TorrentFilter::Checking);
const TorrentFilter TorrentFilter::MovingTorrent(TorrentFilter::Moving);
const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored); const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored);
using BitTorrent::Torrent; using BitTorrent::Torrent;
@ -106,6 +107,8 @@ bool TorrentFilter::setTypeByName(const QString &filter)
type = StalledDownloading; type = StalledDownloading;
else if (filter == u"checking") else if (filter == u"checking")
type = Checking; type = Checking;
else if (filter == u"moving")
type = Moving;
else if (filter == u"errored") else if (filter == u"errored")
type = Errored; type = Errored;
@ -184,6 +187,8 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const
return (torrent->state() == BitTorrent::TorrentState::CheckingUploading) return (torrent->state() == BitTorrent::TorrentState::CheckingUploading)
|| (torrent->state() == BitTorrent::TorrentState::CheckingDownloading) || (torrent->state() == BitTorrent::TorrentState::CheckingDownloading)
|| (torrent->state() == BitTorrent::TorrentState::CheckingResumeData); || (torrent->state() == BitTorrent::TorrentState::CheckingResumeData);
case Moving:
return torrent->isMoving();
case Errored: case Errored:
return torrent->isErrored(); return torrent->isErrored();
} }

2
src/base/torrentfilter.h

@ -59,6 +59,7 @@ public:
StalledUploading, StalledUploading,
StalledDownloading, StalledDownloading,
Checking, Checking,
Moving,
Errored Errored
}; };
@ -78,6 +79,7 @@ public:
static const TorrentFilter StalledUploadingTorrent; static const TorrentFilter StalledUploadingTorrent;
static const TorrentFilter StalledDownloadingTorrent; static const TorrentFilter StalledDownloadingTorrent;
static const TorrentFilter CheckingTorrent; static const TorrentFilter CheckingTorrent;
static const TorrentFilter MovingTorrent;
static const TorrentFilter ErroredTorrent; static const TorrentFilter ErroredTorrent;
TorrentFilter() = default; TorrentFilter() = default;

7
src/gui/transferlistfilterswidget.cpp

@ -207,6 +207,9 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran
auto *checking = new QListWidgetItem(this); auto *checking = new QListWidgetItem(this);
checking->setData(Qt::DisplayRole, tr("Checking (0)")); checking->setData(Qt::DisplayRole, tr("Checking (0)"));
checking->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"force-recheck"_qs)); checking->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"force-recheck"_qs));
auto *moving = new QListWidgetItem(this);
moving->setData(Qt::DisplayRole, tr("Moving (0)"));
moving->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"set-location"_qs));
auto *errored = new QListWidgetItem(this); auto *errored = new QListWidgetItem(this);
errored->setData(Qt::DisplayRole, tr("Errored (0)")); errored->setData(Qt::DisplayRole, tr("Errored (0)"));
errored->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"error"_qs)); errored->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"error"_qs));
@ -267,6 +270,7 @@ void StatusFilterWidget::updateTorrentStatus(const BitTorrent::Torrent *torrent)
update(TorrentFilter::StalledUploading, m_nbStalledUploading); update(TorrentFilter::StalledUploading, m_nbStalledUploading);
update(TorrentFilter::StalledDownloading, m_nbStalledDownloading); update(TorrentFilter::StalledDownloading, m_nbStalledDownloading);
update(TorrentFilter::Checking, m_nbChecking); update(TorrentFilter::Checking, m_nbChecking);
update(TorrentFilter::Moving, m_nbMoving);
update(TorrentFilter::Errored, m_nbErrored); update(TorrentFilter::Errored, m_nbErrored);
m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading; m_nbStalled = m_nbStalledUploading + m_nbStalledDownloading;
@ -287,6 +291,7 @@ void StatusFilterWidget::updateTexts()
item(TorrentFilter::StalledUploading)->setData(Qt::DisplayRole, tr("Stalled Uploading (%1)").arg(m_nbStalledUploading)); item(TorrentFilter::StalledUploading)->setData(Qt::DisplayRole, tr("Stalled Uploading (%1)").arg(m_nbStalledUploading));
item(TorrentFilter::StalledDownloading)->setData(Qt::DisplayRole, tr("Stalled Downloading (%1)").arg(m_nbStalledDownloading)); item(TorrentFilter::StalledDownloading)->setData(Qt::DisplayRole, tr("Stalled Downloading (%1)").arg(m_nbStalledDownloading));
item(TorrentFilter::Checking)->setData(Qt::DisplayRole, tr("Checking (%1)").arg(m_nbChecking)); item(TorrentFilter::Checking)->setData(Qt::DisplayRole, tr("Checking (%1)").arg(m_nbChecking));
item(TorrentFilter::Moving)->setData(Qt::DisplayRole, tr("Moving (%1)").arg(m_nbMoving));
item(TorrentFilter::Errored)->setData(Qt::DisplayRole, tr("Errored (%1)").arg(m_nbErrored)); item(TorrentFilter::Errored)->setData(Qt::DisplayRole, tr("Errored (%1)").arg(m_nbErrored));
} }
@ -350,6 +355,8 @@ void StatusFilterWidget::torrentAboutToBeDeleted(BitTorrent::Torrent *const torr
--m_nbStalledDownloading; --m_nbStalledDownloading;
if (status[TorrentFilter::Checking]) if (status[TorrentFilter::Checking])
--m_nbChecking; --m_nbChecking;
if (status[TorrentFilter::Moving])
--m_nbMoving;
if (status[TorrentFilter::Errored]) if (status[TorrentFilter::Errored])
--m_nbErrored; --m_nbErrored;

1
src/gui/transferlistfilterswidget.h

@ -114,6 +114,7 @@ private:
int m_nbStalledUploading = 0; int m_nbStalledUploading = 0;
int m_nbStalledDownloading = 0; int m_nbStalledDownloading = 0;
int m_nbChecking = 0; int m_nbChecking = 0;
int m_nbMoving = 0;
int m_nbErrored = 0; int m_nbErrored = 0;
}; };

Loading…
Cancel
Save