|
|
@ -44,6 +44,8 @@ QHash<QString, TorrentTempData::TorrentData> TorrentTempData::data = QHash<QStri |
|
|
|
QHash<QString, TorrentTempData::TorrentMoveState> TorrentTempData::torrentMoveStates = QHash<QString, TorrentTempData::TorrentMoveState>(); |
|
|
|
QHash<QString, TorrentTempData::TorrentMoveState> TorrentTempData::torrentMoveStates = QHash<QString, TorrentTempData::TorrentMoveState>(); |
|
|
|
QHash<QString, bool> HiddenData::data = QHash<QString, bool>(); |
|
|
|
QHash<QString, bool> HiddenData::data = QHash<QString, bool>(); |
|
|
|
unsigned int HiddenData::metadata_counter = 0; |
|
|
|
unsigned int HiddenData::metadata_counter = 0; |
|
|
|
|
|
|
|
QHash<QString, QVariant> TorrentPersistentData::all_data = QHash<QString, QVariant>(); |
|
|
|
|
|
|
|
bool TorrentPersistentData::dirty = false; |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentTempData::hasTempData(const QString &hash) { |
|
|
|
bool TorrentTempData::hasTempData(const QString &hash) { |
|
|
|
return data.contains(hash); |
|
|
|
return data.contains(hash); |
|
|
@ -197,37 +199,41 @@ void HiddenData::gotMetadata(const QString &hash) { |
|
|
|
metadata_counter++; |
|
|
|
metadata_counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentPersistentData::isKnownTorrent(QString hash) { |
|
|
|
void TorrentPersistentData::load() { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
dirty = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::save() { |
|
|
|
|
|
|
|
if (dirty) { |
|
|
|
|
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
|
|
|
|
dirty = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TorrentPersistentData::isKnownTorrent(QString hash) { |
|
|
|
return all_data.contains(hash); |
|
|
|
return all_data.contains(hash); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QStringList TorrentPersistentData::knownTorrents() { |
|
|
|
QStringList TorrentPersistentData::knownTorrents() { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
return all_data.keys(); |
|
|
|
return all_data.keys(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::setRatioLimit(const QString &hash, const qreal &ratio) { |
|
|
|
void TorrentPersistentData::setRatioLimit(const QString &hash, const qreal &ratio) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
data["max_ratio"] = ratio; |
|
|
|
data["max_ratio"] = ratio; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
qreal TorrentPersistentData::getRatioLimit(const QString &hash) { |
|
|
|
qreal TorrentPersistentData::getRatioLimit(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("max_ratio", USE_GLOBAL_RATIO).toReal(); |
|
|
|
return data.value("max_ratio", USE_GLOBAL_RATIO).toReal(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentPersistentData::hasPerTorrentRatioLimit() { |
|
|
|
bool TorrentPersistentData::hasPerTorrentRatioLimit() { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant>::ConstIterator it = all_data.constBegin(); |
|
|
|
QHash<QString, QVariant>::ConstIterator it = all_data.constBegin(); |
|
|
|
QHash<QString, QVariant>::ConstIterator itend = all_data.constEnd(); |
|
|
|
QHash<QString, QVariant>::ConstIterator itend = all_data.constEnd(); |
|
|
|
for ( ; it != itend; ++it) { |
|
|
|
for ( ; it != itend; ++it) { |
|
|
@ -239,19 +245,15 @@ bool TorrentPersistentData::hasPerTorrentRatioLimit() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::setAddedDate(const QString &hash, const QDateTime &time) { |
|
|
|
void TorrentPersistentData::setAddedDate(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.value(hash).toHash(); |
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
if (!data.contains("add_date")) { |
|
|
|
if (!data.contains("add_date")) { |
|
|
|
data["add_date"] = time; |
|
|
|
data["add_date"] = time; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QDateTime TorrentPersistentData::getAddedDate(const QString &hash) { |
|
|
|
QDateTime TorrentPersistentData::getAddedDate(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
QDateTime dt = data.value("add_date").toDateTime(); |
|
|
|
QDateTime dt = data.value("add_date").toDateTime(); |
|
|
|
if (!dt.isValid()) { |
|
|
|
if (!dt.isValid()) { |
|
|
@ -262,34 +264,26 @@ QDateTime TorrentPersistentData::getAddedDate(const QString &hash) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::setErrorState(const QString &hash, const bool has_error) { |
|
|
|
void TorrentPersistentData::setErrorState(const QString &hash, const bool has_error) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
data["has_error"] = has_error; |
|
|
|
data["has_error"] = has_error; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentPersistentData::hasError(const QString &hash) { |
|
|
|
bool TorrentPersistentData::hasError(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("has_error", false).toBool(); |
|
|
|
return data.value("has_error", false).toBool(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QDateTime TorrentPersistentData::getSeedDate(const QString &hash) { |
|
|
|
QDateTime TorrentPersistentData::getSeedDate(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("seed_date").toDateTime(); |
|
|
|
return data.value("seed_date").toDateTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::deletePersistentData(const QString &hash) { |
|
|
|
void TorrentPersistentData::deletePersistentData(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
if (all_data.contains(hash)) { |
|
|
|
if (all_data.contains(hash)) { |
|
|
|
all_data.remove(hash); |
|
|
|
all_data.remove(hash); |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -297,8 +291,6 @@ void TorrentPersistentData::saveTorrentPersistentData(const QTorrentHandle &h, c |
|
|
|
Q_ASSERT(h.is_valid()); |
|
|
|
Q_ASSERT(h.is_valid()); |
|
|
|
qDebug("Saving persistent data for %s", qPrintable(h.hash())); |
|
|
|
qDebug("Saving persistent data for %s", qPrintable(h.hash())); |
|
|
|
// Save persistent data
|
|
|
|
// Save persistent data
|
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(h.hash()).toHash(); |
|
|
|
QHash<QString, QVariant> data = all_data.value(h.hash()).toHash(); |
|
|
|
data["is_magnet"] = is_magnet; |
|
|
|
data["is_magnet"] = is_magnet; |
|
|
|
if (is_magnet) { |
|
|
|
if (is_magnet) { |
|
|
@ -317,7 +309,7 @@ void TorrentPersistentData::saveTorrentPersistentData(const QTorrentHandle &h, c |
|
|
|
data["label"] = TorrentTempData::getLabel(h.hash()); |
|
|
|
data["label"] = TorrentTempData::getLabel(h.hash()); |
|
|
|
// Save data
|
|
|
|
// Save data
|
|
|
|
all_data[h.hash()] = data; |
|
|
|
all_data[h.hash()] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
qDebug("TorrentPersistentData: Saving save_path %s, hash: %s", qPrintable(h.save_path()), qPrintable(h.hash())); |
|
|
|
qDebug("TorrentPersistentData: Saving save_path %s, hash: %s", qPrintable(h.save_path()), qPrintable(h.hash())); |
|
|
|
// Set Added date
|
|
|
|
// Set Added date
|
|
|
|
setAddedDate(h.hash(), QDateTime::currentDateTime()); |
|
|
|
setAddedDate(h.hash(), QDateTime::currentDateTime()); |
|
|
@ -328,120 +320,92 @@ void TorrentPersistentData::saveTorrentPersistentData(const QTorrentHandle &h, c |
|
|
|
void TorrentPersistentData::saveSavePath(const QString &hash, const QString &save_path) { |
|
|
|
void TorrentPersistentData::saveSavePath(const QString &hash, const QString &save_path) { |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
qDebug("TorrentPersistentData::saveSavePath(%s)", qPrintable(save_path)); |
|
|
|
qDebug("TorrentPersistentData::saveSavePath(%s)", qPrintable(save_path)); |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
data["save_path"] = save_path; |
|
|
|
data["save_path"] = save_path; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
qDebug("TorrentPersistentData: Saving save_path: %s, hash: %s", qPrintable(save_path), qPrintable(hash)); |
|
|
|
qDebug("TorrentPersistentData: Saving save_path: %s, hash: %s", qPrintable(save_path), qPrintable(hash)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::saveLabel(const QString &hash, const QString &label) { |
|
|
|
void TorrentPersistentData::saveLabel(const QString &hash, const QString &label) { |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
data["label"] = label; |
|
|
|
data["label"] = label; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::saveName(const QString &hash, const QString &name) { |
|
|
|
void TorrentPersistentData::saveName(const QString &hash, const QString &name) { |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
Q_ASSERT(!hash.isEmpty()); |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
data["name"] = name; |
|
|
|
data["name"] = name; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::savePriority(const QTorrentHandle &h) { |
|
|
|
void TorrentPersistentData::savePriority(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(); |
|
|
|
QHash<QString, QVariant> data = all_data[h.hash()].toHash(); |
|
|
|
data["priority"] = h.queue_position(); |
|
|
|
data["priority"] = h.queue_position(); |
|
|
|
all_data[h.hash()] = data; |
|
|
|
all_data[h.hash()] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::savePriority(const QString &hash, const int &queue_pos) { |
|
|
|
void TorrentPersistentData::savePriority(const QString &hash, const int &queue_pos) { |
|
|
|
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(); |
|
|
|
QHash<QString, QVariant> data = all_data[hash].toHash(); |
|
|
|
data["priority"] = queue_pos; |
|
|
|
data["priority"] = queue_pos; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::saveSeedStatus(const QTorrentHandle &h) { |
|
|
|
void TorrentPersistentData::saveSeedStatus(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(); |
|
|
|
QHash<QString, QVariant> data = all_data[h.hash()].toHash(); |
|
|
|
bool was_seed = data.value("seed", false).toBool(); |
|
|
|
bool was_seed = data.value("seed", false).toBool(); |
|
|
|
if (was_seed != h.is_seed()) { |
|
|
|
if (was_seed != h.is_seed()) { |
|
|
|
data["seed"] = !was_seed; |
|
|
|
data["seed"] = !was_seed; |
|
|
|
all_data[h.hash()] = data; |
|
|
|
all_data[h.hash()] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentPersistentData::saveSeedStatus(const QString &hash, const bool seedStatus) { |
|
|
|
void TorrentPersistentData::saveSeedStatus(const QString &hash, const bool seedStatus) { |
|
|
|
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(); |
|
|
|
QHash<QString, QVariant> data = all_data[hash].toHash(); |
|
|
|
data["seed"] = seedStatus; |
|
|
|
data["seed"] = seedStatus; |
|
|
|
all_data[hash] = data; |
|
|
|
all_data[hash] = data; |
|
|
|
settings.setValue("torrents", all_data); |
|
|
|
dirty = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString TorrentPersistentData::getSavePath(const QString &hash) { |
|
|
|
QString TorrentPersistentData::getSavePath(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
//qDebug("TorrentPersistentData: getSavePath %s", data["save_path"].toString().toLocal8Bit().data());
|
|
|
|
//qDebug("TorrentPersistentData: getSavePath %s", data["save_path"].toString().toLocal8Bit().data());
|
|
|
|
return data.value("save_path").toString(); |
|
|
|
return data.value("save_path").toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString TorrentPersistentData::getLabel(const QString &hash) { |
|
|
|
QString TorrentPersistentData::getLabel(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("label", "").toString(); |
|
|
|
return data.value("label", "").toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString TorrentPersistentData::getName(const QString &hash) { |
|
|
|
QString TorrentPersistentData::getName(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("name", "").toString(); |
|
|
|
return data.value("name", "").toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int TorrentPersistentData::getPriority(const QString &hash) { |
|
|
|
int TorrentPersistentData::getPriority(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("priority", -1).toInt(); |
|
|
|
return data.value("priority", -1).toInt(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentPersistentData::isSeed(const QString &hash) { |
|
|
|
bool TorrentPersistentData::isSeed(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("seed", false).toBool(); |
|
|
|
return data.value("seed", false).toBool(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TorrentPersistentData::isMagnet(const QString &hash) { |
|
|
|
bool TorrentPersistentData::isMagnet(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
return data.value("is_magnet", false).toBool(); |
|
|
|
return data.value("is_magnet", false).toBool(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString TorrentPersistentData::getMagnetUri(const QString &hash) { |
|
|
|
QString TorrentPersistentData::getMagnetUri(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
Q_ASSERT(data.value("is_magnet", false).toBool()); |
|
|
|
Q_ASSERT(data.value("is_magnet", false).toBool()); |
|
|
|
return data.value("magnet_uri").toString(); |
|
|
|
return data.value("magnet_uri").toString(); |
|
|
|