Browse Source

Properly pre-select the selected torrent's current ratio limiting options in UpDownRatioDlg dialogs. Fixes #7352

adaptive-webui-19844
thalieht 7 years ago
parent
commit
f27e75e8fa
  1. 2
      src/base/bittorrent/session.cpp
  2. 36
      src/base/bittorrent/torrenthandle.cpp
  3. 4
      src/base/bittorrent/torrenthandle.h
  4. 10
      src/gui/transferlistwidget.cpp

2
src/base/bittorrent/session.cpp

@ -3383,7 +3383,7 @@ bool Session::isKnownTorrent(const InfoHash &hash) const @@ -3383,7 +3383,7 @@ bool Session::isKnownTorrent(const InfoHash &hash) const
void Session::updateSeedingLimitTimer()
{
if ((globalMaxRatio() == -1) && !hasPerTorrentRatioLimit()
if ((globalMaxRatio() == TorrentHandle::NO_RATIO_LIMIT) && !hasPerTorrentRatioLimit()
&& (globalMaxSeedingMinutes() == TorrentHandle::NO_SEEDING_TIME_LIMIT) && !hasPerTorrentSeedingTimeLimit()) {
if (m_seedingLimitTimer->isActive())
m_seedingLimitTimer->stop();

36
src/base/bittorrent/torrenthandle.cpp

@ -1180,38 +1180,20 @@ qreal TorrentHandle::distributedCopies() const @@ -1180,38 +1180,20 @@ qreal TorrentHandle::distributedCopies() const
return m_nativeStatus.distributed_copies;
}
qreal TorrentHandle::maxRatio(bool *usesGlobalRatio) const
qreal TorrentHandle::maxRatio() const
{
qreal ratioLimit = m_ratioLimit;
if (m_ratioLimit == USE_GLOBAL_RATIO)
return m_session->globalMaxRatio();
if (ratioLimit == USE_GLOBAL_RATIO) {
ratioLimit = m_session->globalMaxRatio();
if (usesGlobalRatio)
*usesGlobalRatio = true;
}
else {
if (usesGlobalRatio)
*usesGlobalRatio = false;
}
return ratioLimit;
return m_ratioLimit;
}
int TorrentHandle::maxSeedingTime(bool *usesGlobalSeedingTime) const
int TorrentHandle::maxSeedingTime() const
{
int seedingTimeLimit = m_seedingTimeLimit;
if (m_seedingTimeLimit == USE_GLOBAL_SEEDING_TIME)
return m_session->globalMaxSeedingMinutes();
if (seedingTimeLimit == USE_GLOBAL_SEEDING_TIME) {
seedingTimeLimit = m_session->globalMaxSeedingMinutes();
if (usesGlobalSeedingTime)
*usesGlobalSeedingTime = true;
}
else {
if (usesGlobalSeedingTime)
*usesGlobalSeedingTime = false;
}
return seedingTimeLimit;
return m_seedingTimeLimit;
}
qreal TorrentHandle::realRatio() const
@ -1688,7 +1670,7 @@ void TorrentHandle::handleSaveResumeDataAlert(libtorrent::save_resume_data_alert @@ -1688,7 +1670,7 @@ void TorrentHandle::handleSaveResumeDataAlert(libtorrent::save_resume_data_alert
}
resumeData["qBt-savePath"] = m_useAutoTMM ? "" : Profile::instance().toPortablePath(m_savePath).toStdString();
resumeData["qBt-ratioLimit"] = QString::number(m_ratioLimit).toStdString();
resumeData["qBt-seedingTimeLimit"] = QString::number(m_seedingTimeLimit).toStdString();
resumeData["qBt-seedingTimeLimit"] = m_seedingTimeLimit;
resumeData["qBt-category"] = m_category.toStdString();
resumeData["qBt-tags"] = setToEntryList(m_tags);
resumeData["qBt-name"] = m_name.toStdString();

4
src/base/bittorrent/torrenthandle.h

@ -328,8 +328,8 @@ namespace BitTorrent @@ -328,8 +328,8 @@ namespace BitTorrent
QBitArray downloadingPieces() const;
QVector<int> pieceAvailability() const;
qreal distributedCopies() const;
qreal maxRatio(bool *usesGlobalRatio = 0) const;
int maxSeedingTime(bool *usesGlobalSeedingTime = 0) const;
qreal maxRatio() const;
int maxSeedingTime() const;
qreal realRatio() const;
int uploadPayloadRate() const;
int downloadPayloadRate() const;

10
src/gui/transferlistwidget.cpp

@ -627,14 +627,18 @@ void TransferListWidget::setMaxRatioSelectedTorrents() @@ -627,14 +627,18 @@ void TransferListWidget::setMaxRatioSelectedTorrents()
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
if (torrents.isEmpty()) return;
bool useGlobalValue = true;
qreal currentMaxRatio = BitTorrent::Session::instance()->globalMaxRatio();
if (torrents.count() == 1)
currentMaxRatio = torrents[0]->maxRatio(&useGlobalValue);
currentMaxRatio = torrents[0]->maxRatio();
int currentMaxSeedingTime = BitTorrent::Session::instance()->globalMaxSeedingMinutes();
if (torrents.count() == 1)
currentMaxSeedingTime = torrents[0]->maxSeedingTime(&useGlobalValue);
currentMaxSeedingTime = torrents[0]->maxSeedingTime();
bool useGlobalValue = true;
if (torrents.count() == 1)
useGlobalValue = (torrents[0]->ratioLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_RATIO)
&& (torrents[0]->seedingTimeLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME);
UpDownRatioDlg dlg(useGlobalValue, currentMaxRatio, BitTorrent::TorrentHandle::MAX_RATIO,
currentMaxSeedingTime, BitTorrent::TorrentHandle::MAX_SEEDING_TIME, this);

Loading…
Cancel
Save