Browse Source

Added Json encode support for QVariantList and QStringList

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
8f28804f8c
  1. 5
      src/eventmanager.cpp
  2. 8
      src/json.h

5
src/eventmanager.cpp

@ -231,9 +231,8 @@ QVariantMap EventManager::getGlobalPreferences() const {
data["save_path"] = Preferences::getSavePath(); data["save_path"] = Preferences::getSavePath();
data["temp_path_enabled"] = Preferences::isTempPathEnabled(); data["temp_path_enabled"] = Preferences::isTempPathEnabled();
data["temp_path"] = Preferences::getTempPath(); data["temp_path"] = Preferences::getTempPath();
// XXX: json.h does not encode QStringList correctly data["scan_dirs"] = Preferences::getScanDirs();
//data["scan_dirs"] = Preferences::getScanDirs(); data["download_in_scan_dirs"] = Preferences::getDownloadInScanDirs();
//data["download_in_scan_dirs"] = Preferences::getDownloadInScanDirs();
data["export_dir_enabled"] = Preferences::isTorrentExportEnabled(); data["export_dir_enabled"] = Preferences::isTorrentExportEnabled();
data["export_dir"] = Preferences::getExportDir(); data["export_dir"] = Preferences::getExportDir();
data["preallocate_all"] = Preferences::preAllocateAllFiles(); data["preallocate_all"] = Preferences::preAllocateAllFiles();

8
src/json.h

@ -49,6 +49,14 @@ namespace json {
case QVariant::ULongLong: case QVariant::ULongLong:
case QMetaType::Float: case QMetaType::Float:
return v.value<QString>(); return v.value<QString>();
case QVariant::StringList:
case QVariant::List: {
QStringList strList;
foreach(const QVariant &var, v.toList()) {
strList << toJson(var);
}
return "["+strList.join(",")+"]";
}
case QVariant::String: case QVariant::String:
{ {
QString s = v.value<QString>(); QString s = v.value<QString>();

Loading…
Cancel
Save