summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-09-30 01:00:19 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-09-30 01:00:19 +0200
commit07e92611050f78dae93bcd362112efd8efa7b41e (patch)
tree6951f77a6344436150c4f83f407e09d946f2c6c3 /src/widgets/dialogs
parent69e68218e5082166d5c4ab1903fbacde00418a1c (diff)
parentcaa598c843eb27fd0c645e62723fd2d4e3e12f60 (diff)
Merge remote-tracking branch 'origin/5.11' into 5.12
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp14
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h4
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp46
3 files changed, 33 insertions, 31 deletions
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index aef13a563f..1e03ad8b06 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -80,7 +80,7 @@ static QString translateDriveName(const QFileInfo &drive)
*/
QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
: QThread(parent), abort(false),
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
watcher(0),
#endif
#ifdef Q_OS_WIN
@@ -88,7 +88,7 @@ QFileInfoGatherer::QFileInfoGatherer(QObject *parent)
#endif
m_iconProvider(&defaultProvider)
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(list(QString)));
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString)));
@@ -179,7 +179,7 @@ void QFileInfoGatherer::fetchExtendedInformation(const QString &path, const QStr
this->files.push(files);
condition.wakeAll();
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
if (files.isEmpty()
&& !path.isEmpty()
&& !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) {
@@ -208,7 +208,7 @@ void QFileInfoGatherer::updateFile(const QString &filePath)
*/
void QFileInfoGatherer::clear()
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
QMutexLocker locker(&mutex);
watcher->removePaths(watcher->files());
watcher->removePaths(watcher->directories());
@@ -222,7 +222,7 @@ void QFileInfoGatherer::clear()
*/
void QFileInfoGatherer::removePath(const QString &path)
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
QMutexLocker locker(&mutex);
watcher->removePath(path);
#else
@@ -266,7 +266,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
QExtendedInformation info(fileInfo);
info.icon = m_iconProvider->icon(fileInfo);
info.displayType = m_iconProvider->type(fileInfo);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
// ### Not ready to listen all modifications by default
static const bool watchFiles = qEnvironmentVariableIsSet("QT_FILESYSTEMMODEL_WATCH_FILES");
if (watchFiles) {
@@ -280,7 +280,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
}
}
}
-#endif
+#endif // filesystemwatcher
#ifdef Q_OS_WIN
if (m_resolveSymlinks && info.isSymLink(/* ignoreNtfsSymLinks = */ true)) {
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index cc82f42850..134a14b7ce 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -56,7 +56,9 @@
#include <qthread.h>
#include <qmutex.h>
#include <qwaitcondition.h>
+#if QT_CONFIG(filesystemwatcher)
#include <qfilesystemwatcher.h>
+#endif
#include <qfileiconprovider.h>
#include <qpair.h>
#include <qstack.h>
@@ -207,7 +209,7 @@ private:
// end protected by mutex
QAtomicInt abort;
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
QFileSystemWatcher *watcher;
#endif
#ifdef Q_OS_WIN
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index e54fdc97d4..8b3549c3f5 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -475,7 +475,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);
node = p->addNode(parent, element,info);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
node->populate(fileInfoGatherer.getInfo(info));
#endif
} else {
@@ -513,7 +513,7 @@ void QFileSystemModel::timerEvent(QTimerEvent *event)
Q_D(QFileSystemModel);
if (event->timerId() == d->fetchingTimer.timerId()) {
d->fetchingTimer.stop();
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
for (int i = 0; i < d->toFetch.count(); ++i) {
const QFileSystemModelPrivate::QFileSystemNode *node = d->toFetch.at(i).node;
if (!node->hasInformation()) {
@@ -661,7 +661,7 @@ void QFileSystemModel::fetchMore(const QModelIndex &parent)
if (indexNode->populatedChildren)
return;
indexNode->populatedChildren = true;
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
d->fileInfoGatherer.list(filePath(parent));
#endif
}
@@ -697,13 +697,13 @@ int QFileSystemModel::columnCount(const QModelIndex &parent) const
*/
QVariant QFileSystemModel::myComputer(int role) const
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
Q_D(const QFileSystemModel);
#endif
switch (role) {
case Qt::DisplayRole:
return QFileSystemModelPrivate::myComputer();
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
case Qt::DecorationRole:
return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer);
#endif
@@ -740,14 +740,14 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const
case Qt::DecorationRole:
if (index.column() == 0) {
QIcon icon = d->icon(index);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
if (icon.isNull()) {
if (d->node(index)->isDir())
icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder);
else
icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File);
}
-#endif // QT_NO_FILESYSTEMWATCHER
+#endif // filesystemwatcher
return icon;
}
break;
@@ -824,7 +824,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
return QString();
QFileSystemNode *dirNode = node(index);
if (
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
fileInfoGatherer.resolveSymlinks() &&
#endif
!resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) {
@@ -926,7 +926,7 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in
QScopedPointer<QFileSystemModelPrivate::QFileSystemNode> nodeToRename(parentNode->children.take(oldName));
nodeToRename->fileName = newName;
nodeToRename->parent = parentNode;
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
nodeToRename->populate(d->fileInfoGatherer.getInfo(QFileInfo(parentPath, newName)));
#endif
nodeToRename->isVisible = true;
@@ -1277,7 +1277,7 @@ QString QFileSystemModel::filePath(const QModelIndex &index) const
QString fullPath = d->filePath(index);
QFileSystemModelPrivate::QFileSystemNode *dirNode = d->node(index);
if (dirNode->isSymLink()
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
&& d->fileInfoGatherer.resolveSymlinks()
#endif
&& d->resolvedSymLinks.contains(fullPath)
@@ -1333,7 +1333,7 @@ QModelIndex QFileSystemModel::mkdir(const QModelIndex &parent, const QString &na
d->addNode(parentNode, name, QFileInfo());
Q_ASSERT(parentNode->children.contains(name));
QFileSystemModelPrivate::QFileSystemNode *node = parentNode->children[name];
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
node->populate(d->fileInfoGatherer.getInfo(QFileInfo(dir.absolutePath() + QDir::separator() + name)));
#endif
d->addVisibleFiles(parentNode, QStringList(name));
@@ -1397,7 +1397,7 @@ QModelIndex QFileSystemModel::setRootPath(const QString &newPath)
//We remove the watcher on the previous path
if (!rootPath().isEmpty() && rootPath() != QLatin1String(".")) {
//This remove the watcher for the old rootPath
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
d->fileInfoGatherer.removePath(rootPath());
#endif
//This line "marks" the node as dirty, so the next fetchMore
@@ -1453,7 +1453,7 @@ QDir QFileSystemModel::rootDirectory() const
void QFileSystemModel::setIconProvider(QFileIconProvider *provider)
{
Q_D(QFileSystemModel);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
d->fileInfoGatherer.setIconProvider(provider);
#endif
d->root.updateIcon(provider, QString());
@@ -1464,7 +1464,7 @@ void QFileSystemModel::setIconProvider(QFileIconProvider *provider)
*/
QFileIconProvider *QFileSystemModel::iconProvider() const
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
Q_D(const QFileSystemModel);
return d->fileInfoGatherer.iconProvider();
#else
@@ -1516,7 +1516,7 @@ QDir::Filters QFileSystemModel::filter() const
*/
void QFileSystemModel::setResolveSymlinks(bool enable)
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
Q_D(QFileSystemModel);
d->fileInfoGatherer.setResolveSymlinks(enable);
#else
@@ -1526,7 +1526,7 @@ void QFileSystemModel::setResolveSymlinks(bool enable)
bool QFileSystemModel::resolveSymlinks() const
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
Q_D(const QFileSystemModel);
return d->fileInfoGatherer.resolveSymlinks();
#else
@@ -1628,7 +1628,7 @@ QStringList QFileSystemModel::nameFilters() const
*/
bool QFileSystemModel::event(QEvent *event)
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
Q_D(QFileSystemModel);
if (event->type() == QEvent::LanguageChange) {
d->root.retranslateStrings(d->fileInfoGatherer.iconProvider(), QString());
@@ -1642,7 +1642,7 @@ bool QFileSystemModel::rmdir(const QModelIndex &aindex)
{
QString path = filePath(aindex);
const bool success = QDir().rmdir(path);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
if (success) {
QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
d->fileInfoGatherer.removePath(path);
@@ -1685,7 +1685,7 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile
{
// In the common case, itemLocation == count() so check there first
QFileSystemModelPrivate::QFileSystemNode *node = new QFileSystemModelPrivate::QFileSystemNode(fileName, parentNode);
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
node->populate(info);
#else
Q_UNUSED(info)
@@ -1793,7 +1793,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int
*/
void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QVector<QPair<QString, QFileInfo> > &updates)
{
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
Q_Q(QFileSystemModel);
QVector<QString> rowsToUpdate;
QStringList newFiles;
@@ -1889,7 +1889,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QV
#else
Q_UNUSED(path)
Q_UNUSED(updates)
-#endif // !QT_NO_FILESYSTEMWATCHER
+#endif // filesystemwatcher
}
/*!
@@ -1947,7 +1947,7 @@ void QFileSystemModelPrivate::init()
{
Q_Q(QFileSystemModel);
qRegisterMetaType<QVector<QPair<QString,QFileInfo> > >();
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)),
q, SLOT(_q_directoryChanged(QString,QStringList)));
q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QVector<QPair<QString,QFileInfo> >)),
@@ -1956,7 +1956,7 @@ void QFileSystemModelPrivate::init()
q, SLOT(_q_resolvedName(QString,QString)));
q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)),
q, SIGNAL(directoryLoaded(QString)));
-#endif // !QT_NO_FILESYSTEMWATCHER
+#endif // filesystemwatcher
q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration