2023-01-08 15:31:03 +00:00
|
|
|
// This file Copyright © 2022-2023 Mnemosyne LLC.
|
2022-12-21 21:26:25 +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
|
|
|
|
|
2023-01-08 15:31:03 +00:00
|
|
|
#include "SorterBase.h"
|
2022-12-26 21:13:21 +00:00
|
|
|
#include "Torrent.h"
|
2022-12-21 21:26:25 +00:00
|
|
|
|
2022-12-27 01:43:20 +00:00
|
|
|
#include <glibmm/refptr.h>
|
|
|
|
|
2023-01-08 15:31:03 +00:00
|
|
|
class TorrentSorter : public SorterBase<Torrent>
|
2022-12-21 21:26:25 +00:00
|
|
|
{
|
|
|
|
using CompareFunc = int (*)(Torrent const&, Torrent const&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_mode(std::string_view mode);
|
|
|
|
void set_reversed(bool is_reversed);
|
|
|
|
|
2023-01-08 15:31:03 +00:00
|
|
|
// SorterBase<Torrent>
|
|
|
|
int compare(Torrent const& lhs, Torrent const& rhs) const override;
|
2022-12-21 21:26:25 +00:00
|
|
|
|
|
|
|
void update(Torrent::ChangeFlags changes);
|
|
|
|
|
|
|
|
static Glib::RefPtr<TorrentSorter> create();
|
|
|
|
|
|
|
|
private:
|
|
|
|
TorrentSorter();
|
|
|
|
|
|
|
|
private:
|
|
|
|
CompareFunc compare_func_ = nullptr;
|
|
|
|
bool is_reversed_ = false;
|
|
|
|
};
|