2009-11-12 21:24:51 +03:00
|
|
|
#ifndef FILESYSTEMWATCHER_H
|
|
|
|
#define FILESYSTEMWATCHER_H
|
|
|
|
|
|
|
|
#include <QFileSystemWatcher>
|
2010-04-28 15:45:13 +04:00
|
|
|
#include <QDir>
|
2009-11-12 21:24:51 +03:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QStringList>
|
2010-11-11 20:36:28 +03:00
|
|
|
#include <QHash>
|
|
|
|
|
2009-11-12 21:24:51 +03:00
|
|
|
/*
|
|
|
|
* Subclassing QFileSystemWatcher in order to support Network File
|
|
|
|
* System watching (NFS, CIFS) on Linux and Mac OS.
|
|
|
|
*/
|
2015-04-16 20:08:30 +03:00
|
|
|
class FileSystemWatcher : public QFileSystemWatcher
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2009-11-12 21:24:51 +03:00
|
|
|
|
|
|
|
public:
|
2015-04-16 20:08:30 +03:00
|
|
|
explicit FileSystemWatcher(QObject *parent = 0);
|
|
|
|
~FileSystemWatcher();
|
2009-11-12 21:24:51 +03:00
|
|
|
|
2015-04-16 20:08:30 +03:00
|
|
|
QStringList directories() const;
|
|
|
|
void addPath(const QString &path);
|
|
|
|
void removePath(const QString &path);
|
2009-11-12 21:24:51 +03:00
|
|
|
|
2015-04-16 20:08:30 +03:00
|
|
|
signals:
|
|
|
|
void torrentsAdded(QStringList &pathList);
|
2009-11-12 21:24:51 +03:00
|
|
|
|
2015-04-16 20:08:30 +03:00
|
|
|
protected slots:
|
|
|
|
void scanLocalFolder(QString path);
|
|
|
|
void scanNetworkFolders();
|
|
|
|
void processPartialTorrents();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void startPartialTorrentTimer();
|
|
|
|
void addTorrentsFromDir(const QDir &dir, QStringList &torrents);
|
2014-09-11 06:44:25 +04:00
|
|
|
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
2015-04-16 20:08:30 +03:00
|
|
|
static bool isNetworkFileSystem(QString path);
|
2009-11-12 21:24:51 +03:00
|
|
|
#endif
|
|
|
|
|
2013-09-21 11:59:58 +04:00
|
|
|
#ifndef Q_OS_WIN
|
2015-04-16 20:08:30 +03:00
|
|
|
QList<QDir> m_watchedFolders;
|
|
|
|
QPointer<QTimer> m_watchTimer;
|
2009-11-12 21:24:51 +03:00
|
|
|
#endif
|
2015-04-16 20:08:30 +03:00
|
|
|
QStringList m_filters;
|
|
|
|
// Partial torrents
|
|
|
|
QHash<QString, int> m_partialTorrents;
|
|
|
|
QPointer<QTimer> m_partialTorrentTimer;
|
2009-11-12 21:24:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FILESYSTEMWATCHER_H
|