Files
transmission/gtk/TorrentFilter.h
Charles Kerr 554cc56bdf refactor: rename our namespace to tr (#8256)
tr and tr::app are less cluttered than libtransmission:: and transmission::app
2026-01-28 18:11:34 -06:00

59 lines
1.5 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.
#pragma once
#include "FilterBase.h"
#include "Torrent.h"
#include <libtransmission-app/display-modes.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <cstdint>
class TorrentFilter : public FilterBase<Torrent>
{
public:
using ShowMode = tr::app::ShowMode;
enum class Tracker : int8_t
{
ALL,
HOST,
};
public:
void set_mode(ShowMode mode);
void set_tracker(Tracker type, Glib::ustring const& host);
void set_text(Glib::ustring const& text);
bool match_mode(Torrent const& torrent) const;
bool match_text(Torrent const& torrent) const;
bool match_tracker(Torrent const& torrent) const;
// FilterBase<Torrent>
bool match(Torrent const& torrent) const override;
bool matches_all() const override;
void update(Torrent::ChangeFlags changes);
static Glib::RefPtr<TorrentFilter> create();
static bool match_mode(Torrent const& torrent, ShowMode mode);
static bool match_tracker(Torrent const& torrent, Tracker type, Glib::ustring const& host);
static bool match_text(Torrent const& torrent, Glib::ustring const& text);
private:
TorrentFilter();
private:
ShowMode show_mode_ = tr::app::DefaultShowMode;
Tracker tracker_type_ = Tracker::ALL;
Glib::ustring tracker_host_;
Glib::ustring text_;
};