GUI: Use rootpath from Project file.

If rootpath is given in project file then use it as a current
directory. Also check if paths given in project file are
relative and use rootpath as base path for relative paths.
This commit is contained in:
Kimmo Varis 2010-08-21 19:38:51 +03:00
parent d967151c32
commit 2f063ad775
1 changed files with 19 additions and 1 deletions

View File

@ -711,10 +711,28 @@ void MainWindow::OpenProjectFile()
mUI.mActionEditProjectFile->setEnabled(true);
mProject = new Project(filepath, this);
mProject->Open();
QString rootpath = mProject->GetProjectFile()->GetRootPath();
// If root path not give or "current dir" then use project file's directory
// as check path
if (rootpath.isEmpty() || rootpath == ".")
mCurrentDirectory = inf.canonicalPath();
else
mCurrentDirectory = rootpath;
QStringList paths = mProject->GetProjectFile()->GetCheckPaths();
if (!paths.isEmpty())
{
mCurrentDirectory = paths[0];
for (int i = 0; i < paths.size(); i++)
{
if (!QDir::isAbsolutePath(paths[i]))
{
QString path = mCurrentDirectory + "/";
path += paths[i];
paths[i] = QDir::cleanPath(path);
}
}
DoCheckFiles(paths);
}
}