From cb4f75426d49fed6d9d134d0688aeaf70f71e52d Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 13 Sep 2021 12:55:01 +0200 Subject: [PATCH] ProjectExplorer: Remove one constructor overload of DeployableFile Change-Id: I87e444349129e9370b5fec505444723d36e21448 Reviewed-by: Christian Kandeler --- .../cmakeprojectmanager/cmakebuildsystem.cpp | 2 +- .../projectexplorer/deployablefile.cpp | 4 ---- src/plugins/projectexplorer/deployablefile.h | 2 -- .../projectexplorer/deployconfiguration.cpp | 4 +++- .../projectexplorer/deploymentdata.cpp | 6 ++++-- src/plugins/projectexplorer/deploymentdata.h | 2 +- .../projectexplorer/deploymentdataview.cpp | 4 ++-- src/plugins/qbsprojectmanager/qbsproject.cpp | 2 +- .../qmakeprojectmanager/qmakeproject.cpp | 16 +++++++------- src/plugins/qmlprojectmanager/qmlproject.cpp | 2 +- .../qnx/qnxdeployqtlibrariesdialog.cpp | 3 ++- ...abstractuploadandinstallpackageservice.cpp | 21 +++++++------------ .../abstractuploadandinstallpackageservice.h | 2 -- .../remotelinux/deploymenttimeinfo.cpp | 5 +++-- src/plugins/remotelinux/makeinstallstep.cpp | 2 +- .../remotelinux/tarpackagecreationstep.cpp | 2 +- 16 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index c258645dd65..bd5e6f259c1 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -1127,7 +1127,7 @@ DeploymentData CMakeBuildSystem::deploymentData() const if (ct.targetType == ExecutableType || ct.targetType == DynamicLibraryType) { if (!ct.executable.isEmpty() && result.deployableForLocalFile(ct.executable).localFilePath() != ct.executable) { - result.addFile(ct.executable.toString(), + result.addFile(ct.executable, deploymentPrefix + buildDir.relativeFilePath(ct.executable.toFileInfo().dir().path()), DeployableFile::TypeExecutable); } diff --git a/src/plugins/projectexplorer/deployablefile.cpp b/src/plugins/projectexplorer/deployablefile.cpp index d8ea6cd33a6..78fbcb165e7 100644 --- a/src/plugins/projectexplorer/deployablefile.cpp +++ b/src/plugins/projectexplorer/deployablefile.cpp @@ -33,10 +33,6 @@ using namespace Utils; namespace ProjectExplorer { -DeployableFile::DeployableFile(const QString &localFilePath, const QString &remoteDir, Type type) - : m_localFilePath(FilePath::fromUserInput(localFilePath)), m_remoteDir(remoteDir), m_type(type) -{ } - DeployableFile::DeployableFile(const FilePath &localFilePath, const QString &remoteDir, Type type) : m_localFilePath(localFilePath), m_remoteDir(remoteDir), m_type(type) { } diff --git a/src/plugins/projectexplorer/deployablefile.h b/src/plugins/projectexplorer/deployablefile.h index b1a6c6a1d62..4709206b16d 100644 --- a/src/plugins/projectexplorer/deployablefile.h +++ b/src/plugins/projectexplorer/deployablefile.h @@ -43,8 +43,6 @@ public: }; DeployableFile() = default; - DeployableFile(const QString &m_localFilePath, const QString &m_remoteDir, - Type type = TypeNormal); DeployableFile(const Utils::FilePath &localFilePath, const QString &remoteDir, Type type = TypeNormal); diff --git a/src/plugins/projectexplorer/deployconfiguration.cpp b/src/plugins/projectexplorer/deployconfiguration.cpp index d4187da115b..df10a323101 100644 --- a/src/plugins/projectexplorer/deployconfiguration.cpp +++ b/src/plugins/projectexplorer/deployconfiguration.cpp @@ -35,6 +35,8 @@ #include +using namespace Utils; + namespace ProjectExplorer { const char BUILD_STEP_LIST_COUNT[] = "ProjectExplorer.BuildConfiguration.BuildStepListCount"; @@ -107,7 +109,7 @@ bool DeployConfiguration::fromMap(const QVariantMap &map) m_usesCustomDeploymentData = map.value(USES_DEPLOYMENT_DATA, false).toBool(); const QVariantMap deployData = map.value(DEPLOYMENT_DATA).toMap(); for (auto it = deployData.begin(); it != deployData.end(); ++it) - m_customDeploymentData.addFile(it.key(), it.value().toString()); + m_customDeploymentData.addFile(FilePath::fromString(it.key()), it.value().toString()); return true; } diff --git a/src/plugins/projectexplorer/deploymentdata.cpp b/src/plugins/projectexplorer/deploymentdata.cpp index 4d4aec4a12f..7c2c60ab5dd 100644 --- a/src/plugins/projectexplorer/deploymentdata.cpp +++ b/src/plugins/projectexplorer/deploymentdata.cpp @@ -31,6 +31,8 @@ #include #include +using namespace Utils; + namespace ProjectExplorer { void DeploymentData::setLocalInstallRoot(const Utils::FilePath &installRoot) @@ -43,7 +45,7 @@ void DeploymentData::addFile(const DeployableFile &file) m_files << file; } -void DeploymentData::addFile(const QString &localFilePath, const QString &remoteDirectory, +void DeploymentData::addFile(const FilePath &localFilePath, const QString &remoteDirectory, DeployableFile::Type type) { addFile(DeployableFile(localFilePath, remoteDirectory, type)); @@ -94,7 +96,7 @@ QString DeploymentData::addFilesFromDeploymentFile(const QString &deploymentFile QString targetFile = line.mid(splitPoint + 1); if (QFileInfo(targetFile).isRelative()) targetFile.prepend(deploymentPrefix); - addFile(sourceFile, targetFile); + addFile(FilePath::fromString(sourceFile), targetFile); } } return deploymentPrefix; diff --git a/src/plugins/projectexplorer/deploymentdata.h b/src/plugins/projectexplorer/deploymentdata.h index ad4209330eb..9a5ae43a633 100644 --- a/src/plugins/projectexplorer/deploymentdata.h +++ b/src/plugins/projectexplorer/deploymentdata.h @@ -54,7 +54,7 @@ public: Utils::FilePath localInstallRoot() const { return m_localInstallRoot; } void addFile(const DeployableFile &file); - void addFile(const QString &localFilePath, const QString &remoteDirectory, + void addFile(const Utils::FilePath &localFilePath, const QString &remoteDirectory, DeployableFile::Type type = DeployableFile::TypeNormal); QString addFilesFromDeploymentFile(const QString &deploymentFilePath, const QString &sourceDir); diff --git a/src/plugins/projectexplorer/deploymentdataview.cpp b/src/plugins/projectexplorer/deploymentdataview.cpp index f3fcc072b4f..689c351125f 100644 --- a/src/plugins/projectexplorer/deploymentdataview.cpp +++ b/src/plugins/projectexplorer/deploymentdataview.cpp @@ -74,9 +74,9 @@ public: if (role != Qt::EditRole) return false; if (column == 0) - file = DeployableFile(data.toString(), file.remoteDirectory()); + file = DeployableFile(FilePath::fromVariant(data), file.remoteDirectory()); else if (column == 1) - file = DeployableFile(file.localFilePath().toString(), data.toString()); + file = DeployableFile(file.localFilePath(), data.toString()); return true; } diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp index ae1ec86379d..b1402e70f2f 100644 --- a/src/plugins/qbsprojectmanager/qbsproject.cpp +++ b/src/plugins/qbsprojectmanager/qbsproject.cpp @@ -1161,7 +1161,7 @@ void QbsBuildSystem::updateDeploymentInfo() const QJsonObject installData = artifact.value("install-data").toObject(); if (installData.value("is-installable").toBool()) { deploymentData.addFile( - artifact.value("file-path").toString(), + FilePath::fromVariant(artifact.value("file-path")), QFileInfo(installData.value("install-file-path").toString()).path(), artifact.value("is-executable").toBool() ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal); diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 420194a1181..793ec73ba86 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -1230,8 +1230,8 @@ void QmakeBuildSystem::collectData(const QmakeProFile *file, DeploymentData &dep if (!item.active) continue; for (const auto &localFile : item.files) { - deploymentData.addFile(localFile.fileName, item.path, item.executable - ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal); + deploymentData.addFile(FilePath::fromString(localFile.fileName), item.path, + item.executable ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal); } } @@ -1260,7 +1260,7 @@ void QmakeBuildSystem::collectApplicationData(const QmakeProFile *file, Deployme { const FilePath executable = executableFor(file); if (!executable.isEmpty()) - deploymentData.addFile(executable.path(), file->installsList().targetPath, + deploymentData.addFile(executable, file->installsList().targetPath, DeployableFile::TypeExecutable); } @@ -1301,7 +1301,7 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa } targetFileName += targetVersionExt + QLatin1Char('.'); targetFileName += QLatin1String(isStatic ? "lib" : "dll"); - deploymentData.addFile(destDirFor(ti).toString() + '/' + targetFileName, targetPath); + deploymentData.addFile(destDirFor(ti) / targetFileName, targetPath); break; } case Abi::DarwinOS: { @@ -1324,7 +1324,7 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa targetFileName += file->singleVariableValue(isStatic ? Variable::StaticLibExtension : Variable::ShLibExtension); } - deploymentData.addFile(destDir.toString() + '/' + targetFileName, targetPath); + deploymentData.addFile(destDir / targetFileName, targetPath); break; } case Abi::LinuxOS: @@ -1339,7 +1339,7 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa targetFileName += QLatin1Char('a'); } else { targetFileName += QLatin1String("so"); - deploymentData.addFile(destDirFor(ti).toString() + '/' + targetFileName, targetPath); + deploymentData.addFile(destDirFor(ti) / targetFileName, targetPath); if (nameIsVersioned) { QString version = file->singleVariableValue(Variable::Version); if (version.isEmpty()) @@ -1350,8 +1350,8 @@ void QmakeBuildSystem::collectLibraryData(const QmakeProFile *file, DeploymentDa targetFileName += QLatin1Char('.'); while (!versionComponents.isEmpty()) { const QString versionString = versionComponents.join(QLatin1Char('.')); - deploymentData.addFile(destDirFor(ti).toString() + '/' - + targetFileName + versionString, targetPath); + deploymentData.addFile(destDirFor(ti) / targetFileName + versionString, + targetPath); versionComponents.removeLast(); } } diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index e33877c6f51..f248773faf5 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -520,7 +520,7 @@ void QmlBuildSystem::updateDeploymentData() ProjectExplorer::DeploymentData deploymentData; for (const QString &file : m_projectItem->files()) { deploymentData.addFile( - file, + FilePath::fromString(file), targetFile(Utils::FilePath::fromString(file)).parentDir().toString()); } diff --git a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp index 2e3f9c2d4d9..5f6d5f888cb 100644 --- a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp +++ b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp @@ -286,7 +286,8 @@ QList QnxDeployQtLibrariesDialog::gatherFiles( remoteDir = fullRemoteDirectory() + QLatin1Char('/') + baseDir.relativeFilePath(dirPath); } - result.append(DeployableFile(fileInfo.absoluteFilePath(), remoteDir)); + result.append(DeployableFile(Utils::FilePath::fromString(fileInfo.absoluteFilePath()), + remoteDir)); } } diff --git a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp index d94270eaebe..af3a23df947 100644 --- a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp +++ b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp @@ -35,6 +35,7 @@ #include using namespace ProjectExplorer; +using namespace Utils; namespace RemoteLinux { namespace Internal { @@ -53,7 +54,7 @@ public: State state; PackageUploader * const uploader; - QString packageFilePath; + Utils::FilePath packageFilePath; }; } // namespace Internal @@ -72,12 +73,7 @@ AbstractUploadAndInstallPackageService::~AbstractUploadAndInstallPackageService( void AbstractUploadAndInstallPackageService::setPackageFilePath(const QString &filePath) { - d->packageFilePath = filePath; -} - -QString AbstractUploadAndInstallPackageService::packageFilePath() const -{ - return d->packageFilePath; + d->packageFilePath = FilePath::fromString(filePath); } QString AbstractUploadAndInstallPackageService::uploadDir() const @@ -87,7 +83,7 @@ QString AbstractUploadAndInstallPackageService::uploadDir() const bool AbstractUploadAndInstallPackageService::isDeploymentNecessary() const { - return hasLocalFileChanged(DeployableFile(packageFilePath(), QString())); + return hasLocalFileChanged(DeployableFile(d->packageFilePath, QString())); } void AbstractUploadAndInstallPackageService::doDeviceSetup() @@ -109,13 +105,13 @@ void AbstractUploadAndInstallPackageService::doDeploy() QTC_ASSERT(d->state == Inactive, return); d->state = Uploading; - const QString fileName = Utils::FilePath::fromString(packageFilePath()).fileName(); + const QString fileName = d->packageFilePath.fileName(); const QString remoteFilePath = uploadDir() + QLatin1Char('/') + fileName; connect(d->uploader, &PackageUploader::progress, this, &AbstractUploadAndInstallPackageService::progressMessage); connect(d->uploader, &PackageUploader::uploadFinished, this, &AbstractUploadAndInstallPackageService::handleUploadFinished); - d->uploader->uploadPackage(connection(), packageFilePath(), remoteFilePath); + d->uploader->uploadPackage(connection(), d->packageFilePath.toString(), remoteFilePath); } void AbstractUploadAndInstallPackageService::stopDeployment() @@ -146,8 +142,7 @@ void AbstractUploadAndInstallPackageService::handleUploadFinished(const QString } emit progressMessage(tr("Successfully uploaded package file.")); - const QString remoteFilePath = uploadDir() + QLatin1Char('/') - + Utils::FilePath::fromString(packageFilePath()).fileName(); + const QString remoteFilePath = uploadDir() + '/' + d->packageFilePath.fileName(); d->state = Installing; emit progressMessage(tr("Installing package to device...")); connect(packageInstaller(), &AbstractRemoteLinuxPackageInstaller::stdoutData, @@ -164,7 +159,7 @@ void AbstractUploadAndInstallPackageService::handleInstallationFinished(const QS QTC_ASSERT(d->state == Installing, return); if (errorMsg.isEmpty()) { - saveDeploymentTimeStamp(DeployableFile(packageFilePath(), QString()), QDateTime()); + saveDeploymentTimeStamp(DeployableFile(d->packageFilePath, QString()), QDateTime()); emit progressMessage(tr("Package installed.")); } else { emit errorMessage(errorMsg); diff --git a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.h b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.h index cef3ccf6b33..2ca0a3dc626 100644 --- a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.h +++ b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.h @@ -44,8 +44,6 @@ protected: AbstractUploadAndInstallPackageService(); ~AbstractUploadAndInstallPackageService() override; - QString packageFilePath() const; - private: void handleUploadFinished(const QString &errorMsg); void handleInstallationFinished(const QString &errorMsg); diff --git a/src/plugins/remotelinux/deploymenttimeinfo.cpp b/src/plugins/remotelinux/deploymenttimeinfo.cpp index 983bc76110a..3130aadf20c 100644 --- a/src/plugins/remotelinux/deploymenttimeinfo.cpp +++ b/src/plugins/remotelinux/deploymenttimeinfo.cpp @@ -33,9 +33,9 @@ #include #include -#include using namespace ProjectExplorer; +using namespace Utils; using namespace QSsh; namespace RemoteLinux { @@ -180,7 +180,8 @@ void DeploymentTimeInfo::importDeployTimes(const QVariantMap &map) sysrootList.size()); for (int i = 0; i < elemCount; ++i) { - const DeployableFile df(fileList.at(i).toString(), remotePathList.at(i).toString()); + const DeployableFile df(FilePath::fromVariant(fileList.at(i)), + remotePathList.at(i).toString()); const DeployParameters dp{df, hostList.at(i).toString(), sysrootList.at(i).toString()}; d->lastDeployed.insert(dp, { localTimesList.at(i).toDateTime(), remoteTimesList.length() > i diff --git a/src/plugins/remotelinux/makeinstallstep.cpp b/src/plugins/remotelinux/makeinstallstep.cpp index 5321683e4f0..9d51a024e4f 100644 --- a/src/plugins/remotelinux/makeinstallstep.cpp +++ b/src/plugins/remotelinux/makeinstallstep.cpp @@ -201,7 +201,7 @@ void MakeInstallStep::finish(bool success) const DeployableFile::Type type = appFileNames.contains(fi.fileName()) ? DeployableFile::TypeExecutable : DeployableFile::TypeNormal; - m_deploymentData.addFile(fi.filePath(), + m_deploymentData.addFile(FilePath::fromString(fi.filePath()), fi.dir().path().mid(installRoot().toString().length()), type); } buildSystem()->setDeploymentData(m_deploymentData); diff --git a/src/plugins/remotelinux/tarpackagecreationstep.cpp b/src/plugins/remotelinux/tarpackagecreationstep.cpp index ffaaddca727..ef3647d6c58 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.cpp +++ b/src/plugins/remotelinux/tarpackagecreationstep.cpp @@ -130,7 +130,7 @@ void TarPackageCreationStep::addNeededDeploymentFiles( } for (const QString &fileName : files) { - const QString localFilePath = deployable.localFilePath().pathAppended(fileName).toString(); + const FilePath localFilePath = deployable.localFilePath().pathAppended(fileName); const QString remoteDir = deployable.remoteDirectory() + '/' + fileInfo.fileName();