|
|
Watch directories for changes.
It uses stat
(2) and
compares stored and actual changed time of directories. If
there is a difference it notifies about the change. Directories can be
added, removed from the list and scanning of particular directories
can be stopped and restarted. The whole class can be stopped and
restarted. Directories can be added/removed from list in
any state.
When a watched directory is changed, KDirWatch will emit
the signal dirty().
If a watched directory gets deleted, KDirwatch will remove it from the list, and emit the signal deleted().
KDirWatch ( int freq = 500 )
| KDirWatch |
Constructor.
Does not begin scanning until startScan() is called. Default frequency is 500 ms. The created list of directories has deep copies.
~KDirWatch ()
| ~KDirWatch |
Destructor.
Stops scanning and cleans up.
void addDir (const QString& path)
| addDir |
Add a directory to the list of directories to be watched.
The list makes deep copies.
time_t ctime (const QString& path)
| ctime |
Retrieve the time the directory was last changed.
void removeDir (const QString& path)
| removeDir |
Remove a directory from the list of scanned directories.
If specified path is not in the list this does nothing.
bool stopDirScan (const QString& path)
| stopDirScan |
Stop scanning the specified path.
The path
is not deleted from the interal just, it is just skipped.
Call this function when you perform an huge operation
on this directory (copy/move big files or many files). When finished,
call restartDirScan (path).
Returns false
if specified path is not in list, true
otherwise.
bool restartDirScan (const QString& path)
| restartDirScan |
Restart scanning for specified path.
Resets ctime. It doesn't notify the change (by emitted a signal), since the ctime value is reset.
Call it when you are finished with big operations on that path,
and when you have refreshed that path. Returns false
if specified path is not in list, true
otherwise.
void startScan ( bool notify=false, bool skippedToo=false )
| startScan |
Start scanning of all dirs in list.
If notify is true
, all changed directories (since stopScan() call) will be notified for refresh. If notify is
false
, all ctimes will be reset (except those who are stopped,
but only if skippedToo
is false
) and changed dirs won't be
notified. You can start scanning even if the list is
empty. First call should be called with false
or else all
directories
in list will be notified. If
skippedToo
is true, the skipped directoris (scanning of which was
stopped with stopDirScan() ) will be reset and notified
for change. Otherwise, stopped directories will continue to be
unnotified.
void stopScan ()
| stopScan |
Stop scanning of all directories in internal list.
The timer is stopped, but the list is not cleared.
bool contains ( const QString& path )
| contains |
[const]
void setFileDirty ( const QString & _file )
| setFileDirty |
signal fileDirty()
KDirWatch* self ()
| self |
[static]
void dirty (const QString& dir)
| dirty |
[signal]
Emitted when a directory is changed.
The new ctime is set before the signal is emited.
void fileDirty (const QString& _file)
| fileDirty |
[signal]
Emitted when KDirWatch learns that the file
_file
has changed.
This happens for instance when a .desktop file gets a new icon - but this isn't automatic, one has to call setFileDirty() for this signal to be emitted.
void deleted (const QString& dir)
| deleted |
[signal]
Emitted when directory is deleted.
When you receive this signal, the directory is not yet deleted from the list. You will receive this signal only once, because one directory cannot be deleted more than once. Please, forget the last^H^H^H^Hprevious sentence.
void resetList (bool reallyall)
| resetList |
[ protected: ]
void slotRescan ()
| slotRescan |
[ protected slots: slot]
void famEventReceived ()
| famEventReceived |
[ protected slots: slot]