mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Replace QVariantMap by QVariantHash
This commit is contained in:
parent
7f300b757f
commit
f6ee96ed83
@ -95,7 +95,7 @@ void AppController::preferencesAction()
|
|||||||
{
|
{
|
||||||
const Preferences *const pref = Preferences::instance();
|
const Preferences *const pref = Preferences::instance();
|
||||||
const auto *session = BitTorrent::Session::instance();
|
const auto *session = BitTorrent::Session::instance();
|
||||||
QVariantMap data;
|
QVariantHash data;
|
||||||
|
|
||||||
// Downloads
|
// Downloads
|
||||||
// When adding a torrent
|
// When adding a torrent
|
||||||
@ -116,7 +116,7 @@ void AppController::preferencesAction()
|
|||||||
data["export_dir_fin"] = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory());
|
data["export_dir_fin"] = Utils::Fs::toNativePath(session->finishedTorrentExportDirectory());
|
||||||
// Automatically add torrents from
|
// Automatically add torrents from
|
||||||
const QVariantHash dirs = pref->getScanDirs();
|
const QVariantHash dirs = pref->getScanDirs();
|
||||||
QVariantMap nativeDirs;
|
QVariantHash nativeDirs;
|
||||||
for (auto i = dirs.cbegin(); i != dirs.cend(); ++i) {
|
for (auto i = dirs.cbegin(); i != dirs.cend(); ++i) {
|
||||||
if (i.value().type() == QVariant::Int)
|
if (i.value().type() == QVariant::Int)
|
||||||
nativeDirs.insert(Utils::Fs::toNativePath(i.key()), i.value().toInt());
|
nativeDirs.insert(Utils::Fs::toNativePath(i.key()), i.value().toInt());
|
||||||
@ -311,7 +311,7 @@ void AppController::preferencesAction()
|
|||||||
data["announce_to_all_tiers"] = session->announceToAllTiers();
|
data["announce_to_all_tiers"] = session->announceToAllTiers();
|
||||||
data["announce_ip"] = session->announceIP();
|
data["announce_ip"] = session->announceIP();
|
||||||
|
|
||||||
setResult(QJsonObject::fromVariantMap(data));
|
setResult(QJsonObject::fromVariantHash(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppController::setPreferencesAction()
|
void AppController::setPreferencesAction()
|
||||||
@ -320,9 +320,9 @@ void AppController::setPreferencesAction()
|
|||||||
|
|
||||||
Preferences *const pref = Preferences::instance();
|
Preferences *const pref = Preferences::instance();
|
||||||
auto session = BitTorrent::Session::instance();
|
auto session = BitTorrent::Session::instance();
|
||||||
const QVariantMap m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toMap();
|
const QVariantHash m = QJsonDocument::fromJson(params()["json"].toUtf8()).toVariant().toHash();
|
||||||
|
|
||||||
QVariantMap::ConstIterator it;
|
QVariantHash::ConstIterator it;
|
||||||
const auto hasKey = [&it, &m](const char *key) -> bool
|
const auto hasKey = [&it, &m](const char *key) -> bool
|
||||||
{
|
{
|
||||||
it = m.find(QLatin1String(key));
|
it = m.find(QLatin1String(key));
|
||||||
@ -364,7 +364,7 @@ void AppController::setPreferencesAction()
|
|||||||
session->setFinishedTorrentExportDirectory(it.value().toString());
|
session->setFinishedTorrentExportDirectory(it.value().toString());
|
||||||
// Automatically add torrents from
|
// Automatically add torrents from
|
||||||
if (hasKey("scan_dirs")) {
|
if (hasKey("scan_dirs")) {
|
||||||
const QVariantMap nativeDirs = it.value().toMap();
|
const QVariantHash nativeDirs = it.value().toHash();
|
||||||
QVariantHash oldScanDirs = pref->getScanDirs();
|
QVariantHash oldScanDirs = pref->getScanDirs();
|
||||||
QVariantHash scanDirs;
|
QVariantHash scanDirs;
|
||||||
ScanFoldersModel *model = ScanFoldersModel::instance();
|
ScanFoldersModel *model = ScanFoldersModel::instance();
|
||||||
@ -750,7 +750,7 @@ void AppController::networkInterfaceListAction()
|
|||||||
QVariantList ifaceList;
|
QVariantList ifaceList;
|
||||||
for (const QNetworkInterface &iface : asConst(QNetworkInterface::allInterfaces())) {
|
for (const QNetworkInterface &iface : asConst(QNetworkInterface::allInterfaces())) {
|
||||||
if (!iface.addressEntries().isEmpty()) {
|
if (!iface.addressEntries().isEmpty()) {
|
||||||
ifaceList.append(QVariantMap {
|
ifaceList.append(QVariantHash {
|
||||||
{"name", iface.humanReadableName()},
|
{"name", iface.humanReadableName()},
|
||||||
{"value", iface.name()}
|
{"value", iface.name()}
|
||||||
});
|
});
|
||||||
|
@ -79,7 +79,7 @@ void LogController::mainAction()
|
|||||||
|| (msg.type == Log::CRITICAL && isCritical)))
|
|| (msg.type == Log::CRITICAL && isCritical)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
msgList.append(QVariantMap {
|
msgList.append(QVariantHash {
|
||||||
{KEY_LOG_ID, msg.id},
|
{KEY_LOG_ID, msg.id},
|
||||||
{KEY_LOG_TIMESTAMP, msg.timestamp},
|
{KEY_LOG_TIMESTAMP, msg.timestamp},
|
||||||
{KEY_LOG_MSG_TYPE, msg.type},
|
{KEY_LOG_MSG_TYPE, msg.type},
|
||||||
@ -113,7 +113,7 @@ void LogController::peersAction()
|
|||||||
QVariantList peerList;
|
QVariantList peerList;
|
||||||
|
|
||||||
for (const Log::Peer &peer : asConst(logger->getPeers(lastKnownId))) {
|
for (const Log::Peer &peer : asConst(logger->getPeers(lastKnownId))) {
|
||||||
peerList.append(QVariantMap {
|
peerList.append(QVariantHash {
|
||||||
{KEY_LOG_ID, peer.id},
|
{KEY_LOG_ID, peer.id},
|
||||||
{KEY_LOG_TIMESTAMP, peer.timestamp},
|
{KEY_LOG_TIMESTAMP, peer.timestamp},
|
||||||
{KEY_LOG_PEER_IP, peer.ip},
|
{KEY_LOG_PEER_IP, peer.ip},
|
||||||
|
@ -161,7 +161,7 @@ namespace
|
|||||||
const QString privateMsg {QCoreApplication::translate("TrackerListWidget", "This torrent is private")};
|
const QString privateMsg {QCoreApplication::translate("TrackerListWidget", "This torrent is private")};
|
||||||
const bool isTorrentPrivate = torrent->isPrivate();
|
const bool isTorrentPrivate = torrent->isPrivate();
|
||||||
|
|
||||||
const QVariantMap dht {
|
const QVariantHash dht {
|
||||||
{KEY_TRACKER_URL, "** [DHT] **"},
|
{KEY_TRACKER_URL, "** [DHT] **"},
|
||||||
{KEY_TRACKER_TIER, ""},
|
{KEY_TRACKER_TIER, ""},
|
||||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : "")},
|
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : "")},
|
||||||
@ -172,7 +172,7 @@ namespace
|
|||||||
{KEY_TRACKER_LEECHES_COUNT, leechesDHT}
|
{KEY_TRACKER_LEECHES_COUNT, leechesDHT}
|
||||||
};
|
};
|
||||||
|
|
||||||
const QVariantMap pex {
|
const QVariantHash pex {
|
||||||
{KEY_TRACKER_URL, "** [PeX] **"},
|
{KEY_TRACKER_URL, "** [PeX] **"},
|
||||||
{KEY_TRACKER_TIER, ""},
|
{KEY_TRACKER_TIER, ""},
|
||||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : "")},
|
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : "")},
|
||||||
@ -183,7 +183,7 @@ namespace
|
|||||||
{KEY_TRACKER_LEECHES_COUNT, leechesPeX}
|
{KEY_TRACKER_LEECHES_COUNT, leechesPeX}
|
||||||
};
|
};
|
||||||
|
|
||||||
const QVariantMap lsd {
|
const QVariantHash lsd {
|
||||||
{KEY_TRACKER_URL, "** [LSD] **"},
|
{KEY_TRACKER_URL, "** [LSD] **"},
|
||||||
{KEY_TRACKER_TIER, ""},
|
{KEY_TRACKER_TIER, ""},
|
||||||
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : "")},
|
{KEY_TRACKER_MSG, (isTorrentPrivate ? privateMsg : "")},
|
||||||
@ -309,7 +309,7 @@ void TorrentsController::propertiesAction()
|
|||||||
checkParams({"hash"});
|
checkParams({"hash"});
|
||||||
|
|
||||||
const QString hash {params()["hash"]};
|
const QString hash {params()["hash"]};
|
||||||
QVariantMap dataDict;
|
QVariantHash dataDict;
|
||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||||
if (!torrent)
|
if (!torrent)
|
||||||
throw APIError(APIErrorType::NotFound);
|
throw APIError(APIErrorType::NotFound);
|
||||||
@ -358,7 +358,7 @@ void TorrentsController::propertiesAction()
|
|||||||
dataDict[KEY_PROP_SAVE_PATH] = Utils::Fs::toNativePath(torrent->savePath());
|
dataDict[KEY_PROP_SAVE_PATH] = Utils::Fs::toNativePath(torrent->savePath());
|
||||||
dataDict[KEY_PROP_COMMENT] = torrent->comment();
|
dataDict[KEY_PROP_COMMENT] = torrent->comment();
|
||||||
|
|
||||||
setResult(QJsonObject::fromVariantMap(dataDict));
|
setResult(QJsonObject::fromVariantHash(dataDict));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the trackers for a torrent in JSON format.
|
// Returns the trackers for a torrent in JSON format.
|
||||||
@ -387,7 +387,7 @@ void TorrentsController::trackersAction()
|
|||||||
for (const BitTorrent::TrackerEntry &tracker : asConst(torrent->trackers())) {
|
for (const BitTorrent::TrackerEntry &tracker : asConst(torrent->trackers())) {
|
||||||
const BitTorrent::TrackerInfo data = trackersData.value(tracker.url());
|
const BitTorrent::TrackerInfo data = trackersData.value(tracker.url());
|
||||||
|
|
||||||
trackerList << QVariantMap {
|
trackerList << QVariantHash {
|
||||||
{KEY_TRACKER_URL, tracker.url()},
|
{KEY_TRACKER_URL, tracker.url()},
|
||||||
{KEY_TRACKER_TIER, tracker.tier()},
|
{KEY_TRACKER_TIER, tracker.tier()},
|
||||||
{KEY_TRACKER_STATUS, static_cast<int>(tracker.status())},
|
{KEY_TRACKER_STATUS, static_cast<int>(tracker.status())},
|
||||||
@ -417,7 +417,7 @@ void TorrentsController::webseedsAction()
|
|||||||
throw APIError(APIErrorType::NotFound);
|
throw APIError(APIErrorType::NotFound);
|
||||||
|
|
||||||
for (const QUrl &webseed : asConst(torrent->urlSeeds())) {
|
for (const QUrl &webseed : asConst(torrent->urlSeeds())) {
|
||||||
webSeedList.append(QVariantMap {
|
webSeedList.append(QVariantHash {
|
||||||
{KEY_WEBSEED_URL, webseed.toString()}
|
{KEY_WEBSEED_URL, webseed.toString()}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -451,7 +451,7 @@ void TorrentsController::filesAction()
|
|||||||
const QVector<qreal> fileAvailability = torrent->availableFileFractions();
|
const QVector<qreal> fileAvailability = torrent->availableFileFractions();
|
||||||
const BitTorrent::TorrentInfo info = torrent->info();
|
const BitTorrent::TorrentInfo info = torrent->info();
|
||||||
for (int i = 0; i < torrent->filesCount(); ++i) {
|
for (int i = 0; i < torrent->filesCount(); ++i) {
|
||||||
QVariantMap fileDict = {
|
QVariantHash fileDict = {
|
||||||
{KEY_FILE_PROGRESS, fp[i]},
|
{KEY_FILE_PROGRESS, fp[i]},
|
||||||
{KEY_FILE_PRIORITY, static_cast<int>(priorities[i])},
|
{KEY_FILE_PRIORITY, static_cast<int>(priorities[i])},
|
||||||
{KEY_FILE_SIZE, torrent->fileSize(i)},
|
{KEY_FILE_SIZE, torrent->fileSize(i)},
|
||||||
@ -743,7 +743,7 @@ void TorrentsController::uploadLimitAction()
|
|||||||
checkParams({"hashes"});
|
checkParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
QVariantMap map;
|
QVariantHash map;
|
||||||
for (const QString &hash : hashes) {
|
for (const QString &hash : hashes) {
|
||||||
int limit = -1;
|
int limit = -1;
|
||||||
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||||
@ -752,7 +752,7 @@ void TorrentsController::uploadLimitAction()
|
|||||||
map[hash] = limit;
|
map[hash] = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
setResult(QJsonObject::fromVariantMap(map));
|
setResult(QJsonObject::fromVariantHash(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentsController::downloadLimitAction()
|
void TorrentsController::downloadLimitAction()
|
||||||
@ -760,7 +760,7 @@ void TorrentsController::downloadLimitAction()
|
|||||||
checkParams({"hashes"});
|
checkParams({"hashes"});
|
||||||
|
|
||||||
const QStringList hashes {params()["hashes"].split('|')};
|
const QStringList hashes {params()["hashes"].split('|')};
|
||||||
QVariantMap map;
|
QVariantHash map;
|
||||||
for (const QString &hash : hashes) {
|
for (const QString &hash : hashes) {
|
||||||
int limit = -1;
|
int limit = -1;
|
||||||
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
const BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(hash);
|
||||||
@ -769,7 +769,7 @@ void TorrentsController::downloadLimitAction()
|
|||||||
map[hash] = limit;
|
map[hash] = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
setResult(QJsonObject::fromVariantMap(map));
|
setResult(QJsonObject::fromVariantHash(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentsController::setUploadLimitAction()
|
void TorrentsController::setUploadLimitAction()
|
||||||
|
Loading…
Reference in New Issue
Block a user