QCodeEdit 2.2
|
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2006-2009 fullmetalcoder <fullmetalcoder@hotmail.fr> 00004 ** 00005 ** This file is part of the Edyuk project <http://edyuk.org> 00006 ** 00007 ** This file may be used under the terms of the GNU General Public License 00008 ** version 3 as published by the Free Software Foundation and appearing in the 00009 ** file GPL.txt included in the packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ****************************************************************************/ 00015 00016 #ifndef _QRELIABLE_FILE_WATCH_H_ 00017 #define _QRELIABLE_FILE_WATCH_H_ 00018 00019 #include "qce-config.h" 00020 00026 #include <QHash> 00027 #include <QTimer> 00028 #include <QPointer> 00029 #include <QFileSystemWatcher> 00030 00031 class QCE_EXPORT QReliableFileWatch : protected QFileSystemWatcher 00032 { 00033 friend class QPointer<QReliableFileWatch>; 00034 00035 Q_OBJECT 00036 00037 public: 00038 QReliableFileWatch(QObject *p = 0); 00039 virtual ~QReliableFileWatch(); 00040 00041 public slots: 00042 void addWatch(const QString& file, QObject *recipient); 00043 00044 void removeWatch(QObject *recipient); 00045 void removeWatch(const QString& file, QObject *recipient); 00046 00047 protected: 00048 virtual void timerEvent(QTimerEvent *e); 00049 00050 private slots: 00051 void sourceChanged(const QString& filepath); 00052 00053 private: 00054 enum State 00055 { 00056 Clean = 0, 00057 Recent = 1, 00058 Duplicate = 2 00059 }; 00060 00061 struct Watch 00062 { 00063 char state; 00064 qint64 size; 00065 QList< QPointer<QObject> > recipients; 00066 }; 00067 00068 QBasicTimer m_timer; 00069 00070 QHash<QString, Watch> m_targets; 00071 }; 00072 00073 #endif // !_QRELIABLE_FILE_WATCH_H_