1/* 2 * This file Copyright (C) Mnemosyne LLC 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 6 * as published by the Free Software Foundation. 7 * 8 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 9 * 10 * $Id: watchdir.h 11092 2010-08-01 20:36:13Z charles $ 11 */ 12 13#ifndef QTR_WATCHDIR_H 14#define QTR_WATCHDIR_H 15 16#include <QObject> 17#include <QSet> 18#include <QString> 19 20class TorrentModel; 21class QFileSystemWatcher; 22 23class WatchDir: public QObject 24{ 25 Q_OBJECT 26 27 public: 28 WatchDir( const TorrentModel& ); 29 ~WatchDir( ); 30 31 public: 32 void setPath( const QString& path, bool isEnabled ); 33 34 private: 35 enum { OK, DUPLICATE, ERROR }; 36 int metainfoTest( const QString& filename ) const; 37 38 39 signals: 40 void torrentFileAdded( QString filename ); 41 42 private slots: 43 void watcherActivated( const QString& path ); 44 void onTimeout( ); 45 46 private: 47 const TorrentModel& myModel; 48 QSet<QString> myWatchDirFiles; 49 QFileSystemWatcher * myWatcher; 50}; 51 52#endif 53