GUI: Add include paths as relative to project file.

When adding a new include path check if the path is relative path to
the project file's path. If path is relative then remove the begin of
the path making it a relative path in project file.

Ticket: #3019 (GUI: Add project include paths as relative paths)
This commit is contained in:
Kimmo Varis 2012-01-10 22:14:51 +02:00
parent c74e246e9b
commit cc92f1c432
1 changed files with 11 additions and 1 deletions

View File

@ -204,13 +204,23 @@ void ProjectFileDialog::SetExcludedPaths(const QStringList &paths)
void ProjectFileDialog::AddIncludeDir()
{
QFileInfo inf(mFilePath);
const QFileInfo inf(mFilePath);
const QString rootpath = inf.absolutePath();
QString selectedDir = QFileDialog::getExistingDirectory(this,
tr("Select include directory"),
rootpath);
if (!selectedDir.isEmpty()) {
// Check if the path is relative to project file's path and if so
// make it a relative path instead of absolute path.
const QDir dir(selectedDir);
QString absPath = dir.absolutePath();
if (absPath.startsWith(rootpath)) {
// Remove also the slash from begin of new relative path
selectedDir = absPath.remove(0, rootpath.length() + 1);
}
if (!selectedDir.endsWith("/"))
selectedDir += '/';
AddIncludeDir(selectedDir);
}
}