Fixup previous commit.

This commit is contained in:
sledgehammer999 2015-11-10 21:59:55 +02:00
parent 1f17a7836d
commit 5b232528cc
9 changed files with 145 additions and 3555 deletions

View file

@ -502,19 +502,19 @@ QList<bool> Preferences::getDownloadInScanDirs() const
return Utils::Misc::boolListfromStringList(value("Preferences/Downloads/DownloadInScanDirs").toStringList());
}
void Preferences::setDownloadPathsInScanDir(const QStringList &downloadpaths)
{
setValue(QString::fromUtf8("Preferences/Downloads/DownloadPaths"), downloadpaths);
}
QStringList Preferences::getDownloadPathsInScanDir() const
{
return value(QString::fromUtf8("Preferences/Downloads/DownloadPaths"), QStringList()).toStringList();
}
void Preferences::setDownloadInScanDirs(const QList<bool> &list)
{
setValue("Preferences/Downloads/DownloadInScanDirs", Utils::Misc::toStringList(list));
setValue("Preferences/Downloads/ScanDirsDownloadPaths", Utils::Misc::toStringList(list));
}
void Preferences::setScanDirsDownloadPaths(const QStringList &downloadpaths)
{
setValue("Preferences/Downloads/ScanDirsDownloadPaths", downloadpaths);
}
QStringList Preferences::getScanDirsDownloadPaths() const
{
return value("Preferences/Downloads/DownloadPaths").toStringList();
}
QString Preferences::getScanDirsLastPath() const

View file

@ -179,8 +179,8 @@ public:
QList<bool> getDownloadInScanDirs() const;
void setDownloadInScanDirs(const QList<bool> &list);
QString getScanDirsLastPath() const;
void setDownloadPathsInScanDir(const QStringList &downloadpaths);
QStringList getDownloadPathsInScanDir() const;
void setScanDirsDownloadPaths(const QStringList &downloadpaths);
QStringList getScanDirsDownloadPaths() const;
void setScanDirsLastPath(const QString &path);
bool isTorrentExportEnabled() const;
QString getTorrentExportDir() const;

File diff suppressed because it is too large Load diff

View file

@ -45,6 +45,7 @@ namespace
{
const int PathColumn = 0;
const int DownloadAtTorrentColumn = 1;
const int DownloadPath = 2;
}
class ScanFoldersModel::PathData
@ -53,17 +54,20 @@ public:
PathData(const QString &path)
: path(path)
, downloadAtPath(false)
, downloadPath(path)
{
}
PathData(const QString &path, bool download_at_path)
PathData(const QString &path, bool downloadAtPath, const QString &downloadPath)
: path(path)
, downloadAtPath(download_at_path)
, downloadAtPath(downloadAtPath)
, downloadPath(downloadPath)
{
}
const QString path;
bool downloadAtPath;
const QString path; //watching directory
bool downloadAtPath; //if TRUE save data to watching directory
QString downloadPath; //if 'downloadAtPath' FALSE use this path for save data
};
ScanFoldersModel *ScanFoldersModel::m_instance = 0;
@ -112,7 +116,7 @@ int ScanFoldersModel::rowCount(const QModelIndex &parent) const
int ScanFoldersModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return 2;
return 3;
}
QVariant ScanFoldersModel::data(const QModelIndex &index, int role) const
@ -121,13 +125,24 @@ QVariant ScanFoldersModel::data(const QModelIndex &index, int role) const
return QVariant();
const PathData *pathData = m_pathList.at(index.row());
if ((index.column() == PathColumn) && (role == Qt::DisplayRole))
return Utils::Fs::toNativePath(pathData->path);
QVariant value;
if ((index.column() == DownloadAtTorrentColumn) && (role == Qt::CheckStateRole))
return (pathData->downloadAtPath ? Qt::Checked : Qt::Unchecked);
switch (index.column()) {
case PathColumn:
if (role == Qt::DisplayRole)
value = Utils::Fs::toNativePath(pathData->path);
break;
case DownloadAtTorrentColumn:
if (role == Qt::CheckStateRole)
value = pathData->downloadAtPath ? Qt::Checked : Qt::Unchecked;
break;
case DownloadPath:
if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole)
value = Utils::Fs::toNativePath(pathData->downloadPath);
break;
}
return QVariant();
return value;
}
QVariant ScanFoldersModel::headerData(int section, Qt::Orientation orientation, int role) const
@ -135,32 +150,80 @@ QVariant ScanFoldersModel::headerData(int section, Qt::Orientation orientation,
if ((orientation != Qt::Horizontal) || (role != Qt::DisplayRole) || (section < 0) || (section >= columnCount()))
return QVariant();
if (section == PathColumn)
return tr("Watched Folder");
QVariant title;
return tr("Download here");
switch (section) {
case PathColumn:
title = tr("Watched Folder");
break;
case DownloadAtTorrentColumn:
title = tr("Download here");
break;
case DownloadPath:
title = tr("Download path");
break;
}
return title;
}
Qt::ItemFlags ScanFoldersModel::flags(const QModelIndex &index) const
{
if (!index.isValid() || (index.row() >= rowCount()) || (index.column() != DownloadAtTorrentColumn))
if (!index.isValid() || (index.row() >= rowCount()))
return QAbstractTableModel::flags(index);
return (QAbstractTableModel::flags(index) | Qt::ItemIsUserCheckable);
const PathData *pathData = m_pathList.at(index.row());
Qt::ItemFlags flags;
switch (index.column()) {
case PathColumn:
flags = QAbstractTableModel::flags(index);
break;
case DownloadAtTorrentColumn:
flags = QAbstractTableModel::flags(index) | Qt::ItemIsUserCheckable;
break;
case DownloadPath:
if (pathData->downloadAtPath == false)
flags = QAbstractTableModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
else
flags = QAbstractTableModel::flags(index) ^ Qt::ItemIsEnabled; //dont edit DownloadPath if checked 'downloadAtPath'
break;
}
return flags;
}
bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid() || (index.row() >= rowCount()) || (index.column() > DownloadAtTorrentColumn) || (role != Qt::CheckStateRole))
if (!index.isValid() || (index.row() >= rowCount()) || (index.column() > DownloadPath))
return false;
bool success = true;
switch (index.column()) {
case PathColumn:
success = false;
break;
case DownloadAtTorrentColumn:
if (role == Qt::CheckStateRole) {
Q_ASSERT(index.column() == DownloadAtTorrentColumn);
m_pathList[index.row()]->downloadAtPath = (value.toInt() == Qt::Checked);
emit dataChanged(index, index);
return true;
success = true;
}
break;
case DownloadPath:
Q_ASSERT(index.column() == DownloadPath);
m_pathList[index.row()]->downloadPath = value.toString();
emit dataChanged(index, index);
success = true;
break;
}
return success;
}
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &path, bool downloadAtPath)
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &path, bool downloadAtPath, const QString &downloadPath)
{
QDir dir(path);
if (!dir.exists()) return DoesNotExist;
@ -175,7 +238,8 @@ ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &path, bool
}
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_pathList << new PathData(canonicalPath, downloadAtPath);
QString downloadToPath = downloadPath.isEmpty() ? path : downloadPath;
m_pathList << new PathData(canonicalPath, downloadAtPath, downloadToPath);
endInsertRows();
// Start scanning
@ -227,6 +291,13 @@ bool ScanFoldersModel::downloadInTorrentFolder(const QString &filePath) const
return m_pathList.at(row)->downloadAtPath;
}
QString ScanFoldersModel::downloadPathTorrentFolder(const QString &filePath) const
{
const int row = findPathData(QFileInfo(filePath).dir().path());
Q_ASSERT(row != -1);
return m_pathList.at(row)->downloadPath;
}
int ScanFoldersModel::findPathData(const QString &path) const
{
for (int i = 0; i < m_pathList.count(); ++i)
@ -241,13 +312,16 @@ void ScanFoldersModel::makePersistent()
Preferences *const pref = Preferences::instance();
QStringList paths;
QList<bool> downloadInFolderInfo;
QStringList downloadPaths;
foreach (const PathData *pathData, m_pathList) {
paths << pathData->path;
downloadInFolderInfo << pathData->downloadAtPath;
downloadPaths << pathData->downloadPath;
}
pref->setScanDirs(paths);
pref->setDownloadInScanDirs(downloadInFolderInfo);
pref->setScanDirsDownloadPaths(downloadPaths);
}
void ScanFoldersModel::configure()
@ -255,10 +329,12 @@ void ScanFoldersModel::configure()
Preferences *const pref = Preferences::instance();
int i = 0;
QStringList downloadPaths = pref->getScanDirsDownloadPaths();
QList<bool> downloadInDirList = pref->getDownloadInScanDirs();
foreach (const QString &dir, pref->getScanDirs()) {
bool downloadInDir = downloadInDirList.value(i, false);
addPath(dir, downloadInDir);
bool downloadInDir = downloadInDirList.value(i, true);
QString downloadPath = downloadPaths.value(i); //empty string if out-of-bounds
addPath(dir, downloadInDir, downloadPath);
++i;
}
}
@ -281,6 +357,8 @@ void ScanFoldersModel::addTorrentsToSession(const QStringList &pathList)
BitTorrent::AddTorrentParams params;
if (downloadInTorrentFolder(file))
params.savePath = QFileInfo(file).dir().path();
else
params.savePath = downloadPathTorrentFolder(file); //if empty it will use the default savePath
BitTorrent::TorrentInfo torrentInfo = BitTorrent::TorrentInfo::loadFromFile(file);
if (torrentInfo.isValid()) {

View file

@ -67,12 +67,13 @@ public:
// TODO: removePaths(); singular version becomes private helper functions;
// also: remove functions should take modelindexes
PathStatus addPath(const QString &path, bool downloadAtPath);
PathStatus addPath(const QString &path, bool downloadAtPath, const QString &downloadPath);
void removePath(int row);
bool removePath(const QString &path);
PathStatus setDownloadAtPath(int row, bool downloadAtPath);
bool downloadInTorrentFolder(const QString &filePath) const;
QString downloadPathTorrentFolder(const QString &filePath) const;
void makePersistent();
private slots:

View file

@ -1,256 +0,0 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#include "scannedfoldersmodel.h"
#include "preferences.h"
#include "filesystemwatcher.h"
#include <QDir>
#include <QFileInfo>
#include <QString>
#include <QTemporaryFile>
#include "misc.h"
namespace {
const int PathColumn = 0;
const int DownloadAtTorrentColumn = 1;
const int DownloadPath = 2;
}
class ScanFoldersModel::PathData {
public:
PathData(const QString &path) : path(path), downloadAtPath(false), downloadPath(path) {}
PathData(const QString &path, bool download_at_path, const QString &download_path) : path(path), downloadAtPath(download_at_path), downloadPath(download_path) {}
const QString path; //watching directory
bool downloadAtPath; //if TRUE save data to watching directory
QString downloadPath; //if 'downloadAtPath' FALSE use this path for save data
};
ScanFoldersModel *ScanFoldersModel::instance(QObject *parent) {
//Q_ASSERT(!parent != !m_instance);
if (!m_instance)
m_instance = new ScanFoldersModel(parent);
return m_instance;
}
ScanFoldersModel::ScanFoldersModel(QObject *parent) :
QAbstractTableModel(parent), m_fsWatcher(0)
{ }
ScanFoldersModel::~ScanFoldersModel() {
qDeleteAll(m_pathList);
}
int ScanFoldersModel::rowCount(const QModelIndex &parent) const {
return parent.isValid() ? 0 : m_pathList.count();
}
int ScanFoldersModel::columnCount(const QModelIndex &parent) const {
Q_UNUSED(parent);
return 3;
}
QVariant ScanFoldersModel::data(const QModelIndex &index, int role) const {
if (!index.isValid() || index.row() >= rowCount())
return QVariant();
const PathData* pathData = m_pathList.at(index.row());
switch (index.column()) {
case PathColumn: {
if (role == Qt::DisplayRole)
return fsutils::toNativePath(pathData->path);
break;
}
case DownloadAtTorrentColumn: {
if (role == Qt::CheckStateRole)
return pathData->downloadAtPath ? Qt::Checked : Qt::Unchecked;
break;
}
case DownloadPath: {
if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole){
return fsutils::toNativePath(pathData->downloadPath);
}
break;
}
}
return QVariant();
}
QVariant ScanFoldersModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (orientation != Qt::Horizontal || role != Qt::DisplayRole || section < 0 || section >= columnCount())
return QVariant();
switch (section) {
case PathColumn: return tr("Watched Folder");
case DownloadAtTorrentColumn: return tr("Download here");
case DownloadPath: return tr("Download path");
}
return QVariant();
}
Qt::ItemFlags ScanFoldersModel::flags(const QModelIndex &index) const {
if (!index.isValid() || index.row() >= rowCount())
return QAbstractTableModel::flags(index);
const PathData* pathData = m_pathList.at(index.row());
switch (index.column()) {
case PathColumn: return QAbstractTableModel::flags(index);
case DownloadAtTorrentColumn: return QAbstractTableModel::flags(index) | Qt::ItemIsUserCheckable;
case DownloadPath: {
if (pathData->downloadAtPath == false){
return QAbstractTableModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
}
else{ //dont edit DownloadPath if checked 'downloadAtPath'
return QAbstractTableModel::flags(index) ^ Qt::ItemIsEnabled;
}
}
}
return QAbstractTableModel::flags(index);
}
bool ScanFoldersModel::setData(const QModelIndex &index, const QVariant &value, int role) {
if (!index.isValid() || index.row() >= rowCount() || index.column() > DownloadPath)
return false;
if (index.column() == PathColumn)
return false;
if (index.column() == DownloadAtTorrentColumn && role == Qt::CheckStateRole) {
Q_ASSERT(index.column() == DownloadAtTorrentColumn);
m_pathList[index.row()]->downloadAtPath = (value.toInt() == Qt::Checked);
emit dataChanged(index, index);
return true;
}
if (index.column() == DownloadPath) {
Q_ASSERT(index.column() == DownloadPath);
m_pathList[index.row()]->downloadPath = value.toString();
emit dataChanged(index, index);
return true;
}
return true;
}
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &path, bool download_at_path, const QString &download_path) {
QDir dir(path);
if (!dir.exists())
return DoesNotExist;
if (!dir.isReadable())
return CannotRead;
const QString &canonicalPath = dir.canonicalPath();
if (findPathData(canonicalPath) != -1)
return AlreadyInList;
if (!m_fsWatcher) {
m_fsWatcher = new FileSystemWatcher(this);
connect(m_fsWatcher, SIGNAL(torrentsAdded(QStringList&)), this, SIGNAL(torrentsAdded(QStringList&)));
}
beginInsertRows(QModelIndex(), rowCount(), rowCount());
QString download_to_path = download_path.isEmpty() ? path:download_path;
m_pathList << new PathData(canonicalPath, download_at_path, download_to_path);
endInsertRows();
// Start scanning
m_fsWatcher->addPath(canonicalPath);
return Ok;
}
void ScanFoldersModel::removePath(int row) {
Q_ASSERT(row >= 0 && row < rowCount());
beginRemoveRows(QModelIndex(), row, row);
m_fsWatcher->removePath(m_pathList.at(row)->path);
m_pathList.removeAt(row);
endRemoveRows();
}
bool ScanFoldersModel::removePath(const QString &path) {
const int row = findPathData(path);
if (row == -1)
return false;
removePath(row);
return true;
}
ScanFoldersModel::PathStatus ScanFoldersModel::setDownloadAtPath(int row, bool downloadAtPath) {
Q_ASSERT(row >= 0 && row < rowCount());
bool &oldValue = m_pathList[row]->downloadAtPath;
if (oldValue != downloadAtPath) {
if (downloadAtPath) {
QTemporaryFile testFile(m_pathList[row]->path + "/tmpFile");
if (!testFile.open())
return CannotWrite;
}
oldValue = downloadAtPath;
const QModelIndex changedIndex = index(row, DownloadAtTorrentColumn);
emit dataChanged(changedIndex, changedIndex);
}
return Ok;
}
bool ScanFoldersModel::downloadInTorrentFolder(const QString &filePath) const {
const int row = findPathData(QFileInfo(filePath).dir().path());
Q_ASSERT(row != -1);
return m_pathList.at(row)->downloadAtPath;
}
QString ScanFoldersModel::downloadPathTorrentFolder(const QString &filePath) const {
const int row = findPathData(QFileInfo(filePath).dir().path());
Q_ASSERT(row != -1);
return m_pathList.at(row)->downloadPath;
}
int ScanFoldersModel::findPathData(const QString &path) const {
for (int i = 0; i < m_pathList.count(); ++i) {
const PathData* pathData = m_pathList.at(i);
if (pathData->path == fsutils::fromNativePath(path))
return i;
}
return -1;
}
void ScanFoldersModel::makePersistent() {
Preferences* const pref = Preferences::instance();
QStringList paths;
QStringList downloadpaths;
QList<bool> downloadInFolderInfo;
foreach (const PathData* pathData, m_pathList) {
paths << pathData->path;
downloadpaths << pathData->downloadPath;
downloadInFolderInfo << pathData->downloadAtPath;
}
pref->setScanDirs(paths);
pref->setDownloadInScanDirs(downloadInFolderInfo);
pref->setDownloadPathsInScanDir(downloadpaths);
}
ScanFoldersModel *ScanFoldersModel::m_instance = 0;

View file

@ -1,81 +0,0 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christian Kandeler, Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/
#ifndef SCANNEDFOLDERSMODEL_H
#define SCANNEDFOLDERSMODEL_H
#include <QAbstractTableModel>
#include <QList>
#include <QStringList>
class FileSystemWatcher;
class ScanFoldersModel : public QAbstractTableModel {
Q_OBJECT
Q_DISABLE_COPY(ScanFoldersModel)
public:
enum PathStatus { Ok, DoesNotExist, CannotRead, CannotWrite, AlreadyInList };
static ScanFoldersModel *instance(QObject *parent = 0);
virtual ~ScanFoldersModel();
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
// TODO: removePaths(); singular version becomes private helper functions;
// also: remove functions should take modelindexes
PathStatus addPath(const QString &path, bool download_at_path, const QString &download_path);
void removePath(int row);
bool removePath(const QString &path);
PathStatus setDownloadAtPath(int row, bool downloadAtPath);
bool downloadInTorrentFolder(const QString &filePath) const;
QString downloadPathTorrentFolder(const QString &filePath) const;
void makePersistent();
signals:
// The absolute paths of new torrent files in the scanned directories.
void torrentsAdded(QStringList &pathList);
private:
explicit ScanFoldersModel(QObject *parent);
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
static ScanFoldersModel *m_instance;
class PathData;
int findPathData(const QString &path) const;
QList<PathData*> m_pathList;
FileSystemWatcher *m_fsWatcher;
};
#endif // SCANNEDFOLDERSMODEL_H

View file

@ -162,8 +162,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>484</width>
<height>692</height>
<width>454</width>
<height>610</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
@ -519,9 +519,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-282</y>
<width>487</width>
<height>965</height>
<y>0</y>
<width>454</width>
<height>942</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -1036,8 +1036,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>658</height>
<width>361</width>
<height>586</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_20">
@ -1566,8 +1566,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>502</width>
<height>538</height>
<width>275</width>
<height>401</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@ -1819,12 +1819,8 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
<property name="calendarPopup">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000000</number>
@ -1846,9 +1842,6 @@
<property name="text">
<string>KiB/s</string>
</property>
<property name="displayFormat">
<string notr="true">hh:mm</string>
</property>
</widget>
</item>
<item row="0" column="4">
@ -1957,8 +1950,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>555</width>
<height>410</height>
<width>440</width>
<height>481</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -2351,8 +2344,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>419</width>
<height>537</height>
<width>332</width>
<height>480</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
@ -2737,8 +2730,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>366</height>
<width>89</width>
<height>28</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_36">

View file

@ -58,16 +58,16 @@ QByteArray prefjson::getPreferences()
data["temp_path"] = Utils::Fs::toNativePath(pref->getTempPath());
data["preallocate_all"] = pref->preAllocateAllFiles();
data["incomplete_files_ext"] = pref->useIncompleteFilesExtension();
QVariantList l;
QVariantList scanDirs;
foreach (const QString& s, pref->getScanDirs()) {
l << Utils::Fs::toNativePath(s);
scanDirs << Utils::Fs::toNativePath(s);
}
data["scan_dirs"] = l;
QVariantList l2;
foreach (const QString& s, pref->getDownloadPathsInScanDir()) {
l2 << fsutils::toNativePath(s);
data["scan_dirs"] = scanDirs;
QVariantList ScanDirsDownloadPaths;
foreach (const QString& s, pref->getScanDirsDownloadPaths()) {
ScanDirsDownloadPaths << Utils::Fs::toNativePath(s);
}
data["download_paths"] = l2;
data["scan_dirs_download_paths"] = ScanDirsDownloadPaths;
QVariantList var_list;
foreach (bool b, pref->getDownloadInScanDirs()) {
var_list << b;
@ -188,7 +188,7 @@ void prefjson::setPreferences(const QString& json)
pref->preAllocateAllFiles(m["preallocate_all"].toBool());
if (m.contains("incomplete_files_ext"))
pref->useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs") && m.contains("download_paths")) {
if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs") && m.contains("scan_dirs_download_paths")) {
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
QList<bool> download_at_path;
foreach (QVariant var, download_at_path_tmp) {
@ -196,11 +196,11 @@ void prefjson::setPreferences(const QString& json)
}
QStringList old_folders = pref->getScanDirs();
QStringList new_folders = m["scan_dirs"].toStringList();
QStringList download_paths = m["download_paths"].toStringList();
QStringList download_paths = m["scan_dirs_download_paths"].toStringList();
if (download_at_path.size() == new_folders.size()) {
pref->setScanDirs(new_folders);
pref->setDownloadInScanDirs(download_at_path);
pref->setDownloadPathsInScanDir(download_paths);
pref->setScanDirsDownloadPaths(download_paths);
foreach (const QString &old_folder, old_folders) {
// Update deleted folders
if (!new_folders.contains(old_folder)) {