|
|
@ -130,25 +130,29 @@ void EventManager::setGlobalPreferences(QVariantMap m) const { |
|
|
|
Preferences::setTempPathEnabled(m["temp_path_enabled"].toBool()); |
|
|
|
Preferences::setTempPathEnabled(m["temp_path_enabled"].toBool()); |
|
|
|
if(m.contains("temp_path")) |
|
|
|
if(m.contains("temp_path")) |
|
|
|
Preferences::setTempPath(m["temp_path"].toString()); |
|
|
|
Preferences::setTempPath(m["temp_path"].toString()); |
|
|
|
if(m.contains("scan_dirs")) { |
|
|
|
if(m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) { |
|
|
|
|
|
|
|
QVariantList download_at_path = m["download_in_scan_dirs"].toList(); |
|
|
|
QStringList old_folders = Preferences::getScanDirs(); |
|
|
|
QStringList old_folders = Preferences::getScanDirs(); |
|
|
|
QStringList new_folders = m["scan_dirs"].toStringList(); |
|
|
|
QStringList new_folders = m["scan_dirs"].toStringList(); |
|
|
|
foreach(const QString &old_folder, old_folders) { |
|
|
|
Preferences::setScanDirs(new_folders); |
|
|
|
// Update deleted folders
|
|
|
|
Preferences::setDownloadInScanDirs(download_at_path); |
|
|
|
if(!new_folders.contains(old_folder)) { |
|
|
|
if(download_at_path.size() == new_folders.size()) { |
|
|
|
BTSession->getScanFoldersModel()->removePath(old_folder); |
|
|
|
foreach(const QString &old_folder, old_folders) { |
|
|
|
|
|
|
|
// Update deleted folders
|
|
|
|
|
|
|
|
if(!new_folders.contains(old_folder)) { |
|
|
|
|
|
|
|
BTSession->getScanFoldersModel()->removePath(old_folder); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
int i = 0; |
|
|
|
foreach(const QString &new_folder, new_folders) { |
|
|
|
foreach(const QString &new_folder, new_folders) { |
|
|
|
// Update new folders
|
|
|
|
// Update new folders
|
|
|
|
if(!old_folders.contains(new_folder)) { |
|
|
|
if(!old_folders.contains(new_folder)) { |
|
|
|
BTSession->getScanFoldersModel()->addPath(new_folder); |
|
|
|
BTSession->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i).toBool()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
++i; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Preferences::setScanDirs(new_folders); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if(m.contains("download_in_scan_dirs")) |
|
|
|
|
|
|
|
Preferences::setDownloadInScanDirs(m["download_in_scan_dirs"].toList()); |
|
|
|
|
|
|
|
if(m.contains("export_dir")) |
|
|
|
if(m.contains("export_dir")) |
|
|
|
Preferences::setExportDir(m["export_dir"].toString()); |
|
|
|
Preferences::setExportDir(m["export_dir"].toString()); |
|
|
|
if(m.contains("preallocate_all")) |
|
|
|
if(m.contains("preallocate_all")) |
|
|
|