45 #ifndef QT_NO_FILESYSTEMWATCHER 57 #elif defined(Q_OS_LINUX) 60 #elif defined(Q_OS_QNX) && !defined(QT_NO_INOTIFY) 62 #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) 63 # if (defined Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 65 # endif //MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 67 #elif defined(Q_OS_SYMBIAN) 68 # include "qfilesystemwatcher_symbian_p.h" 89 : ownerId(fileInfo.ownerId()),
90 groupId(fileInfo.groupId()),
91 permissions(fileInfo.permissions()),
92 lastModified(fileInfo.lastModified())
94 if (fileInfo.
isDir()) {
108 return (ownerId != fileInfo.
ownerId()
109 || groupId != fileInfo.
groupId()
153 QMutableListIterator<QString>
it(p);
154 while (it.hasNext()) {
161 directories->
append(path);
164 this->directories.
insert(path, fi);
168 this->files.
insert(path, fi);
182 QMutableListIterator<QString>
it(p);
183 while (it.hasNext()) {
185 if (this->directories.remove(path)) {
188 }
else if (this->files.remove(path)) {
209 QMutableHashIterator<QString, FileInfo> fit(
files);
210 while (fit.hasNext()) {
217 }
else if (x.
value() != fi) {
222 QMutableHashIterator<QString, FileInfo> dit(
directories);
223 while (dit.hasNext()) {
232 }
else if (x.
value() != fi) {
251 #if defined(Q_OS_WIN) 253 #elif defined(Q_OS_QNX) && !defined(QT_NO_INOTIFY) 255 #elif defined(Q_OS_LINUX) 260 #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC) 261 # if 0 && defined(Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) 267 #elif defined(Q_OS_SYMBIAN) 268 return new QSymbianFileSystemWatcherEngine;
275 : native(0), poller(0), forced(0)
302 #if defined(Q_OS_LINUX) 350 emit q->fileChanged(path);
362 emit q->directoryChanged(path);
486 qWarning(
"QFileSystemWatcher::addPath: path is empty");
514 qWarning(
"QFileSystemWatcher::addPaths: list is empty");
526 d_func()->initPollerEngine();
534 qDebug() <<
"QFileSystemWatcher: skipping native engine, using only polling engine";
535 d_func()->initPollerEngine();
538 qDebug() <<
"QFileSystemWatcher: skipping polling engine, using only native engine";
541 qDebug() <<
"QFileSystemWatcher: skipping polling and native engine, using only explicit" << forceName <<
"engine";
542 d_func()->initForcedEngine(forceName);
548 p = engine->
addPaths(p, &
d->files, &
d->directories);
551 qWarning(
"QFileSystemWatcher: failed to add paths: %s",
563 qWarning(
"QFileSystemWatcher::removePath: path is empty");
577 qWarning(
"QFileSystemWatcher::removePaths: list is empty");
583 p =
d->native->removePaths(p, &
d->files, &
d->directories);
585 p =
d->poller->removePaths(p, &
d->files, &
d->directories);
587 p =
d->forced->removePaths(p, &
d->files, &
d->directories);
643 return d->directories;
654 #include "moc_qfilesystemwatcher.cpp" 656 #include "qfilesystemwatcher.moc" 658 #endif // QT_NO_FILESYSTEMWATCHER
void fileChanged(const QString &path, bool removed)
#define QT_END_NAMESPACE
This macro expands to.
The QMutex class provides access serialization between threads.
QHash< QString, FileInfo > files
The QFileSystemWatcher class provides an interface for monitoring files and directories for modificat...
#define it(className, varName)
void refresh()
Refreshes the information about the file, i.e.
void removePath(const QString &file)
Removes the specified path from the file system watcher.
static QFSEventsFileSystemWatcherEngine * create()
QDir absoluteDir() const
Returns the file's absolute path as a QDir object.
void unlock()
Unlocks this mutex locker.
void removePaths(const QStringList &files)
Removes the specified paths from the file system watcher.
void insert(int i, const T &t)
Inserts value at index position i in the list.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool exists() const
Returns true if the file exists; otherwise returns false.
void initForcedEngine(const QString &)
static QInotifyFileSystemWatcherEngine * create()
FileInfo(const QFileInfo &fileInfo)
T & value() const
Returns a modifiable reference to the current item's value.
The QString class provides a Unicode character string.
The QHash class is a template class that provides a hash-table-based dictionary.
QFile::Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permissions for the file.
The QObject class is the base class of all Qt objects.
void run()
The starting point for the thread.
void quit()
Tells the thread's event loop to exit with return code 0 (success).
QFileSystemWatcherEngine * native
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
QPollingFileSystemWatcherEngine()
~QFileSystemWatcher()
Destroys the file system watcher.
Q_CORE_EXPORT void qDebug(const char *,...)
uint ownerId() const
Returns the id of the owner of the file.
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories)
void append(const T &t)
Inserts value at the end of the list.
void _q_fileChanged(const QString &path, bool removed)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QHash< QString, FileInfo > directories
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory; otherwise ret...
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QStringList files() const
Returns a list of paths to files that are being watched.
The QStringList class provides a list of strings.
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
void _q_directoryChanged(const QString &path, bool removed)
const Key & key() const
Returns the current item's key as a const reference.
QFileSystemWatcher(QObject *parent=0)
Constructs a new file system watcher object with the given parent.
QFileSystemWatcherEngine * poller
void directoryChanged(const QString &path, bool removed)
QFileSystemWatcherEngine * forced
static QFileSystemWatcherEngine * createNativeEngine()
QString join(const QString &sep) const
Joins all the string list's strings into a single string with each element separated by the given sep...
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
static QDnotifyFileSystemWatcherEngine * create()
FileInfo & operator=(const QFileInfo &fileInfo)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
void addPaths(const QStringList &files)
Adds each path in paths to the file system watcher.
QStringList directories() const
Returns a list of paths to directories that are being watched.
The QDateTime class provides date and time functions.
QFileSystemWatcherPrivate()
void start(Priority=InheritPriority)
Begins execution of the thread by calling run().
QObject * parent() const
Returns a pointer to the parent object.
bool wait(unsigned long time=ULONG_MAX)
Blocks the thread until either of these conditions is met:
QFile::Permissions permissions
int exec()
Enters the event loop and waits until exit() is called, returning the value that was passed to exit()...
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
QString objectName() const
uint groupId() const
Returns the id of the group the file belongs to.
virtual QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories)=0
static QKqueueFileSystemWatcherEngine * create()
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories)
void addPath(const QString &file)
Adds path to the file system watcher if path exists.
static const MacVersion MacintoshVersion
the version of the Macintosh operating system on which the application is run (Mac only)...
The QTimer class provides repetitive and single-shot timers.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
The QFileInfo class provides system-independent file information.
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
#define qPrintable(string)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QStringList entryList(Filters filters=NoFilter, SortFlags sort=NoSort) const
Returns a list of the names of all the files and directories in the directory, ordered according to t...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
bool operator!=(const QFileInfo &fileInfo) const
QDateTime lastModified() const
Returns the date and time when the file was last modified.