Files
transmission/gtk/TorrentFilter.h
Charles Kerr d5314e2c44 refactor: add libtransmission-app (#7978)
* 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
2025-12-22 20:05:57 -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 = transmission::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_ = transmission::app::DefaultShowMode;
Tracker tracker_type_ = Tracker::ALL;
Glib::ustring tracker_host_;
Glib::ustring text_;
};