mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Fix processHash function
Fix processHash function to not use QVariantHash as result because of QJsonDocument doesn't support QVariantHash variables in Qt 5.
This commit is contained in:
parent
8931eec5b0
commit
28f573e9a8
@ -156,7 +156,7 @@ static const char KEY_SUFFIX_REMOVED[] = "_removed";
|
|||||||
QVariantMap getTranserInfoMap();
|
QVariantMap getTranserInfoMap();
|
||||||
QVariantMap toMap(const QTorrentHandle& h);
|
QVariantMap toMap(const QTorrentHandle& h);
|
||||||
void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData);
|
void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData);
|
||||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncData, QVariantList &removedItems);
|
void processHash(QVariantHash prevData, QVariantHash data, QVariantMap &syncData, QVariantList &removedItems);
|
||||||
void processList(QVariantList prevData, QVariantList data, QVariantList &syncData, QVariantList &removedItems);
|
void processList(QVariantList prevData, QVariantList data, QVariantList &syncData, QVariantList &removedItems);
|
||||||
QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantMap &lastAcceptedData, QVariantMap &lastData);
|
QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantMap &lastAcceptedData, QVariantMap &lastData);
|
||||||
|
|
||||||
@ -589,10 +589,10 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QVariant::Hash: {
|
case QVariant::Hash: {
|
||||||
QVariantHash hash;
|
QVariantMap map;
|
||||||
processHash(prevData[key].toHash(), data[key].toHash(), hash, removedItems);
|
processHash(prevData[key].toHash(), data[key].toHash(), map, removedItems);
|
||||||
if (!hash.isEmpty())
|
if (!map.isEmpty())
|
||||||
syncData[key] = hash;
|
syncData[key] = map;
|
||||||
if (!removedItems.isEmpty())
|
if (!removedItems.isEmpty())
|
||||||
syncData[key + KEY_SUFFIX_REMOVED] = removedItems;
|
syncData[key + KEY_SUFFIX_REMOVED] = removedItems;
|
||||||
}
|
}
|
||||||
@ -626,7 +626,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
|
|||||||
// Compare two lists of structures (prevData, data) and calculate difference (syncData, removedItems).
|
// Compare two lists of structures (prevData, data) and calculate difference (syncData, removedItems).
|
||||||
// Structures encoded as map.
|
// Structures encoded as map.
|
||||||
// Lists are encoded as hash table (indexed by structure key value) to improve ease of searching for removed items.
|
// Lists are encoded as hash table (indexed by structure key value) to improve ease of searching for removed items.
|
||||||
void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncData, QVariantList &removedItems)
|
void processHash(QVariantHash prevData, QVariantHash data, QVariantMap &syncData, QVariantList &removedItems)
|
||||||
{
|
{
|
||||||
// initialize output variables
|
// initialize output variables
|
||||||
syncData.clear();
|
syncData.clear();
|
||||||
@ -634,7 +634,8 @@ void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncDat
|
|||||||
|
|
||||||
if (prevData.isEmpty()) {
|
if (prevData.isEmpty()) {
|
||||||
// If list was empty before, then difference is a whole new list.
|
// If list was empty before, then difference is a whole new list.
|
||||||
syncData = data;
|
foreach (QString key, data.keys())
|
||||||
|
syncData[key] = data[key];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (QString key, data.keys()) {
|
foreach (QString key, data.keys()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user