ProjectExplorer: Use more FilePaths in ProjectNodes

... and related classes.

Change-Id: I50844a0b60e4b0769727b17d5b3d544cd6d10f0d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-08-09 14:03:54 +02:00
parent 34b7ef6bb3
commit 2a20778937
16 changed files with 72 additions and 75 deletions

View File

@@ -59,12 +59,12 @@ namespace ProjectExplorer {
// Helper: // Helper:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
static QString generatedProjectFilePath(const QList<JsonWizard::GeneratorFile> &files) static FilePath generatedProjectFilePath(const QList<JsonWizard::GeneratorFile> &files)
{ {
foreach (const JsonWizard::GeneratorFile &file, files) for (const JsonWizard::GeneratorFile &file : files)
if (file.file.attributes() & GeneratedFile::OpenProjectAttribute) if (file.file.attributes() & GeneratedFile::OpenProjectAttribute)
return file.file.path(); return file.file.filePath();
return QString(); return {};
} }
static IWizardFactory::WizardKind wizardKind(JsonWizard *wiz) static IWizardFactory::WizardKind wizardKind(JsonWizard *wiz)
@@ -118,17 +118,17 @@ void JsonSummaryPage::initializePage()
IWizardFactory::WizardKind kind = wizardKind(m_wizard); IWizardFactory::WizardKind kind = wizardKind(m_wizard);
bool isProject = (kind == IWizardFactory::ProjectWizard); bool isProject = (kind == IWizardFactory::ProjectWizard);
QStringList files; FilePaths files;
if (isProject) { if (isProject) {
JsonWizard::GeneratorFile f JsonWizard::GeneratorFile f
= Utils::findOrDefault(m_fileList, [](const JsonWizard::GeneratorFile &f) { = Utils::findOrDefault(m_fileList, [](const JsonWizard::GeneratorFile &f) {
return f.file.attributes() & GeneratedFile::OpenProjectAttribute; return f.file.attributes() & GeneratedFile::OpenProjectAttribute;
}); });
files << f.file.path(); files << f.file.filePath();
} else { } else {
files = Utils::transform(m_fileList, files = Utils::transform(m_fileList,
[](const JsonWizard::GeneratorFile &f) { [](const JsonWizard::GeneratorFile &f) {
return f.file.path(); return f.file.filePath();
}); });
} }
@@ -183,7 +183,7 @@ void JsonSummaryPage::triggerCommit(const JsonWizard::GeneratorFiles &files)
void JsonSummaryPage::addToProject(const JsonWizard::GeneratorFiles &files) void JsonSummaryPage::addToProject(const JsonWizard::GeneratorFiles &files)
{ {
QTC_CHECK(m_fileList.isEmpty()); // Happens after this page is done QTC_CHECK(m_fileList.isEmpty()); // Happens after this page is done
QString generatedProject = generatedProjectFilePath(files); const FilePath generatedProject = generatedProjectFilePath(files);
IWizardFactory::WizardKind kind = wizardKind(m_wizard); IWizardFactory::WizardKind kind = wizardKind(m_wizard);
FolderNode *folder = currentNode(); FolderNode *folder = currentNode();
@@ -193,7 +193,7 @@ void JsonSummaryPage::addToProject(const JsonWizard::GeneratorFiles &files)
if (!static_cast<ProjectNode *>(folder)->addSubProject(generatedProject)) { if (!static_cast<ProjectNode *>(folder)->addSubProject(generatedProject)) {
QMessageBox::critical(m_wizard, tr("Failed to Add to Project"), QMessageBox::critical(m_wizard, tr("Failed to Add to Project"),
tr("Failed to add subproject \"%1\"\nto project \"%2\".") tr("Failed to add subproject \"%1\"\nto project \"%2\".")
.arg(QDir::toNativeSeparators(generatedProject)) .arg(generatedProject.toUserOutput())
.arg(folder->filePath().toUserOutput())); .arg(folder->filePath().toUserOutput()));
return; return;
} }

View File

@@ -3593,7 +3593,7 @@ void ProjectExplorerPluginPrivate::addExistingProjects()
FilePaths failedProjects; FilePaths failedProjects;
QStringList addedProjects; QStringList addedProjects;
for (const FilePath &filePath : qAsConst(subProjectFilePaths)) { for (const FilePath &filePath : qAsConst(subProjectFilePaths)) {
if (projectNode->addSubProject(filePath.toString())) if (projectNode->addSubProject(filePath))
addedProjects << filePath.toString(); addedProjects << filePath.toString();
else else
failedProjects << filePath; failedProjects << filePath;
@@ -3670,7 +3670,7 @@ void ProjectExplorerPluginPrivate::removeProject()
RemoveFileDialog removeFileDialog(node->filePath().toString(), ICore::dialogParent()); RemoveFileDialog removeFileDialog(node->filePath().toString(), ICore::dialogParent());
removeFileDialog.setDeleteFileVisible(false); removeFileDialog.setDeleteFileVisible(false);
if (removeFileDialog.exec() == QDialog::Accepted) if (removeFileDialog.exec() == QDialog::Accepted)
projectNode->removeSubProject(node->filePath().toString()); projectNode->removeSubProject(node->filePath());
} }
} }

View File

@@ -103,12 +103,12 @@ ProjectFileWizardExtension::~ProjectFileWizardExtension()
delete m_context; delete m_context;
} }
static QString generatedProjectFilePath(const QList<GeneratedFile> &files) static FilePath generatedProjectFilePath(const QList<GeneratedFile> &files)
{ {
foreach (const GeneratedFile &file, files) for (const GeneratedFile &file : files)
if (file.attributes() & GeneratedFile::OpenProjectAttribute) if (file.attributes() & GeneratedFile::OpenProjectAttribute)
return file.path(); return file.filePath();
return QString(); return {};
} }
void ProjectFileWizardExtension::firstExtensionPageShown( void ProjectFileWizardExtension::firstExtensionPageShown(
@@ -121,7 +121,7 @@ void ProjectFileWizardExtension::firstExtensionPageShown(
QStringList fileNames = Utils::transform(files, &GeneratedFile::path); QStringList fileNames = Utils::transform(files, &GeneratedFile::path);
m_context->page->setFiles(fileNames); m_context->page->setFiles(fileNames);
QStringList filePaths; FilePaths filePaths;
ProjectAction projectAction; ProjectAction projectAction;
const IWizardFactory::WizardKind kind = m_context->wizard->kind(); const IWizardFactory::WizardKind kind = m_context->wizard->kind();
if (kind == IWizardFactory::ProjectWizard) { if (kind == IWizardFactory::ProjectWizard) {
@@ -129,13 +129,13 @@ void ProjectFileWizardExtension::firstExtensionPageShown(
filePaths << generatedProjectFilePath(files); filePaths << generatedProjectFilePath(files);
} else { } else {
projectAction = AddNewFile; projectAction = AddNewFile;
filePaths = Utils::transform(files, &GeneratedFile::path); filePaths = Utils::transform(files, &GeneratedFile::filePath);
} }
// Static cast from void * to avoid qobject_cast (which needs a valid object) in value(). // Static cast from void * to avoid qobject_cast (which needs a valid object) in value().
auto contextNode = static_cast<Node *>(extraValues.value(QLatin1String(Constants::PREFERRED_PROJECT_NODE)).value<void *>()); auto contextNode = static_cast<Node *>(extraValues.value(QLatin1String(Constants::PREFERRED_PROJECT_NODE)).value<void *>());
auto project = static_cast<Project *>(extraValues.value(Constants::PROJECT_POINTER).value<void *>()); auto project = static_cast<Project *>(extraValues.value(Constants::PROJECT_POINTER).value<void *>());
const QString path = extraValues.value(Constants::PREFERRED_PROJECT_NODE_PATH).toString(); const FilePath path = FilePath::fromVariant(extraValues.value(Constants::PREFERRED_PROJECT_NODE_PATH));
m_context->page->initializeProjectTree(findWizardContextNode(contextNode, project, path), m_context->page->initializeProjectTree(findWizardContextNode(contextNode, project, path),
filePaths, m_context->wizard->kind(), filePaths, m_context->wizard->kind(),
@@ -152,12 +152,12 @@ void ProjectFileWizardExtension::firstExtensionPageShown(
} }
Node *ProjectFileWizardExtension::findWizardContextNode(Node *contextNode, Project *project, Node *ProjectFileWizardExtension::findWizardContextNode(Node *contextNode, Project *project,
const QString &path) const FilePath &path)
{ {
if (contextNode && !ProjectTree::hasNode(contextNode)) { if (contextNode && !ProjectTree::hasNode(contextNode)) {
if (SessionManager::projects().contains(project) && project->rootProjectNode()) { if (SessionManager::projects().contains(project) && project->rootProjectNode()) {
contextNode = project->rootProjectNode()->findNode([path](const Node *n) { contextNode = project->rootProjectNode()->findNode([path](const Node *n) {
return path == n->filePath().toString(); return path == n->filePath();
}); });
} }
} }
@@ -204,7 +204,7 @@ bool ProjectFileWizardExtension::processProject(
{ {
*removeOpenProjectAttribute = false; *removeOpenProjectAttribute = false;
QString generatedProject = generatedProjectFilePath(files); const FilePath generatedProject = generatedProjectFilePath(files);
FolderNode *folder = m_context->page->currentNode(); FolderNode *folder = m_context->page->currentNode();
if (!folder) if (!folder)
@@ -212,7 +212,7 @@ bool ProjectFileWizardExtension::processProject(
if (m_context->wizard->kind() == IWizardFactory::ProjectWizard) { if (m_context->wizard->kind() == IWizardFactory::ProjectWizard) {
if (!static_cast<ProjectNode *>(folder)->addSubProject(generatedProject)) { if (!static_cast<ProjectNode *>(folder)->addSubProject(generatedProject)) {
*errorMessage = tr("Failed to add subproject \"%1\"\nto project \"%2\".") *errorMessage = tr("Failed to add subproject \"%1\"\nto project \"%2\".")
.arg(generatedProject).arg(folder->filePath().toUserOutput()); .arg(generatedProject.toUserOutput()).arg(folder->filePath().toUserOutput());
return false; return false;
} }
*removeOpenProjectAttribute = true; *removeOpenProjectAttribute = true;

View File

@@ -54,7 +54,7 @@ public slots:
void firstExtensionPageShown(const QList<Core::GeneratedFile> &files, const QVariantMap &extraValues) override; void firstExtensionPageShown(const QList<Core::GeneratedFile> &files, const QVariantMap &extraValues) override;
private: private:
Node *findWizardContextNode(Node *contextNode, Project *project, const QString &path); Node *findWizardContextNode(Node *contextNode, Project *project, const Utils::FilePath &path);
bool processProject(const QList<Core::GeneratedFile> &files, bool processProject(const QList<Core::GeneratedFile> &files,
bool *removeOpenProjectAttribute, QString *errorMessage); bool *removeOpenProjectAttribute, QString *errorMessage);

View File

@@ -768,7 +768,7 @@ bool FolderNode::deleteFiles(const FilePaths &filePaths)
return false; return false;
} }
bool FolderNode::canRenameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) bool FolderNode::canRenameFile(const FilePath &oldFilePath, const FilePath &newFilePath)
{ {
ProjectNode *pn = managingProject(); ProjectNode *pn = managingProject();
if (pn) if (pn)
@@ -776,7 +776,7 @@ bool FolderNode::canRenameFile(const Utils::FilePath &oldFilePath, const Utils::
return false; return false;
} }
bool FolderNode::renameFile(const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) bool FolderNode::renameFile(const FilePath &oldFilePath, const FilePath &newFilePath)
{ {
ProjectNode *pn = managingProject(); ProjectNode *pn = managingProject();
if (pn) if (pn)
@@ -791,7 +791,7 @@ bool FolderNode::addDependencies(const QStringList &dependencies)
return false; return false;
} }
FolderNode::AddNewInformation FolderNode::addNewInformation(const QStringList &files, Node *context) const FolderNode::AddNewInformation FolderNode::addNewInformation(const FilePaths &files, Node *context) const
{ {
Q_UNUSED(files) Q_UNUSED(files)
return AddNewInformation(displayName(), context == this ? 120 : 100); return AddNewInformation(displayName(), context == this ? 120 : 100);
@@ -839,7 +839,7 @@ bool FolderNode::showWhenEmpty() const
\sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode \sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode
*/ */
VirtualFolderNode::VirtualFolderNode(const Utils::FilePath &folderPath) : VirtualFolderNode::VirtualFolderNode(const FilePath &folderPath) :
FolderNode(folderPath) FolderNode(folderPath)
{ {
} }
@@ -857,7 +857,7 @@ VirtualFolderNode::VirtualFolderNode(const Utils::FilePath &folderPath) :
/*! /*!
Creates an uninitialized project node object. Creates an uninitialized project node object.
*/ */
ProjectNode::ProjectNode(const Utils::FilePath &projectFilePath) : ProjectNode::ProjectNode(const FilePath &projectFilePath) :
FolderNode(projectFilePath) FolderNode(projectFilePath)
{ {
setPriority(DefaultProjectPriority); setPriority(DefaultProjectPriority);
@@ -865,13 +865,13 @@ ProjectNode::ProjectNode(const Utils::FilePath &projectFilePath) :
setDisplayName(projectFilePath.fileName()); setDisplayName(projectFilePath.fileName());
} }
bool ProjectNode::canAddSubProject(const QString &proFilePath) const bool ProjectNode::canAddSubProject(const FilePath &proFilePath) const
{ {
Q_UNUSED(proFilePath) Q_UNUSED(proFilePath)
return false; return false;
} }
bool ProjectNode::addSubProject(const QString &proFilePath) bool ProjectNode::addSubProject(const FilePath &proFilePath)
{ {
Q_UNUSED(proFilePath) Q_UNUSED(proFilePath)
return false; return false;
@@ -882,7 +882,7 @@ QStringList ProjectNode::subProjectFileNamePatterns() const
return QStringList(); return QStringList();
} }
bool ProjectNode::removeSubProject(const QString &proFilePath) bool ProjectNode::removeSubProject(const FilePath &proFilePath)
{ {
Q_UNUSED(proFilePath) Q_UNUSED(proFilePath)
return false; return false;

View File

@@ -317,7 +317,7 @@ public:
int priority; int priority;
}; };
virtual AddNewInformation addNewInformation(const QStringList &files, Node *context) const; virtual AddNewInformation addNewInformation(const Utils::FilePaths &files, Node *context) const;
// determines if node will be shown in the flat view, by default folder and projects aren't shown // determines if node will be shown in the flat view, by default folder and projects aren't shown
@@ -370,10 +370,10 @@ class PROJECTEXPLORER_EXPORT ProjectNode : public FolderNode
public: public:
explicit ProjectNode(const Utils::FilePath &projectFilePath); explicit ProjectNode(const Utils::FilePath &projectFilePath);
virtual bool canAddSubProject(const QString &proFilePath) const; virtual bool canAddSubProject(const Utils::FilePath &proFilePath) const;
virtual bool addSubProject(const QString &proFile); virtual bool addSubProject(const Utils::FilePath &proFile);
virtual QStringList subProjectFileNamePatterns() const; virtual QStringList subProjectFileNamePatterns() const;
virtual bool removeSubProject(const QString &proFilePath); virtual bool removeSubProject(const Utils::FilePath &proFilePath);
virtual Utils::optional<Utils::FilePath> visibleAfterAddFileAction() const { virtual Utils::optional<Utils::FilePath> visibleAfterAddFileAction() const {
return Utils::nullopt; return Utils::nullopt;
} }

View File

@@ -141,7 +141,7 @@ Qt::ItemFlags AddNewTree::flags(int) const
class BestNodeSelector class BestNodeSelector
{ {
public: public:
BestNodeSelector(const QString &commonDirectory, const QStringList &files); BestNodeSelector(const QString &commonDirectory, const FilePaths &files);
void inspect(AddNewTree *tree, bool isContextNode); void inspect(AddNewTree *tree, bool isContextNode);
AddNewTree *bestChoice() const; AddNewTree *bestChoice() const;
bool deploys(); bool deploys();
@@ -149,7 +149,7 @@ public:
private: private:
QString m_commonDirectory; QString m_commonDirectory;
QStringList m_files; FilePaths m_files;
bool m_deploys = false; bool m_deploys = false;
QString m_deployText; QString m_deployText;
AddNewTree *m_bestChoice = nullptr; AddNewTree *m_bestChoice = nullptr;
@@ -157,7 +157,7 @@ private:
int m_bestMatchPriority = -1; int m_bestMatchPriority = -1;
}; };
BestNodeSelector::BestNodeSelector(const QString &commonDirectory, const QStringList &files) : BestNodeSelector::BestNodeSelector(const QString &commonDirectory, const FilePaths &files) :
m_commonDirectory(commonDirectory), m_commonDirectory(commonDirectory),
m_files(files), m_files(files),
m_deployText(QCoreApplication::translate("ProjectWizard", "The files are implicitly added to the projects:") + QLatin1Char('\n')) m_deployText(QCoreApplication::translate("ProjectWizard", "The files are implicitly added to the projects:") + QLatin1Char('\n'))
@@ -230,7 +230,8 @@ static inline AddNewTree *createNoneNode(BestNodeSelector *selector)
return new AddNewTree(displayName); return new AddNewTree(displayName);
} }
static inline AddNewTree *buildAddProjectTree(ProjectNode *root, const QString &projectPath, Node *contextNode, BestNodeSelector *selector) static inline AddNewTree *buildAddProjectTree(ProjectNode *root, const FilePath &projectPath,
Node *contextNode, BestNodeSelector *selector)
{ {
QList<AddNewTree *> children; QList<AddNewTree *> children;
for (Node *node : root->nodes()) { for (Node *node : root->nodes()) {
@@ -242,7 +243,7 @@ static inline AddNewTree *buildAddProjectTree(ProjectNode *root, const QString &
if (root->supportsAction(AddSubProject, root) && !root->supportsAction(InheritedFromParent, root)) { if (root->supportsAction(AddSubProject, root) && !root->supportsAction(InheritedFromParent, root)) {
if (projectPath.isEmpty() || root->canAddSubProject(projectPath)) { if (projectPath.isEmpty() || root->canAddSubProject(projectPath)) {
FolderNode::AddNewInformation info = root->addNewInformation(QStringList() << projectPath, contextNode); FolderNode::AddNewInformation info = root->addNewInformation({projectPath}, contextNode);
auto item = new AddNewTree(root, children, info); auto item = new AddNewTree(root, children, info);
selector->inspect(item, root == contextNode); selector->inspect(item, root == contextNode);
return item; return item;
@@ -254,8 +255,8 @@ static inline AddNewTree *buildAddProjectTree(ProjectNode *root, const QString &
return new AddNewTree(root, children, root->displayName()); return new AddNewTree(root, children, root->displayName());
} }
static inline AddNewTree *buildAddFilesTree(FolderNode *root, const QStringList &files, static AddNewTree *buildAddFilesTree(FolderNode *root, const FilePaths &files,
Node *contextNode, BestNodeSelector *selector) Node *contextNode, BestNodeSelector *selector)
{ {
QList<AddNewTree *> children; QList<AddNewTree *> children;
foreach (FolderNode *fn, root->folderNodes()) { foreach (FolderNode *fn, root->folderNodes()) {
@@ -436,7 +437,7 @@ bool ProjectWizardPage::runVersionControl(const QList<GeneratedFile> &files, QSt
return true; return true;
} }
void ProjectWizardPage::initializeProjectTree(Node *context, const QStringList &paths, void ProjectWizardPage::initializeProjectTree(Node *context, const FilePaths &paths,
IWizardFactory::WizardKind kind, IWizardFactory::WizardKind kind,
ProjectAction action) ProjectAction action)
{ {

View File

@@ -69,7 +69,7 @@ public:
bool runVersionControl(const QList<Core::GeneratedFile> &files, QString *errorMessage); bool runVersionControl(const QList<Core::GeneratedFile> &files, QString *errorMessage);
void initializeProjectTree(Node *context, const QStringList &paths, void initializeProjectTree(Node *context, const Utils::FilePaths &paths,
Core::IWizardFactory::WizardKind kind, Core::IWizardFactory::WizardKind kind,
ProjectAction action); ProjectAction action);

View File

@@ -78,7 +78,7 @@ QbsGroupNode::QbsGroupNode(const QJsonObject &grp) : ProjectNode(FilePath()), m_
setEnabled(grp.value("is-enabled").toBool()); setEnabled(grp.value("is-enabled").toBool());
} }
FolderNode::AddNewInformation QbsGroupNode::addNewInformation(const QStringList &files, FolderNode::AddNewInformation QbsGroupNode::addNewInformation(const FilePaths &files,
Node *context) const Node *context) const
{ {
AddNewInformation info = ProjectNode::addNewInformation(files, context); AddNewInformation info = ProjectNode::addNewInformation(files, context);

View File

@@ -46,7 +46,7 @@ public:
private: private:
friend class QbsBuildSystem; friend class QbsBuildSystem;
AddNewInformation addNewInformation(const QStringList &files, Node *context) const override; AddNewInformation addNewInformation(const Utils::FilePaths &files, Node *context) const override;
QVariant data(Utils::Id role) const override; QVariant data(Utils::Id role) const override;
const QJsonObject m_groupData; const QJsonObject m_groupData;

View File

@@ -169,19 +169,19 @@ bool QmakeBuildSystem::supportsAction(Node *context, ProjectAction action, const
return BuildSystem::supportsAction(context, action, node); return BuildSystem::supportsAction(context, action, node);
} }
bool QmakePriFileNode::canAddSubProject(const QString &proFilePath) const bool QmakePriFileNode::canAddSubProject(const FilePath &proFilePath) const
{ {
const QmakePriFile *pri = priFile(); const QmakePriFile *pri = priFile();
return pri ? pri->canAddSubProject(proFilePath) : false; return pri ? pri->canAddSubProject(proFilePath) : false;
} }
bool QmakePriFileNode::addSubProject(const QString &proFilePath) bool QmakePriFileNode::addSubProject(const FilePath &proFilePath)
{ {
QmakePriFile *pri = priFile(); QmakePriFile *pri = priFile();
return pri ? pri->addSubProject(proFilePath) : false; return pri ? pri->addSubProject(proFilePath) : false;
} }
bool QmakePriFileNode::removeSubProject(const QString &proFilePath) bool QmakePriFileNode::removeSubProject(const FilePath &proFilePath)
{ {
QmakePriFile *pri = priFile(); QmakePriFile *pri = priFile();
return pri ? pri->removeSubProjects(proFilePath) : false; return pri ? pri->removeSubProjects(proFilePath) : false;
@@ -299,7 +299,7 @@ bool QmakeBuildSystem::addDependencies(Node *context, const QStringList &depende
return BuildSystem::addDependencies(context, dependencies); return BuildSystem::addDependencies(context, dependencies);
} }
FolderNode::AddNewInformation QmakePriFileNode::addNewInformation(const QStringList &files, Node *context) const FolderNode::AddNewInformation QmakePriFileNode::addNewInformation(const FilePaths &files, Node *context) const
{ {
Q_UNUSED(files) Q_UNUSED(files)
return FolderNode::AddNewInformation(filePath().fileName(), context && context->parentProjectNode() == this ? 120 : 90); return FolderNode::AddNewInformation(filePath().fileName(), context && context->parentProjectNode() == this ? 120 : 90);
@@ -483,7 +483,7 @@ bool QmakeProFileNode::includedInExactParse() const
return pro && pro->includedInExactParse(); return pro && pro->includedInExactParse();
} }
FolderNode::AddNewInformation QmakeProFileNode::addNewInformation(const QStringList &files, Node *context) const FolderNode::AddNewInformation QmakeProFileNode::addNewInformation(const FilePaths &files, Node *context) const
{ {
Q_UNUSED(files) Q_UNUSED(files)
return AddNewInformation(filePath().fileName(), context && context->parentProjectNode() == this ? 120 : 100); return AddNewInformation(filePath().fileName(), context && context->parentProjectNode() == this ? 120 : 100);

View File

@@ -48,12 +48,12 @@ public:
bool showInSimpleTree() const override { return false; } bool showInSimpleTree() const override { return false; }
bool canAddSubProject(const QString &proFilePath) const override; bool canAddSubProject(const Utils::FilePath &proFilePath) const override;
bool addSubProject(const QString &proFilePath) override; bool addSubProject(const Utils::FilePath &proFilePath) override;
bool removeSubProject(const QString &proFilePath) override; bool removeSubProject(const Utils::FilePath &proFilePath) override;
QStringList subProjectFileNamePatterns() const override; QStringList subProjectFileNamePatterns() const override;
AddNewInformation addNewInformation(const QStringList &files, Node *context) const override; AddNewInformation addNewInformation(const Utils::FilePaths &files, Node *context) const override;
bool deploysFolder(const QString &folder) const override; bool deploysFolder(const QString &folder) const override;
@@ -93,7 +93,7 @@ public:
void build() override; void build() override;
QStringList targetApplications() const override; QStringList targetApplications() const override;
AddNewInformation addNewInformation(const QStringList &files, Node *context) const override; AddNewInformation addNewInformation(const Utils::FilePaths &files, Node *context) const override;
QVariant data(Utils::Id role) const override; QVariant data(Utils::Id role) const override;
bool setData(Utils::Id role, const QVariant &value) const override; bool setData(Utils::Id role, const QVariant &value) const override;

View File

@@ -496,13 +496,9 @@ void QmakePriFile::setIncludedInExactParse(bool b)
m_includedInExactParse = b; m_includedInExactParse = b;
} }
bool QmakePriFile::canAddSubProject(const QString &proFilePath) const bool QmakePriFile::canAddSubProject(const FilePath &proFilePath) const
{ {
QFileInfo fi(proFilePath); return proFilePath.suffix() == "pro" || proFilePath.suffix() == "pri";
if (fi.suffix() == QLatin1String("pro")
|| fi.suffix() == QLatin1String("pri"))
return true;
return false;
} }
static FilePath simplifyProFilePath(const FilePath &proFilePath) static FilePath simplifyProFilePath(const FilePath &proFilePath)
@@ -517,11 +513,11 @@ static FilePath simplifyProFilePath(const FilePath &proFilePath)
return proFilePath; return proFilePath;
} }
bool QmakePriFile::addSubProject(const QString &proFile) bool QmakePriFile::addSubProject(const FilePath &proFile)
{ {
FilePaths uniqueProFilePaths; FilePaths uniqueProFilePaths;
if (!m_recursiveEnumerateFiles.contains(FilePath::fromString(proFile))) if (!m_recursiveEnumerateFiles.contains(proFile))
uniqueProFilePaths.append(simplifyProFilePath(FilePath::fromString(proFile))); uniqueProFilePaths.append(simplifyProFilePath(proFile));
FilePaths failedFiles; FilePaths failedFiles;
changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), uniqueProFilePaths, &failedFiles, AddToProFile); changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), uniqueProFilePaths, &failedFiles, AddToProFile);
@@ -529,10 +525,10 @@ bool QmakePriFile::addSubProject(const QString &proFile)
return failedFiles.isEmpty(); return failedFiles.isEmpty();
} }
bool QmakePriFile::removeSubProjects(const QString &proFilePath) bool QmakePriFile::removeSubProjects(const FilePath &proFilePath)
{ {
FilePaths failedOriginalFiles; FilePaths failedOriginalFiles;
changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), {FilePath::fromString(proFilePath)}, &failedOriginalFiles, RemoveFromProFile); changeFiles(QLatin1String(Constants::PROFILE_MIMETYPE), {proFilePath}, &failedOriginalFiles, RemoveFromProFile);
FilePaths simplifiedProFiles = Utils::transform(failedOriginalFiles, &simplifyProFilePath); FilePaths simplifiedProFiles = Utils::transform(failedOriginalFiles, &simplifyProFilePath);

View File

@@ -157,10 +157,10 @@ public:
void update(const Internal::QmakePriFileEvalResult &result); void update(const Internal::QmakePriFileEvalResult &result);
bool canAddSubProject(const QString &proFilePath) const; bool canAddSubProject(const Utils::FilePath &proFilePath) const;
bool addSubProject(const QString &proFile); bool addSubProject(const Utils::FilePath &proFile);
bool removeSubProjects(const QString &proFilePath); bool removeSubProjects(const Utils::FilePath &proFilePath);
bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr); bool addFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr);
bool removeFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notRemoved = nullptr); bool removeFiles(const Utils::FilePaths &filePaths, Utils::FilePaths *notRemoved = nullptr);

View File

@@ -119,7 +119,7 @@ static int getPriorityFromContextNode(const ProjectExplorer::Node *resourceNode,
return -1; return -1;
} }
static bool hasPriority(const QStringList &files) static bool hasPriority(const FilePaths &files)
{ {
if (files.isEmpty()) if (files.isEmpty())
return false; return false;
@@ -446,7 +446,7 @@ bool ResourceTopLevelNode::removeNonExistingFiles()
return true; return true;
} }
FolderNode::AddNewInformation ResourceTopLevelNode::addNewInformation(const QStringList &files, Node *context) const FolderNode::AddNewInformation ResourceTopLevelNode::addNewInformation(const FilePaths &files, Node *context) const
{ {
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2") QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2")
.arg(filePath().fileName()) .arg(filePath().fileName())
@@ -587,7 +587,7 @@ bool ResourceFolderNode::renamePrefix(const QString &prefix, const QString &lang
return true; return true;
} }
FolderNode::AddNewInformation ResourceFolderNode::addNewInformation(const QStringList &files, Node *context) const FolderNode::AddNewInformation ResourceFolderNode::addNewInformation(const FilePaths &files, Node *context) const
{ {
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2") QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2")
.arg(m_topLevelNode->filePath().fileName()) .arg(m_topLevelNode->filePath().fileName())

View File

@@ -49,7 +49,7 @@ public:
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);
AddNewInformation addNewInformation(const QStringList &files, Node *context) const override; AddNewInformation addNewInformation(const Utils::FilePaths &files, Node *context) const override;
bool showInSimpleTree() const override; bool showInSimpleTree() const override;
bool removeNonExistingFiles(); bool removeNonExistingFiles();
@@ -78,7 +78,7 @@ public:
bool renamePrefix(const QString &prefix, const QString &lang); bool renamePrefix(const QString &prefix, const QString &lang);
AddNewInformation addNewInformation(const QStringList &files, Node *context) const override; AddNewInformation addNewInformation(const Utils::FilePaths &files, Node *context) const override;
QString prefix() const; QString prefix() const;
QString lang() const; QString lang() const;