ProjectManager: Return FilePaths from ProjectImporter::importCandidates

Proliferates FilePath use a bit further. Actual changes to the
individual importers are left for further patches.

Change-Id: Ie7c6b2e3f4ac7d0eca6d2f56d30fb23354bb404b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
hjk
2022-09-26 14:21:12 +02:00
parent bcadea2285
commit 985c8b1a43
11 changed files with 28 additions and 49 deletions

View File

@@ -25,15 +25,13 @@
#include <utils/temporarydirectory.h> #include <utils/temporarydirectory.h>
#include <QApplication> #include <QApplication>
#include <QDir>
#include <QLoggingCategory> #include <QLoggingCategory>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace QtSupport; using namespace QtSupport;
using namespace Utils; using namespace Utils;
namespace CMakeProjectManager { namespace CMakeProjectManager::Internal {
namespace Internal {
static Q_LOGGING_CATEGORY(cmInputLog, "qtc.cmake.import", QtWarningMsg); static Q_LOGGING_CATEGORY(cmInputLog, "qtc.cmake.import", QtWarningMsg);
@@ -104,7 +102,7 @@ CMakeProjectImporter::CMakeProjectImporter(const FilePath &path, const PresetsDa
} }
QStringList CMakeProjectImporter::importCandidates() FilePaths CMakeProjectImporter::importCandidates()
{ {
FilePaths candidates; FilePaths candidates;
@@ -131,7 +129,7 @@ QStringList CMakeProjectImporter::importCandidates()
const FilePaths finalists = Utils::filteredUnique(candidates); const FilePaths finalists = Utils::filteredUnique(candidates);
qCInfo(cmInputLog) << "import candidates:" << finalists; qCInfo(cmInputLog) << "import candidates:" << finalists;
return finalists; return Utils::transform(finalists, &FilePath::fromString);
} }
static CMakeConfig configurationFromPresetProbe( static CMakeConfig configurationFromPresetProbe(
@@ -685,8 +683,7 @@ void CMakeProjectImporter::persistTemporaryCMake(Kit *k, const QVariantList &vl)
qCDebug(cmInputLog) << "Temporary CMake tool made persistent."; qCDebug(cmInputLog) << "Temporary CMake tool made persistent.";
} }
} // namespace Internal } // CMakeProjectManager::Internal
} // namespace CMakeProjectManager
#ifdef WITH_TESTS #ifdef WITH_TESTS

View File

@@ -21,7 +21,7 @@ class CMakeProjectImporter : public QtSupport::QtProjectImporter
public: public:
CMakeProjectImporter(const Utils::FilePath &path, const Internal::PresetsData &presetsData); CMakeProjectImporter(const Utils::FilePath &path, const Internal::PresetsData &presetsData);
QStringList importCandidates() final; Utils::FilePaths importCandidates() final;
private: private:
QList<void *> examineDirectory(const Utils::FilePath &importPath, QList<void *> examineDirectory(const Utils::FilePath &importPath,

View File

@@ -16,7 +16,7 @@ MesonProjectImporter::MesonProjectImporter(const Utils::FilePath &path)
: QtSupport::QtProjectImporter{path} : QtSupport::QtProjectImporter{path}
{} {}
QStringList MesonProjectImporter::importCandidates() Utils::FilePaths MesonProjectImporter::importCandidates()
{ {
//TODO, this can be done later //TODO, this can be done later
return {}; return {};

View File

@@ -3,21 +3,18 @@
#pragma once #pragma once
#include "exewrappers/mesonwrapper.h"
#include <projectexplorer/buildinfo.h> #include <projectexplorer/buildinfo.h>
#include <projectexplorer/kit.h> #include <projectexplorer/kit.h>
#include <qtsupport/qtprojectimporter.h> #include <qtsupport/qtprojectimporter.h>
namespace MesonProjectManager { namespace MesonProjectManager::Internal {
namespace Internal {
class MesonProjectImporter final : public QtSupport::QtProjectImporter class MesonProjectImporter final : public QtSupport::QtProjectImporter
{ {
public: public:
MesonProjectImporter(const Utils::FilePath &path); MesonProjectImporter(const Utils::FilePath &path);
QStringList importCandidates() final; Utils::FilePaths importCandidates() final;
private: private:
// importPath is an existing directory at this point! // importPath is an existing directory at this point!
@@ -32,5 +29,4 @@ private:
void deleteDirectoryData(void *directoryData) const final; void deleteDirectoryData(void *directoryData) const final;
}; };
} // namespace Internal } // MesonProjectManager::Internal
} // namespace MesonProjectManager

View File

@@ -34,7 +34,7 @@ public:
const Utils::FilePath projectDirectory() const { return m_projectPath.parentDir(); } const Utils::FilePath projectDirectory() const { return m_projectPath.parentDir(); }
virtual const QList<BuildInfo> import(const Utils::FilePath &importPath, bool silent = false); virtual const QList<BuildInfo> import(const Utils::FilePath &importPath, bool silent = false);
virtual QStringList importCandidates() = 0; virtual Utils::FilePaths importCandidates() = 0;
virtual Target *preferredTarget(const QList<Target *> &possibleTargets); virtual Target *preferredTarget(const QList<Target *> &possibleTargets);
bool isUpdating() const { return m_isUpdating; } bool isUpdating() const { return m_isUpdating; }

View File

@@ -334,9 +334,9 @@ void TargetSetupPage::setupImports()
if (!m_importer || m_projectPath.isEmpty()) if (!m_importer || m_projectPath.isEmpty())
return; return;
const QStringList toImport = m_importer->importCandidates(); const FilePaths toImport = m_importer->importCandidates();
for (const QString &path : toImport) for (const FilePath &path : toImport)
import(FilePath::fromString(path), true); import(path, true);
} }
void TargetSetupPage::handleKitAddition(Kit *k) void TargetSetupPage::handleKitAddition(Kit *k)

View File

@@ -24,8 +24,7 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace QbsProjectManager { namespace QbsProjectManager::Internal {
namespace Internal {
struct BuildGraphData struct BuildGraphData
{ {
@@ -88,7 +87,7 @@ static QStringList candidatesForDirectory(const QString &dir)
return candidates; return candidates;
} }
QStringList QbsProjectImporter::importCandidates() FilePaths QbsProjectImporter::importCandidates()
{ {
const QString projectDir = projectFilePath().toFileInfo().absolutePath(); const QString projectDir = projectFilePath().toFileInfo().absolutePath();
QStringList candidates = candidatesForDirectory(projectDir); QStringList candidates = candidatesForDirectory(projectDir);
@@ -105,7 +104,7 @@ QStringList QbsProjectImporter::importCandidates()
} }
} }
qCDebug(qbsPmLog) << "build directory candidates:" << candidates; qCDebug(qbsPmLog) << "build directory candidates:" << candidates;
return candidates; return Utils::transform(candidates, &FilePath::fromString);
} }
QList<void *> QbsProjectImporter::examineDirectory(const FilePath &importPath, QList<void *> QbsProjectImporter::examineDirectory(const FilePath &importPath,
@@ -212,5 +211,4 @@ void QbsProjectImporter::deleteDirectoryData(void *directoryData) const
delete static_cast<BuildGraphData *>(directoryData); delete static_cast<BuildGraphData *>(directoryData);
} }
} // namespace Internal } // QbsProjectManager::Internal
} // namespace QbsProjectManager

View File

@@ -5,8 +5,7 @@
#include <qtsupport/qtprojectimporter.h> #include <qtsupport/qtprojectimporter.h>
namespace QbsProjectManager { namespace QbsProjectManager::Internal {
namespace Internal {
class QbsProjectImporter final : public QtSupport::QtProjectImporter class QbsProjectImporter final : public QtSupport::QtProjectImporter
{ {
@@ -16,7 +15,7 @@ public:
QbsProjectImporter(const Utils::FilePath &path); QbsProjectImporter(const Utils::FilePath &path);
private: private:
QStringList importCandidates() override; Utils::FilePaths importCandidates() override;
QList<void *> examineDirectory(const Utils::FilePath &importPath, QString *warningMessage) const override; QList<void *> examineDirectory(const Utils::FilePath &importPath, QString *warningMessage) const override;
bool matchKit(void *directoryData, const ProjectExplorer::Kit *k) const override; bool matchKit(void *directoryData, const ProjectExplorer::Kit *k) const override;
ProjectExplorer::Kit *createKit(void *directoryData) const override; ProjectExplorer::Kit *createKit(void *directoryData) const override;
@@ -24,5 +23,4 @@ private:
void deleteDirectoryData(void *directoryData) const override; void deleteDirectoryData(void *directoryData) const override;
}; };
} // namespace Internal } // QbsProjectManager::Internal
} // namespace QbsProjectManager

View File

@@ -54,8 +54,7 @@ struct DirectoryData
} // namespace } // namespace
namespace QmakeProjectManager { namespace QmakeProjectManager::Internal {
namespace Internal {
const Utils::Id QT_IS_TEMPORARY("Qmake.TempQt"); const Utils::Id QT_IS_TEMPORARY("Qmake.TempQt");
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // ugly const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // ugly
@@ -64,7 +63,7 @@ QmakeProjectImporter::QmakeProjectImporter(const FilePath &path) :
QtProjectImporter(path) QtProjectImporter(path)
{ } { }
QStringList QmakeProjectImporter::importCandidates() FilePaths QmakeProjectImporter::importCandidates()
{ {
QStringList candidates; QStringList candidates;
@@ -84,7 +83,7 @@ QStringList QmakeProjectImporter::importCandidates()
candidates << path; candidates << path;
} }
} }
return candidates; return Utils::transform(candidates, &FilePath::fromString);
} }
QList<void *> QmakeProjectImporter::examineDirectory(const FilePath &importPath, QList<void *> QmakeProjectImporter::examineDirectory(const FilePath &importPath,
@@ -255,5 +254,4 @@ Kit *QmakeProjectImporter::createTemporaryKit(const QtProjectImporter::QtVersion
}); });
} }
} // namespace Internal } // QmakeProjectManager::Internal
} // namespace QmakeProjectManager

View File

@@ -7,8 +7,7 @@
#include <qtsupport/qtprojectimporter.h> #include <qtsupport/qtprojectimporter.h>
namespace QmakeProjectManager { namespace QmakeProjectManager::Internal {
namespace Internal {
// Documentation inside. // Documentation inside.
class QmakeProjectImporter : public QtSupport::QtProjectImporter class QmakeProjectImporter : public QtSupport::QtProjectImporter
@@ -16,7 +15,7 @@ class QmakeProjectImporter : public QtSupport::QtProjectImporter
public: public:
QmakeProjectImporter(const Utils::FilePath &path); QmakeProjectImporter(const Utils::FilePath &path);
QStringList importCandidates() final; Utils::FilePaths importCandidates() final;
private: private:
QList<void *> examineDirectory(const Utils::FilePath &importPath, QString *warningMessage) const final; QList<void *> examineDirectory(const Utils::FilePath &importPath, QString *warningMessage) const final;
@@ -31,5 +30,4 @@ private:
const QMakeStepConfig::OsType &osType) const; const QMakeStepConfig::OsType &osType) const;
}; };
} // namespace Internal } // QmakeProjectManager::Internal
} // namespace QmakeProjectManager

View File

@@ -16,7 +16,6 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/temporarydirectory.h> #include <utils/temporarydirectory.h>
#include <QFileInfo>
#include <QList> #include <QList>
using namespace ProjectExplorer; using namespace ProjectExplorer;
@@ -153,7 +152,7 @@ public:
m_testData(testData) m_testData(testData)
{ } { }
QStringList importCandidates() override; FilePaths importCandidates() override { return {}; }
bool allDeleted() const { return m_deletedTestData.count() == m_testData.count();} bool allDeleted() const { return m_deletedTestData.count() == m_testData.count();}
@@ -173,11 +172,6 @@ private:
QList<Kit *> m_deletedKits; QList<Kit *> m_deletedKits;
}; };
QStringList TestQtProjectImporter::importCandidates()
{
return QStringList();
}
QList<void *> TestQtProjectImporter::examineDirectory(const Utils::FilePath &importPath, QList<void *> TestQtProjectImporter::examineDirectory(const Utils::FilePath &importPath,
QString *warningMessage) const QString *warningMessage) const
{ {