Commit Graph

54 Commits

Author SHA1 Message Date
hjk
bf8bf1adc0 Utils: Also use device name when trying to disambiguate path displays
With two /tmp/foo.cpp from different devices there is no directly
visible difference in the Open Documents. Adding the device path
for remote cases introduces a difference.

For local files there is no visible difference.

Change-Id: I6f1632d6f51ff24573831af3161492989c5c0bec
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-06-14 13:50:54 +00:00
hjk
8b6aeb9d16 Utils: Use case folding instead of toUpper for hashing file paths
Change-Id: I680db342b6b0b2433951064bb236ef7efadabf3f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-06-10 11:02:41 +00:00
hjk
31f0ba4ef9 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>
2022-06-02 15:14:27 +00:00
Jarek Kobus
2853660a59 Utils: More forward declarations / drop unused headers [D-G]
Round 1 - focus on headers.
For classes with initial in range [D-G].
Try to keep the same separators between different kind of headers.

Change-Id: Id42cd7b3743a816f75cecb6b576c0e37cb057473
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:13:52 +00:00
Jarek Kobus
0a8dbaf153 Utils lib: Remove unneeded includes from cpp files
It's a result of a team work consisting of yellow triangle and me.

Change-Id: I8b4812766da70e0785ae71bf0cb71357379e2514
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-05-19 12:37:20 +00:00
hjk
4ca780ccb3 Utils: Use simplistic percentencoding for host parts of FilePath
Host parts with true slashes (as possible currently for docker ids
using the repo:tag style) breaks parsing in FilePath::fromString.

This provides a means to use such names nevertheless.

Task-number: QTCREATORBUG-26856
Change-Id: Iba3568c5708fe495d0dd657540f30a2519e7f45f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-25 15:33:47 +00:00
Alessandro Portale
a386725c6c Utils: Support sorting by QDir::Time in FilePath::dirEntries
Amends: f9c97d23c7

Task-number: QTCREATORBUG-26939
Change-Id: I9122d51af102547086687b1b9c6cb1553b609673
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit ec0513bf4b)
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-27 09:22:06 +00:00
hjk
1fc83d2a56 Utils: Wrap various file system iteration flags and filters
... into a single class.

This makes passing them around as a whole easier, and opens a path
to have "generic" filters in form of a lambda or such.

Change-Id: Ibf644b2fedcf0f1a35258030710afff8f5873f88
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-26 13:13:41 +00:00
hjk
f9c97d23c7 Utils: Add optional recursion for file system iteration
Change-Id: Icded897b129aebd7132376cff55717e16dffc040
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-18 11:52:29 +00:00
Jarek Kobus
35cde5ddae Introduce IDevice::bytesAvailable()
It's going to replace RemoteLinuxCheckForFreeDiskSpaceService.

Change-Id: If8c30a57b9013387c69412f12102bcd4d41a88b5
Reviewed-by: hjk <hjk@qt.io>
2022-01-05 14:33:50 +00:00
hjk
7677dc4ba0 Utils: Use callbacks when iterating remote file systems
This will make recursion easier and has the potential to avoid creating
big intermediate lists.

Change-Id: I44d42925dae9c0048338c7d0a6aa26606f314c28
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2021-12-17 06:57:46 +00:00
hjk
3fd1122759 Utils: Rename FilePath::deviceLocalPath() to nativePath()
Change-Id: Id2b2b7d54a536d569c6dc717365ee28421e2b56b
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-12 09:02:45 +00:00
hjk
652b9844e6 Utils: FilePathify Environment::{ap,pre}pendOrSetPath etc
Change-Id: Idfa5ec247337570936b0236cab9d3a5669792ca0
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-10 07:26:31 +00:00
Christian Stenger
39d04fa886 Utils: Clean path when transforming into QFileInfo
Fixes icons for relative paths inside locator.

Fixes: QTCREATORBUG-26411
Change-Id: Ia34d3b4af791ef79be4f349bd416df1190678557
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2021-10-29 12:38:04 +00:00
hjk
c6bc5583d6 Utils: Don't expose FilePath::mapToGlobalPath anymore
The indirection is triggered via scheme and host. And if it already is in
that form we do not need to add these information.

Change-Id: I13c2bd0864a956c5cdaa5e2e6b324bb7f67c93e3
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-28 07:53:37 +00:00
hjk
c82e3cf6a8 Utils: Map local path path in FilePath::onDevice(), too
To cover cases like Windows -> Docker/Linux, where these parts are not
an exact 1:1 mapping.

Change-Id: Iecc26e06771fb190644988950271ff7990962b6b
Reviewed-by: hjk <hjk@qt.io>
2021-10-26 07:01:13 +00:00
Orgad Shaneh
3871e40f43 Fix qHash-related size compatibility warnings by MSVC
Change-Id: I3b7981ce78b67db4b996f99682284a0b911d8cd7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-10-20 15:03:51 +00:00
hjk
34b42a4772 Utils: Introduce FilePath::mapTo{Device,Global}Path
Re-directing via IDevice::mapTo{Device,Global}Path

Change-Id: Ica957839479967790bbd93e90eced66aa0b122a8
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-12 11:24:29 +00:00
hjk
3a02e03729 Utils: Add an Environment::searchInDirectories
And use it in the local branch for FilePath::searchInDirectory which
so far erroneously also looked into the system environment's path.

Change-Id: I60316831b74a55dee84fbf4b54c0eecc49dd8dde
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-10-04 11:24:26 +00:00
hjk
4d3374d23a Utils: Drop .exists() check in some FilePath functions
... when it is implicit by other checks in the same expression.

Change-Id: I10c6bd92e4890bdf611f3a222dc6c2d271e98f37
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-10-04 06:03:26 +00:00
hjk
afe60b1669 Utils: Re-do FilePath::toUserOutput()
Use the FilePath's knowledge of the target os instead of always using
the host os.

Change-Id: I996db68486f4616c8636ae501cce7a778269f1cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-28 13:38:48 +00:00
Artem Sokolovskii
905325358a FilePath: Add bool to lambda iterateDirectory
Change-Id: I017426a48981da2fbeb32b6d5bee87865d583c0b
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-17 11:37:24 +00:00
Artem Sokolovskii
464f665735 FilePath: Add const to iterateDirectory
Change-Id: I49c1366ca16ca295d0f54a17740a501a6d7a9442
Reviewed-by: hjk <hjk@qt.io>
2021-09-15 11:41:07 +00:00
Artem Sokolovskii
d543ab0fbd FilePath: Add function which iterates through the directory
Change-Id: Iaebd2b08341781307b98b6aae61b0b44b127ce18
Reviewed-by: hjk <hjk@qt.io>
2021-09-15 10:51:45 +00:00
hjk
f6f7f410dd Utils: Remove Utils::FileUtils::renameFile()
There's FilePath::renameFile() nowadays.

Change-Id: Id37f24910f0c608ccfa6e52c5608c6707353a073
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-14 07:22:45 +00:00
hjk
64324db662 Utils: Remove FilePath::isChildOf(QDir) overload
After replacing its use in the two remaining places.

Change-Id: I6900ccdaf4ba4cf035e59b1222f06b037e7da512
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-14 07:22:08 +00:00
Artem Sokolovskii
c941f7d0f5 Font settings: Add import and export functions
Fixed: QTCREATORBUG-6833

Change-Id: I23eec56aeb53ed10dd7f04c071318f5cc335b14e
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-13 13:11:36 +00:00
Eike Ziller
a060ea2ec8 FilePath: Fix fromStringWithExtension
Amends a04e1eaf84

Change-Id: I440e8b79d52f0a77ef1ee1aae278c34e815e877a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-13 09:59:27 +00:00
David Schulz
ea215d612d FilePath: only assert on relative paths passed to absolute(File)Path
Change-Id: Id765f2e9ae3fdf17b1f16388caa5d09a17b87371
Reviewed-by: hjk <hjk@qt.io>
2021-09-09 09:03:22 +00:00
hjk
bdefc13eba Utils: Rename FilePath::absolutePath(FilePath) to resolvePath
There was already a similar function taking a QString.

After that, the remaining no-argument version of absolutePath()
can be deprecated.

Change-Id: I5b9ad8c8b68a5723891b0aa9f5a37e90db0fe09e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-09 05:42:30 +00:00
David Schulz
b485890b19 Utils: Guard QFileInfo usages of non local FilePaths
Helps keeping track of usages of potential wrong paths and partially
makes sure to not leave the correct device.

Change-Id: I19fff7ae8abc3fa6045f7d4459f1140ba71e4f16
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-09 04:17:06 +00:00
David Schulz
a04e1eaf84 Utils: avoid QFileInfo in FilePath::fromStringWithExtension
Change-Id: I853e678e98af09a53d1165c51cf00377df1b7f4d
Reviewed-by: hjk <hjk@qt.io>
2021-09-08 11:53:13 +00:00
Henning Gruendl
a09ec2e0e9 QmlDesigner: Fix project tree widget renaming
When renaming an item in the project tree widget which has concatenated
filename extensions like *.ui.qml the selection in the LineEdit will
reach till the last dot.

* Extend FilePath suffix and completeBaseName function so they will
  treat the suffix *.ui.qml as one
* Make use of the function in ProjectTreeWidget::editCurrentItem
* Replace QFileInfo::suffix with Utils::FilePath::suffix in
  FlatModel::setData

Task-number: QDS-2713
Change-Id: I30d0e6d87a7512d42fd3d40b2282b94e79b43684
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2021-09-08 06:47:51 +00:00
hjk
ebf0917b9f Utils: Start adding some asynchronous API to FilePath
Especially with the "remote" scenarios synchronous operations cannot
be expected to work reasonably well.

This here starts with adding asynchronous versions to some of the
FilePath member functions, taking additional "Continuation" style.

This is not necessarily the final syntax (sugar like .then(...) comes
to mind...), but is simple enough for now for the few uses we have,
and it is too early to see what will be needed in the end.

Change-Id: Idf4dde1b77d04cafb81b6c024031145bdd91a762
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-01 11:21:30 +00:00
hjk
87b3de0e39 Utils: Add a code path taking care of cross-device file copies
Not optimal, but will suffice for docker callgrind.

Change-Id: Iac669fe9dd29206df2a4ffc61d659afce2f7a6c4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-31 13:38:51 +00:00
hjk
30f171a491 Utils: Rename FilePath::normalizePathName to normalizedPathName
Change-Id: Ib7bcc9968749649f762a396d3861f7b67711e926
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-26 07:03:13 +00:00
hjk
57a90b019f Utils: Introduce a FilePath::searchInPath() convenience function
Diverts to searchInDirectory(). Use it in some places.

Change-Id: I9e5642f0ae0ed4dd9fb9f34bcaa11a25bd26c690
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-23 11:56:24 +00:00
hjk
53050255de Utils: Rename FilePath::normalizePathName to normalizedPathName
Change-Id: Idf5faab1cf55d6f7cca493c8ad451825310f5d66
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-08-23 11:15:01 +00:00
hjk
db014de91c Utils: Introduce FilePath::normalizePathName()
... as wrapper around FileUtils::normalizePathName, and use it
in some places.

Change-Id: I42792e1f175b8119c8db930eae80a9f822ac70fa
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-23 10:37:26 +00:00
Eike Ziller
b09b6bd747 Merge remote-tracking branch 'origin/5.0'
Change-Id: I370268624bd6e91e7b44fa236e913f5f55867e17
2021-08-20 09:50:30 +02:00
hjk
142a34464f Utils: Avoid adding duplicated slashs in FilePath::pathAppended
Change-Id: I791412906e94a967a61d9b3212b704936c447183
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-20 05:33:34 +00:00
hjk
f8ff5d0652 Utils: Use FilePath::toString() for logging reasons
Change-Id: Id3a26327994e55a8d400739e9b7a6e7dcb9b99c5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-19 11:49:20 +00:00
hjk
6e8c4aa835 Use new FilePath::setPermissions in a few cases
Change-Id: Ic7122c86c273a87134ea8cd1a00b1bbdf5035971
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-08-19 08:33:12 +00:00
Christian Stenger
28d2674b54 Utils: Adjust FilePath::relativePath()
When using the same path for the anchor and the relative path
we end up in an empty path which is conceptually wrong.
Especially when passing such a result directly without further
checking may lead to bad issues.
Return a path containing just the '.' (dot) instead.

Change-Id: I86e1ab91e6610831fc05bd81776d278e9fe10105
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Jochen Becher <jochen_becher@gmx.de>
Reviewed-by: hjk <hjk@qt.io>
2021-08-19 04:39:05 +00:00
hjk
27708158db Utils: Introduce FilePath::setPermission()
And implement it for the direct access docker case.

Change-Id: I5c91402630a5b010fdbcaab96c435f66a36f2e3e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-18 12:25:44 +00:00
hjk
7c28c4f744 Utils: Introduce a FilePath constructor from char arrays
Similar to QT_RESTRICTED_CAST_FROM_ASCII to avoid the need for
decorations in user code.

At the same time, drop some convenience constructors and functions
in CommandLine and Icon essentially serving the same purpose.

Change-Id: Ida4e5ac19c2da0a4298a97b2a8e1511d56bbb79d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-17 05:34:10 +00:00
hjk
a78665ede7 Utils: Rename FilePath::searchOnDevice to searchInDirectories
Makes it a bit clearer that there's no magic path use or similar
beyond this point.

Change-Id: I86c06850d16bf777db05ad23b540d8096926c059
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-08-12 08:29:09 +00:00
Eike Ziller
c7168d1063 Merge remote-tracking branch 'origin/5.0'
Conflicts:
	src/plugins/coreplugin/locator/executefilter.cpp

Change-Id: Iff5b82a9e491b782e4720138904f389d318b005c
2021-08-11 10:10:51 +02:00
hjk
2ab2d96753 Utils: Use FilePath in copy helpers
Change-Id: I81b367a5851c0fbcdf45c63c5536c206845a8337
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-10 07:19:10 +00:00
Christian Stenger
1e901c5d61 Utils: Add helper function
Recurring pattern for local Windows paths.

Change-Id: I4deb7e42012a06281c6081a63415eaeb60203157
Reviewed-by: hjk <hjk@qt.io>
2021-08-05 09:57:35 +00:00