Improve the "Watch folders" UI. Closes #4300.

This commit is contained in:
sledgehammer999
2015-12-12 22:26:17 +02:00
parent e9547f7a1c
commit bc92f156c1
10 changed files with 405 additions and 206 deletions

View File

@@ -31,7 +31,7 @@
#ifndef SCANFOLDERSMODEL_H
#define SCANFOLDERSMODEL_H
#include <QAbstractTableModel>
#include <QAbstractListModel>
#include <QList>
QT_BEGIN_NAMESPACE
@@ -40,7 +40,7 @@ QT_END_NAMESPACE
class FileSystemWatcher;
class ScanFoldersModel : public QAbstractTableModel
class ScanFoldersModel : public QAbstractListModel
{
Q_OBJECT
Q_DISABLE_COPY(ScanFoldersModel)
@@ -55,6 +55,20 @@ public:
AlreadyInList
};
enum Column
{
WATCH,
DOWNLOAD,
NB_COLUMNS
};
enum PathType
{
DOWNLOAD_IN_WATCH_FOLDER,
DEFAULT_LOCATION,
CUSTOM_LOCATION
};
static bool initInstance(QObject *parent = 0);
static void freeInstance();
static ScanFoldersModel *instance();
@@ -67,13 +81,10 @@ public:
// TODO: removePaths(); singular version becomes private helper functions;
// also: remove functions should take modelindexes
PathStatus addPath(const QString &path, bool downloadAtPath, const QString &downloadPath);
PathStatus addPath(const QString &watchPath, const PathType& downloadType, 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:
@@ -85,10 +96,15 @@ private:
~ScanFoldersModel();
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
static ScanFoldersModel *m_instance;
class PathData;
bool downloadInWatchFolder(const QString &filePath) const;
bool downloadInDefaultFolder(const QString &filePath) const;
QString downloadPathTorrentFolder(const QString &filePath) const;
int findPathData(const QString &path) const;
private:
static ScanFoldersModel *m_instance;
struct PathData;
QList<PathData*> m_pathList;
FileSystemWatcher *m_fsWatcher;
};