1 /* 2 * This file Copyright (C) 2009-2015 Mnemosyne LLC 3 * 4 * It may be used under the GNU GPL versions 2 or 3 5 * or any future license endorsed by Mnemosyne LLC. 6 * 7 */ 8 9 #pragma once 10 11 #include <QObject> 12 #include <QSet> 13 #include <QString> 14 15 class QFileSystemWatcher; 16 17 class TorrentModel; 18 19 class WatchDir : public QObject 20 { 21 Q_OBJECT 22 23 public: 24 WatchDir(TorrentModel const&); 25 26 void setPath(QString const& path, bool isEnabled); 27 28 signals: 29 void torrentFileAdded(QString const& filename); 30 31 private: 32 enum 33 { 34 OK, 35 DUPLICATE, 36 ERROR 37 }; 38 39 private: 40 int metainfoTest(QString const& filename) const; 41 42 private slots: 43 void watcherActivated(QString const& path); 44 void onTimeout(); 45 46 void rescanAllWatchedDirectories(); 47 48 private: 49 TorrentModel const& myModel; 50 51 QSet<QString> myWatchDirFiles; 52 QFileSystemWatcher* myWatcher; 53 }; 54