From 2f063ad7753b218aa3c856520b20b107ce12916f Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 21 Aug 2010 19:38:51 +0300 Subject: [PATCH] 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. --- gui/mainwindow.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e35955017..fbfb30ac1 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -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); } }