mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 16:53:08 -07:00
Further rewriting of the JSON-related code
This commit is contained in:
parent
122655758d
commit
a0d21ead18
11 changed files with 155 additions and 200 deletions
|
@ -103,6 +103,10 @@ static const char KEY_FILE_PROGRESS[] = "progress";
|
|||
static const char KEY_FILE_PRIORITY[] = "priority";
|
||||
static const char KEY_FILE_IS_SEED[] = "is_seed";
|
||||
|
||||
// TransferInfo keys
|
||||
static const char KEY_TRANSFER_DLSPEED[] = "dl_info";
|
||||
static const char KEY_TRANSFER_UPSPEED[] = "up_info";
|
||||
|
||||
static JsonDict toJson(const QTorrentHandle& h)
|
||||
{
|
||||
JsonDict ret;
|
||||
|
@ -343,3 +347,20 @@ QString btjson::getFilesForTorrent(const QString& hash)
|
|||
|
||||
return file_list.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the global transfer information in JSON format.
|
||||
*
|
||||
* The return value is a JSON-formatted dictionary.
|
||||
* The dictionary keys are:
|
||||
* - "dl_info": Global download info
|
||||
* - "up_info": Global upload info
|
||||
*/
|
||||
QString btjson::getTransferInfo()
|
||||
{
|
||||
CACHED_VARIABLE(JsonDict, info, CACHE_DURATION_MS);
|
||||
session_status sessionStatus = QBtSession::instance()->getSessionStatus();
|
||||
info.add(KEY_TRANSFER_DLSPEED, tr("D: %1/s - T: %2", "Download speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_download_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_download)));
|
||||
info.add(KEY_TRANSFER_UPSPEED, tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload)));
|
||||
return info.toString();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue