Locator on Linux/Mac: Show ~ instead of $HOME in paths.

With this, you will see more of the "relevant" path.

Change-Id: I03c4c7bd2bdaa9148c70a68678306e259f9c7204
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Nikolai Kosjar
2012-08-24 15:00:44 +02:00
parent ce9b7bf123
commit 9483408fec
6 changed files with 36 additions and 6 deletions

View File

@@ -205,6 +205,24 @@ FileName FileUtils::resolveSymlinks(const FileName &path)
return FileName::fromString(f.filePath());
}
/*!
Like QDir::toNativeSeparators(), but use prefix '~' instead of $HOME on unix systems when an
absolute path is given.
return Possibly shortened path with native separators.
*/
QString FileUtils::shortNativePath(const FileName &path)
{
if (HostOsInfo::isAnyUnixHost()) {
const FileName home = FileName::fromString(QDir::cleanPath(QDir::homePath()));
if (path.isChildOf(home)) {
return QLatin1Char('~') + QDir::separator()
+ QDir::toNativeSeparators(path.relativeChildPath(home).toString());
}
}
return path.toUserOutput();
}
QByteArray FileReader::fetchQrc(const QString &fileName)
{
QTC_ASSERT(fileName.startsWith(QLatin1Char(':')), return QByteArray());