2023-11-01 21:11:11 +00:00
|
|
|
// This file Copyright © Mnemosyne LLC.
|
2023-01-08 15:31:03 +00:00
|
|
|
// 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 "GtkCompat.h"
|
|
|
|
|
2023-01-21 12:06:20 +00:00
|
|
|
#include <libtransmission/tr-macros.h>
|
|
|
|
|
2023-01-08 15:31:03 +00:00
|
|
|
#if GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
#include <gtkmm/filter.h>
|
|
|
|
#else
|
|
|
|
#include <glibmm/object.h>
|
|
|
|
#endif
|
|
|
|
|
2024-01-08 14:32:58 +00:00
|
|
|
#include <cstdint>
|
|
|
|
|
2023-01-08 15:31:03 +00:00
|
|
|
template<typename T>
|
|
|
|
class FilterBase : public IF_GTKMM4(Gtk::Filter, Glib::Object)
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
#if !GTKMM_CHECK_VERSION(4, 0, 0)
|
2024-01-08 14:32:58 +00:00
|
|
|
enum class Change : uint8_t{
|
2023-01-08 15:31:03 +00:00
|
|
|
DIFFERENT,
|
|
|
|
LESS_STRICT,
|
|
|
|
MORE_STRICT,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
public:
|
2023-01-21 12:06:20 +00:00
|
|
|
FilterBase() = default;
|
2023-01-08 15:31:03 +00:00
|
|
|
~FilterBase() override = default;
|
|
|
|
|
2023-01-21 12:06:20 +00:00
|
|
|
TR_DISABLE_COPY_MOVE(FilterBase)
|
|
|
|
|
2023-01-08 15:31:03 +00:00
|
|
|
virtual bool match(T const& item) const = 0;
|
|
|
|
|
|
|
|
virtual bool matches_all() const;
|
|
|
|
virtual bool matches_none() const;
|
|
|
|
|
|
|
|
#if !GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
sigc::signal<void(Change)>& signal_changed();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
protected:
|
|
|
|
#if GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
// Gtk::Filter
|
|
|
|
bool match_vfunc(Glib::RefPtr<Glib::ObjectBase> const& object) override;
|
|
|
|
Match get_strictness_vfunc() override;
|
|
|
|
#else
|
|
|
|
void changed(Change change);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
#if !GTKMM_CHECK_VERSION(4, 0, 0)
|
|
|
|
sigc::signal<void(Change)> signal_changed_;
|
|
|
|
#endif
|
|
|
|
};
|