ProjectExplorer: Use FilePaths in project tree nodes

Change-Id: I31b15c428d9b962333947b1e32641fd80f61d069
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-07-14 16:49:42 +02:00
parent a58686cf96
commit 1bde4ddbec
42 changed files with 343 additions and 308 deletions

View File

@@ -1433,6 +1433,27 @@ Environment FilePath::deviceEnvironment() const
return Environment::systemEnvironment(); return Environment::systemEnvironment();
} }
QString FilePath::formatFilePaths(const QList<FilePath> &files, const QString &separator)
{
const QStringList nativeFiles = Utils::transform(files, &FilePath::toUserOutput);
return nativeFiles.join(separator);
}
void FilePath::removeDuplicates(QList<FilePath> &files)
{
// FIXME: Improve.
QStringList list = Utils::transform<QStringList>(files, &FilePath::toString);
list.removeDuplicates();
files = Utils::transform(list, &FilePath::fromString);
}
void FilePath::sort(QList<FilePath> &files)
{
// FIXME: Improve.
QStringList list = Utils::transform<QStringList>(files, &FilePath::toString);
list.sort();
files = Utils::transform(list, &FilePath::fromString);
}
FilePath FilePath::pathAppended(const QString &path) const FilePath FilePath::pathAppended(const QString &path) const
{ {
@@ -1590,9 +1611,9 @@ bool FileUtils::CopyAskingForOverwrite::operator()(const QFileInfo &src,
return true; return true;
} }
QStringList FileUtils::CopyAskingForOverwrite::files() const FilePaths FileUtils::CopyAskingForOverwrite::files() const
{ {
return m_files; return transform(m_files, &FilePath::fromString);
} }
#endif // QT_GUI_LIB #endif // QT_GUI_LIB

View File

@@ -223,6 +223,10 @@ public:
FilePath searchOnDevice(const QList<FilePath> &dirs) const; FilePath searchOnDevice(const QList<FilePath> &dirs) const;
Environment deviceEnvironment() const; Environment deviceEnvironment() const;
static QString formatFilePaths(const QList<FilePath> &files, const QString &separator);
static void removeDuplicates(QList<FilePath> &files);
static void sort(QList<FilePath> &files);
private: private:
friend class ::tst_fileutils; friend class ::tst_fileutils;
static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath); static QString calcRelativePath(const QString &absolutePath, const QString &absoluteAnchorPath);
@@ -245,7 +249,7 @@ public:
CopyAskingForOverwrite(QWidget *dialogParent, CopyAskingForOverwrite(QWidget *dialogParent,
const std::function<void(QFileInfo)> &postOperation = {}); const std::function<void(QFileInfo)> &postOperation = {});
bool operator()(const QFileInfo &src, const QFileInfo &dest, QString *error); bool operator()(const QFileInfo &src, const QFileInfo &dest, QString *error);
QStringList files() const; QList<FilePath> files() const;
private: private:
QWidget *m_parent; QWidget *m_parent;

View File

@@ -77,20 +77,20 @@ using namespace Utils;
namespace CMakeProjectManager { namespace CMakeProjectManager {
namespace Internal { namespace Internal {
static void copySourcePathsToClipboard(QStringList srcPaths, const ProjectNode *node) static void copySourcePathsToClipboard(const FilePaths &srcPaths, const ProjectNode *node)
{ {
QClipboard *clip = QGuiApplication::clipboard(); QClipboard *clip = QGuiApplication::clipboard();
QDir projDir{node->filePath().toFileInfo().absoluteFilePath()}; QDir projDir{node->filePath().toFileInfo().absoluteFilePath()};
QString data = Utils::transform(srcPaths, [projDir](const QString &path) { QString data = Utils::transform(srcPaths, [projDir](const FilePath &path) {
return QDir::cleanPath(projDir.relativeFilePath(path)); return QDir::cleanPath(projDir.relativeFilePath(path.toString()));
}).join(" "); }).join(" ");
clip->setText(data); clip->setText(data);
} }
static void noAutoAdditionNotify(const QStringList &filePaths, const ProjectNode *node) static void noAutoAdditionNotify(const FilePaths &filePaths, const ProjectNode *node)
{ {
const QStringList srcPaths = Utils::filtered(filePaths, [](const QString& file) { const FilePaths srcPaths = Utils::filtered(filePaths, [](const FilePath &file) {
const auto mimeType = Utils::mimeTypeForFile(file).name(); const auto mimeType = Utils::mimeTypeForFile(file).name();
return mimeType == CppTools::Constants::C_SOURCE_MIMETYPE || return mimeType == CppTools::Constants::C_SOURCE_MIMETYPE ||
mimeType == CppTools::Constants::C_HEADER_MIMETYPE || mimeType == CppTools::Constants::C_HEADER_MIMETYPE ||
@@ -307,7 +307,7 @@ bool CMakeBuildSystem::supportsAction(Node *context, ProjectAction action, const
return BuildSystem::supportsAction(context, action, node); return BuildSystem::supportsAction(context, action, node);
} }
bool CMakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStringList *notAdded) bool CMakeBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FilePaths *notAdded)
{ {
if (auto n = dynamic_cast<CMakeProjectNode *>(context)) { if (auto n = dynamic_cast<CMakeProjectNode *>(context)) {
noAutoAdditionNotify(filePaths, n); noAutoAdditionNotify(filePaths, n);
@@ -322,9 +322,9 @@ bool CMakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QSt
return BuildSystem::addFiles(context, filePaths, notAdded); return BuildSystem::addFiles(context, filePaths, notAdded);
} }
QStringList CMakeBuildSystem::filesGeneratedFrom(const QString &sourceFile) const FilePaths CMakeBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const
{ {
QFileInfo fi(sourceFile); QFileInfo fi = sourceFile.toFileInfo();
FilePath project = projectDirectory(); FilePath project = projectDirectory();
FilePath baseDirectory = FilePath::fromString(fi.absolutePath()); FilePath baseDirectory = FilePath::fromString(fi.absolutePath());
@@ -344,12 +344,13 @@ QStringList CMakeBuildSystem::filesGeneratedFrom(const QString &sourceFile) cons
generatedFilePath += "/ui_"; generatedFilePath += "/ui_";
generatedFilePath += fi.completeBaseName(); generatedFilePath += fi.completeBaseName();
generatedFilePath += ".h"; generatedFilePath += ".h";
return {QDir::cleanPath(generatedFilePath)}; return {FilePath::fromString(QDir::cleanPath(generatedFilePath))};
} }
if (fi.suffix() == "scxml") { if (fi.suffix() == "scxml") {
generatedFilePath += "/"; generatedFilePath += "/";
generatedFilePath += QDir::cleanPath(fi.completeBaseName()); generatedFilePath += QDir::cleanPath(fi.completeBaseName());
return {generatedFilePath + ".h", generatedFilePath + ".cpp"}; return {FilePath::fromString(generatedFilePath + ".h"),
FilePath::fromString(generatedFilePath + ".cpp")};
} }
// TODO: Other types will be added when adapters for their compilers become available. // TODO: Other types will be added when adapters for their compilers become available.
@@ -1173,16 +1174,13 @@ QList<ExtraCompiler *> CMakeBuildSystem::findExtraCompilers()
}); });
QTC_ASSERT(factory, continue); QTC_ASSERT(factory, continue);
QStringList generated = filesGeneratedFrom(file.toString()); FilePaths generated = filesGeneratedFrom(file);
qCDebug(cmakeBuildSystemLog) qCDebug(cmakeBuildSystemLog)
<< "Finding Extra Compilers: generated files:" << generated; << "Finding Extra Compilers: generated files:" << generated;
if (generated.isEmpty()) if (generated.isEmpty())
continue; continue;
const FilePaths fileNames = transform(generated, [](const QString &s) { extraCompilers.append(factory->create(p, file, generated));
return FilePath::fromString(s);
});
extraCompilers.append(factory->create(p, file, fileNames));
qCDebug(cmakeBuildSystemLog) qCDebug(cmakeBuildSystemLog)
<< "Finding Extra Compilers: done with" << file.toUserOutput(); << "Finding Extra Compilers: done with" << file.toUserOutput();
} }

View File

@@ -67,9 +67,9 @@ public:
const ProjectExplorer::Node *node) const final; const ProjectExplorer::Node *node) const final;
bool addFiles(ProjectExplorer::Node *context, bool addFiles(ProjectExplorer::Node *context,
const QStringList &filePaths, QStringList *) final; const Utils::FilePaths &filePaths, Utils::FilePaths *) final;
QStringList filesGeneratedFrom(const QString &sourceFile) const final; Utils::FilePaths filesGeneratedFrom(const Utils::FilePath &sourceFile) const final;
// Actions: // Actions:
void runCMake(); void runCMake();

View File

@@ -95,6 +95,11 @@ QString GeneratedFile::path() const
return m_d->path; return m_d->path;
} }
FilePath GeneratedFile::filePath() const
{
return FilePath::fromString(m_d->path);
}
void GeneratedFile::setPath(const QString &p) void GeneratedFile::setPath(const QString &p)
{ {
m_d->path = QDir::cleanPath(p); m_d->path = QDir::cleanPath(p);

View File

@@ -32,6 +32,8 @@
#include <QList> #include <QList>
#include <QSharedDataPointer> #include <QSharedDataPointer>
namespace Utils { class FilePath; }
namespace Core { namespace Core {
class GeneratedFilePrivate; class GeneratedFilePrivate;
@@ -63,6 +65,7 @@ public:
// Full path of the file should be created, or the suggested file name // Full path of the file should be created, or the suggested file name
QString path() const; QString path() const;
void setPath(const QString &p); void setPath(const QString &p);
Utils::FilePath filePath() const;
// Contents of the file (UTF8) // Contents of the file (UTF8)
QString contents() const; QString contents() const;

View File

@@ -39,6 +39,7 @@
// Debug helpers for code model. @todo: Move to some CppTools library? // Debug helpers for code model. @todo: Move to some CppTools library?
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
using DependencyMap = QMap<QString, QStringList>; using DependencyMap = QMap<QString, QStringList>;
using DocumentPtr = CPlusPlus::Document::Ptr; using DocumentPtr = CPlusPlus::Document::Ptr;
@@ -48,19 +49,18 @@ using DocumentPtrList = QList<DocumentPtr>;
static const char setupUiC[] = "setupUi"; static const char setupUiC[] = "setupUi";
// Find the generated "ui_form.h" header of the form via project. // Find the generated "ui_form.h" header of the form via project.
static QString generatedHeaderOf(const QString &uiFileName) static FilePath generatedHeaderOf(const FilePath &uiFileName)
{ {
if (const Project *uiProject = if (const Project *uiProject = SessionManager::projectForFile(uiFileName)) {
SessionManager::projectForFile(Utils::FilePath::fromString(uiFileName))) {
if (Target *t = uiProject->activeTarget()) { if (Target *t = uiProject->activeTarget()) {
if (BuildSystem *bs = t->buildSystem()) { if (BuildSystem *bs = t->buildSystem()) {
QStringList files = bs->filesGeneratedFrom(uiFileName); FilePaths files = bs->filesGeneratedFrom(uiFileName);
if (!files.isEmpty()) // There should be at most one header generated from a .ui if (!files.isEmpty()) // There should be at most one header generated from a .ui
return files.front(); return files.front();
} }
} }
} }
return QString(); return {};
} }
namespace { namespace {
@@ -121,7 +121,7 @@ bool navigateToSlot(const QString &uiFileName,
{ {
// Find the generated header. // Find the generated header.
const QString generatedHeaderFile = generatedHeaderOf(uiFileName); const FilePath generatedHeaderFile = generatedHeaderOf(FilePath::fromString(uiFileName));
if (generatedHeaderFile.isEmpty()) { if (generatedHeaderFile.isEmpty()) {
*errorMessage = QCoreApplication::translate("Designer", "The generated header of the form \"%1\" could not be found.\nRebuilding the project might help.").arg(uiFileName); *errorMessage = QCoreApplication::translate("Designer", "The generated header of the form \"%1\" could not be found.\nRebuilding the project might help.").arg(uiFileName);
return false; return false;
@@ -129,7 +129,7 @@ bool navigateToSlot(const QString &uiFileName,
const CPlusPlus::Snapshot snapshot = CppTools::CppModelManager::instance()->snapshot(); const CPlusPlus::Snapshot snapshot = CppTools::CppModelManager::instance()->snapshot();
const DocumentPtr generatedHeaderDoc = snapshot.document(generatedHeaderFile); const DocumentPtr generatedHeaderDoc = snapshot.document(generatedHeaderFile);
if (!generatedHeaderDoc) { if (!generatedHeaderDoc) {
*errorMessage = QCoreApplication::translate("Designer", "The generated header \"%1\" could not be found in the code model.\nRebuilding the project might help.").arg(generatedHeaderFile); *errorMessage = QCoreApplication::translate("Designer", "The generated header \"%1\" could not be found in the code model.\nRebuilding the project might help.").arg(generatedHeaderFile.toUserOutput());
return false; return false;
} }
@@ -139,7 +139,7 @@ bool navigateToSlot(const QString &uiFileName,
if (funcs.size() != 1) { if (funcs.size() != 1) {
*errorMessage = QString::fromLatin1( *errorMessage = QString::fromLatin1(
"Internal error: The function \"%1\" could not be found in %2") "Internal error: The function \"%1\" could not be found in %2")
.arg(QLatin1String(setupUiC), generatedHeaderFile); .arg(QLatin1String(setupUiC), generatedHeaderFile.toUserOutput());
return false; return false;
} }
return true; return true;

View File

@@ -37,6 +37,7 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
@@ -142,7 +143,7 @@ void ResourceHandler::updateResourcesHelper(bool updateProjectResources)
} }
if (!qrcPathsToBeAdded.isEmpty()) { if (!qrcPathsToBeAdded.isEmpty()) {
m_handlingResources = true; m_handlingResources = true;
projectNodeForUiFile->addFiles(qrcPathsToBeAdded); projectNodeForUiFile->addFiles(Utils::transform(qrcPathsToBeAdded, &FilePath::fromString));
m_handlingResources = false; m_handlingResources = false;
projectQrcFiles += qrcPathsToBeAdded; projectQrcFiles += qrcPathsToBeAdded;
} }

View File

@@ -135,11 +135,9 @@ public:
|| action == Rename; || action == Rename;
} }
RemovedFilesFromProject removeFiles(Node *, const QStringList &filePaths, QStringList *) final; RemovedFilesFromProject removeFiles(Node *, const FilePaths &filePaths, FilePaths *) final;
bool renameFile(Node *, bool renameFile(Node *, const FilePath &oldFilePath, const FilePath &newFilePath) final;
const Utils::FilePath &oldFilePath, bool addFiles(Node *, const FilePaths &filePaths, FilePaths *) final;
const Utils::FilePath &newFilePath) final;
bool addFiles(Node *, const QStringList &filePaths, QStringList *) final;
FilePath filesFilePath() const { return ::FilePath::fromString(m_filesFileName); } FilePath filesFilePath() const { return ::FilePath::fromString(m_filesFileName); }
@@ -157,7 +155,7 @@ public:
void updateDeploymentData(); void updateDeploymentData();
bool setFiles(const QStringList &filePaths); bool setFiles(const QStringList &filePaths);
void removeFiles(const QStringList &filesToRemove); void removeFiles(const FilePaths &filesToRemove);
private: private:
QString m_filesFileName; QString m_filesFileName;
@@ -327,8 +325,9 @@ static void insertSorted(QStringList *list, const QString &value)
list->insert(it, value); list->insert(it, value);
} }
bool GenericBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringList *) bool GenericBuildSystem::addFiles(Node *, const FilePaths &filePaths_, FilePaths *)
{ {
const QStringList filePaths = Utils::transform(filePaths_, &FilePath::toString);
const QDir baseDir(projectDirectory().toString()); const QDir baseDir(projectDirectory().toString());
QStringList newList = m_rawFileList; QStringList newList = m_rawFileList;
if (filePaths.size() > m_rawFileList.size()) { if (filePaths.size() > m_rawFileList.size()) {
@@ -368,12 +367,12 @@ bool GenericBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringL
return result; return result;
} }
RemovedFilesFromProject GenericBuildSystem::removeFiles(Node *, const QStringList &filePaths, QStringList *) RemovedFilesFromProject GenericBuildSystem::removeFiles(Node *, const FilePaths &filePaths, FilePaths *)
{ {
QStringList newList = m_rawFileList; QStringList newList = m_rawFileList;
for (const QString &filePath : filePaths) { for (const FilePath &filePath : filePaths) {
QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath); QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath.toString());
if (i != m_rawListEntries.end()) if (i != m_rawListEntries.end())
newList.removeOne(i.value()); newList.removeOne(i.value());
} }
@@ -609,7 +608,7 @@ void GenericBuildSystem::updateDeploymentData()
} }
} }
void GenericBuildSystem::removeFiles(const QStringList &filesToRemove) void GenericBuildSystem::removeFiles(const FilePaths &filesToRemove)
{ {
if (removeFiles(nullptr, filesToRemove, nullptr) == RemovedFilesFromProject::Error) { if (removeFiles(nullptr, filesToRemove, nullptr) == RemovedFilesFromProject::Error) {
TaskHub::addTask(BuildSystemTask(Task::Error, TaskHub::addTask(BuildSystemTask(Task::Error,
@@ -695,7 +694,7 @@ void GenericProject::editFilesTriggered()
} }
} }
void GenericProject::removeFilesTriggered(const QStringList &filesToRemove) void GenericProject::removeFilesTriggered(const FilePaths &filesToRemove)
{ {
if (Target *t = activeTarget()) if (Target *t = activeTarget())
static_cast<GenericBuildSystem *>(t->buildSystem())->removeFiles(filesToRemove); static_cast<GenericBuildSystem *>(t->buildSystem())->removeFiles(filesToRemove);

View File

@@ -38,7 +38,7 @@ public:
explicit GenericProject(const Utils::FilePath &filename); explicit GenericProject(const Utils::FilePath &filename);
void editFilesTriggered(); void editFilesTriggered();
void removeFilesTriggered(const QStringList &filesToRemove); void removeFilesTriggered(const Utils::FilePaths &filesToRemove);
private: private:
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) final; RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) final;

View File

@@ -108,9 +108,9 @@ GenericProjectPluginPrivate::GenericProjectPluginPrivate()
QTC_ASSERT(folderNode, return); QTC_ASSERT(folderNode, return);
const auto project = qobject_cast<GenericProject *>(folderNode->getProject()); const auto project = qobject_cast<GenericProject *>(folderNode->getProject());
QTC_ASSERT(project, return); QTC_ASSERT(project, return);
const QStringList filesToRemove = transform<QStringList>( const FilePaths filesToRemove = transform(
folderNode->findNodes([](const Node *node) { return node->asFileNode(); }), folderNode->findNodes([](const Node *node) { return node->asFileNode(); }),
[](const Node *node) { return node->filePath().toString();}); [](const Node *node) { return node->filePath();});
project->removeFilesTriggered(filesToRemove); project->removeFilesTriggered(filesToRemove);
}); });
} }

View File

@@ -245,19 +245,19 @@ bool NimbleBuildSystem::supportsAction(Node *context, ProjectAction action, cons
return BuildSystem::supportsAction(context, action, node); return BuildSystem::supportsAction(context, action, node);
} }
bool NimbleBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringList *) bool NimbleBuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *)
{ {
return m_projectScanner.addFiles(filePaths); return m_projectScanner.addFiles(Utils::transform(filePaths, &FilePath::toString));
} }
RemovedFilesFromProject NimbleBuildSystem::removeFiles(Node *, RemovedFilesFromProject NimbleBuildSystem::removeFiles(Node *,
const QStringList &filePaths, const FilePaths &filePaths,
QStringList *) FilePaths *)
{ {
return m_projectScanner.removeFiles(filePaths); return m_projectScanner.removeFiles(Utils::transform(filePaths, &FilePath::toString));
} }
bool NimbleBuildSystem::deleteFiles(Node *, const QStringList &) bool NimbleBuildSystem::deleteFiles(Node *, const FilePaths &)
{ {
return true; return true;
} }

View File

@@ -75,11 +75,11 @@ private:
ProjectExplorer::ProjectAction action, ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const override; const ProjectExplorer::Node *node) const override;
bool addFiles(ProjectExplorer::Node *node, bool addFiles(ProjectExplorer::Node *node,
const QStringList &filePaths, QStringList *) override; const Utils::FilePaths &filePaths, Utils::FilePaths *) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *node, ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *node,
const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *) override; Utils::FilePaths *) override;
bool deleteFiles(ProjectExplorer::Node *, const QStringList &) override; bool deleteFiles(ProjectExplorer::Node *, const Utils::FilePaths &) override;
bool renameFile(ProjectExplorer::Node *, bool renameFile(ProjectExplorer::Node *,
const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override; const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;

View File

@@ -222,19 +222,19 @@ bool NimBuildSystem::supportsAction(Node *context, ProjectAction action, const N
return BuildSystem::supportsAction(context, action, node); return BuildSystem::supportsAction(context, action, node);
} }
bool NimBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringList *) bool NimBuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *)
{ {
return m_projectScanner.addFiles(filePaths); return m_projectScanner.addFiles(Utils::transform(filePaths, &FilePath::toString));
} }
RemovedFilesFromProject NimBuildSystem::removeFiles(Node *, RemovedFilesFromProject NimBuildSystem::removeFiles(Node *,
const QStringList &filePaths, const FilePaths &filePaths,
QStringList *) FilePaths *)
{ {
return m_projectScanner.removeFiles(filePaths); return m_projectScanner.removeFiles(Utils::transform(filePaths, &FilePath::toString));
} }
bool NimBuildSystem::deleteFiles(Node *, const QStringList &) bool NimBuildSystem::deleteFiles(Node *, const FilePaths &)
{ {
return true; return true;
} }

View File

@@ -80,11 +80,11 @@ public:
ProjectExplorer::ProjectAction action, ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const final; const ProjectExplorer::Node *node) const final;
bool addFiles(ProjectExplorer::Node *node, bool addFiles(ProjectExplorer::Node *node,
const QStringList &filePaths, QStringList *) final; const Utils::FilePaths &filePaths, Utils::FilePaths *) final;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *node, ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *node,
const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *) override; Utils::FilePaths *) override;
bool deleteFiles(ProjectExplorer::Node *, const QStringList &) final; bool deleteFiles(ProjectExplorer::Node *, const Utils::FilePaths &) final;
bool renameFile(ProjectExplorer::Node *, bool renameFile(ProjectExplorer::Node *,
const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final; const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final;

View File

@@ -200,22 +200,22 @@ void BuildSystem::requestParseHelper(int delay)
d->m_delayedParsingTimer.start(); d->m_delayedParsingTimer.start();
} }
bool BuildSystem::addFiles(Node *, const QStringList &filePaths, QStringList *notAdded) bool BuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *notAdded)
{ {
Q_UNUSED(filePaths) Q_UNUSED(filePaths)
Q_UNUSED(notAdded) Q_UNUSED(notAdded)
return false; return false;
} }
RemovedFilesFromProject BuildSystem::removeFiles(Node *, const QStringList &filePaths, RemovedFilesFromProject BuildSystem::removeFiles(Node *, const FilePaths &filePaths,
QStringList *notRemoved) FilePaths *notRemoved)
{ {
Q_UNUSED(filePaths) Q_UNUSED(filePaths)
Q_UNUSED(notRemoved) Q_UNUSED(notRemoved)
return RemovedFilesFromProject::Error; return RemovedFilesFromProject::Error;
} }
bool BuildSystem::deleteFiles(Node *, const QStringList &filePaths) bool BuildSystem::deleteFiles(Node *, const FilePaths &filePaths)
{ {
Q_UNUSED(filePaths) Q_UNUSED(filePaths)
return false; return false;
@@ -246,7 +246,7 @@ bool BuildSystem::supportsAction(Node *, ProjectAction, const Node *) const
return false; return false;
} }
QStringList BuildSystem::filesGeneratedFrom(const QString &sourceFile) const FilePaths BuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const
{ {
Q_UNUSED(sourceFile) Q_UNUSED(sourceFile)
return {}; return {};

View File

@@ -86,10 +86,13 @@ public:
Utils::Environment activeParseEnvironment() const; Utils::Environment activeParseEnvironment() const;
virtual bool addFiles(Node *context, const QStringList &filePaths, QStringList *notAdded = nullptr); virtual bool addFiles(Node *context,
virtual RemovedFilesFromProject removeFiles(Node *context, const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *notRemoved = nullptr); Utils::FilePaths *notAdded = nullptr);
virtual bool deleteFiles(Node *context, const QStringList &filePaths); virtual RemovedFilesFromProject removeFiles(Node *context,
const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved = nullptr);
virtual bool deleteFiles(Node *context, const Utils::FilePaths &filePaths);
virtual bool canRenameFile(Node *context, virtual bool canRenameFile(Node *context,
const Utils::FilePath &oldFilePath, const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath); const Utils::FilePath &newFilePath);
@@ -99,7 +102,7 @@ public:
virtual bool addDependencies(Node *context, const QStringList &dependencies); virtual bool addDependencies(Node *context, const QStringList &dependencies);
virtual bool supportsAction(Node *context, ProjectAction action, const Node *node) const; virtual bool supportsAction(Node *context, ProjectAction action, const Node *node) const;
virtual QStringList filesGeneratedFrom(const QString &sourceFile) const; virtual Utils::FilePaths filesGeneratedFrom(const Utils::FilePath &sourceFile) const;
virtual QVariant additionalData(Utils::Id id) const; virtual QVariant additionalData(Utils::Id id) const;
void setDeploymentData(const DeploymentData &deploymentData); void setDeploymentData(const DeploymentData &deploymentData);

View File

@@ -546,7 +546,7 @@ void FolderNavigationWidget::removeCurrentItem()
const QVector<FolderNode *> folderNodes = removableFolderNodes(filePath); const QVector<FolderNode *> folderNodes = removableFolderNodes(filePath);
const QVector<FolderNode *> failedNodes = Utils::filtered(folderNodes, const QVector<FolderNode *> failedNodes = Utils::filtered(folderNodes,
[filePath](FolderNode *folder) { [filePath](FolderNode *folder) {
return folder->removeFiles({filePath.toString()}) != RemovedFilesFromProject::Ok; return folder->removeFiles({filePath}) != RemovedFilesFromProject::Ok;
}); });
Core::FileChangeBlocker changeGuard(filePath); Core::FileChangeBlocker changeGuard(filePath);
Core::FileUtils::removeFiles({filePath}, true /*delete from disk*/); Core::FileUtils::removeFiles({filePath}, true /*delete from disk*/);

View File

@@ -45,6 +45,7 @@
#include <QMessageBox> #include <QMessageBox>
using namespace Core; using namespace Core;
using namespace Utils;
static char KEY_SELECTED_PROJECT[] = "SelectedProject"; static char KEY_SELECTED_PROJECT[] = "SelectedProject";
static char KEY_SELECTED_NODE[] = "SelectedFolderNode"; static char KEY_SELECTED_NODE[] = "SelectedFolderNode";
@@ -198,15 +199,14 @@ void JsonSummaryPage::addToProject(const JsonWizard::GeneratorFiles &files)
} }
m_wizard->removeAttributeFromAllFiles(GeneratedFile::OpenProjectAttribute); m_wizard->removeAttributeFromAllFiles(GeneratedFile::OpenProjectAttribute);
} else { } else {
QStringList filePaths = Utils::transform(files, [](const JsonWizard::GeneratorFile &f) { FilePaths filePaths = Utils::transform(files, [](const JsonWizard::GeneratorFile &f) {
return f.file.path(); return f.file.filePath();
}); });
if (!folder->addFiles(filePaths)) { if (!folder->addFiles(filePaths)) {
QStringList nativeFilePaths = Utils::transform(filePaths, &QDir::toNativeSeparators);
QMessageBox::critical(wizard(), tr("Failed to Add to Project"), QMessageBox::critical(wizard(), tr("Failed to Add to Project"),
tr("Failed to add one or more files to project\n\"%1\" (%2).") tr("Failed to add one or more files to project\n\"%1\" (%2).")
.arg(folder->filePath().toUserOutput(), .arg(folder->filePath().toUserOutput(),
nativeFilePaths.join(QLatin1String(", ")))); FilePath::formatFilePaths(filePaths, ", ")));
return; return;
} }
const QStringList dependencies = m_wizard->stringValue("Dependencies") const QStringList dependencies = m_wizard->stringValue("Dependencies")

View File

@@ -3593,7 +3593,8 @@ void ProjectExplorerPluginPrivate::handleAddExistingFiles()
if (fileNames.isEmpty()) if (fileNames.isEmpty())
return; return;
ProjectExplorerPlugin::addExistingFiles(folderNode, fileNames); ProjectExplorerPlugin::addExistingFiles(folderNode,
Utils::transform(fileNames, &FilePath::fromString));
} }
void ProjectExplorerPluginPrivate::addExistingDirectory() void ProjectExplorerPluginPrivate::addExistingDirectory()
@@ -3608,32 +3609,30 @@ void ProjectExplorerPluginPrivate::addExistingDirectory()
dialog.setAddFileFilter({}); dialog.setAddFileFilter({});
if (dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
ProjectExplorerPlugin::addExistingFiles(folderNode, Utils::transform(dialog.selectedFiles(), &Utils::FilePath::toString)); ProjectExplorerPlugin::addExistingFiles(folderNode, dialog.selectedFiles());
} }
void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStringList &filePaths) void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const FilePaths &filePaths)
{ {
// can happen when project is not yet parsed or finished parsing while the dialog was open: // can happen when project is not yet parsed or finished parsing while the dialog was open:
if (!folderNode || !ProjectTree::hasNode(folderNode)) if (!folderNode || !ProjectTree::hasNode(folderNode))
return; return;
const QString dir = folderNode->directory(); const QString dir = folderNode->directory();
QStringList fileNames = filePaths; FilePaths fileNames = filePaths;
QStringList notAdded; FilePaths notAdded;
folderNode->addFiles(fileNames, &notAdded); folderNode->addFiles(fileNames, &notAdded);
if (!notAdded.isEmpty()) { if (!notAdded.isEmpty()) {
const QString message = tr("Could not add following files to project %1:") const QString message = tr("Could not add following files to project %1:")
.arg(folderNode->managingProject()->displayName()) + QLatin1Char('\n'); .arg(folderNode->managingProject()->displayName()) + QLatin1Char('\n');
const QStringList nativeFiles
= Utils::transform(notAdded, &QDir::toNativeSeparators);
QMessageBox::warning(ICore::dialogParent(), tr("Adding Files to Project Failed"), QMessageBox::warning(ICore::dialogParent(), tr("Adding Files to Project Failed"),
message + nativeFiles.join(QLatin1Char('\n'))); message + FilePath::formatFilePaths(notAdded, "\n"));
fileNames = Utils::filtered(fileNames, fileNames = Utils::filtered(fileNames,
[&notAdded](const QString &f) { return !notAdded.contains(f); }); [&notAdded](const FilePath &f) { return !notAdded.contains(f); });
} }
VcsManager::promptToAdd(dir, fileNames); VcsManager::promptToAdd(dir, Utils::transform(fileNames, &FilePath::toString));
} }
void ProjectExplorerPluginPrivate::removeProject() void ProjectExplorerPluginPrivate::removeProject()
@@ -3752,8 +3751,7 @@ void ProjectExplorerPluginPrivate::removeFile()
QTC_ASSERT(folderNode, return); QTC_ASSERT(folderNode, return);
const Utils::FilePath &currentFilePath = file.second; const Utils::FilePath &currentFilePath = file.second;
const RemovedFilesFromProject status const RemovedFilesFromProject status = folderNode->removeFiles({currentFilePath});
= folderNode->removeFiles(QStringList(currentFilePath.toString()));
const bool success = status == RemovedFilesFromProject::Ok const bool success = status == RemovedFilesFromProject::Ok
|| (status == RemovedFilesFromProject::Wildcard || (status == RemovedFilesFromProject::Wildcard
&& removeFileDialog.isDeleteFileChecked()); && removeFileDialog.isDeleteFileChecked());
@@ -3810,7 +3808,7 @@ void ProjectExplorerPluginPrivate::duplicateFile()
QDir::toNativeSeparators(newFilePath), sourceFile.errorString())); QDir::toNativeSeparators(newFilePath), sourceFile.errorString()));
return; return;
} }
if (!folderNode->addFiles(QStringList(newFilePath))) { if (!folderNode->addFiles({FilePath::fromString(newFilePath)})) {
QMessageBox::critical(ICore::dialogParent(), tr("Duplicating File Failed"), QMessageBox::critical(ICore::dialogParent(), tr("Duplicating File Failed"),
tr("Failed to add new file \"%1\" to the project.") tr("Failed to add new file \"%1\" to the project.")
.arg(QDir::toNativeSeparators(newFilePath))); .arg(QDir::toNativeSeparators(newFilePath)));
@@ -3826,12 +3824,12 @@ void ProjectExplorerPluginPrivate::deleteFile()
FileNode *fileNode = currentNode->asFileNode(); FileNode *fileNode = currentNode->asFileNode();
QString filePath = currentNode->filePath().toString(); FilePath filePath = currentNode->filePath();
QMessageBox::StandardButton button = QMessageBox::StandardButton button =
QMessageBox::question(ICore::dialogParent(), QMessageBox::question(ICore::dialogParent(),
tr("Delete File"), tr("Delete File"),
tr("Delete %1 from file system?") tr("Delete %1 from file system?")
.arg(QDir::toNativeSeparators(filePath)), .arg(filePath.toUserOutput()),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (button != QMessageBox::Yes) if (button != QMessageBox::Yes)
return; return;
@@ -3839,19 +3837,18 @@ void ProjectExplorerPluginPrivate::deleteFile()
FolderNode *folderNode = fileNode->parentFolderNode(); FolderNode *folderNode = fileNode->parentFolderNode();
QTC_ASSERT(folderNode, return); QTC_ASSERT(folderNode, return);
folderNode->deleteFiles(QStringList(filePath)); folderNode->deleteFiles({filePath});
FileChangeBlocker changeGuard(currentNode->filePath()); FileChangeBlocker changeGuard(currentNode->filePath());
if (IVersionControl *vc = if (IVersionControl *vc =
VcsManager::findVersionControlForDirectory(QFileInfo(filePath).absolutePath())) { VcsManager::findVersionControlForDirectory(filePath.absolutePath().toString())) {
vc->vcsDelete(filePath); vc->vcsDelete(filePath.toString());
} }
QFile file(filePath); if (filePath.exists()) {
if (file.exists()) { if (!filePath.removeFile())
if (!file.remove())
QMessageBox::warning(ICore::dialogParent(), tr("Deleting File Failed"), QMessageBox::warning(ICore::dialogParent(), tr("Deleting File Failed"),
tr("Could not delete file %1.") tr("Could not delete file %1.")
.arg(QDir::toNativeSeparators(filePath))); .arg(filePath.toUserOutput()));
} }
} }

View File

@@ -163,7 +163,7 @@ public:
static QList<QPair<Runnable, Utils::ProcessHandle>> runningRunControlProcesses(); static QList<QPair<Runnable, Utils::ProcessHandle>> runningRunControlProcesses();
static QList<RunControl *> allRunControls(); static QList<RunControl *> allRunControls();
static void addExistingFiles(FolderNode *folderNode, const QStringList &filePaths); static void addExistingFiles(FolderNode *folderNode, const Utils::FilePaths &filePaths);
static void initiateInlineRenaming(); static void initiateInlineRenaming();

View File

@@ -217,10 +217,11 @@ bool ProjectFileWizardExtension::processProject(
} }
*removeOpenProjectAttribute = true; *removeOpenProjectAttribute = true;
} else { } else {
QStringList filePaths = Utils::transform(files, &GeneratedFile::path); FilePaths filePaths = Utils::transform(files, &GeneratedFile::filePath);
if (!folder->addFiles(filePaths)) { if (!folder->addFiles(filePaths)) {
*errorMessage = tr("Failed to add one or more files to project\n\"%1\" (%2)."). *errorMessage = tr("Failed to add one or more files to project\n\"%1\" (%2).")
arg(folder->filePath().toUserOutput(), filePaths.join(QLatin1Char(','))); .arg(folder->filePath().toUserOutput())
.arg(FilePath::formatFilePaths(filePaths, ","));
return false; return false;
} }
} }
@@ -257,7 +258,7 @@ void ProjectFileWizardExtension::applyCodeStyle(GeneratedFile *file) const
Indenter *indenter = nullptr; Indenter *indenter = nullptr;
if (factory) { if (factory) {
indenter = factory->createIndenter(&doc); indenter = factory->createIndenter(&doc);
indenter->setFileName(Utils::FilePath::fromString(file->path())); indenter->setFileName(file->filePath());
} }
if (!indenter) if (!indenter)
indenter = new TextIndenter(&doc); indenter = new TextIndenter(&doc);

View File

@@ -717,8 +717,8 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
return true; return true;
// Some helper functions for the file operations. // Some helper functions for the file operations.
const auto targetFilePath = [&targetDir](const QString &sourceFilePath) { const auto targetFilePath = [&targetDir](const FilePath &sourceFilePath) {
return targetDir.pathAppended(QFileInfo(sourceFilePath).fileName()).toString(); return targetDir.pathAppended(sourceFilePath.fileName());
}; };
struct VcsInfo { struct VcsInfo {
@@ -741,25 +741,23 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
}; };
// Now do the actual work. // Now do the actual work.
const QStringList sourceFiles = transform(fileNodes, [](const Node *n) { const FilePaths sourceFiles = transform(fileNodes, [](const Node *n) { return n->filePath(); });
return n->filePath().toString(); FilePaths failedRemoveFromProject;
}); FilePaths failedAddToProject;
QStringList failedRemoveFromProject; FilePaths failedCopyOrMove;
QStringList failedAddToProject; FilePaths failedDelete;
QStringList failedCopyOrMove; FilePaths failedVcsOp;
QStringList failedDelete;
QStringList failedVcsOp;
switch (dlg.dropAction()) { switch (dlg.dropAction()) {
case DropAction::CopyWithFiles: { case DropAction::CopyWithFiles: {
QStringList filesToAdd; FilePaths filesToAdd;
Core::IVersionControl * const vcs = Core::VcsManager::findVersionControlForDirectory( Core::IVersionControl * const vcs = Core::VcsManager::findVersionControlForDirectory(
targetDir.toString()); targetDir.toString());
const bool addToVcs = vcs && vcs->supportsOperation(Core::IVersionControl::AddOperation); const bool addToVcs = vcs && vcs->supportsOperation(Core::IVersionControl::AddOperation);
for (const QString &sourceFile : sourceFiles) { for (const FilePath &sourceFile : sourceFiles) {
const QString targetFile = targetFilePath(sourceFile); const FilePath targetFile = targetFilePath(sourceFile);
if (QFile::copy(sourceFile, targetFile)) { if (sourceFile.copyFile(targetFile)) {
filesToAdd << targetFile; filesToAdd << targetFile;
if (addToVcs && !vcs->vcsAdd(targetFile)) if (addToVcs && !vcs->vcsAdd(targetFile.toString()))
failedVcsOp << targetFile; failedVcsOp << targetFile;
} else { } else {
failedCopyOrMove << sourceFile; failedCopyOrMove << sourceFile;
@@ -772,17 +770,17 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
targetProjectNode->addFiles(sourceFiles, &failedAddToProject); targetProjectNode->addFiles(sourceFiles, &failedAddToProject);
break; break;
case DropAction::MoveWithFiles: { case DropAction::MoveWithFiles: {
QStringList filesToAdd; FilePaths filesToAdd;
QStringList filesToRemove; FilePaths filesToRemove;
const VcsInfo targetVcs = vcsInfoForFile(targetDir.toString()); const VcsInfo targetVcs = vcsInfoForFile(targetDir.toString());
const bool vcsAddPossible = targetVcs.vcs const bool vcsAddPossible = targetVcs.vcs
&& targetVcs.vcs->supportsOperation(Core::IVersionControl::AddOperation); && targetVcs.vcs->supportsOperation(Core::IVersionControl::AddOperation);
for (const QString &sourceFile : sourceFiles) { for (const FilePath &sourceFile : sourceFiles) {
const QString targetFile = targetFilePath(sourceFile); const FilePath targetFile = targetFilePath(sourceFile);
const VcsInfo sourceVcs = vcsInfoForFile(sourceFile); const VcsInfo sourceVcs = vcsInfoForFile(sourceFile.toString());
if (sourceVcs.vcs && targetVcs.vcs && sourceVcs == targetVcs if (sourceVcs.vcs && targetVcs.vcs && sourceVcs == targetVcs
&& sourceVcs.vcs->supportsOperation(Core::IVersionControl::MoveOperation)) { && sourceVcs.vcs->supportsOperation(Core::IVersionControl::MoveOperation)) {
if (sourceVcs.vcs->vcsMove(sourceFile, targetFile)) { if (sourceVcs.vcs->vcsMove(sourceFile.toString(), targetFile.toString())) {
filesToAdd << targetFile; filesToAdd << targetFile;
filesToRemove << sourceFile; filesToRemove << sourceFile;
} else { } else {
@@ -790,21 +788,21 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
} }
continue; continue;
} }
if (!QFile::copy(sourceFile, targetFile)) { if (!sourceFile.copyFile(targetFile)) {
failedCopyOrMove << sourceFile; failedCopyOrMove << sourceFile;
continue; continue;
} }
filesToAdd << targetFile; filesToAdd << targetFile;
filesToRemove << sourceFile; filesToRemove << sourceFile;
Core::FileChangeBlocker changeGuard(FilePath::fromString(sourceFile)); Core::FileChangeBlocker changeGuard(sourceFile);
if (sourceVcs.vcs && sourceVcs.vcs->supportsOperation( if (sourceVcs.vcs && sourceVcs.vcs->supportsOperation(
Core::IVersionControl::DeleteOperation) Core::IVersionControl::DeleteOperation)
&& !sourceVcs.vcs->vcsDelete(sourceFile)) { && !sourceVcs.vcs->vcsDelete(sourceFile.toString())) {
failedVcsOp << sourceFile; failedVcsOp << sourceFile;
} }
if (QFile::exists(sourceFile) && !QFile::remove(sourceFile)) if (sourceFile.exists() && !sourceFile.removeFile())
failedDelete << sourceFile; failedDelete << sourceFile;
if (vcsAddPossible && !targetVcs.vcs->vcsAdd(targetFile)) if (vcsAddPossible && !targetVcs.vcs->vcsAdd(targetFile.toString()))
failedVcsOp << targetFile; failedVcsOp << targetFile;
} }
const RemovedFilesFromProject result const RemovedFilesFromProject result
@@ -821,9 +819,8 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
} }
// Summary for the user in case anything went wrong. // Summary for the user in case anything went wrong.
const auto makeUserFileList = [](const QStringList &files) { const auto makeUserFileList = [](const FilePaths &files) {
return transform(files, [](const QString &f) { return QDir::toNativeSeparators(f); }) return FilePath::formatFilePaths(files, "\n ");
.join("\n ");
}; };
if (!failedAddToProject.empty() || !failedRemoveFromProject.empty() if (!failedAddToProject.empty() || !failedRemoveFromProject.empty()
|| !failedCopyOrMove.empty() || !failedDelete.empty() || !failedVcsOp.empty()) { || !failedCopyOrMove.empty() || !failedDelete.empty() || !failedVcsOp.empty()) {

View File

@@ -54,6 +54,8 @@
#include <memory> #include <memory>
using namespace Utils;
namespace ProjectExplorer { namespace ProjectExplorer {
QHash<QString, QIcon> DirectoryIcon::m_cache; QHash<QString, QIcon> DirectoryIcon::m_cache;
@@ -741,7 +743,7 @@ bool FolderNode::supportsAction(ProjectAction action, const Node *node) const
return parentFolder && parentFolder->supportsAction(action, node); return parentFolder && parentFolder->supportsAction(action, node);
} }
bool FolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded) bool FolderNode::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{ {
ProjectNode *pn = managingProject(); ProjectNode *pn = managingProject();
if (pn) if (pn)
@@ -749,15 +751,14 @@ bool FolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
return false; return false;
} }
RemovedFilesFromProject FolderNode::removeFiles(const QStringList &filePaths, RemovedFilesFromProject FolderNode::removeFiles(const FilePaths &filePaths, FilePaths *notRemoved)
QStringList *notRemoved)
{ {
if (ProjectNode * const pn = managingProject()) if (ProjectNode * const pn = managingProject())
return pn->removeFiles(filePaths, notRemoved); return pn->removeFiles(filePaths, notRemoved);
return RemovedFilesFromProject::Error; return RemovedFilesFromProject::Error;
} }
bool FolderNode::deleteFiles(const QStringList &filePaths) bool FolderNode::deleteFiles(const FilePaths &filePaths)
{ {
ProjectNode *pn = managingProject(); ProjectNode *pn = managingProject();
if (pn) if (pn)
@@ -885,22 +886,21 @@ bool ProjectNode::removeSubProject(const QString &proFilePath)
return false; return false;
} }
bool ProjectNode::addFiles(const QStringList &filePaths, QStringList *notAdded) bool ProjectNode::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{ {
if (BuildSystem *bs = buildSystem()) if (BuildSystem *bs = buildSystem())
return bs->addFiles(this, filePaths, notAdded); return bs->addFiles(this, filePaths, notAdded);
return false; return false;
} }
RemovedFilesFromProject ProjectNode::removeFiles(const QStringList &filePaths, RemovedFilesFromProject ProjectNode::removeFiles(const FilePaths &filePaths, FilePaths *notRemoved)
QStringList *notRemoved)
{ {
if (BuildSystem *bs = buildSystem()) if (BuildSystem *bs = buildSystem())
return bs->removeFiles(this, filePaths, notRemoved); return bs->removeFiles(this, filePaths, notRemoved);
return RemovedFilesFromProject::Error; return RemovedFilesFromProject::Error;
} }
bool ProjectNode::deleteFiles(const QStringList &filePaths) bool ProjectNode::deleteFiles(const FilePaths &filePaths)
{ {
if (BuildSystem *bs = buildSystem()) if (BuildSystem *bs = buildSystem())
return bs->deleteFiles(this, filePaths); return bs->deleteFiles(this, filePaths);

View File

@@ -298,10 +298,10 @@ public:
bool supportsAction(ProjectAction action, const Node *node) const override; bool supportsAction(ProjectAction action, const Node *node) const override;
virtual bool addFiles(const QStringList &filePaths, QStringList *notAdded = nullptr); virtual bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr);
virtual RemovedFilesFromProject removeFiles(const QStringList &filePaths, virtual RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
QStringList *notRemoved = nullptr); Utils::FilePaths *notRemoved = nullptr);
virtual bool deleteFiles(const QStringList &filePaths); virtual bool deleteFiles(const Utils::FilePaths &filePaths);
virtual bool canRenameFile(const Utils::FilePath &oldFilePath, virtual bool canRenameFile(const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath); const Utils::FilePath &newFilePath);
virtual bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath); virtual bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath);
@@ -382,10 +382,10 @@ public:
bool isProjectNodeType() const override { return true; } bool isProjectNodeType() const override { return true; }
bool showInSimpleTree() const override { return true; } bool showInSimpleTree() const override { return true; }
bool addFiles(const QStringList &filePaths, QStringList *notAdded = nullptr) final; bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr) final;
RemovedFilesFromProject removeFiles(const QStringList &filePaths, RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
QStringList *notRemoved = nullptr) final; Utils::FilePaths *notRemoved = nullptr) final;
bool deleteFiles(const QStringList &filePaths) final; bool deleteFiles(const Utils::FilePaths &filePaths) final;
bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final; bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final;
bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final; bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final;
bool addDependencies(const QStringList &dependencies) final; bool addDependencies(const QStringList &dependencies) final;

View File

@@ -63,9 +63,9 @@ public:
explicit PythonBuildSystem(Target *target); explicit PythonBuildSystem(Target *target);
bool supportsAction(Node *context, ProjectAction action, const Node *node) const override; bool supportsAction(Node *context, ProjectAction action, const Node *node) const override;
bool addFiles(Node *, const QStringList &filePaths, QStringList *) override; bool addFiles(Node *, const Utils::FilePaths &filePaths, Utils::FilePaths *) override;
RemovedFilesFromProject removeFiles(Node *, const QStringList &filePaths, QStringList *) override; RemovedFilesFromProject removeFiles(Node *, const Utils::FilePaths &filePaths, Utils::FilePaths *) override;
bool deleteFiles(Node *, const QStringList &) override; bool deleteFiles(Node *, const Utils::FilePaths &) override;
bool renameFile(Node *, bool renameFile(Node *,
const Utils::FilePath &oldFilePath, const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath) override; const Utils::FilePath &newFilePath) override;
@@ -349,23 +349,23 @@ bool PythonBuildSystem::writePyProjectFile(const QString &fileName, QString &con
return true; return true;
} }
bool PythonBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringList *) bool PythonBuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths *)
{ {
QStringList newList = m_rawFileList; QStringList newList = m_rawFileList;
const QDir baseDir(projectDirectory().toString()); const QDir baseDir(projectDirectory().toString());
for (const QString &filePath : filePaths) for (const FilePath &filePath : filePaths)
newList.append(baseDir.relativeFilePath(filePath)); newList.append(baseDir.relativeFilePath(filePath.toString()));
return saveRawFileList(newList); return saveRawFileList(newList);
} }
RemovedFilesFromProject PythonBuildSystem::removeFiles(Node *, const QStringList &filePaths, QStringList *) RemovedFilesFromProject PythonBuildSystem::removeFiles(Node *, const FilePaths &filePaths, FilePaths *)
{ {
QStringList newList = m_rawFileList; QStringList newList = m_rawFileList;
for (const QString &filePath : filePaths) { for (const FilePath &filePath : filePaths) {
const QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath); const QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath.toString());
if (i != m_rawListEntries.end()) if (i != m_rawListEntries.end())
newList.removeOne(i.value()); newList.removeOne(i.value());
} }
@@ -375,7 +375,7 @@ RemovedFilesFromProject PythonBuildSystem::removeFiles(Node *, const QStringList
return res ? RemovedFilesFromProject::Ok : RemovedFilesFromProject::Error; return res ? RemovedFilesFromProject::Ok : RemovedFilesFromProject::Error;
} }
bool PythonBuildSystem::deleteFiles(Node *, const QStringList &) bool PythonBuildSystem::deleteFiles(Node *, const FilePaths &)
{ {
return true; return true;
} }

View File

@@ -245,10 +245,10 @@ bool QbsBuildSystem::supportsAction(Node *context, ProjectAction action, const N
return supportsNodeAction(action, node); return supportsNodeAction(action, node);
} }
bool QbsBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStringList *notAdded) bool QbsBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FilePaths *notAdded)
{ {
if (auto n = dynamic_cast<QbsGroupNode *>(context)) { if (auto n = dynamic_cast<QbsGroupNode *>(context)) {
QStringList notAddedDummy; FilePaths notAddedDummy;
if (!notAdded) if (!notAdded)
notAdded = &notAddedDummy; notAdded = &notAddedDummy;
@@ -258,7 +258,7 @@ bool QbsBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStri
} }
if (auto n = dynamic_cast<QbsProductNode *>(context)) { if (auto n = dynamic_cast<QbsProductNode *>(context)) {
QStringList notAddedDummy; FilePaths notAddedDummy;
if (!notAdded) if (!notAdded)
notAdded = &notAddedDummy; notAdded = &notAddedDummy;
return addFilesToProduct(filePaths, n->productData(), n->mainGroup(), notAdded); return addFilesToProduct(filePaths, n->productData(), n->mainGroup(), notAdded);
@@ -267,11 +267,11 @@ bool QbsBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStri
return BuildSystem::addFiles(context, filePaths, notAdded); return BuildSystem::addFiles(context, filePaths, notAdded);
} }
RemovedFilesFromProject QbsBuildSystem::removeFiles(Node *context, const QStringList &filePaths, RemovedFilesFromProject QbsBuildSystem::removeFiles(Node *context, const FilePaths &filePaths,
QStringList *notRemoved) FilePaths *notRemoved)
{ {
if (auto n = dynamic_cast<QbsGroupNode *>(context)) { if (auto n = dynamic_cast<QbsGroupNode *>(context)) {
QStringList notRemovedDummy; FilePaths notRemovedDummy;
if (!notRemoved) if (!notRemoved)
notRemoved = &notRemovedDummy; notRemoved = &notRemovedDummy;
const QbsProductNode * const prdNode = parentQbsProductNode(n); const QbsProductNode * const prdNode = parentQbsProductNode(n);
@@ -281,7 +281,7 @@ RemovedFilesFromProject QbsBuildSystem::removeFiles(Node *context, const QString
} }
if (auto n = dynamic_cast<QbsProductNode *>(context)) { if (auto n = dynamic_cast<QbsProductNode *>(context)) {
QStringList notRemovedDummy; FilePaths notRemovedDummy;
if (!notRemoved) if (!notRemoved)
notRemoved = &notRemovedDummy; notRemoved = &notRemovedDummy;
return removeFilesFromProduct(filePaths, n->productData(), n->mainGroup(), notRemoved); return removeFilesFromProduct(filePaths, n->productData(), n->mainGroup(), notRemoved);
@@ -335,9 +335,9 @@ ProjectExplorer::DeploymentKnowledge QbsProject::deploymentKnowledge() const
return DeploymentKnowledge::Perfect; return DeploymentKnowledge::Perfect;
} }
QStringList QbsBuildSystem::filesGeneratedFrom(const QString &sourceFile) const FilePaths QbsBuildSystem::filesGeneratedFrom(const FilePath &sourceFile) const
{ {
return session()->filesGeneratedFrom(sourceFile); return transform(session()->filesGeneratedFrom(sourceFile.toString()), &FilePath::fromString);
} }
bool QbsBuildSystem::isProjectEditable() const bool QbsBuildSystem::isProjectEditable() const
@@ -367,40 +367,40 @@ bool QbsBuildSystem::ensureWriteableQbsFile(const QString &file)
} }
bool QbsBuildSystem::addFilesToProduct( bool QbsBuildSystem::addFilesToProduct(
const QStringList &filePaths, const FilePaths &filePaths,
const QJsonObject &product, const QJsonObject &product,
const QJsonObject &group, const QJsonObject &group,
QStringList *notAdded) FilePaths *notAdded)
{ {
const QString groupFilePath = group.value("location").toObject().value("file-path").toString(); const QString groupFilePath = group.value("location").toObject().value("file-path").toString();
ensureWriteableQbsFile(groupFilePath); ensureWriteableQbsFile(groupFilePath);
const FileChangeResult result = session()->addFiles( const FileChangeResult result = session()->addFiles(
filePaths, Utils::transform(filePaths, &FilePath::toString),
product.value("full-display-name").toString(), product.value("full-display-name").toString(),
group.value("name").toString()); group.value("name").toString());
if (result.error().hasError()) { if (result.error().hasError()) {
MessageManager::writeDisrupting(result.error().toString()); MessageManager::writeDisrupting(result.error().toString());
*notAdded = result.failedFiles(); *notAdded = Utils::transform(result.failedFiles(), &FilePath::fromString);
} }
return notAdded->isEmpty(); return notAdded->isEmpty();
} }
RemovedFilesFromProject QbsBuildSystem::removeFilesFromProduct( RemovedFilesFromProject QbsBuildSystem::removeFilesFromProduct(
const QStringList &filePaths, const FilePaths &filePaths,
const QJsonObject &product, const QJsonObject &product,
const QJsonObject &group, const QJsonObject &group,
QStringList *notRemoved) FilePaths *notRemoved)
{ {
const auto allWildcardsInGroup = transform<QStringList>( const auto allWildcardsInGroup = transform<QStringList>(
group.value("source-artifacts-from-wildcards").toArray(), group.value("source-artifacts-from-wildcards").toArray(),
[](const QJsonValue &v) { return v.toObject().value("file-path").toString(); }); [](const QJsonValue &v) { return v.toObject().value("file-path").toString(); });
QStringList wildcardFiles; FilePaths wildcardFiles;
QStringList nonWildcardFiles; QStringList nonWildcardFiles;
for (const QString &filePath : filePaths) { for (const FilePath &filePath : filePaths) {
if (allWildcardsInGroup.contains(filePath)) if (allWildcardsInGroup.contains(filePath.toString()))
wildcardFiles << filePath; wildcardFiles << filePath;
else else
nonWildcardFiles << filePath; nonWildcardFiles << filePath.toString();
} }
const QString groupFilePath = group.value("location") const QString groupFilePath = group.value("location")
@@ -411,7 +411,7 @@ RemovedFilesFromProject QbsBuildSystem::removeFilesFromProduct(
product.value("name").toString(), product.value("name").toString(),
group.value("name").toString()); group.value("name").toString());
*notRemoved = result.failedFiles(); *notRemoved = Utils::transform(result.failedFiles(), &FilePath::fromString);
if (result.error().hasError()) if (result.error().hasError())
MessageManager::writeDisrupting(result.error().toString()); MessageManager::writeDisrupting(result.error().toString());
const bool success = notRemoved->isEmpty(); const bool success = notRemoved->isEmpty();
@@ -432,12 +432,12 @@ bool QbsBuildSystem::renameFileInProduct(
{ {
if (newPath.isEmpty()) if (newPath.isEmpty())
return false; return false;
QStringList dummy; FilePaths dummy;
if (removeFilesFromProduct(QStringList(oldPath), product, group, &dummy) if (removeFilesFromProduct({FilePath::fromString(oldPath)}, product, group, &dummy)
!= RemovedFilesFromProject::Ok) { != RemovedFilesFromProject::Ok) {
return false; return false;
} }
return addFilesToProduct(QStringList(newPath), product, group, &dummy); return addFilesToProduct({FilePath::fromString(newPath)}, product, group, &dummy);
} }
QString QbsBuildSystem::profile() const QString QbsBuildSystem::profile() const

View File

@@ -84,26 +84,26 @@ public:
ProjectExplorer::ProjectAction action, ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const final; const ProjectExplorer::Node *node) const final;
bool addFiles(ProjectExplorer::Node *context, bool addFiles(ProjectExplorer::Node *context,
const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *notAdded = nullptr) final; Utils::FilePaths *notAdded = nullptr) final;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *context, ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *context,
const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *notRemoved = nullptr) final; Utils::FilePaths *notRemoved = nullptr) final;
bool renameFile(ProjectExplorer::Node *context, bool renameFile(ProjectExplorer::Node *context,
const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final; const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final;
QStringList filesGeneratedFrom(const QString &sourceFile) const final; Utils::FilePaths filesGeneratedFrom(const Utils::FilePath &sourceFile) const final;
QVariant additionalData(Utils::Id id) const final; QVariant additionalData(Utils::Id id) const final;
bool isProjectEditable() const; bool isProjectEditable() const;
bool addFilesToProduct(const QStringList &filePaths, bool addFilesToProduct(const Utils::FilePaths &filePaths,
const QJsonObject &product, const QJsonObject &product,
const QJsonObject &group, const QJsonObject &group,
QStringList *notAdded); Utils::FilePaths *notAdded);
ProjectExplorer::RemovedFilesFromProject removeFilesFromProduct(const QStringList &filePaths, ProjectExplorer::RemovedFilesFromProject removeFilesFromProduct(const Utils::FilePaths &filePaths,
const QJsonObject &product, const QJsonObject &product,
const QJsonObject &group, const QJsonObject &group,
QStringList *notRemoved); Utils::FilePaths *notRemoved);
bool renameFileInProduct(const QString &oldPath, bool renameFileInProduct(const QString &oldPath,
const QString &newPath, const QJsonObject &product, const QString &newPath, const QJsonObject &product,
const QJsonObject &group); const QJsonObject &group);

View File

@@ -192,14 +192,14 @@ QStringList QmakePriFileNode::subProjectFileNamePatterns() const
return QStringList("*.pro"); return QStringList("*.pro");
} }
bool QmakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStringList *notAdded) bool QmakeBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FilePaths *notAdded)
{ {
if (auto n = dynamic_cast<QmakePriFileNode *>(context)) { if (auto n = dynamic_cast<QmakePriFileNode *>(context)) {
QmakePriFile *pri = n->priFile(); QmakePriFile *pri = n->priFile();
if (!pri) if (!pri)
return false; return false;
QList<Node *> matchingNodes = n->findNodes([filePaths](const Node *nn) { QList<Node *> matchingNodes = n->findNodes([filePaths](const Node *nn) {
return nn->asFileNode() && filePaths.contains(nn->filePath().toString()); return nn->asFileNode() && filePaths.contains(nn->filePath());
}); });
matchingNodes = filtered(matchingNodes, [](const Node *n) { matchingNodes = filtered(matchingNodes, [](const Node *n) {
for (const Node *parent = n->parentFolderNode(); parent; for (const Node *parent = n->parentFolderNode(); parent;
@@ -209,11 +209,11 @@ bool QmakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QSt
} }
return true; return true;
}); });
QStringList alreadyPresentFiles = transform<QStringList>(matchingNodes, FilePaths alreadyPresentFiles = transform(matchingNodes, [](const Node *n) { return n->filePath(); });
[](const Node *n) { return n->filePath().toString(); }); FilePath::removeDuplicates(alreadyPresentFiles);
alreadyPresentFiles.removeDuplicates();
QStringList actualFilePaths = filePaths; FilePaths actualFilePaths = filePaths;
for (const QString &e : alreadyPresentFiles) for (const FilePath &e : alreadyPresentFiles)
actualFilePaths.removeOne(e); actualFilePaths.removeOne(e);
if (notAdded) if (notAdded)
*notAdded = alreadyPresentFiles; *notAdded = alreadyPresentFiles;
@@ -226,17 +226,17 @@ bool QmakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QSt
return BuildSystem::addFiles(context, filePaths, notAdded); return BuildSystem::addFiles(context, filePaths, notAdded);
} }
RemovedFilesFromProject QmakeBuildSystem::removeFiles(Node *context, const QStringList &filePaths, RemovedFilesFromProject QmakeBuildSystem::removeFiles(Node *context, const FilePaths &filePaths,
QStringList *notRemoved) FilePaths *notRemoved)
{ {
if (auto n = dynamic_cast<QmakePriFileNode *>(context)) { if (auto n = dynamic_cast<QmakePriFileNode *>(context)) {
QmakePriFile * const pri = n->priFile(); QmakePriFile * const pri = n->priFile();
if (!pri) if (!pri)
return RemovedFilesFromProject::Error; return RemovedFilesFromProject::Error;
QStringList wildcardFiles; FilePaths wildcardFiles;
QStringList nonWildcardFiles; FilePaths nonWildcardFiles;
for (const QString &file : filePaths) { for (const FilePath &file : filePaths) {
if (pri->proFile()->isFileFromWildcard(file)) if (pri->proFile()->isFileFromWildcard(file.toString()))
wildcardFiles << file; wildcardFiles << file;
else else
nonWildcardFiles << file; nonWildcardFiles << file;
@@ -254,7 +254,7 @@ RemovedFilesFromProject QmakeBuildSystem::removeFiles(Node *context, const QStri
return BuildSystem::removeFiles(context, filePaths, notRemoved); return BuildSystem::removeFiles(context, filePaths, notRemoved);
} }
bool QmakeBuildSystem::deleteFiles(Node *context, const QStringList &filePaths) bool QmakeBuildSystem::deleteFiles(Node *context, const FilePaths &filePaths)
{ {
if (auto n = dynamic_cast<QmakePriFileNode *>(context)) { if (auto n = dynamic_cast<QmakePriFileNode *>(context)) {
QmakePriFile *pri = n->priFile(); QmakePriFile *pri = n->priFile();

View File

@@ -505,25 +505,25 @@ bool QmakePriFile::canAddSubProject(const QString &proFilePath) const
return false; return false;
} }
static QString simplifyProFilePath(const QString &proFilePath) static FilePath simplifyProFilePath(const FilePath &proFilePath)
{ {
// if proFilePath is like: _path_/projectName/projectName.pro // if proFilePath is like: _path_/projectName/projectName.pro
// we simplify it to: _path_/projectName // we simplify it to: _path_/projectName
QFileInfo fi(proFilePath); QFileInfo fi = proFilePath.toFileInfo(); // FIXME
const QString parentPath = fi.absolutePath(); const QString parentPath = fi.absolutePath();
QFileInfo parentFi(parentPath); QFileInfo parentFi(parentPath);
if (parentFi.fileName() == fi.completeBaseName()) if (parentFi.fileName() == fi.completeBaseName())
return parentPath; return FilePath::fromString(parentPath);
return proFilePath; return proFilePath;
} }
bool QmakePriFile::addSubProject(const QString &proFile) bool QmakePriFile::addSubProject(const QString &proFile)
{ {
QStringList uniqueProFilePaths; FilePaths uniqueProFilePaths;
if (!m_recursiveEnumerateFiles.contains(FilePath::fromString(proFile))) if (!m_recursiveEnumerateFiles.contains(FilePath::fromString(proFile)))
uniqueProFilePaths.append(simplifyProFilePath(proFile)); uniqueProFilePaths.append(simplifyProFilePath(FilePath::fromString(proFile)));
QStringList failedFiles; FilePaths failedFiles;
changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), uniqueProFilePaths, &failedFiles, AddToProFile); changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), uniqueProFilePaths, &failedFiles, AddToProFile);
return failedFiles.isEmpty(); return failedFiles.isEmpty();
@@ -531,57 +531,57 @@ bool QmakePriFile::addSubProject(const QString &proFile)
bool QmakePriFile::removeSubProjects(const QString &proFilePath) bool QmakePriFile::removeSubProjects(const QString &proFilePath)
{ {
QStringList failedOriginalFiles; FilePaths failedOriginalFiles;
changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), QStringList(proFilePath), &failedOriginalFiles, RemoveFromProFile); changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), {FilePath::fromString(proFilePath)}, &failedOriginalFiles, RemoveFromProFile);
QStringList simplifiedProFiles = Utils::transform(failedOriginalFiles, &simplifyProFilePath); FilePaths simplifiedProFiles = Utils::transform(failedOriginalFiles, &simplifyProFilePath);
QStringList failedSimplifiedFiles; FilePaths failedSimplifiedFiles;
changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), simplifiedProFiles, &failedSimplifiedFiles, RemoveFromProFile); changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), simplifiedProFiles, &failedSimplifiedFiles, RemoveFromProFile);
return failedSimplifiedFiles.isEmpty(); return failedSimplifiedFiles.isEmpty();
} }
bool QmakePriFile::addFiles(const QStringList &filePaths, QStringList *notAdded) bool QmakePriFile::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{ {
// If a file is already referenced in the .pro file then we don't add them. // If a file is already referenced in the .pro file then we don't add them.
// That ignores scopes and which variable was used to reference the file // That ignores scopes and which variable was used to reference the file
// So it's obviously a bit limited, but in those cases you need to edit the // So it's obviously a bit limited, but in those cases you need to edit the
// project files manually anyway. // project files manually anyway.
using TypeFileMap = QMap<QString, QStringList>; using TypeFileMap = QMap<QString, FilePaths>;
// Split into lists by file type and bulk-add them. // Split into lists by file type and bulk-add them.
TypeFileMap typeFileMap; TypeFileMap typeFileMap;
foreach (const QString &file, filePaths) { for (const FilePath &file : filePaths) {
const Utils::MimeType mt = Utils::mimeTypeForFile(file); const Utils::MimeType mt = Utils::mimeTypeForFile(file);
typeFileMap[mt.name()] << file; typeFileMap[mt.name()] << file;
} }
QStringList failedFiles; FilePaths failedFiles;
foreach (const QString &type, typeFileMap.keys()) { foreach (const QString &type, typeFileMap.keys()) {
const QStringList typeFiles = typeFileMap.value(type); const FilePaths typeFiles = typeFileMap.value(type);
QStringList qrcFiles; // the list of qrc files referenced from ui files FilePaths qrcFiles; // the list of qrc files referenced from ui files
if (type == QLatin1String(ProjectExplorer::Constants::RESOURCE_MIMETYPE)) { if (type == QLatin1String(ProjectExplorer::Constants::RESOURCE_MIMETYPE)) {
foreach (const QString &formFile, typeFiles) { for (const FilePath &formFile : typeFiles) {
QStringList resourceFiles = formResources(formFile); const FilePaths resourceFiles = formResources(formFile);
foreach (const QString &resourceFile, resourceFiles) for (const FilePath &resourceFile : resourceFiles)
if (!qrcFiles.contains(resourceFile)) if (!qrcFiles.contains(resourceFile))
qrcFiles.append(resourceFile); qrcFiles.append(resourceFile);
} }
} }
QStringList uniqueQrcFiles; FilePaths uniqueQrcFiles;
foreach (const QString &file, qrcFiles) { for (const FilePath &file : qAsConst(qrcFiles)) {
if (!m_recursiveEnumerateFiles.contains(FilePath::fromString(file))) if (!m_recursiveEnumerateFiles.contains(file))
uniqueQrcFiles.append(file); uniqueQrcFiles.append(file);
} }
QStringList uniqueFilePaths; FilePaths uniqueFilePaths;
foreach (const QString &file, typeFiles) { for (const FilePath &file : typeFiles) {
if (!m_recursiveEnumerateFiles.contains(FilePath::fromString(file))) if (!m_recursiveEnumerateFiles.contains(file))
uniqueFilePaths.append(file); uniqueFilePaths.append(file);
} }
uniqueFilePaths.sort(); FilePath::sort(uniqueFilePaths);
changeFiles(type, uniqueFilePaths, &failedFiles, AddToProFile); changeFiles(type, uniqueFilePaths, &failedFiles, AddToProFile);
if (notAdded) if (notAdded)
@@ -593,19 +593,18 @@ bool QmakePriFile::addFiles(const QStringList &filePaths, QStringList *notAdded)
return failedFiles.isEmpty(); return failedFiles.isEmpty();
} }
bool QmakePriFile::removeFiles(const QStringList &filePaths, bool QmakePriFile::removeFiles(const FilePaths &filePaths, FilePaths *notRemoved)
QStringList *notRemoved)
{ {
QStringList failedFiles; FilePaths failedFiles;
using TypeFileMap = QMap<QString, QStringList>; using TypeFileMap = QMap<QString, FilePaths>;
// Split into lists by file type and bulk-add them. // Split into lists by file type and bulk-add them.
TypeFileMap typeFileMap; TypeFileMap typeFileMap;
foreach (const QString &file, filePaths) { for (const FilePath &file : filePaths) {
const Utils::MimeType mt = Utils::mimeTypeForFile(file); const Utils::MimeType mt = Utils::mimeTypeForFile(file);
typeFileMap[mt.name()] << file; typeFileMap[mt.name()] << file;
} }
foreach (const QString &type, typeFileMap.keys()) { foreach (const QString &type, typeFileMap.keys()) {
const QStringList typeFiles = typeFileMap.value(type); const FilePaths typeFiles = typeFileMap.value(type);
changeFiles(type, typeFiles, &failedFiles, RemoveFromProFile); changeFiles(type, typeFiles, &failedFiles, RemoveFromProFile);
if (notRemoved) if (notRemoved)
*notRemoved = failedFiles; *notRemoved = failedFiles;
@@ -613,7 +612,7 @@ bool QmakePriFile::removeFiles(const QStringList &filePaths,
return failedFiles.isEmpty(); return failedFiles.isEmpty();
} }
bool QmakePriFile::deleteFiles(const QStringList &filePaths) bool QmakePriFile::deleteFiles(const FilePaths &filePaths)
{ {
removeFiles(filePaths); removeFiles(filePaths);
return true; return true;
@@ -705,16 +704,16 @@ bool QmakePriFile::saveModifiedEditors()
return true; return true;
} }
QStringList QmakePriFile::formResources(const QString &formFile) const FilePaths QmakePriFile::formResources(const FilePath &formFile) const
{ {
QStringList resourceFiles; QStringList resourceFiles;
QFile file(formFile); QFile file(formFile.toString());
if (!file.open(QIODevice::ReadOnly)) if (!file.open(QIODevice::ReadOnly))
return resourceFiles; return {};
QXmlStreamReader reader(&file); QXmlStreamReader reader(&file);
QFileInfo fi(formFile); QFileInfo fi(formFile.toString());
QDir formDir = fi.absoluteDir(); QDir formDir = fi.absoluteDir();
while (!reader.atEnd()) { while (!reader.atEnd()) {
reader.readNext(); reader.readNext();
@@ -737,7 +736,7 @@ QStringList QmakePriFile::formResources(const QString &formFile) const
if (reader.hasError()) if (reader.hasError())
qWarning() << "Could not read form file:" << formFile; qWarning() << "Could not read form file:" << formFile;
return resourceFiles; return Utils::transform(resourceFiles, &FilePath::fromString);
} }
bool QmakePriFile::ensureWriteableProFile(const QString &file) bool QmakePriFile::ensureWriteableProFile(const QString &file)
@@ -855,9 +854,9 @@ bool QmakePriFile::renameFile(const FilePath &oldFilePath, const FilePath &newFi
} }
void QmakePriFile::changeFiles(const QString &mimeType, void QmakePriFile::changeFiles(const QString &mimeType,
const QStringList &filePaths, const FilePaths &filePaths,
QStringList *notChanged, FilePaths *notChanged,
ChangeType change, Change mode) ChangeType change, Change mode)
{ {
if (filePaths.isEmpty()) if (filePaths.isEmpty())
return; return;
@@ -879,12 +878,18 @@ void QmakePriFile::changeFiles(const QString &mimeType,
<< filePaths << "change type:" << int(change) << "mode:" << int(mode); << filePaths << "change type:" << int(change) << "mode:" << int(mode);
if (change == AddToProFile) { if (change == AddToProFile) {
// Use the first variable for adding. // Use the first variable for adding.
ProWriter::addFiles(includeFile, &lines, filePaths, varNameForAdding(mimeType), ProWriter::addFiles(includeFile, &lines,
Utils::transform(filePaths, &FilePath::toString),
varNameForAdding(mimeType),
continuationIndent()); continuationIndent());
notChanged->clear(); notChanged->clear();
} else { // RemoveFromProFile } else { // RemoveFromProFile
QDir priFileDir = QDir(m_qmakeProFile->directoryPath().toString()); QDir priFileDir = QDir(m_qmakeProFile->directoryPath().toString());
*notChanged = ProWriter::removeFiles(includeFile, &lines, priFileDir, filePaths, varNamesForRemoving()); *notChanged = Utils::transform(
ProWriter::removeFiles(includeFile, &lines, priFileDir,
Utils::transform(filePaths, &FilePath::toString),
varNamesForRemoving()),
&FilePath::fromString);
} }
// save file // save file

View File

@@ -162,9 +162,9 @@ public:
bool addSubProject(const QString &proFile); bool addSubProject(const QString &proFile);
bool removeSubProjects(const QString &proFilePath); bool removeSubProjects(const QString &proFilePath);
bool addFiles(const QStringList &filePaths, QStringList *notAdded = nullptr); bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr);
bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = nullptr); bool removeFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notRemoved = nullptr);
bool deleteFiles(const QStringList &filePaths); bool deleteFiles(const Utils::FilePaths &filePaths);
bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath); bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath);
bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath); bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath);
bool addDependencies(const QStringList &dependencies); bool addDependencies(const QStringList &dependencies);
@@ -205,8 +205,8 @@ protected:
enum class Change { Save, TestOnly }; enum class Change { Save, TestOnly };
bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath, Change mode); bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath, Change mode);
void changeFiles(const QString &mimeType, void changeFiles(const QString &mimeType,
const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *notChanged, Utils::FilePaths *notChanged,
ChangeType change, ChangeType change,
Change mode = Change::Save); Change mode = Change::Save);
@@ -221,7 +221,7 @@ private:
static QPair<ProFile *, QStringList> readProFileFromContents(const QString &contents); static QPair<ProFile *, QStringList> readProFileFromContents(const QString &contents);
void save(const QStringList &lines); void save(const QStringList &lines);
bool saveModifiedEditors(); bool saveModifiedEditors();
QStringList formResources(const QString &formFile) const; Utils::FilePaths formResources(const Utils::FilePath &formFile) const;
static QStringList baseVPaths(QtSupport::ProFileReader *reader, const QString &projectDir, const QString &buildDir); static QStringList baseVPaths(QtSupport::ProFileReader *reader, const QString &projectDir, const QString &buildDir);
static QStringList fullVPaths(const QStringList &baseVPaths, QtSupport::ProFileReader *reader, const QString &qmakeVariable, const QString &projectDir); static QStringList fullVPaths(const QStringList &baseVPaths, QtSupport::ProFileReader *reader, const QString &qmakeVariable, const QString &projectDir);
static void extractSources(QHash<int, Internal::QmakePriFileEvalResult *> proToResult, static void extractSources(QHash<int, Internal::QmakePriFileEvalResult *> proToResult,

View File

@@ -1470,18 +1470,17 @@ void QmakeBuildSystem::triggerParsing()
asyncUpdate(); asyncUpdate();
} }
QStringList QmakeBuildSystem::filesGeneratedFrom(const QString &input) const FilePaths QmakeBuildSystem::filesGeneratedFrom(const FilePath &input) const
{ {
if (!project()->rootProjectNode()) if (!project()->rootProjectNode())
return {}; return {};
if (const FileNode *file = fileNodeOf(project()->rootProjectNode(), FilePath::fromString(input))) { if (const FileNode *file = fileNodeOf(project()->rootProjectNode(), input)) {
const QmakeProFileNode *pro = dynamic_cast<QmakeProFileNode *>(file->parentFolderNode()); const QmakeProFileNode *pro = dynamic_cast<QmakeProFileNode *>(file->parentFolderNode());
QTC_ASSERT(pro, return {}); QTC_ASSERT(pro, return {});
if (const QmakeProFile *proFile = pro->proFile()) if (const QmakeProFile *proFile = pro->proFile())
return Utils::transform(proFile->generatedFiles(buildDir(pro->filePath()), return proFile->generatedFiles(buildDir(pro->filePath()),
file->filePath(), file->fileType()), file->filePath(), file->fileType());
&FilePath::toString);
} }
return {}; return {};
} }

View File

@@ -90,13 +90,13 @@ public:
const ProjectExplorer::Node *node) const override; const ProjectExplorer::Node *node) const override;
bool addFiles(ProjectExplorer::Node *context, bool addFiles(ProjectExplorer::Node *context,
const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *notAdded = nullptr) override; Utils::FilePaths *notAdded = nullptr) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *context, ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *context,
const QStringList &filePaths, const Utils::FilePaths &filePaths,
QStringList *notRemoved = nullptr) override; Utils::FilePaths *notRemoved = nullptr) override;
bool deleteFiles(ProjectExplorer::Node *context, bool deleteFiles(ProjectExplorer::Node *context,
const QStringList &filePaths) override; const Utils::FilePaths &filePaths) override;
bool canRenameFile(ProjectExplorer::Node *context, bool canRenameFile(ProjectExplorer::Node *context,
const Utils::FilePath &oldFilePath, const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath) override; const Utils::FilePath &newFilePath) override;
@@ -107,7 +107,7 @@ public:
const QStringList &dependencies) override; const QStringList &dependencies) override;
void triggerParsing() final; void triggerParsing() final;
QStringList filesGeneratedFrom(const QString &file) const final; Utils::FilePaths filesGeneratedFrom(const Utils::FilePath &file) const final;
QVariant additionalData(Utils::Id id) const final; QVariant additionalData(Utils::Id id) const final;
void asyncUpdate(); void asyncUpdate();

View File

@@ -1016,7 +1016,7 @@ static bool addFilesToProject(const QStringList &fileNames, const QString &defau
if (node) { if (node) {
ProjectExplorer::FolderNode *containingFolder = node->parentFolderNode(); ProjectExplorer::FolderNode *containingFolder = node->parentFolderNode();
if (containingFolder) if (containingFolder)
containingFolder->addFiles(QStringList(filePair.second)); containingFolder->addFiles({Utils::FilePath::fromString(filePair.second)});
} }
} else { } else {
allSuccessful = false; allSuccessful = false;

View File

@@ -474,7 +474,7 @@ bool DocumentManager::addResourceFileToIsoProject(const QString &resourceFilePro
if (!projectNode) if (!projectNode)
return false; return false;
if (!projectNode->addFiles({resourceFilePath})) { if (!projectNode->addFiles({Utils::FilePath::fromString(resourceFilePath)})) {
qCWarning(documentManagerLog) << "Failed to add resource file to" << projectNode->displayName(); qCWarning(documentManagerLog) << "Failed to add resource file to" << projectNode->displayName();
return false; return false;
} }

View File

@@ -53,6 +53,7 @@
using namespace QmlJS::AST; using namespace QmlJS::AST;
using QmlJS::SourceLocation; using QmlJS::SourceLocation;
using namespace QmlJSTools; using namespace QmlJSTools;
using namespace Utils;
namespace QmlJSEditor { namespace QmlJSEditor {
@@ -198,7 +199,7 @@ public:
if (oldFileNode) { if (oldFileNode) {
ProjectExplorer::FolderNode *containingFolder = oldFileNode->parentFolderNode(); ProjectExplorer::FolderNode *containingFolder = oldFileNode->parentFolderNode();
if (containingFolder) if (containingFolder)
containingFolder->addFiles(QStringList(newFileName)); containingFolder->addFiles({FilePath::fromString(newFileName)});
} }
} }

View File

@@ -500,20 +500,20 @@ bool QmlBuildSystem::forceFreeType() const
return false; return false;
} }
bool QmlBuildSystem::addFiles(Node *context, const QStringList &filePaths, QStringList *) bool QmlBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FilePaths *)
{ {
if (!dynamic_cast<QmlProjectNode *>(context)) if (!dynamic_cast<QmlProjectNode *>(context))
return false; return false;
QStringList toAdd; FilePaths toAdd;
foreach (const QString &filePath, filePaths) { for (const FilePath &filePath : filePaths) {
if (!m_projectItem.data()->matchesFile(filePath)) if (!m_projectItem.data()->matchesFile(filePath.toString()))
toAdd << filePaths; toAdd << filePaths;
} }
return toAdd.isEmpty(); return toAdd.isEmpty();
} }
bool QmlBuildSystem::deleteFiles(Node *context, const QStringList &filePaths) bool QmlBuildSystem::deleteFiles(Node *context, const FilePaths &filePaths)
{ {
if (dynamic_cast<QmlProjectNode *>(context)) if (dynamic_cast<QmlProjectNode *>(context))
return true; return true;

View File

@@ -54,9 +54,9 @@ public:
ProjectExplorer::ProjectAction action, ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const override; const ProjectExplorer::Node *node) const override;
bool addFiles(ProjectExplorer::Node *context, bool addFiles(ProjectExplorer::Node *context,
const QStringList &filePaths, QStringList *notAdded = nullptr) override; const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr) override;
bool deleteFiles(ProjectExplorer::Node *context, bool deleteFiles(ProjectExplorer::Node *context,
const QStringList &filePaths) override; const Utils::FilePaths &filePaths) override;
bool renameFile(ProjectExplorer::Node *context, bool renameFile(ProjectExplorer::Node *context,
const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override; const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;

View File

@@ -59,6 +59,7 @@
#include <QApplication> #include <QApplication>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace ResourceEditor { namespace ResourceEditor {
namespace Internal { namespace Internal {
@@ -322,18 +323,18 @@ void ResourceEditorPluginPrivate::removeFileContextMenu()
{ {
auto rfn = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode()); auto rfn = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QTC_ASSERT(rfn, return); QTC_ASSERT(rfn, return);
QString path = rfn->filePath().toString(); FilePath path = rfn->filePath();
FolderNode *parent = rfn->parentFolderNode(); FolderNode *parent = rfn->parentFolderNode();
QTC_ASSERT(parent, return); QTC_ASSERT(parent, return);
if (parent->removeFiles(QStringList() << path) != RemovedFilesFromProject::Ok) if (parent->removeFiles({path}) != RemovedFilesFromProject::Ok)
QMessageBox::warning(Core::ICore::dialogParent(), QMessageBox::warning(Core::ICore::dialogParent(),
tr("File Removal Failed"), tr("File Removal Failed"),
tr("Removing file %1 from the project failed.").arg(path)); tr("Removing file %1 from the project failed.").arg(path.toUserOutput()));
} }
void ResourceEditorPluginPrivate::openEditorContextMenu() void ResourceEditorPluginPrivate::openEditorContextMenu()
{ {
Core::EditorManager::openEditor(ProjectTree::currentNode()->filePath().toString()); Core::EditorManager::openEditor(ProjectTree::currentNode()->filePath());
} }
void ResourceEditorPluginPrivate::copyPathContextMenu() void ResourceEditorPluginPrivate::copyPathContextMenu()

View File

@@ -133,8 +133,8 @@ static bool hasPriority(const QStringList &files)
} }
static bool addFilesToResource(const FilePath &resourceFile, static bool addFilesToResource(const FilePath &resourceFile,
const QStringList &filePaths, const FilePaths &filePaths,
QStringList *notAdded, FilePaths *notAdded,
const QString &prefix, const QString &prefix,
const QString &lang) const QString &lang)
{ {
@@ -151,12 +151,12 @@ static bool addFilesToResource(const FilePath &resourceFile,
if (notAdded) if (notAdded)
notAdded->clear(); notAdded->clear();
foreach (const QString &path, filePaths) { for (const FilePath &path : filePaths) {
if (file.contains(index, path)) { if (file.contains(index, path.toString())) {
if (notAdded) if (notAdded)
*notAdded << path; *notAdded << path;
} else { } else {
file.addFile(index, path); file.addFile(index, path.toString());
} }
} }
@@ -174,9 +174,9 @@ public:
ResourceTopLevelNode *topLevel, ResourceFolderNode *prefixNode); ResourceTopLevelNode *topLevel, ResourceFolderNode *prefixNode);
bool supportsAction(ProjectAction, const Node *node) const final; bool supportsAction(ProjectAction, const Node *node) const final;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) final; bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded) final;
RemovedFilesFromProject removeFiles(const QStringList &filePaths, RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
QStringList *notRemoved) final; Utils::FilePaths *notRemoved) final;
bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override; bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;
bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final; bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) final;
@@ -215,13 +215,13 @@ bool SimpleResourceFolderNode::supportsAction(ProjectAction action, const Node *
|| action == InheritedFromParent; // Do not add to list of projects when adding new file || action == InheritedFromParent; // Do not add to list of projects when adding new file
} }
bool SimpleResourceFolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded) bool SimpleResourceFolderNode::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{ {
return addFilesToResource(m_topLevelNode->filePath(), filePaths, notAdded, m_prefix, m_lang); return addFilesToResource(m_topLevelNode->filePath(), filePaths, notAdded, m_prefix, m_lang);
} }
RemovedFilesFromProject SimpleResourceFolderNode::removeFiles(const QStringList &filePaths, RemovedFilesFromProject SimpleResourceFolderNode::removeFiles(const FilePaths &filePaths,
QStringList *notRemoved) FilePaths *notRemoved)
{ {
return prefixNode()->removeFiles(filePaths, notRemoved); return prefixNode()->removeFiles(filePaths, notRemoved);
} }
@@ -385,13 +385,13 @@ bool ResourceTopLevelNode::supportsAction(ProjectAction action, const Node *node
|| action == Rename; || action == Rename;
} }
bool ResourceTopLevelNode::addFiles(const QStringList &filePaths, QStringList *notAdded) bool ResourceTopLevelNode::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{ {
return addFilesToResource(filePath(), filePaths, notAdded, QLatin1String("/"), QString()); return addFilesToResource(filePath(), filePaths, notAdded, "/", QString());
} }
RemovedFilesFromProject ResourceTopLevelNode::removeFiles(const QStringList &filePaths, RemovedFilesFromProject ResourceTopLevelNode::removeFiles(const FilePaths &filePaths,
QStringList *notRemoved) FilePaths *notRemoved)
{ {
return parentFolderNode()->removeFiles(filePaths, notRemoved); return parentFolderNode()->removeFiles(filePaths, notRemoved);
} }
@@ -498,13 +498,13 @@ bool ResourceFolderNode::supportsAction(ProjectAction action, const Node *node)
|| action == HidePathActions; // hides open terminal etc. || action == HidePathActions; // hides open terminal etc.
} }
bool ResourceFolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded) bool ResourceFolderNode::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{ {
return addFilesToResource(m_topLevelNode->filePath(), filePaths, notAdded, m_prefix, m_lang); return addFilesToResource(m_topLevelNode->filePath(), filePaths, notAdded, m_prefix, m_lang);
} }
RemovedFilesFromProject ResourceFolderNode::removeFiles(const QStringList &filePaths, RemovedFilesFromProject ResourceFolderNode::removeFiles(const FilePaths &filePaths,
QStringList *notRemoved) FilePaths *notRemoved)
{ {
if (notRemoved) if (notRemoved)
*notRemoved = filePaths; *notRemoved = filePaths;
@@ -516,10 +516,10 @@ RemovedFilesFromProject ResourceFolderNode::removeFiles(const QStringList &fileP
return RemovedFilesFromProject::Error; return RemovedFilesFromProject::Error;
for (int j = 0; j < file.fileCount(index); ++j) { for (int j = 0; j < file.fileCount(index); ++j) {
QString fileName = file.file(index, j); QString fileName = file.file(index, j);
if (!filePaths.contains(fileName)) if (!filePaths.contains(FilePath::fromString(fileName)))
continue; continue;
if (notRemoved) if (notRemoved)
notRemoved->removeOne(fileName); notRemoved->removeOne(FilePath::fromString(fileName));
file.removeFile(index, j); file.removeFile(index, j);
--j; --j;
} }

View File

@@ -42,9 +42,9 @@ public:
void addInternalNodes(); void addInternalNodes();
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override; bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) override; bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(const QStringList &filePaths, ProjectExplorer::RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
QStringList *notRemoved) override; Utils::FilePaths *notRemoved) override;
bool addPrefix(const QString &prefix, const QString &lang); bool addPrefix(const QString &prefix, const QString &lang);
bool removePrefix(const QString &prefix, const QString &lang); bool removePrefix(const QString &prefix, const QString &lang);
@@ -70,9 +70,9 @@ public:
QString displayName() const override; QString displayName() const override;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) override; bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(const QStringList &filePaths, ProjectExplorer::RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
QStringList *notRemoved) override; Utils::FilePaths *notRemoved) override;
bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override; bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;
bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override; bool renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;

View File

@@ -210,7 +210,7 @@ void SuppressionDialog::accept()
if (!ProjectExplorer::SessionManager::projectForFile(path)) { if (!ProjectExplorer::SessionManager::projectForFile(path)) {
for (ProjectExplorer::Project *p : ProjectExplorer::SessionManager::projects()) { for (ProjectExplorer::Project *p : ProjectExplorer::SessionManager::projects()) {
if (path.startsWith(p->projectDirectory().toString())) { if (path.startsWith(p->projectDirectory().toString())) {
p->rootProjectNode()->addFiles({path.toString()}); p->rootProjectNode()->addFiles({path});
break; break;
} }
} }