Browse Source

Remove watch folders permanently only if the user accepts the Preferences dialog.

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
06be9edfe1
  1. 15
      src/base/scanfoldersmodel.cpp
  2. 9
      src/base/scanfoldersmodel.h
  3. 9
      src/gui/options_imp.cpp
  4. 1
      src/gui/options_imp.h

15
src/base/scanfoldersmodel.cpp

@ -268,24 +268,31 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths) @@ -268,24 +268,31 @@ void ScanFoldersModel::addToFSWatcher(const QStringList &watchPaths)
}
}
void ScanFoldersModel::removePath(int row)
void ScanFoldersModel::removePath(int row, bool removeFromFSWatcher)
{
Q_ASSERT((row >= 0) && (row < rowCount()));
beginRemoveRows(QModelIndex(), row, row);
m_fsWatcher->removePath(m_pathList.at(row)->watchPath);
if (removeFromFSWatcher)
m_fsWatcher->removePath(m_pathList.at(row)->watchPath);
delete m_pathList.takeAt(row);
endRemoveRows();
}
bool ScanFoldersModel::removePath(const QString &path)
bool ScanFoldersModel::removePath(const QString &path, bool removeFromFSWatcher)
{
const int row = findPathData(path);
if (row == -1) return false;
removePath(row);
removePath(row, removeFromFSWatcher);
return true;
}
void ScanFoldersModel::removeFromFSWatcher(const QStringList &watchPaths)
{
foreach (const QString &path, watchPaths)
m_fsWatcher->removePath(path);
}
bool ScanFoldersModel::downloadInWatchFolder(const QString &filePath) const
{
const int row = findPathData(QFileInfo(filePath).dir().path());

9
src/base/scanfoldersmodel.h

@ -85,13 +85,16 @@ public: @@ -85,13 +85,16 @@ public:
PathStatus updatePath(const QString &watchPath, const PathType& downloadType, const QString &downloadPath);
// PRECONDITION: The paths must have been added with addPath() first.
void addToFSWatcher(const QStringList &watchPaths);
void removePath(int row);
bool removePath(const QString &path);
void removePath(int row, bool removeFromFSWatcher = true);
bool removePath(const QString &path, bool removeFromFSWatcher = true);
void removeFromFSWatcher(const QStringList &watchPaths);
void makePersistent();
private slots:
public slots:
void configure();
private slots:
void addTorrentsToSession(const QStringList &pathList);
private:

9
src/gui/options_imp.cpp

@ -308,6 +308,7 @@ options_imp::~options_imp() @@ -308,6 +308,7 @@ options_imp::~options_imp()
qDebug("-> destructing Options");
foreach (const QString &path, addedScanDirs)
ScanFoldersModel::instance()->removePath(path);
ScanFoldersModel::instance()->configure(); // reloads "removed" paths
delete scrollArea_advanced->layout();
delete advancedSettings;
}
@ -418,8 +419,10 @@ void options_imp::saveOptions() @@ -418,8 +419,10 @@ void options_imp::saveOptions()
pref->useAdditionDialog(useAdditionDialog());
pref->additionDialogFront(checkAdditionDialogFront->isChecked());
pref->addTorrentsInPause(addTorrentsInPause());
ScanFoldersModel::instance()->removeFromFSWatcher(removedScanDirs);
ScanFoldersModel::instance()->addToFSWatcher(addedScanDirs);
ScanFoldersModel::instance()->makePersistent();
removedScanDirs.clear();
addedScanDirs.clear();
pref->setTorrentExportDir(getTorrentExportDir());
pref->setFinishedTorrentExportDir(getFinishedTorrentExportDir());
@ -1236,7 +1239,11 @@ void options_imp::on_removeScanFolderButton_clicked() @@ -1236,7 +1239,11 @@ void options_imp::on_removeScanFolderButton_clicked()
if (selected.isEmpty())
return;
Q_ASSERT(selected.count() == ScanFoldersModel::instance()->columnCount());
ScanFoldersModel::instance()->removePath(selected.first().row());
foreach (const QModelIndex &index, selected) {
if (index.column() == ScanFoldersModel::WATCH)
removedScanDirs << index.data().toString();
}
ScanFoldersModel::instance()->removePath(selected.first().row(), false);
}
void options_imp::handleScanFolderViewSelectionChanged()

1
src/gui/options_imp.h

@ -172,6 +172,7 @@ private: @@ -172,6 +172,7 @@ private:
QAbstractButton *applyButton;
AdvancedSettings *advancedSettings;
QList<QString> addedScanDirs;
QList<QString> removedScanDirs;
// SSL Cert / key
QByteArray m_sslCert, m_sslKey;
};

Loading…
Cancel
Save