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();
}
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
{
@@ -1590,9 +1611,9 @@ bool FileUtils::CopyAskingForOverwrite::operator()(const QFileInfo &src,
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

View File

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

View File

@@ -77,20 +77,20 @@ using namespace Utils;
namespace CMakeProjectManager {
namespace Internal {
static void copySourcePathsToClipboard(QStringList srcPaths, const ProjectNode *node)
static void copySourcePathsToClipboard(const FilePaths &srcPaths, const ProjectNode *node)
{
QClipboard *clip = QGuiApplication::clipboard();
QDir projDir{node->filePath().toFileInfo().absoluteFilePath()};
QString data = Utils::transform(srcPaths, [projDir](const QString &path) {
return QDir::cleanPath(projDir.relativeFilePath(path));
QString data = Utils::transform(srcPaths, [projDir](const FilePath &path) {
return QDir::cleanPath(projDir.relativeFilePath(path.toString()));
}).join(" ");
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();
return mimeType == CppTools::Constants::C_SOURCE_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);
}
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)) {
noAutoAdditionNotify(filePaths, n);
@@ -322,9 +322,9 @@ bool CMakeBuildSystem::addFiles(Node *context, const QStringList &filePaths, QSt
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 baseDirectory = FilePath::fromString(fi.absolutePath());
@@ -344,12 +344,13 @@ QStringList CMakeBuildSystem::filesGeneratedFrom(const QString &sourceFile) cons
generatedFilePath += "/ui_";
generatedFilePath += fi.completeBaseName();
generatedFilePath += ".h";
return {QDir::cleanPath(generatedFilePath)};
return {FilePath::fromString(QDir::cleanPath(generatedFilePath))};
}
if (fi.suffix() == "scxml") {
generatedFilePath += "/";
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.
@@ -1173,16 +1174,13 @@ QList<ExtraCompiler *> CMakeBuildSystem::findExtraCompilers()
});
QTC_ASSERT(factory, continue);
QStringList generated = filesGeneratedFrom(file.toString());
FilePaths generated = filesGeneratedFrom(file);
qCDebug(cmakeBuildSystemLog)
<< "Finding Extra Compilers: generated files:" << generated;
if (generated.isEmpty())
continue;
const FilePaths fileNames = transform(generated, [](const QString &s) {
return FilePath::fromString(s);
});
extraCompilers.append(factory->create(p, file, fileNames));
extraCompilers.append(factory->create(p, file, generated));
qCDebug(cmakeBuildSystemLog)
<< "Finding Extra Compilers: done with" << file.toUserOutput();
}

View File

@@ -67,9 +67,9 @@ public:
const ProjectExplorer::Node *node) const final;
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:
void runCMake();

View File

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

View File

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

View File

@@ -39,6 +39,7 @@
// Debug helpers for code model. @todo: Move to some CppTools library?
using namespace ProjectExplorer;
using namespace Utils;
using DependencyMap = QMap<QString, QStringList>;
using DocumentPtr = CPlusPlus::Document::Ptr;
@@ -48,19 +49,18 @@ using DocumentPtrList = QList<DocumentPtr>;
static const char setupUiC[] = "setupUi";
// 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 =
SessionManager::projectForFile(Utils::FilePath::fromString(uiFileName))) {
if (const Project *uiProject = SessionManager::projectForFile(uiFileName)) {
if (Target *t = uiProject->activeTarget()) {
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
return files.front();
}
}
}
return QString();
return {};
}
namespace {
@@ -121,7 +121,7 @@ bool navigateToSlot(const QString &uiFileName,
{
// Find the generated header.
const QString generatedHeaderFile = generatedHeaderOf(uiFileName);
const FilePath generatedHeaderFile = generatedHeaderOf(FilePath::fromString(uiFileName));
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);
return false;
@@ -129,7 +129,7 @@ bool navigateToSlot(const QString &uiFileName,
const CPlusPlus::Snapshot snapshot = CppTools::CppModelManager::instance()->snapshot();
const DocumentPtr generatedHeaderDoc = snapshot.document(generatedHeaderFile);
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;
}
@@ -139,7 +139,7 @@ bool navigateToSlot(const QString &uiFileName,
if (funcs.size() != 1) {
*errorMessage = QString::fromLatin1(
"Internal error: The function \"%1\" could not be found in %2")
.arg(QLatin1String(setupUiC), generatedHeaderFile);
.arg(QLatin1String(setupUiC), generatedHeaderFile.toUserOutput());
return false;
}
return true;

View File

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

View File

@@ -135,11 +135,9 @@ public:
|| action == Rename;
}
RemovedFilesFromProject removeFiles(Node *, const QStringList &filePaths, QStringList *) final;
bool renameFile(Node *,
const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath) final;
bool addFiles(Node *, const QStringList &filePaths, QStringList *) final;
RemovedFilesFromProject removeFiles(Node *, const FilePaths &filePaths, FilePaths *) final;
bool renameFile(Node *, const FilePath &oldFilePath, const FilePath &newFilePath) final;
bool addFiles(Node *, const FilePaths &filePaths, FilePaths *) final;
FilePath filesFilePath() const { return ::FilePath::fromString(m_filesFileName); }
@@ -157,7 +155,7 @@ public:
void updateDeploymentData();
bool setFiles(const QStringList &filePaths);
void removeFiles(const QStringList &filesToRemove);
void removeFiles(const FilePaths &filesToRemove);
private:
QString m_filesFileName;
@@ -327,8 +325,9 @@ static void insertSorted(QStringList *list, const QString &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());
QStringList newList = m_rawFileList;
if (filePaths.size() > m_rawFileList.size()) {
@@ -368,12 +367,12 @@ bool GenericBuildSystem::addFiles(Node *, const QStringList &filePaths, QStringL
return result;
}
RemovedFilesFromProject GenericBuildSystem::removeFiles(Node *, const QStringList &filePaths, QStringList *)
RemovedFilesFromProject GenericBuildSystem::removeFiles(Node *, const FilePaths &filePaths, FilePaths *)
{
QStringList newList = m_rawFileList;
for (const QString &filePath : filePaths) {
QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath);
for (const FilePath &filePath : filePaths) {
QHash<QString, QString>::iterator i = m_rawListEntries.find(filePath.toString());
if (i != m_rawListEntries.end())
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) {
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())
static_cast<GenericBuildSystem *>(t->buildSystem())->removeFiles(filesToRemove);

View File

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

View File

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

View File

@@ -245,19 +245,19 @@ bool NimbleBuildSystem::supportsAction(Node *context, ProjectAction action, cons
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 *,
const QStringList &filePaths,
QStringList *)
const FilePaths &filePaths,
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;
}

View File

@@ -75,11 +75,11 @@ private:
ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const override;
bool addFiles(ProjectExplorer::Node *node,
const QStringList &filePaths, QStringList *) override;
const Utils::FilePaths &filePaths, Utils::FilePaths *) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *node,
const QStringList &filePaths,
QStringList *) override;
bool deleteFiles(ProjectExplorer::Node *, const QStringList &) override;
const Utils::FilePaths &filePaths,
Utils::FilePaths *) override;
bool deleteFiles(ProjectExplorer::Node *, const Utils::FilePaths &) override;
bool renameFile(ProjectExplorer::Node *,
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);
}
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 *,
const QStringList &filePaths,
QStringList *)
const FilePaths &filePaths,
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;
}

View File

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

View File

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

View File

@@ -86,10 +86,13 @@ public:
Utils::Environment activeParseEnvironment() const;
virtual bool addFiles(Node *context, const QStringList &filePaths, QStringList *notAdded = nullptr);
virtual RemovedFilesFromProject removeFiles(Node *context, const QStringList &filePaths,
QStringList *notRemoved = nullptr);
virtual bool deleteFiles(Node *context, const QStringList &filePaths);
virtual bool addFiles(Node *context,
const Utils::FilePaths &filePaths,
Utils::FilePaths *notAdded = nullptr);
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,
const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath);
@@ -99,7 +102,7 @@ public:
virtual bool addDependencies(Node *context, const QStringList &dependencies);
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;
void setDeploymentData(const DeploymentData &deploymentData);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -54,6 +54,8 @@
#include <memory>
using namespace Utils;
namespace ProjectExplorer {
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);
}
bool FolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
bool FolderNode::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{
ProjectNode *pn = managingProject();
if (pn)
@@ -749,15 +751,14 @@ bool FolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
return false;
}
RemovedFilesFromProject FolderNode::removeFiles(const QStringList &filePaths,
QStringList *notRemoved)
RemovedFilesFromProject FolderNode::removeFiles(const FilePaths &filePaths, FilePaths *notRemoved)
{
if (ProjectNode * const pn = managingProject())
return pn->removeFiles(filePaths, notRemoved);
return RemovedFilesFromProject::Error;
}
bool FolderNode::deleteFiles(const QStringList &filePaths)
bool FolderNode::deleteFiles(const FilePaths &filePaths)
{
ProjectNode *pn = managingProject();
if (pn)
@@ -885,22 +886,21 @@ bool ProjectNode::removeSubProject(const QString &proFilePath)
return false;
}
bool ProjectNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
bool ProjectNode::addFiles(const FilePaths &filePaths, FilePaths *notAdded)
{
if (BuildSystem *bs = buildSystem())
return bs->addFiles(this, filePaths, notAdded);
return false;
}
RemovedFilesFromProject ProjectNode::removeFiles(const QStringList &filePaths,
QStringList *notRemoved)
RemovedFilesFromProject ProjectNode::removeFiles(const FilePaths &filePaths, FilePaths *notRemoved)
{
if (BuildSystem *bs = buildSystem())
return bs->removeFiles(this, filePaths, notRemoved);
return RemovedFilesFromProject::Error;
}
bool ProjectNode::deleteFiles(const QStringList &filePaths)
bool ProjectNode::deleteFiles(const FilePaths &filePaths)
{
if (BuildSystem *bs = buildSystem())
return bs->deleteFiles(this, filePaths);

View File

@@ -298,10 +298,10 @@ public:
bool supportsAction(ProjectAction action, const Node *node) const override;
virtual bool addFiles(const QStringList &filePaths, QStringList *notAdded = nullptr);
virtual RemovedFilesFromProject removeFiles(const QStringList &filePaths,
QStringList *notRemoved = nullptr);
virtual bool deleteFiles(const QStringList &filePaths);
virtual bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr);
virtual RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved = nullptr);
virtual bool deleteFiles(const Utils::FilePaths &filePaths);
virtual bool canRenameFile(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 showInSimpleTree() const override { return true; }
bool addFiles(const QStringList &filePaths, QStringList *notAdded = nullptr) final;
RemovedFilesFromProject removeFiles(const QStringList &filePaths,
QStringList *notRemoved = nullptr) final;
bool deleteFiles(const QStringList &filePaths) final;
bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr) final;
RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved = nullptr) final;
bool deleteFiles(const Utils::FilePaths &filePaths) final;
bool canRenameFile(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;

View File

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

View File

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

View File

@@ -84,26 +84,26 @@ public:
ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const final;
bool addFiles(ProjectExplorer::Node *context,
const QStringList &filePaths,
QStringList *notAdded = nullptr) final;
const Utils::FilePaths &filePaths,
Utils::FilePaths *notAdded = nullptr) final;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *context,
const QStringList &filePaths,
QStringList *notRemoved = nullptr) final;
const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved = nullptr) final;
bool renameFile(ProjectExplorer::Node *context,
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;
bool isProjectEditable() const;
bool addFilesToProduct(const QStringList &filePaths,
bool addFilesToProduct(const Utils::FilePaths &filePaths,
const QJsonObject &product,
const QJsonObject &group,
QStringList *notAdded);
ProjectExplorer::RemovedFilesFromProject removeFilesFromProduct(const QStringList &filePaths,
Utils::FilePaths *notAdded);
ProjectExplorer::RemovedFilesFromProject removeFilesFromProduct(const Utils::FilePaths &filePaths,
const QJsonObject &product,
const QJsonObject &group,
QStringList *notRemoved);
Utils::FilePaths *notRemoved);
bool renameFileInProduct(const QString &oldPath,
const QString &newPath, const QJsonObject &product,
const QJsonObject &group);

View File

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

View File

@@ -505,25 +505,25 @@ bool QmakePriFile::canAddSubProject(const QString &proFilePath) const
return false;
}
static QString simplifyProFilePath(const QString &proFilePath)
static FilePath simplifyProFilePath(const FilePath &proFilePath)
{
// if proFilePath is like: _path_/projectName/projectName.pro
// we simplify it to: _path_/projectName
QFileInfo fi(proFilePath);
QFileInfo fi = proFilePath.toFileInfo(); // FIXME
const QString parentPath = fi.absolutePath();
QFileInfo parentFi(parentPath);
if (parentFi.fileName() == fi.completeBaseName())
return parentPath;
return FilePath::fromString(parentPath);
return proFilePath;
}
bool QmakePriFile::addSubProject(const QString &proFile)
{
QStringList uniqueProFilePaths;
FilePaths uniqueProFilePaths;
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);
return failedFiles.isEmpty();
@@ -531,57 +531,57 @@ bool QmakePriFile::addSubProject(const QString &proFile)
bool QmakePriFile::removeSubProjects(const QString &proFilePath)
{
QStringList failedOriginalFiles;
changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), QStringList(proFilePath), &failedOriginalFiles, RemoveFromProFile);
FilePaths failedOriginalFiles;
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);
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.
// 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
// project files manually anyway.
using TypeFileMap = QMap<QString, QStringList>;
using TypeFileMap = QMap<QString, FilePaths>;
// Split into lists by file type and bulk-add them.
TypeFileMap typeFileMap;
foreach (const QString &file, filePaths) {
for (const FilePath &file : filePaths) {
const Utils::MimeType mt = Utils::mimeTypeForFile(file);
typeFileMap[mt.name()] << file;
}
QStringList failedFiles;
FilePaths failedFiles;
foreach (const QString &type, typeFileMap.keys()) {
const QStringList typeFiles = typeFileMap.value(type);
QStringList qrcFiles; // the list of qrc files referenced from ui files
const FilePaths typeFiles = typeFileMap.value(type);
FilePaths qrcFiles; // the list of qrc files referenced from ui files
if (type == QLatin1String(ProjectExplorer::Constants::RESOURCE_MIMETYPE)) {
foreach (const QString &formFile, typeFiles) {
QStringList resourceFiles = formResources(formFile);
foreach (const QString &resourceFile, resourceFiles)
for (const FilePath &formFile : typeFiles) {
const FilePaths resourceFiles = formResources(formFile);
for (const FilePath &resourceFile : resourceFiles)
if (!qrcFiles.contains(resourceFile))
qrcFiles.append(resourceFile);
}
}
QStringList uniqueQrcFiles;
foreach (const QString &file, qrcFiles) {
if (!m_recursiveEnumerateFiles.contains(FilePath::fromString(file)))
FilePaths uniqueQrcFiles;
for (const FilePath &file : qAsConst(qrcFiles)) {
if (!m_recursiveEnumerateFiles.contains(file))
uniqueQrcFiles.append(file);
}
QStringList uniqueFilePaths;
foreach (const QString &file, typeFiles) {
if (!m_recursiveEnumerateFiles.contains(FilePath::fromString(file)))
FilePaths uniqueFilePaths;
for (const FilePath &file : typeFiles) {
if (!m_recursiveEnumerateFiles.contains(file))
uniqueFilePaths.append(file);
}
uniqueFilePaths.sort();
FilePath::sort(uniqueFilePaths);
changeFiles(type, uniqueFilePaths, &failedFiles, AddToProFile);
if (notAdded)
@@ -593,19 +593,18 @@ bool QmakePriFile::addFiles(const QStringList &filePaths, QStringList *notAdded)
return failedFiles.isEmpty();
}
bool QmakePriFile::removeFiles(const QStringList &filePaths,
QStringList *notRemoved)
bool QmakePriFile::removeFiles(const FilePaths &filePaths, FilePaths *notRemoved)
{
QStringList failedFiles;
using TypeFileMap = QMap<QString, QStringList>;
FilePaths failedFiles;
using TypeFileMap = QMap<QString, FilePaths>;
// Split into lists by file type and bulk-add them.
TypeFileMap typeFileMap;
foreach (const QString &file, filePaths) {
for (const FilePath &file : filePaths) {
const Utils::MimeType mt = Utils::mimeTypeForFile(file);
typeFileMap[mt.name()] << file;
}
foreach (const QString &type, typeFileMap.keys()) {
const QStringList typeFiles = typeFileMap.value(type);
const FilePaths typeFiles = typeFileMap.value(type);
changeFiles(type, typeFiles, &failedFiles, RemoveFromProFile);
if (notRemoved)
*notRemoved = failedFiles;
@@ -613,7 +612,7 @@ bool QmakePriFile::removeFiles(const QStringList &filePaths,
return failedFiles.isEmpty();
}
bool QmakePriFile::deleteFiles(const QStringList &filePaths)
bool QmakePriFile::deleteFiles(const FilePaths &filePaths)
{
removeFiles(filePaths);
return true;
@@ -705,16 +704,16 @@ bool QmakePriFile::saveModifiedEditors()
return true;
}
QStringList QmakePriFile::formResources(const QString &formFile) const
FilePaths QmakePriFile::formResources(const FilePath &formFile) const
{
QStringList resourceFiles;
QFile file(formFile);
QFile file(formFile.toString());
if (!file.open(QIODevice::ReadOnly))
return resourceFiles;
return {};
QXmlStreamReader reader(&file);
QFileInfo fi(formFile);
QFileInfo fi(formFile.toString());
QDir formDir = fi.absoluteDir();
while (!reader.atEnd()) {
reader.readNext();
@@ -737,7 +736,7 @@ QStringList QmakePriFile::formResources(const QString &formFile) const
if (reader.hasError())
qWarning() << "Could not read form file:" << formFile;
return resourceFiles;
return Utils::transform(resourceFiles, &FilePath::fromString);
}
bool QmakePriFile::ensureWriteableProFile(const QString &file)
@@ -855,8 +854,8 @@ bool QmakePriFile::renameFile(const FilePath &oldFilePath, const FilePath &newFi
}
void QmakePriFile::changeFiles(const QString &mimeType,
const QStringList &filePaths,
QStringList *notChanged,
const FilePaths &filePaths,
FilePaths *notChanged,
ChangeType change, Change mode)
{
if (filePaths.isEmpty())
@@ -879,12 +878,18 @@ void QmakePriFile::changeFiles(const QString &mimeType,
<< filePaths << "change type:" << int(change) << "mode:" << int(mode);
if (change == AddToProFile) {
// 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());
notChanged->clear();
} else { // RemoveFromProFile
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

View File

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

View File

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

View File

@@ -90,13 +90,13 @@ public:
const ProjectExplorer::Node *node) const override;
bool addFiles(ProjectExplorer::Node *context,
const QStringList &filePaths,
QStringList *notAdded = nullptr) override;
const Utils::FilePaths &filePaths,
Utils::FilePaths *notAdded = nullptr) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(ProjectExplorer::Node *context,
const QStringList &filePaths,
QStringList *notRemoved = nullptr) override;
const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved = nullptr) override;
bool deleteFiles(ProjectExplorer::Node *context,
const QStringList &filePaths) override;
const Utils::FilePaths &filePaths) override;
bool canRenameFile(ProjectExplorer::Node *context,
const Utils::FilePath &oldFilePath,
const Utils::FilePath &newFilePath) override;
@@ -107,7 +107,7 @@ public:
const QStringList &dependencies) override;
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;
void asyncUpdate();

View File

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

View File

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

View File

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

View File

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

View File

@@ -54,9 +54,9 @@ public:
ProjectExplorer::ProjectAction action,
const ProjectExplorer::Node *node) const override;
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,
const QStringList &filePaths) override;
const Utils::FilePaths &filePaths) override;
bool renameFile(ProjectExplorer::Node *context,
const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;

View File

@@ -59,6 +59,7 @@
#include <QApplication>
using namespace ProjectExplorer;
using namespace Utils;
namespace ResourceEditor {
namespace Internal {
@@ -322,18 +323,18 @@ void ResourceEditorPluginPrivate::removeFileContextMenu()
{
auto rfn = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QTC_ASSERT(rfn, return);
QString path = rfn->filePath().toString();
FilePath path = rfn->filePath();
FolderNode *parent = rfn->parentFolderNode();
QTC_ASSERT(parent, return);
if (parent->removeFiles(QStringList() << path) != RemovedFilesFromProject::Ok)
if (parent->removeFiles({path}) != RemovedFilesFromProject::Ok)
QMessageBox::warning(Core::ICore::dialogParent(),
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()
{
Core::EditorManager::openEditor(ProjectTree::currentNode()->filePath().toString());
Core::EditorManager::openEditor(ProjectTree::currentNode()->filePath());
}
void ResourceEditorPluginPrivate::copyPathContextMenu()

View File

@@ -133,8 +133,8 @@ static bool hasPriority(const QStringList &files)
}
static bool addFilesToResource(const FilePath &resourceFile,
const QStringList &filePaths,
QStringList *notAdded,
const FilePaths &filePaths,
FilePaths *notAdded,
const QString &prefix,
const QString &lang)
{
@@ -151,12 +151,12 @@ static bool addFilesToResource(const FilePath &resourceFile,
if (notAdded)
notAdded->clear();
foreach (const QString &path, filePaths) {
if (file.contains(index, path)) {
for (const FilePath &path : filePaths) {
if (file.contains(index, path.toString())) {
if (notAdded)
*notAdded << path;
} else {
file.addFile(index, path);
file.addFile(index, path.toString());
}
}
@@ -174,9 +174,9 @@ public:
ResourceTopLevelNode *topLevel, ResourceFolderNode *prefixNode);
bool supportsAction(ProjectAction, const Node *node) const final;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) final;
RemovedFilesFromProject removeFiles(const QStringList &filePaths,
QStringList *notRemoved) final;
bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded) final;
RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved) final;
bool canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;
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
}
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);
}
RemovedFilesFromProject SimpleResourceFolderNode::removeFiles(const QStringList &filePaths,
QStringList *notRemoved)
RemovedFilesFromProject SimpleResourceFolderNode::removeFiles(const FilePaths &filePaths,
FilePaths *notRemoved)
{
return prefixNode()->removeFiles(filePaths, notRemoved);
}
@@ -385,13 +385,13 @@ bool ResourceTopLevelNode::supportsAction(ProjectAction action, const Node *node
|| 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,
QStringList *notRemoved)
RemovedFilesFromProject ResourceTopLevelNode::removeFiles(const FilePaths &filePaths,
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.
}
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);
}
RemovedFilesFromProject ResourceFolderNode::removeFiles(const QStringList &filePaths,
QStringList *notRemoved)
RemovedFilesFromProject ResourceFolderNode::removeFiles(const FilePaths &filePaths,
FilePaths *notRemoved)
{
if (notRemoved)
*notRemoved = filePaths;
@@ -516,10 +516,10 @@ RemovedFilesFromProject ResourceFolderNode::removeFiles(const QStringList &fileP
return RemovedFilesFromProject::Error;
for (int j = 0; j < file.fileCount(index); ++j) {
QString fileName = file.file(index, j);
if (!filePaths.contains(fileName))
if (!filePaths.contains(FilePath::fromString(fileName)))
continue;
if (notRemoved)
notRemoved->removeOne(fileName);
notRemoved->removeOne(FilePath::fromString(fileName));
file.removeFile(index, j);
--j;
}

View File

@@ -42,9 +42,9 @@ public:
void addInternalNodes();
bool supportsAction(ProjectExplorer::ProjectAction action, const Node *node) const override;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(const QStringList &filePaths,
QStringList *notRemoved) override;
bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved) override;
bool addPrefix(const QString &prefix, const QString &lang);
bool removePrefix(const QString &prefix, const QString &lang);
@@ -70,9 +70,9 @@ public:
QString displayName() const override;
bool addFiles(const QStringList &filePaths, QStringList *notAdded) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(const QStringList &filePaths,
QStringList *notRemoved) override;
bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded) override;
ProjectExplorer::RemovedFilesFromProject removeFiles(const Utils::FilePaths &filePaths,
Utils::FilePaths *notRemoved) override;
bool canRenameFile(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)) {
for (ProjectExplorer::Project *p : ProjectExplorer::SessionManager::projects()) {
if (path.startsWith(p->projectDirectory().toString())) {
p->rootProjectNode()->addFiles({path.toString()});
p->rootProjectNode()->addFiles({path});
break;
}
}