class KDirWatch

Class for watching directory changes. More...

Definition#include <kdirwatch.h>
InheritsQObject (qt)
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Signals

Public Static Methods

Protected Methods

Protected Slots


Detailed Description

Class for watching directory 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 signal 'dirty'.

If a watched directory gets deleted, KDirwatch will remove it from the list, and emit a signal 'deleted'.

 KDirWatch ( int freq = 500 )

Constructor. Does not begin with scanning until startScan is called. Default frequency is 500 ms. The created list of directories has deep copies.

KDirWatch ()

Destructor. Stops scanning and cleans up.

void  addDir (const QString& path)

Adds directory to list of directories to be watched. (The list makes deep copies).

time_t  ctime (const QString& path)

Returns the time the directory was last changed.

void  removeDir (const QString& path)

Removes directory from list of scanned directories. If specified path is not in the list, does nothing.

bool  stopDirScan (const QString& path)

Stops scanning for specified path. Does not delete dir from list, just skips it. Call this function when you make an huge operation on this directory (copy/move big files or lot of files). When finished, call restartDirScan (path). Returns 'false' if specified path is not in list, 'true' otherwise.

bool  restartDirScan (const QString& path)

Restarts scanning for specified path. Resets ctime. It doesn't notify the change, since 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 )

Starts scanning of all dirs in list. If notify is true, all changed dirs (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 dirs in list will be notified. Note that direcories that were. If 'skippedToo' is true, the skipped dirs, (scanning of which was stopped with stopDirScan ) will be reset and notified for change. Otherwise, stopped dirs will continue to be unnotified.

void  stopScan ()

Stops scanning of all dirs in list. List is not cleared, just the timer is stopped.

void  setFileDirty ( const QString & _file )

@see signal fileDirty

void  dirty (const QString& dir)

[signal]

This signal is emited when directory is changed. The new ctime is set before the signal is emited.

void  fileDirty (const QString& _file)

[signal]

This signal is emited 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)

[signal]

This signal is emited when directory is deleted. When you receive this signal, 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.