{
}
-
-void QFileSystemWatcherPrivate::init()
-{
- Q_Q(const QFileSystemWatcher);
- QObject::connect(watcher,
- SIGNAL(fileChanged(QString,bool)),
- q,
- SLOT(_q_fileChanged(QString,bool)));
- QObject::connect(watcher,
- SIGNAL(directoryChanged(QString,bool)),
- q,
- SLOT(_q_directoryChanged(QString,bool)));
-}
-
-
-void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed)
-{
- Q_Q(QFileSystemWatcher);
- if (!files.contains(path)) {
- // the path was removed after a change was detected, but before we delivered the signal
- return;
- }
- if (removed)
- files.removeAll(path);
- emit q->fileChanged(path);
-}
-
-void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed)
-{
- Q_Q(QFileSystemWatcher);
- if (!directories.contains(path)) {
- // perhaps the path was removed after a change was detected, but before we delivered the signal
- return;
- }
- if (removed)
- directories.removeAll(path);
- emit q->directoryChanged(path);
-}
-
-
-
/*!
\class QFileSystemWatcher
\brief The QFileSystemWatcher class provides an interface for monitoring files and directories for modifications.
QFileSystemWatcher::QFileSystemWatcher(QObject *parent)
: QObject(*new QFileSystemWatcherPrivate, parent)
{
- d_func()->init();
+ Q_D(QFileSystemWatcher);
+ connect(
+ d->watcher, SIGNAL(fileChanged(QString)),
+ this, SIGNAL(fileChanged(QString))
+ );
+ connect(
+ d->watcher, SIGNAL(directoryChanged(QString)),
+ this, SIGNAL(directoryChanged(QString))
+ );
}
/*!
QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent)
: QObject(*new QFileSystemWatcherPrivate, parent)
{
- d_func()->init();
+ Q_D(QFileSystemWatcher);
+ connect(
+ d->watcher, SIGNAL(fileChanged(QString)),
+ this, SIGNAL(fileChanged(QString))
+ );
+ connect(
+ d->watcher, SIGNAL(directoryChanged(QString)),
+ this, SIGNAL(directoryChanged(QString))
+ );
addPaths(paths);
}
: timer(this)
{
connect(&timer, SIGNAL(timeout()), this, SLOT(timeout()));
- timer.start(PollingInterval);
}
QStringList QFileSystemWatcherEngineUnix::addPaths(const QStringList &paths,
if (x.value() != fi) {
if (!fi.exists()) {
fit.remove();
- emit fileChanged(path, true);
} else {
x.value() = fi;
- emit fileChanged(path, false);
}
+ emit fileChanged(path);
}
}
QMutableHashIterator<QString, QStatInfo> dit(directories);
if (!fi.dirEquals(x.value())) {
if (!fi.exists()) {
dit.remove();
- emit directoryChanged(path, true);
} else {
x.value() = fi;
- emit directoryChanged(path, false);
}
+ emit directoryChanged(path);
}
}
}