mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-21 07:57:22 -06:00
Speed up lookup operation in TransferListModel
Previously lookup is O(n), add operation is O(n), remove operation is O(n). Now lookup is O(1), add operation is O(1), remove operation is O(n). n is the number of torrents already recorded.
This commit is contained in:
@@ -84,8 +84,8 @@ public:
|
||||
|
||||
explicit TransferListModel(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &index = {}) const override;
|
||||
int columnCount(const QModelIndex &parent=QModelIndex()) const override;
|
||||
int rowCount(const QModelIndex &parent = {}) const override;
|
||||
int columnCount(const QModelIndex &parent = {}) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
@@ -100,7 +100,8 @@ private slots:
|
||||
void handleTorrentsUpdated(const QVector<BitTorrent::TorrentHandle *> &torrents);
|
||||
|
||||
private:
|
||||
QList<BitTorrent::TorrentHandle *> m_torrents;
|
||||
QList<BitTorrent::TorrentHandle *> m_torrentList; // maps row number to torrent handle
|
||||
QHash<BitTorrent::TorrentHandle *, int> m_torrentMap; // maps torrent handle to row number
|
||||
};
|
||||
|
||||
#endif // TRANSFERLISTMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user