summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemwatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qfilesystemwatcher.cpp')
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp101
1 files changed, 30 insertions, 71 deletions
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index bd5a73da84..7138f8260b 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qfilesystemwatcher.h"
#include "qfilesystemwatcher_p.h"
@@ -67,6 +31,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_LOGGING_CATEGORY(lcWatcher, "qt.core.filesystemwatcher")
QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent)
@@ -92,29 +58,29 @@ QFileSystemWatcherPrivate::QFileSystemWatcherPrivate()
{
}
+void QFileSystemWatcherPrivate::connectEngine(QFileSystemWatcherEngine *engine)
+{
+ QObjectPrivate::connect(engine, &QFileSystemWatcherEngine::fileChanged,
+ this, &QFileSystemWatcherPrivate::fileChanged);
+ QObjectPrivate::connect(engine, &QFileSystemWatcherEngine::directoryChanged,
+ this, &QFileSystemWatcherPrivate::directoryChanged);
+}
+
void QFileSystemWatcherPrivate::init()
{
Q_Q(QFileSystemWatcher);
native = createNativeEngine(q);
if (native) {
- QObject::connect(native,
- SIGNAL(fileChanged(QString,bool)),
- q,
- SLOT(_q_fileChanged(QString,bool)));
- QObject::connect(native,
- SIGNAL(directoryChanged(QString,bool)),
- q,
- SLOT(_q_directoryChanged(QString,bool)));
+ connectEngine(native);
#if defined(Q_OS_WIN)
- QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native),
- &QWindowsFileSystemWatcherEngine::driveLockForRemoval,
- q, [this] (const QString &p) { _q_winDriveLockForRemoval(p); });
- QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native),
- &QWindowsFileSystemWatcherEngine::driveLockForRemovalFailed,
- q, [this] (const QString &p) { _q_winDriveLockForRemovalFailed(p); });
- QObject::connect(static_cast<QWindowsFileSystemWatcherEngine *>(native),
- &QWindowsFileSystemWatcherEngine::driveRemoved,
- q, [this] (const QString &p) { _q_winDriveRemoved(p); });
+ auto *windowsWatcher = static_cast<QWindowsFileSystemWatcherEngine *>(native);
+ using WinE = QWindowsFileSystemWatcherEngine;
+ QObjectPrivate::connect(windowsWatcher, &WinE::driveLockForRemoval,
+ this, &QFileSystemWatcherPrivate::winDriveLockForRemoval);
+ QObjectPrivate::connect(windowsWatcher, &WinE::driveLockForRemovalFailed,
+ this, &QFileSystemWatcherPrivate::winDriveLockForRemovalFailed);
+ QObjectPrivate::connect(windowsWatcher, &WinE::driveRemoved,
+ this, &QFileSystemWatcherPrivate::winDriveRemoved);
#endif // Q_OS_WIN
}
}
@@ -126,17 +92,10 @@ void QFileSystemWatcherPrivate::initPollerEngine()
Q_Q(QFileSystemWatcher);
poller = new QPollingFileSystemWatcherEngine(q); // that was a mouthful
- QObject::connect(poller,
- SIGNAL(fileChanged(QString,bool)),
- q,
- SLOT(_q_fileChanged(QString,bool)));
- QObject::connect(poller,
- SIGNAL(directoryChanged(QString,bool)),
- q,
- SLOT(_q_directoryChanged(QString,bool)));
+ connectEngine(poller);
}
-void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed)
+void QFileSystemWatcherPrivate::fileChanged(const QString &path, bool removed)
{
Q_Q(QFileSystemWatcher);
qCDebug(lcWatcher) << "file changed" << path << "removed?" << removed << "watching?" << files.contains(path);
@@ -149,7 +108,7 @@ void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed
emit q->fileChanged(path, QFileSystemWatcher::QPrivateSignal());
}
-void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed)
+void QFileSystemWatcherPrivate::directoryChanged(const QString &path, bool removed)
{
Q_Q(QFileSystemWatcher);
qCDebug(lcWatcher) << "directory changed" << path << "removed?" << removed << "watching?" << directories.contains(path);
@@ -164,7 +123,7 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re
#if defined(Q_OS_WIN)
-void QFileSystemWatcherPrivate::_q_winDriveLockForRemoval(const QString &path)
+void QFileSystemWatcherPrivate::winDriveLockForRemoval(const QString &path)
{
// Windows: Request to lock a (removable/USB) drive for removal, release
// its paths under watch, temporarily storing them should the lock fail.
@@ -181,7 +140,7 @@ void QFileSystemWatcherPrivate::_q_winDriveLockForRemoval(const QString &path)
}
}
-void QFileSystemWatcherPrivate::_q_winDriveLockForRemovalFailed(const QString &path)
+void QFileSystemWatcherPrivate::winDriveLockForRemovalFailed(const QString &path)
{
// Windows: Request to lock a (removable/USB) drive failed (blocked by other
// application), restore the watched paths.
@@ -195,7 +154,7 @@ void QFileSystemWatcherPrivate::_q_winDriveLockForRemovalFailed(const QString &p
}
}
-void QFileSystemWatcherPrivate::_q_winDriveRemoved(const QString &path)
+void QFileSystemWatcherPrivate::winDriveRemoved(const QString &path)
{
// Windows: Drive finally removed, clear out paths stored in lock request.
if (!path.isEmpty())
@@ -364,14 +323,14 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
#ifdef QT_BUILD_INTERNAL
const QString on = objectName();
- if (Q_UNLIKELY(on.startsWith(QLatin1String("_qt_autotest_force_engine_")))) {
+ if (Q_UNLIKELY(on.startsWith("_qt_autotest_force_engine_"_L1))) {
// Autotest override case - use the explicitly selected engine only
const auto forceName = QStringView{on}.mid(26);
- if (forceName == QLatin1String("poller")) {
+ if (forceName == "poller"_L1) {
qCDebug(lcWatcher, "QFileSystemWatcher: skipping native engine, using only polling engine");
d_func()->initPollerEngine();
return d->poller;
- } else if (forceName == QLatin1String("native")) {
+ } else if (forceName == "native"_L1) {
qCDebug(lcWatcher, "QFileSystemWatcher: skipping polling engine, using only native engine");
return d->native;
}