mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Merge pull request #14562 from Chocobo1/disable
Show progress bar in disabled state for paused torrents
This commit is contained in:
commit
f55e0b6775
2
INSTALL
2
INSTALL
@ -11,7 +11,7 @@ qBittorrent - A BitTorrent client in C++ / Qt
|
|||||||
|
|
||||||
- OpenSSL >= 1.1.1
|
- OpenSSL >= 1.1.1
|
||||||
|
|
||||||
- Qt >= 5.9.5
|
- Qt >= 5.12
|
||||||
|
|
||||||
- zlib >= 1.2.11
|
- zlib >= 1.2.11
|
||||||
|
|
||||||
|
@ -68,9 +68,30 @@ void TransferListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
{
|
{
|
||||||
case TransferListModel::TR_PROGRESS:
|
case TransferListModel::TR_PROGRESS:
|
||||||
{
|
{
|
||||||
|
using namespace BitTorrent;
|
||||||
|
|
||||||
|
const auto isEnableState = [](const TorrentState state) -> bool
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case TorrentState::Error:
|
||||||
|
case TorrentState::PausedDownloading:
|
||||||
|
case TorrentState::Unknown:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int progress = static_cast<int>(index.data(TransferListModel::UnderlyingDataRole).toReal());
|
const int progress = static_cast<int>(index.data(TransferListModel::UnderlyingDataRole).toReal());
|
||||||
|
|
||||||
m_progressBarPainter.paint(painter, option, index.data().toString(), progress);
|
const QModelIndex statusIndex = index.siblingAtColumn(TransferListModel::TR_STATUS);
|
||||||
|
const auto torrentState = statusIndex.data(TransferListModel::UnderlyingDataRole).value<TorrentState>();
|
||||||
|
|
||||||
|
QStyleOptionViewItem customOption {option};
|
||||||
|
customOption.state.setFlag(QStyle::State_Enabled, isEnableState(torrentState));
|
||||||
|
|
||||||
|
m_progressBarPainter.paint(painter, customOption, index.data().toString(), progress);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -498,7 +498,7 @@ QVariant TransferListModel::data(const QModelIndex &index, const int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
return displayValue(torrent, index.column());
|
return displayValue(torrent, index.column());
|
||||||
case UnderlyingDataRole:
|
case UnderlyingDataRole:
|
||||||
return internalValue(torrent, index.column());
|
return internalValue(torrent, index.column(), false);
|
||||||
case AdditionalUnderlyingDataRole:
|
case AdditionalUnderlyingDataRole:
|
||||||
return internalValue(torrent, index.column(), true);
|
return internalValue(torrent, index.column(), true);
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
|
@ -110,7 +110,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void configure();
|
void configure();
|
||||||
QString displayValue(const BitTorrent::Torrent *torrent, int column) const;
|
QString displayValue(const BitTorrent::Torrent *torrent, int column) const;
|
||||||
QVariant internalValue(const BitTorrent::Torrent *torrent, int column, bool alt = false) const;
|
QVariant internalValue(const BitTorrent::Torrent *torrent, int column, bool alt) const;
|
||||||
|
|
||||||
QList<BitTorrent::Torrent *> m_torrentList; // maps row number to torrent handle
|
QList<BitTorrent::Torrent *> m_torrentList; // maps row number to torrent handle
|
||||||
QHash<BitTorrent::Torrent *, int> m_torrentMap; // maps torrent handle to row number
|
QHash<BitTorrent::Torrent *, int> m_torrentMap; // maps torrent handle to row number
|
||||||
|
Loading…
Reference in New Issue
Block a user