FileInfoThread::FileInfoThread(QObject *parent)
: QThread(parent),
abort(false),
+#ifndef QT_NO_FILESYSTEMWATCHER
watcher(0),
+#endif
sortFlags(QDir::Name),
needUpdate(true),
folderUpdate(false),
showDotDot(false),
showOnlyReadable(false)
{
+#ifndef QT_NO_FILESYSTEMWATCHER
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString)));
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
+#endif // !QT_NO_FILESYSTEMWATCHER
start(LowPriority);
}
void FileInfoThread::clear()
{
QMutexLocker locker(&mutex);
+#ifndef QT_NO_FILESYSTEMWATCHER
watcher->removePaths(watcher->files());
watcher->removePaths(watcher->directories());
+#endif
}
void FileInfoThread::removePath(const QString &path)
{
QMutexLocker locker(&mutex);
+#ifndef QT_NO_FILESYSTEMWATCHER
watcher->removePath(path);
+#endif
currentPath.clear();
}
Q_ASSERT(!path.isEmpty());
QMutexLocker locker(&mutex);
+#ifndef QT_NO_FILESYSTEMWATCHER
watcher->addPath(path);
+#endif
currentPath = path;
needUpdate = true;
condition.wakeAll();
rootPath = path;
}
+#ifndef QT_NO_FILESYSTEMWATCHER
void FileInfoThread::dirChanged(const QString &directoryPath)
{
Q_UNUSED(directoryPath);
folderUpdate = true;
condition.wakeAll();
}
+#endif
void FileInfoThread::setSortFlags(QDir::SortFlags flags)
{
condition.wakeAll();
}
+#ifndef QT_NO_FILESYSTEMWATCHER
void FileInfoThread::updateFile(const QString &path)
{
Q_UNUSED(path);
folderUpdate = true;
condition.wakeAll();
}
+#endif
void FileInfoThread::run()
{
void setShowOnlyReadable(bool on);
public Q_SLOTS:
+#ifndef QT_NO_FILESYSTEMWATCHER
void dirChanged(const QString &directoryPath);
void updateFile(const QString &path);
+#endif
protected:
void run();
QWaitCondition condition;
volatile bool abort;
+#ifndef QT_NO_FILESYSTEMWATCHER
QFileSystemWatcher *watcher;
+#endif
QList<FileProperty> currentFileList;
QDir::SortFlags sortFlags;
QString currentPath;