diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index a7047d8d612..2d879ecb0af 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -1213,7 +1213,7 @@ static QList minimalPrefixPaths(const QList &p // find minimal prefix, ensure '/' at end for (Utils::FilePath path : qAsConst(paths)) { if (!path.endsWith("/")) - path.setPath(path.path() + "/"); + path.setPath(QString(path.path() + "/")); if (path.path().length() > 1) sortedPaths.append(path); } diff --git a/src/libs/utils/buildablehelperlibrary.cpp b/src/libs/utils/buildablehelperlibrary.cpp index a23ba678dcb..b011959f8fc 100644 --- a/src/libs/utils/buildablehelperlibrary.cpp +++ b/src/libs/utils/buildablehelperlibrary.cpp @@ -60,7 +60,7 @@ FilePath BuildableHelperLibrary::qtChooserToQmakePath(const FilePath &qtChooser) return {}; FilePath qmake = qtChooser; - qmake.setPath(output.mid(pos, end - pos) + "/qmake"); + qmake.setPath(QString(output.mid(pos, end - pos) + "/qmake")); return qmake; } diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index 978d9e601e9..4fd32932b46 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -340,17 +340,46 @@ QString FilePath::completeSuffix() const return {}; } -void FilePath::setScheme(const QString &scheme) +void FilePath::setScheme(const QStringView scheme) { QTC_CHECK(!scheme.contains('/')); - m_scheme = scheme; + m_scheme = scheme.toString(); } -void FilePath::setHost(const QString &host) +void FilePath::setHost(const QStringView host) { - m_host = host; + m_host = host.toString(); } +void FilePath::setPath(const QStringView path) +{ + setRootAndPath(path, HostOsInfo::hostOs()); +} + +QStringView FilePath::scheme() const +{ + return m_scheme; +} + +QStringView FilePath::host() const +{ + return m_host; +} + +QString FilePath::path() const +{ + return m_root + m_path; +} + +QStringView FilePath::root() const +{ + return m_root; +} + +void FilePath::setRoot(const QStringView root) +{ + m_root = root.toString(); +} /// \returns a bool indicating whether a file with this /// FilePath exists. diff --git a/src/libs/utils/filepath.h b/src/libs/utils/filepath.h index c2ac18746ae..fabafc13d6a 100644 --- a/src/libs/utils/filepath.h +++ b/src/libs/utils/filepath.h @@ -89,17 +89,17 @@ public: QVariant toVariant() const; QUrl toUrl() const; - QString scheme() const { return m_scheme; } - void setScheme(const QString &scheme); + QStringView scheme() const; + void setScheme(const QStringView scheme); - QString host() const { return m_host; } - void setHost(const QString &host); + QStringView host() const; + void setHost(const QStringView host); - QString path() const { return m_root + m_path; } - void setPath(const QString &path) { setRootAndPath(path, HostOsInfo::hostOs()); } + QString path() const; + void setPath(const QStringView path); - QString root() const { return m_root; } - void setRoot(const QString &root) { m_root = root; } + QStringView root() const; + void setRoot(const QStringView root); QString fileName() const; QString fileNameWithPathComponents(int pathComponents) const; diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index c0edc99c205..eb81c9b5ac9 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -408,7 +408,7 @@ FilePath FileUtils::commonPath(const FilePaths &paths) FilePath result; // Common scheme - const QString &commonScheme = first.scheme(); + const QStringView commonScheme = first.scheme(); auto sameScheme = [&commonScheme] (const FilePath &fp) { return commonScheme == fp.scheme(); }; @@ -417,7 +417,7 @@ FilePath FileUtils::commonPath(const FilePaths &paths) result.setScheme(commonScheme); // Common host - const QString &commonHost = first.host(); + const QStringView commonHost = first.host(); auto sameHost = [&commonHost] (const FilePath &fp) { return commonHost == fp.host(); }; diff --git a/src/libs/utils/fsengine/fsengine.cpp b/src/libs/utils/fsengine/fsengine.cpp index cbfc2821793..8b542e72709 100644 --- a/src/libs/utils/fsengine/fsengine.cpp +++ b/src/libs/utils/fsengine/fsengine.cpp @@ -78,14 +78,14 @@ QStringList &FSEngine::deviceSchemes() return g_deviceSchemes; } -void FSEngine::registerDeviceScheme(const QString &scheme) +void FSEngine::registerDeviceScheme(const QStringView scheme) { - deviceSchemes().append(scheme); + deviceSchemes().append(scheme.toString()); } -void FSEngine::unregisterDeviceScheme(const QString &scheme) +void FSEngine::unregisterDeviceScheme(const QStringView scheme) { - deviceSchemes().removeAll(scheme); + deviceSchemes().removeAll(scheme.toString()); } QStringList FSEngine::registeredDeviceSchemes() diff --git a/src/libs/utils/fsengine/fsengine.h b/src/libs/utils/fsengine/fsengine.h index 4c6326038e3..56645d4b905 100644 --- a/src/libs/utils/fsengine/fsengine.h +++ b/src/libs/utils/fsengine/fsengine.h @@ -51,8 +51,8 @@ public: static void addDevice(const Utils::FilePath &deviceRoot); static void removeDevice(const Utils::FilePath &deviceRoot); - static void registerDeviceScheme(const QString &scheme); - static void unregisterDeviceScheme(const QString &scheme); + static void registerDeviceScheme(const QStringView scheme); + static void unregisterDeviceScheme(const QStringView scheme); static QStringList registeredDeviceSchemes(); private: diff --git a/src/libs/utils/macroexpander.cpp b/src/libs/utils/macroexpander.cpp index d2340a71b08..44b55bea2c8 100644 --- a/src/libs/utils/macroexpander.cpp +++ b/src/libs/utils/macroexpander.cpp @@ -295,8 +295,8 @@ FilePath MacroExpander::expand(const FilePath &fileNameWithVariables) const { FilePath result = fileNameWithVariables; result.setPath(expand(result.path())); - result.setHost(expand(result.host())); - result.setScheme(expand(result.scheme())); + result.setHost(expand(result.host().toString())); + result.setScheme(expand(result.scheme().toString())); return result; } diff --git a/src/plugins/docker/dockerconstants.h b/src/plugins/docker/dockerconstants.h index b1ed087b228..fa66489536e 100644 --- a/src/plugins/docker/dockerconstants.h +++ b/src/plugins/docker/dockerconstants.h @@ -28,7 +28,7 @@ namespace Docker::Constants { const char DOCKER[] = "docker"; -const char DOCKER_DEVICE_SCHEME[] = "docker"; +const char16_t DOCKER_DEVICE_SCHEME[] = u"docker"; const char DOCKER_SETTINGS_ID[] = "Docker.Settings"; const char DOCKER_DEVICE_TYPE[] = "DockerDeviceType"; diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index 08eaf00c490..7bddde22b06 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -614,7 +614,7 @@ FilePath DockerDevice::mapToGlobalPath(const FilePath &pathOnDevice) const FilePath result; result.setPath(pathOnDevice.path()); - result.setScheme("docker"); + result.setScheme(Constants::DOCKER_DEVICE_SCHEME); result.setHost(d->m_data.repoAndTag()); // The following would work, but gives no hint on repo and tag @@ -646,18 +646,23 @@ Utils::FilePath DockerDevice::rootPath() const FilePath root; root.setScheme(Constants::DOCKER_DEVICE_SCHEME); root.setHost(d->m_data.repoAndTag()); - root.setPath("/"); + root.setPath(u"/"); return root; } bool DockerDevice::handlesFile(const FilePath &filePath) const { - if (filePath.scheme() == "device" && filePath.host() == id().toString()) + if (filePath.scheme() == u"device" && filePath.host() == id().toString()) return true; - if (filePath.scheme() == "docker" && filePath.host() == d->m_data.imageId) + + if (filePath.scheme() == Constants::DOCKER_DEVICE_SCHEME + && filePath.host() == d->m_data.imageId) return true; - if (filePath.scheme() == "docker" && filePath.host() == d->m_data.repo + ':' + d->m_data.tag) + + if (filePath.scheme() == Constants::DOCKER_DEVICE_SCHEME + && filePath.host() == QString(d->m_data.repo + ':' + d->m_data.tag)) return true; + return false; } diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp index 16aeae39108..b1edea6e9c7 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp @@ -377,7 +377,7 @@ IDevice::ConstPtr DeviceManager::deviceForPath(const FilePath &path) { const QList devices = instance()->d->deviceList(); - if (path.scheme() == "device") { + if (path.scheme() == u"device") { for (const IDevice::Ptr &dev : devices) { if (path.host() == dev->id().toString()) return dev; diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index f7ca5633bb7..6a679c22749 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -220,7 +220,7 @@ FilePath IDevice::mapToGlobalPath(const FilePath &pathOnDevice) const // match DeviceManager::deviceForPath FilePath result; result.setPath(pathOnDevice.path()); - result.setScheme("device"); + result.setScheme(u"device"); result.setHost(id().toString()); return result; } @@ -237,7 +237,7 @@ FilePath IDevice::filePath(const QString &pathOnDevice) const bool IDevice::handlesFile(const FilePath &filePath) const { - if (filePath.scheme() == "device" && filePath.host() == id().toString()) + if (filePath.scheme() == u"device" && filePath.host() == id().toString()) return true; return false; } @@ -781,9 +781,9 @@ void IDevice::setMachineType(MachineType machineType) FilePath IDevice::rootPath() const { FilePath root; - root.setScheme("device"); + root.setScheme(u"device"); root.setHost(id().toString()); - root.setPath("/"); + root.setPath(u"/"); return root; } diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index b085edd68f4..3ccb05c6cc1 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -1048,20 +1048,20 @@ QString LinuxDevice::userAtHost() const return sshParameters().userAtHost(); } -Utils::FilePath LinuxDevice::rootPath() const +FilePath LinuxDevice::rootPath() const { - Utils::FilePath root; - root.setScheme("ssh"); + FilePath root; + root.setScheme(u"ssh"); root.setHost(userAtHost()); - root.setPath("/"); + root.setPath(u"/"); return root; } bool LinuxDevice::handlesFile(const FilePath &filePath) const { - if (filePath.scheme() == "device" && filePath.host() == id().toString()) + if (filePath.scheme() == u"device" && filePath.host() == id().toString()) return true; - if (filePath.scheme() == "ssh" && filePath.host() == userAtHost()) + if (filePath.scheme() == u"ssh" && filePath.host() == userAtHost()) return true; return false; } diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index ef93ad8f3fe..e1eb815e9d1 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -117,12 +117,12 @@ static RemoteLinuxPluginPrivate *dd = nullptr; RemoteLinuxPlugin::RemoteLinuxPlugin() { setObjectName(QLatin1String("RemoteLinuxPlugin")); - FSEngine::registerDeviceScheme("ssh"); + FSEngine::registerDeviceScheme(u"ssh"); } RemoteLinuxPlugin::~RemoteLinuxPlugin() { - FSEngine::unregisterDeviceScheme("ssh"); + FSEngine::unregisterDeviceScheme(u"ssh"); delete dd; } diff --git a/tests/auto/utils/fsengine/tst_fsengine.cpp b/tests/auto/utils/fsengine/tst_fsengine.cpp index 5fb9b215f2d..48969c40176 100644 --- a/tests/auto/utils/fsengine/tst_fsengine.cpp +++ b/tests/auto/utils/fsengine/tst_fsengine.cpp @@ -188,9 +188,9 @@ void tst_fsengine::initTestCase() void tst_fsengine::testFilePathFromToString() { FilePath p = FilePath::fromString("device://test/test.txt"); - QCOMPARE(p.scheme(), "device"); - QCOMPARE(p.host(), "test"); - QCOMPARE(p.path(), "/test.txt"); + QCOMPARE(p.scheme(), u"device"); + QCOMPARE(p.host(), u"test"); + QCOMPARE(p.path(), u"/test.txt"); QString asString = p.toString(); QCOMPARE(asString, @@ -198,9 +198,9 @@ void tst_fsengine::testFilePathFromToString() + "/test/test.txt"); FilePath p2 = FilePath::fromString(asString); - QCOMPARE(p.scheme(), "device"); - QCOMPARE(p.host(), "test"); - QCOMPARE(p.path(), "/test.txt"); + QCOMPARE(p.scheme(), u"device"); + QCOMPARE(p.host(), u"test"); + QCOMPARE(p.path(), u"/test.txt"); } void tst_fsengine::testRootPathContainsFakeDir()