mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
fa091495d6
* Refactor sorting and filtering compatibility code Factor out parts of `TorrentFilter` and `TorrentSorter` classes into reusable `FilterBase<>` and `SorterBase<>` templates. Factor out filter and sort models setup from `FilterBar` and `Session` classes into reusable `FilterListModel<>` and `SortListModel<>` templates. * Remove unused lambda capture (Clang build failure)
34 lines
848 B
C++
34 lines
848 B
C++
// This file Copyright © 2022-2023 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 "SorterBase.h"
|
|
#include "Torrent.h"
|
|
|
|
#include <glibmm/refptr.h>
|
|
|
|
class TorrentSorter : public SorterBase<Torrent>
|
|
{
|
|
using CompareFunc = int (*)(Torrent const&, Torrent const&);
|
|
|
|
public:
|
|
void set_mode(std::string_view mode);
|
|
void set_reversed(bool is_reversed);
|
|
|
|
// SorterBase<Torrent>
|
|
int compare(Torrent const& lhs, Torrent const& rhs) const override;
|
|
|
|
void update(Torrent::ChangeFlags changes);
|
|
|
|
static Glib::RefPtr<TorrentSorter> create();
|
|
|
|
private:
|
|
TorrentSorter();
|
|
|
|
private:
|
|
CompareFunc compare_func_ = nullptr;
|
|
bool is_reversed_ = false;
|
|
};
|