QFileDialog: use QString::remove() instead of mid()
Minor, less allocations. Change-Id: I73c188b0030248c6d038fab3dfb949442083d33d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
50b8f22012
commit
acad1711a6
@ -4157,12 +4157,12 @@ QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
|
|||||||
if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {
|
if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {
|
||||||
#if defined(Q_OS_UNIX)
|
#if defined(Q_OS_UNIX)
|
||||||
if (currentLocation == QDir::separator())
|
if (currentLocation == QDir::separator())
|
||||||
return path.mid(currentLocation.size());
|
return path.remove(0, currentLocation.size());
|
||||||
#endif
|
#endif
|
||||||
if (currentLocation.endsWith(u'/'))
|
if (currentLocation.endsWith(u'/'))
|
||||||
return path.mid(currentLocation.size());
|
return path.remove(0, currentLocation.size());
|
||||||
else
|
else
|
||||||
return path.mid(currentLocation.size()+1);
|
return path.remove(0, currentLocation.size()+1);
|
||||||
}
|
}
|
||||||
return index.data(QFileSystemModel::FilePathRole).toString();
|
return index.data(QFileSystemModel::FilePathRole).toString();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user