Browse Source

Fix processHash function

Fix processHash function to not use QVariantHash as result because of QJsonDocument doesn't support QVariantHash variables in Qt 5.
adaptive-webui-19844
buinsky 10 years ago
parent
commit
28f573e9a8
  1. 15
      src/webui/btjson.cpp

15
src/webui/btjson.cpp

@ -156,7 +156,7 @@ static const char KEY_SUFFIX_REMOVED[] = "_removed"; @@ -156,7 +156,7 @@ static const char KEY_SUFFIX_REMOVED[] = "_removed";
QVariantMap getTranserInfoMap();
QVariantMap toMap(const QTorrentHandle& h);
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);
QVariantMap generateSyncData(int acceptedResponseId, QVariantMap data, QVariantMap &lastAcceptedData, QVariantMap &lastData);
@ -589,10 +589,10 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData) @@ -589,10 +589,10 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
}
break;
case QVariant::Hash: {
QVariantHash hash;
processHash(prevData[key].toHash(), data[key].toHash(), hash, removedItems);
if (!hash.isEmpty())
syncData[key] = hash;
QVariantMap map;
processHash(prevData[key].toHash(), data[key].toHash(), map, removedItems);
if (!map.isEmpty())
syncData[key] = map;
if (!removedItems.isEmpty())
syncData[key + KEY_SUFFIX_REMOVED] = removedItems;
}
@ -626,7 +626,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData) @@ -626,7 +626,7 @@ void processMap(QVariantMap prevData, QVariantMap data, QVariantMap &syncData)
// Compare two lists of structures (prevData, data) and calculate difference (syncData, removedItems).
// Structures encoded as map.
// 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
syncData.clear();
@ -634,7 +634,8 @@ void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncDat @@ -634,7 +634,8 @@ void processHash(QVariantHash prevData, QVariantHash data, QVariantHash &syncDat
if (prevData.isEmpty()) {
// If list was empty before, then difference is a whole new list.
syncData = data;
foreach (QString key, data.keys())
syncData[key] = data[key];
}
else {
foreach (QString key, data.keys()) {

Loading…
Cancel
Save