Use completed time from libtorrent directly. Closes #1726.

This commit is contained in:
sledgehammer999 2014-06-07 14:44:08 +03:00
parent 07f76f4939
commit d58d87a691
4 changed files with 1 additions and 39 deletions

View file

@ -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();
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());
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());
int priority = fast.dict_find_int_value("qBt-queuePosition");
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::setAddedDate(hash, addedDate);
TorrentPersistentData::setPreviousSavePath(hash, previousSavePath);
TorrentPersistentData::saveSeedDate(hash, seedDate);
TorrentPersistentData::saveLabel(hash, label);
TorrentPersistentData::savePriority(hash, priority);
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-ratioLimit"] = QString::number(TorrentPersistentData::getRatioLimit(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-queuePosition"] = TorrentPersistentData::getPriority(hash);
(*data)["qBt-seedStatus"] = (int)TorrentPersistentData::isSeed(hash);

View file

@ -83,7 +83,6 @@ TorrentModelItem::TorrentModelItem(const QTorrentHandle &h)
: m_torrent(h)
, m_lastStatus(h.status(torrent_handle::query_accurate_download_counters))
, m_addedTime(TorrentPersistentData::getAddedDate(h.hash()))
, m_seedTime(TorrentPersistentData::getSeedDate(h.hash()))
, m_label(TorrentPersistentData::getLabel(h.hash()))
, m_name(TorrentPersistentData::getName(h.hash()))
, m_hash(h.hash())
@ -189,10 +188,6 @@ bool TorrentModelItem::setData(int column, const QVariant &value, int role)
}
return true;
}
case TR_SEED_DATE: {
m_seedTime = value.toDateTime();
return true;
}
default:
break;
}
@ -246,7 +241,7 @@ QVariant TorrentModelItem::data(int column, int role) const
case TR_ADD_DATE:
return m_addedTime;
case TR_SEED_DATE:
return m_seedTime;
return m_lastStatus.completed_time ? QDateTime::fromTime_t(m_lastStatus.completed_time) : QDateTime();
case TR_TRACKER:
return misc::toQString(m_lastStatus.current_tracker);
case TR_DLLIMIT:
@ -441,7 +436,6 @@ void TorrentModel::handleFinishedTorrent(const QTorrentHandle& h)
return;
// 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));
notifyTorrentChanged(row);
}

View file

@ -69,7 +69,6 @@ private:
QTorrentHandle m_torrent;
libtorrent::torrent_status m_lastStatus;
QDateTime m_addedTime;
QDateTime m_seedTime;
QString m_label;
QString m_name;
mutable QIcon m_icon;

View file

@ -255,30 +255,6 @@ public:
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
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) {
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
@ -389,10 +365,6 @@ public:
data["seed"] = !was_seed;
all_data[h.hash()] = data;
settings.setValue("torrents", all_data);
if (!was_seed) {
// Save completion date
saveSeedDate(h);
}
}
}