|
|
@ -105,6 +105,9 @@ TransferListModel::TransferListModel(QObject *parent) |
|
|
|
{BitTorrent::TorrentState::Error, getColorByState(BitTorrent::TorrentState::Error)} |
|
|
|
{BitTorrent::TorrentState::Error, getColorByState(BitTorrent::TorrentState::Error)} |
|
|
|
} |
|
|
|
} |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
configure(); |
|
|
|
|
|
|
|
connect(Preferences::instance(), &Preferences::changed, this, &TransferListModel::configure); |
|
|
|
|
|
|
|
|
|
|
|
// Load the torrents
|
|
|
|
// Load the torrents
|
|
|
|
using namespace BitTorrent; |
|
|
|
using namespace BitTorrent; |
|
|
|
for (TorrentHandle *const torrent : asConst(Session::instance()->torrents())) |
|
|
|
for (TorrentHandle *const torrent : asConst(Session::instance()->torrents())) |
|
|
@ -205,9 +208,11 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation, |
|
|
|
|
|
|
|
|
|
|
|
QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent, const int column) const |
|
|
|
QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent, const int column) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
const bool isHideState = (Preferences::instance()->getHideZeroComboValues() == 0) |
|
|
|
bool hideValues = false; |
|
|
|
|| (torrent->state() == BitTorrent::TorrentState::PausedDownloading); // paused torrents only
|
|
|
|
if (m_hideZeroValuesMode == HideZeroValuesMode::Always) |
|
|
|
const bool hideValues = Preferences::instance()->getHideZeroValues() && isHideState; |
|
|
|
hideValues = true; |
|
|
|
|
|
|
|
else if (m_hideZeroValuesMode != HideZeroValuesMode::Never) |
|
|
|
|
|
|
|
hideValues = (torrent->state() == BitTorrent::TorrentState::PausedDownloading); |
|
|
|
|
|
|
|
|
|
|
|
const auto availabilityString = [hideValues](const qreal value) -> QString |
|
|
|
const auto availabilityString = [hideValues](const qreal value) -> QString |
|
|
|
{ |
|
|
|
{ |
|
|
@ -575,6 +580,24 @@ void TransferListModel::handleTorrentsUpdated(const QVector<BitTorrent::TorrentH |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TransferListModel::configure() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const Preferences *pref = Preferences::instance(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HideZeroValuesMode hideZeroValuesMode = HideZeroValuesMode::Never; |
|
|
|
|
|
|
|
if (pref->getHideZeroValues()) { |
|
|
|
|
|
|
|
if (pref->getHideZeroComboValues() == 1) |
|
|
|
|
|
|
|
hideZeroValuesMode = HideZeroValuesMode::Paused; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
hideZeroValuesMode = HideZeroValuesMode::Always; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (m_hideZeroValuesMode != hideZeroValuesMode) { |
|
|
|
|
|
|
|
m_hideZeroValuesMode = hideZeroValuesMode; |
|
|
|
|
|
|
|
emit dataChanged(index(0, 0), index((rowCount() - 1), (columnCount() - 1))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListModel::setStateForeground(const BitTorrent::TorrentState state, const QColor &color) |
|
|
|
void TransferListModel::setStateForeground(const BitTorrent::TorrentState state, const QColor &color) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_stateForegroundColors[state] = color; |
|
|
|
m_stateForegroundColors[state] = color; |
|
|
|