mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-14 16:57:55 +00:00
Use completed time from libtorrent directly. Closes #1726.
This commit is contained in:
parent
07f76f4939
commit
d58d87a691
@ -2969,7 +2969,6 @@ void QBtSession::recoverPersistentData(const QString &hash, const std::vector<ch
|
|||||||
qreal ratioLimit = QString::fromUtf8(fast.dict_find_string_value("qBt-ratioLimit").c_str()).toDouble();
|
qreal ratioLimit = QString::fromUtf8(fast.dict_find_string_value("qBt-ratioLimit").c_str()).toDouble();
|
||||||
QDateTime addedDate = QDateTime::fromTime_t(fast.dict_find_int_value("added_time"));
|
QDateTime addedDate = QDateTime::fromTime_t(fast.dict_find_int_value("added_time"));
|
||||||
QString previousSavePath = QString::fromUtf8(fast.dict_find_string_value("qBt-previousSavePath").c_str());
|
QString previousSavePath = QString::fromUtf8(fast.dict_find_string_value("qBt-previousSavePath").c_str());
|
||||||
QDateTime seedDate = QDateTime::fromTime_t(fast.dict_find_int_value("qBt-seedDate"));
|
|
||||||
QString label = QString::fromUtf8(fast.dict_find_string_value("qBt-label").c_str());
|
QString label = QString::fromUtf8(fast.dict_find_string_value("qBt-label").c_str());
|
||||||
int priority = fast.dict_find_int_value("qBt-queuePosition");
|
int priority = fast.dict_find_int_value("qBt-queuePosition");
|
||||||
bool seedStatus = fast.dict_find_int_value("qBt-seedStatus");
|
bool seedStatus = fast.dict_find_int_value("qBt-seedStatus");
|
||||||
@ -2978,7 +2977,6 @@ void QBtSession::recoverPersistentData(const QString &hash, const std::vector<ch
|
|||||||
TorrentPersistentData::setRatioLimit(hash, ratioLimit);
|
TorrentPersistentData::setRatioLimit(hash, ratioLimit);
|
||||||
TorrentPersistentData::setAddedDate(hash, addedDate);
|
TorrentPersistentData::setAddedDate(hash, addedDate);
|
||||||
TorrentPersistentData::setPreviousSavePath(hash, previousSavePath);
|
TorrentPersistentData::setPreviousSavePath(hash, previousSavePath);
|
||||||
TorrentPersistentData::saveSeedDate(hash, seedDate);
|
|
||||||
TorrentPersistentData::saveLabel(hash, label);
|
TorrentPersistentData::saveLabel(hash, label);
|
||||||
TorrentPersistentData::savePriority(hash, priority);
|
TorrentPersistentData::savePriority(hash, priority);
|
||||||
TorrentPersistentData::saveSeedStatus(hash, seedStatus);
|
TorrentPersistentData::saveSeedStatus(hash, seedStatus);
|
||||||
@ -2988,7 +2986,6 @@ void QBtSession::backupPersistentData(const QString &hash, boost::shared_ptr<lib
|
|||||||
(*data)["qBt-savePath"] = fsutils::fromNativePath(TorrentPersistentData::getSavePath(hash)).toUtf8().constData();
|
(*data)["qBt-savePath"] = fsutils::fromNativePath(TorrentPersistentData::getSavePath(hash)).toUtf8().constData();
|
||||||
(*data)["qBt-ratioLimit"] = QString::number(TorrentPersistentData::getRatioLimit(hash)).toUtf8().constData();
|
(*data)["qBt-ratioLimit"] = QString::number(TorrentPersistentData::getRatioLimit(hash)).toUtf8().constData();
|
||||||
(*data)["qBt-previousSavePath"] = fsutils::fromNativePath(TorrentPersistentData::getPreviousPath(hash)).toUtf8().constData();
|
(*data)["qBt-previousSavePath"] = fsutils::fromNativePath(TorrentPersistentData::getPreviousPath(hash)).toUtf8().constData();
|
||||||
(*data)["qBt-seedDate"] = TorrentPersistentData::getSeedDate(hash).toTime_t();
|
|
||||||
(*data)["qBt-label"] = TorrentPersistentData::getLabel(hash).toUtf8().constData();
|
(*data)["qBt-label"] = TorrentPersistentData::getLabel(hash).toUtf8().constData();
|
||||||
(*data)["qBt-queuePosition"] = TorrentPersistentData::getPriority(hash);
|
(*data)["qBt-queuePosition"] = TorrentPersistentData::getPriority(hash);
|
||||||
(*data)["qBt-seedStatus"] = (int)TorrentPersistentData::isSeed(hash);
|
(*data)["qBt-seedStatus"] = (int)TorrentPersistentData::isSeed(hash);
|
||||||
|
@ -83,7 +83,6 @@ TorrentModelItem::TorrentModelItem(const QTorrentHandle &h)
|
|||||||
: m_torrent(h)
|
: m_torrent(h)
|
||||||
, m_lastStatus(h.status(torrent_handle::query_accurate_download_counters))
|
, m_lastStatus(h.status(torrent_handle::query_accurate_download_counters))
|
||||||
, m_addedTime(TorrentPersistentData::getAddedDate(h.hash()))
|
, m_addedTime(TorrentPersistentData::getAddedDate(h.hash()))
|
||||||
, m_seedTime(TorrentPersistentData::getSeedDate(h.hash()))
|
|
||||||
, m_label(TorrentPersistentData::getLabel(h.hash()))
|
, m_label(TorrentPersistentData::getLabel(h.hash()))
|
||||||
, m_name(TorrentPersistentData::getName(h.hash()))
|
, m_name(TorrentPersistentData::getName(h.hash()))
|
||||||
, m_hash(h.hash())
|
, m_hash(h.hash())
|
||||||
@ -189,10 +188,6 @@ bool TorrentModelItem::setData(int column, const QVariant &value, int role)
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case TR_SEED_DATE: {
|
|
||||||
m_seedTime = value.toDateTime();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -246,7 +241,7 @@ QVariant TorrentModelItem::data(int column, int role) const
|
|||||||
case TR_ADD_DATE:
|
case TR_ADD_DATE:
|
||||||
return m_addedTime;
|
return m_addedTime;
|
||||||
case TR_SEED_DATE:
|
case TR_SEED_DATE:
|
||||||
return m_seedTime;
|
return m_lastStatus.completed_time ? QDateTime::fromTime_t(m_lastStatus.completed_time) : QDateTime();
|
||||||
case TR_TRACKER:
|
case TR_TRACKER:
|
||||||
return misc::toQString(m_lastStatus.current_tracker);
|
return misc::toQString(m_lastStatus.current_tracker);
|
||||||
case TR_DLLIMIT:
|
case TR_DLLIMIT:
|
||||||
@ -441,7 +436,6 @@ void TorrentModel::handleFinishedTorrent(const QTorrentHandle& h)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Update completion date
|
// Update completion date
|
||||||
m_torrents[row]->setData(TorrentModelItem::TR_SEED_DATE, QDateTime::currentDateTime(), Qt::DisplayRole);
|
|
||||||
m_torrents[row]->refreshStatus(h.status(torrent_handle::query_accurate_download_counters));
|
m_torrents[row]->refreshStatus(h.status(torrent_handle::query_accurate_download_counters));
|
||||||
notifyTorrentChanged(row);
|
notifyTorrentChanged(row);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,6 @@ private:
|
|||||||
QTorrentHandle m_torrent;
|
QTorrentHandle m_torrent;
|
||||||
libtorrent::torrent_status m_lastStatus;
|
libtorrent::torrent_status m_lastStatus;
|
||||||
QDateTime m_addedTime;
|
QDateTime m_addedTime;
|
||||||
QDateTime m_seedTime;
|
|
||||||
QString m_label;
|
QString m_label;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
mutable QIcon m_icon;
|
mutable QIcon m_icon;
|
||||||
|
@ -255,30 +255,6 @@ public:
|
|||||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||||
return data.value("previous_path").toString();
|
return data.value("previous_path").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void saveSeedDate(const QTorrentHandle &h) {
|
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
|
||||||
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
|
|
||||||
if (h.is_seed())
|
|
||||||
data["seed_date"] = QDateTime::currentDateTime();
|
|
||||||
else
|
|
||||||
data.remove("seed_date");
|
|
||||||
all_data[h.hash()] = data;
|
|
||||||
settings.setValue("torrents", all_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void saveSeedDate(const QString &hash, const QDateTime &time) {
|
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
|
||||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
|
||||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
|
||||||
if (time.isValid())
|
|
||||||
data["seed_date"] = time;
|
|
||||||
else
|
|
||||||
data.remove("seed_date");
|
|
||||||
all_data[hash] = data;
|
|
||||||
settings.setValue("torrents", all_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QDateTime getSeedDate(const QString &hash) {
|
static QDateTime getSeedDate(const QString &hash) {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||||
@ -389,10 +365,6 @@ public:
|
|||||||
data["seed"] = !was_seed;
|
data["seed"] = !was_seed;
|
||||||
all_data[h.hash()] = data;
|
all_data[h.hash()] = data;
|
||||||
settings.setValue("torrents", all_data);
|
settings.setValue("torrents", all_data);
|
||||||
if (!was_seed) {
|
|
||||||
// Save completion date
|
|
||||||
saveSeedDate(h);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user