Back to index

scribus-ng  1.3.4.dfsg+svn20071115
filewatcher.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #ifndef FILEWATCHER_H
00008 #define FILEWATCHER_H
00009 
00010 #include <qobject.h>
00011 #include <qtimer.h>
00012 #include <qmap.h>
00013 #include <qfileinfo.h>
00014 #include <qdatetime.h>
00015 #include <qvaluelist.h>
00016 
00017 #include "scribusapi.h"
00018 
00019 class SCRIBUS_API FileWatcher : public QObject
00020 {
00021        Q_OBJECT
00022 
00023 public:
00024        FileWatcher(QObject* parent);
00025        ~FileWatcher();
00026        bool isActive();
00027        // Set the timer length in milliseconds
00028        void setTimeOut(const int newTimeOut, const bool restartTimer=false);
00029        // Get the timer length
00030        const int timeOut();
00031        QValueList<QString> files();
00032        
00033 public slots:
00034        //Add a file to the watch list for monitoring
00035        void addFile(QString fileName);
00036        //Remove a file from the watch list
00037        void removeFile(QString fileName);
00038        //Add a directory to the watch list for monitoring
00039        void addDir(QString fileName);
00040        //Remove a directory from the watch list
00041        void removeDir(QString fileName);
00042        //Start the watcher's timer for file monitoring
00043        void start();
00044        //Stop the watcher's timer
00045        void stop();
00046        //Force a scan of the watched item list
00047        void forceScan();
00048 
00049 private:
00050        struct fileMod
00051        {
00052               QFileInfo info;
00053               QDateTime timeInfo;
00054               int pendingCount;
00055               bool pending;
00056        };
00057        QMap<QString, fileMod> watchedFiles;
00058        QTimer* watchTimer;
00059        bool blockAddRemove;
00060        bool stopped;
00061        int m_timeOut; // milliseconds
00062 
00063 private slots:
00064        void checkFiles();
00065 
00066 signals:
00067        void fileChanged(QString);
00068        void fileDeleted(QString);
00069        void dirChanged(QString);
00070        void dirDeleted(QString);
00071        void statePending(QString);
00072 
00073 };
00074 
00075 #endif