ProjectExplorer: Use Utils::FileName in ProjectImporter API

Change-Id: I60e05f1bd892b508db90bc48837e29e2725bf333
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Tobias Hunger
2016-11-16 11:20:04 +01:00
parent 028b1170c9
commit 6e17882bfc
7 changed files with 20 additions and 20 deletions

View File

@@ -69,7 +69,7 @@ static bool hasOtherUsers(Core::Id id, const QVariant &v, Kit *k)
}); });
} }
ProjectImporter::ProjectImporter(const QString &path) : m_projectPath(path) ProjectImporter::ProjectImporter(const Utils::FileName &path) : m_projectPath(path)
{ } { }
ProjectImporter::~ProjectImporter() ProjectImporter::~ProjectImporter()
@@ -139,7 +139,7 @@ QList<BuildInfo *> ProjectImporter::import(const Utils::FileName &importPath, bo
QMessageBox::critical(Core::ICore::mainWindow(), QMessageBox::critical(Core::ICore::mainWindow(),
QCoreApplication::translate("ProjectExplorer::ProjectImporter", "No Build Found"), QCoreApplication::translate("ProjectExplorer::ProjectImporter", "No Build Found"),
QCoreApplication::translate("ProjectExplorer::ProjectImporter", "No build found in %1 matching project %2.") QCoreApplication::translate("ProjectExplorer::ProjectImporter", "No build found in %1 matching project %2.")
.arg(importPath.toUserOutput()).arg(QDir::toNativeSeparators(projectFilePath()))); .arg(importPath.toUserOutput()).arg(projectFilePath().toUserOutput()));
return result; return result;
} }
@@ -247,7 +247,7 @@ void ProjectImporter::addProject(Kit *k) const
UpdateGuard guard(*this); UpdateGuard guard(*this);
QStringList projects = k->value(TEMPORARY_OF_PROJECTS, QStringList()).toStringList(); QStringList projects = k->value(TEMPORARY_OF_PROJECTS, QStringList()).toStringList();
projects.append(m_projectPath); // note: There can be more than one instance of the project added! projects.append(m_projectPath.toString()); // note: There can be more than one instance of the project added!
k->setValueSilently(TEMPORARY_OF_PROJECTS, projects); k->setValueSilently(TEMPORARY_OF_PROJECTS, projects);
} }
@@ -258,7 +258,7 @@ void ProjectImporter::removeProject(Kit *k) const
UpdateGuard guard(*this); UpdateGuard guard(*this);
QStringList projects = k->value(TEMPORARY_OF_PROJECTS, QStringList()).toStringList(); QStringList projects = k->value(TEMPORARY_OF_PROJECTS, QStringList()).toStringList();
projects.removeOne(m_projectPath); projects.removeOne(m_projectPath.toString());
if (projects.isEmpty()) { if (projects.isEmpty()) {
cleanupKit(k); cleanupKit(k);

View File

@@ -42,10 +42,10 @@ class Target;
class PROJECTEXPLORER_EXPORT ProjectImporter class PROJECTEXPLORER_EXPORT ProjectImporter
{ {
public: public:
ProjectImporter(const QString &path); ProjectImporter(const Utils::FileName &path);
virtual ~ProjectImporter(); virtual ~ProjectImporter();
const QString projectFilePath() const { return m_projectPath; } const Utils::FileName projectFilePath() const { return m_projectPath; }
virtual QList<BuildInfo *> import(const Utils::FileName &importPath, bool silent = false); virtual QList<BuildInfo *> import(const Utils::FileName &importPath, bool silent = false);
virtual QStringList importCandidates() = 0; virtual QStringList importCandidates() = 0;
@@ -104,7 +104,7 @@ private:
void markKitAsTemporary(Kit *k) const; void markKitAsTemporary(Kit *k) const;
bool findTemporaryHandler(Core::Id id) const; bool findTemporaryHandler(Core::Id id) const;
const QString m_projectPath; const Utils::FileName m_projectPath;
mutable bool m_isUpdating = false; mutable bool m_isUpdating = false;
class TemporaryInformationHandler { class TemporaryInformationHandler {

View File

@@ -1611,7 +1611,7 @@ void QmakeProject::emitBuildDirectoryInitialized()
ProjectImporter *QmakeProject::projectImporter() const ProjectImporter *QmakeProject::projectImporter() const
{ {
if (!m_projectImporter) if (!m_projectImporter)
m_projectImporter = new QmakeProjectImporter(projectFilePath().toString()); m_projectImporter = new QmakeProjectImporter(projectFilePath());
return m_projectImporter; return m_projectImporter;
} }

View File

@@ -80,7 +80,7 @@ namespace Internal {
const Core::Id QT_IS_TEMPORARY("Qmake.TempQt"); const Core::Id QT_IS_TEMPORARY("Qmake.TempQt");
const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // ugly const char IOSQT[] = "Qt4ProjectManager.QtVersion.Ios"; // ugly
QmakeProjectImporter::QmakeProjectImporter(const QString &path) : QmakeProjectImporter::QmakeProjectImporter(const FileName &path) :
QtProjectImporter(path) QtProjectImporter(path)
{ } { }
@@ -88,12 +88,12 @@ QStringList QmakeProjectImporter::importCandidates()
{ {
QStringList candidates; QStringList candidates;
QFileInfo pfi = QFileInfo(projectFilePath()); QFileInfo pfi = projectFilePath().toFileInfo();
const QString prefix = pfi.baseName(); const QString prefix = pfi.baseName();
candidates << pfi.absolutePath(); candidates << pfi.absolutePath();
foreach (Kit *k, KitManager::kits()) { foreach (Kit *k, KitManager::kits()) {
QFileInfo fi(QmakeBuildConfiguration::shadowBuildDirectory(projectFilePath(), k, QFileInfo fi(QmakeBuildConfiguration::shadowBuildDirectory(projectFilePath().toString(), k,
QString(), BuildConfiguration::Unknown)); QString(), BuildConfiguration::Unknown));
const QString baseDir = fi.absolutePath(); const QString baseDir = fi.absolutePath();
@@ -127,7 +127,7 @@ QList<void *> QmakeProjectImporter::examineDirectory(const FileName &importPath)
qCDebug(logs) << " Parsing the makefile failed" << makefile; qCDebug(logs) << " Parsing the makefile failed" << makefile;
continue; continue;
} }
if (parse.srcProFile() != projectFilePath()) { if (parse.srcProFile() != projectFilePath().toString()) {
qCDebug(logs) << " pro files doesn't match" << parse.srcProFile() << projectFilePath(); qCDebug(logs) << " pro files doesn't match" << parse.srcProFile() << projectFilePath();
continue; continue;
} }
@@ -233,7 +233,7 @@ QList<BuildInfo *> QmakeProjectImporter::buildInfoListForKit(const Kit *k, void
QList<BuildInfo *> result; QList<BuildInfo *> result;
DirectoryData *data = static_cast<DirectoryData *>(directoryData); DirectoryData *data = static_cast<DirectoryData *>(directoryData);
auto factory = qobject_cast<QmakeBuildConfigurationFactory *>( auto factory = qobject_cast<QmakeBuildConfigurationFactory *>(
IBuildConfigurationFactory::find(k, projectFilePath())); IBuildConfigurationFactory::find(k, projectFilePath().toString()));
if (!factory) if (!factory)
return result; return result;

View File

@@ -41,7 +41,7 @@ namespace Internal {
class QmakeProjectImporter : public QtSupport::QtProjectImporter class QmakeProjectImporter : public QtSupport::QtProjectImporter
{ {
public: public:
QmakeProjectImporter(const QString &path); QmakeProjectImporter(const Utils::FileName &path);
QStringList importCandidates() final; QStringList importCandidates() final;

View File

@@ -44,7 +44,7 @@ using namespace ProjectExplorer;
namespace QtSupport { namespace QtSupport {
QtProjectImporter::QtProjectImporter(const QString &path) : ProjectImporter(path) QtProjectImporter::QtProjectImporter(const Utils::FileName &path) : ProjectImporter(path)
{ {
useTemporaryKitInformation(QtKitInformation::id(), useTemporaryKitInformation(QtKitInformation::id(),
[this](Kit *k, const QVariantList &vl) { cleanupTemporaryQt(k, vl); }, [this](Kit *k, const QVariantList &vl) { cleanupTemporaryQt(k, vl); },
@@ -172,7 +172,7 @@ struct DirectoryData {
class TestQtProjectImporter : public QtProjectImporter class TestQtProjectImporter : public QtProjectImporter
{ {
public: public:
TestQtProjectImporter(const QString &pp, const QList<void *> &testData) : TestQtProjectImporter(const Utils::FileName &pp, const QList<void *> &testData) :
QtProjectImporter(pp), QtProjectImporter(pp),
m_testData(testData) m_testData(testData)
{ } { }
@@ -418,7 +418,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject()
// Finally set up importer: // Finally set up importer:
// Copy the directoryData so that importer is free to delete it later. // Copy the directoryData so that importer is free to delete it later.
TestQtProjectImporter importer(tempDir1.path(), TestQtProjectImporter importer(Utils::FileName::fromString(tempDir1.path()),
Utils::transform(testData, [](DirectoryData *i) { Utils::transform(testData, [](DirectoryData *i) {
return static_cast<void *>(new DirectoryData(*i)); return static_cast<void *>(new DirectoryData(*i));
})); }));
@@ -431,7 +431,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject()
const QList<BuildInfo *> buildInfo = importer.import(Utils::FileName::fromString(appDir), true); const QList<BuildInfo *> buildInfo = importer.import(Utils::FileName::fromString(appDir), true);
// VALIDATE: Basic TestImporter state: // VALIDATE: Basic TestImporter state:
QCOMPARE(importer.projectFilePath(), tempDir1.path()); QCOMPARE(importer.projectFilePath().toString(), tempDir1.path());
QCOMPARE(importer.allDeleted(), true); QCOMPARE(importer.allDeleted(), true);
// VALIDATE: Result looks reasonable: // VALIDATE: Result looks reasonable:
@@ -535,7 +535,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject()
QCOMPARE(newKitId, newKitIdAfterImport); QCOMPARE(newKitId, newKitIdAfterImport);
// VALIDATE: Importer state // VALIDATE: Importer state
QCOMPARE(importer.projectFilePath(), tempDir1.path()); QCOMPARE(importer.projectFilePath().toString(), tempDir1.path());
QCOMPARE(importer.allDeleted(), true); QCOMPARE(importer.allDeleted(), true);
if (kitIsPersistent) { if (kitIsPersistent) {

View File

@@ -39,7 +39,7 @@ class BaseQtVersion;
class QTSUPPORT_EXPORT QtProjectImporter : public ProjectExplorer::ProjectImporter class QTSUPPORT_EXPORT QtProjectImporter : public ProjectExplorer::ProjectImporter
{ {
public: public:
QtProjectImporter(const QString &path); QtProjectImporter(const Utils::FileName &path);
class QtVersionData class QtVersionData
{ {