Projects: Improve opening of projects

Move logic to detect already open projects into ProjectExplorer itself,
along with some check for the canonicalFilePath.

Remove the same logic from the individual projectmanagers.

Put check that the path is a file into project managers. So far all of
them assume the project file to be a file (e.g. a xcode project manager
would expect a directory though).

Task-number: QTCREATORBUG-9350
Change-Id: I3901958395e3c594c8cfba9a85dc7d3ec3334afb
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
Tobias Hunger
2013-05-27 11:17:47 +02:00
parent 711e67ad65
commit a52063ee39
8 changed files with 65 additions and 71 deletions

View File

@@ -176,28 +176,14 @@ QString Qt4Manager::mimeType() const
ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName, QString *errorString)
{
// TODO Make all file paths relative & remove this hack
// We convert the path to an absolute one here because qt4project.cpp
// && profileevaluator use absolute/canonical file paths all over the place
// Correct fix would be to remove these calls ...
QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
if (canonicalFilePath.isEmpty()) {
if (!QFileInfo(fileName).isFile()) {
if (errorString)
*errorString = tr("Failed opening project '%1': Project file does not exist").arg(QDir::toNativeSeparators(fileName));
*errorString = tr("Failed opening project '%1': Project is not a file")
.arg(fileName);
return 0;
}
foreach (ProjectExplorer::Project *pi, projectExplorer()->session()->projects()) {
if (canonicalFilePath == pi->document()->fileName()) {
if (errorString)
*errorString = tr("Failed opening project '%1': Project already open").arg(QDir::toNativeSeparators(canonicalFilePath));
return 0;
}
}
Qt4Project *pro = new Qt4Project(this, canonicalFilePath);
return pro;
return new Qt4Project(this, fileName);
}
ProjectExplorer::ProjectExplorerPlugin *Qt4Manager::projectExplorer() const