Files
transmission/qt/TrackerModel.h
Yat Ho f495047a33 ci(qt): run clang-tidy on Linux (#8557)
* ci(qt): run clang-tidy

* chore(qt): silence warnings
2026-02-19 09:30:05 -06:00

55 lines
1.3 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 <vector>
#include <QAbstractListModel>
#include "Torrent.h"
#include "Typedefs.h"
class TorrentModel;
struct TrackerInfo
{
TrackerStat st;
int torrent_id = {};
};
Q_DECLARE_METATYPE(TrackerInfo)
class TrackerModel : public QAbstractListModel
{
Q_OBJECT
public:
// NOLINTNEXTLINE(performance-enum-size)
enum Role
{
TrackerRole = Qt::UserRole
};
TrackerModel() = default;
~TrackerModel() override = default;
TrackerModel(TrackerModel&&) = delete;
TrackerModel(TrackerModel const&) = delete;
TrackerModel& operator=(TrackerModel&&) = delete;
TrackerModel& operator=(TrackerModel const&) = delete;
void refresh(TorrentModel const& torrent_model, torrent_ids_t const& ids);
[[nodiscard]] int find(int torrent_id, QString const& url) const;
// QAbstractItemModel
[[nodiscard]] int rowCount(QModelIndex const& parent = QModelIndex{}) const override;
[[nodiscard]] QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const override;
private:
using rows_t = std::vector<TrackerInfo>;
rows_t rows_;
};