mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
Fix transfer list architecture
Model returns string for DisplayRole. Text alignment is set by Model (using TextAlignmentRole). Delegate performs custom painting only where necessary (i.e. for Progress bar).
This commit is contained in:
@@ -34,11 +34,11 @@
|
||||
#include <QColor>
|
||||
#include <QList>
|
||||
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
class InfoHash;
|
||||
class TorrentHandle;
|
||||
enum class TorrentState;
|
||||
}
|
||||
|
||||
class TransferListModel : public QAbstractListModel
|
||||
@@ -84,6 +84,12 @@ public:
|
||||
NB_COLUMNS
|
||||
};
|
||||
|
||||
enum DataRole
|
||||
{
|
||||
UnderlyingDataRole = Qt::UserRole,
|
||||
AdditionalUnderlyingDataRole
|
||||
};
|
||||
|
||||
explicit TransferListModel(QObject *parent = nullptr);
|
||||
|
||||
int rowCount(const QModelIndex &parent = {}) const override;
|
||||
@@ -105,9 +111,12 @@ private slots:
|
||||
void handleTorrentsUpdated(const QVector<BitTorrent::TorrentHandle *> &torrents);
|
||||
|
||||
private:
|
||||
QString displayValue(const BitTorrent::TorrentHandle *torrent, int column) const;
|
||||
QVariant internalValue(const BitTorrent::TorrentHandle *torrent, int column, bool alt = false) const;
|
||||
|
||||
QList<BitTorrent::TorrentHandle *> m_torrentList; // maps row number to torrent handle
|
||||
QHash<BitTorrent::TorrentHandle *, int> m_torrentMap; // maps torrent handle to row number
|
||||
|
||||
const QHash<BitTorrent::TorrentState, QString> m_statusStrings;
|
||||
// row text colors
|
||||
QHash<BitTorrent::TorrentState, QColor> m_stateForegroundColors;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user