forked from qt-creator/qt-creator
Utils: Introduce FilePath::displayName()
To produce "<filepath> on <devicename>" which is nicer to read than "<scheme>://<deviceid>/<filepath>" in some places. Change-Id: Ife47bbf49382cf73dd4709d826bdeaa8730f88be Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -921,6 +921,29 @@ FilePath FilePath::normalizedPathName() const
|
||||
return result;
|
||||
}
|
||||
|
||||
QString FilePath::displayName(const QString &args) const
|
||||
{
|
||||
QString deviceName;
|
||||
if (needsDevice()) {
|
||||
QTC_ASSERT(s_deviceHooks.deviceDisplayName, return m_data);
|
||||
deviceName = s_deviceHooks.deviceDisplayName(*this);
|
||||
}
|
||||
|
||||
if (args.isEmpty()) {
|
||||
if (deviceName.isEmpty())
|
||||
return m_data;
|
||||
|
||||
return QCoreApplication::translate("Utils::FileUtils", "%1 on %2", "File on device")
|
||||
.arg(m_data, deviceName);
|
||||
}
|
||||
|
||||
if (deviceName.isEmpty())
|
||||
return m_data + ' ' + args;
|
||||
|
||||
return QCoreApplication::translate("Utils::FileUtils", "%1 %2 on %3", "File and args on device")
|
||||
.arg(m_data, args, deviceName);
|
||||
}
|
||||
|
||||
/// Constructs a FilePath from \a filename
|
||||
/// \a filename is not checked for validity.
|
||||
FilePath FilePath::fromString(const QString &filepath)
|
||||
|
||||
Reference in New Issue
Block a user