mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
* refactor: add libtransmission-app * refactor: add libtransmission-app/display-modes.h * refactor: use app::SortMode, app:ShowMode in Qt client * feat: add to_variant(), to_value() in serializer * refactor: use app::SortMode in GTK client * refactor: use app::ShowMode in GTK client * refactor: make naming consistent with libtransmission-app
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
// This file Copyright © Mnemosyne LLC.
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
// License text can be found in the licenses/ folder.
|
|
|
|
#include "Filters.h"
|
|
|
|
// NOTE: `ShowModeFields` is the set of all Torrent properties
|
|
// needed to correctly run these tests. If you change these tests,
|
|
// then update `ShowModeFields` accordingly.
|
|
bool should_show_torrent(Torrent const& tor, ShowMode const mode)
|
|
{
|
|
switch (mode)
|
|
{
|
|
case ShowMode::ShowActive:
|
|
return tor.peersWeAreUploadingTo() > 0 || tor.peersWeAreDownloadingFrom() > 0 || tor.isVerifying();
|
|
|
|
case ShowMode::ShowDownloading:
|
|
return tor.isDownloading() || tor.isWaitingToDownload();
|
|
|
|
case ShowMode::ShowError:
|
|
return tor.hasError();
|
|
|
|
case ShowMode::ShowFinished:
|
|
return tor.isFinished();
|
|
|
|
case ShowMode::ShowPaused:
|
|
return tor.isPaused();
|
|
|
|
case ShowMode::ShowSeeding:
|
|
return tor.isSeeding() || tor.isWaitingToSeed();
|
|
|
|
case ShowMode::ShowVerifying:
|
|
return tor.isVerifying() || tor.isWaitingToVerify();
|
|
|
|
default: // SHOW_ALL
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// The Torrent properties that can affect ShowMode filtering.
|
|
// When one of these changes, it's time to refilter.
|
|
// Update this as needed when ShowModeTests changes.
|
|
Torrent::fields_t const ShowModeFields{
|
|
(uint64_t{ 1 } << Torrent::TORRENT_ERROR) | //
|
|
(uint64_t{ 1 } << Torrent::IS_FINISHED) | //
|
|
(uint64_t{ 1 } << Torrent::PEERS_GETTING_FROM_US) | //
|
|
(uint64_t{ 1 } << Torrent::PEERS_SENDING_TO_US) | //
|
|
(uint64_t{ 1 } << Torrent::STATUS) //
|
|
};
|