Commit Graph

187 Commits

Author SHA1 Message Date
hjk
8b72e92167 Utils: Add CommandLine convenience constructors
... taking a QString for the executable.

This weakens the very explicit QString -> FileName conversion via the
named constructors for the special case of constructing a CommandLine.

I think that's worthwhile here, as it reduces the noise on the caller
site under circumstance where the nature of the thing is obvious.

Change-Id: I27b4a73639728893d053b2e7ba65cb745f0ffe83
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-07-23 15:51:45 +00:00
Eike Ziller
917636b88b Merge remote-tracking branch 'origin/4.10'
Conflicts:
        src/libs/utils/consoleprocess.h
        src/libs/utils/consoleprocess_unix.cpp
        src/libs/utils/consoleprocess_win.cpp
        src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp
        src/tools/clangrefactoringbackend/source/symbolscollector.cpp
        tests/unit/mockup/projectexplorer/project.h

Change-Id: I8d10f26b9bcb54829ba31cdc2272885691df1e16
2019-06-18 12:30:55 +02:00
hjk
611e1ea837 Utils: Encourage marking of raw command line parameters
Change-Id: Id66ac07732c66ab8c1232fe1f58042de8a61abb0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-06-06 12:22:47 +00:00
hjk
772b48797d Utils: Add a CommandLine::splitArguments() convenience function
... and use it from within new SynchronousProcess functions
taking CommandLine arguments.

Change-Id: I5d7f83727cbb22f03b1a79b1645db95514c66033
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-06-06 08:42:06 +00:00
hjk
c7e2dc97e1 Utils: Pass an optional OsType parameter to CommandLine::addArg
... and extend the idea to addArgs(list)

Change-Id: Ia5423ee5ab96835b4adc23b72749e9c13892ee83
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-06-05 05:43:02 +00:00
hjk
959fec76dc Utils: Move CommandLine to fileutils.{cpp,h}
Causes less #include hassle when using downstream instead of
command/argument pairs.

Change-Id: I0fa0d016374df0b8e0a22f3786623652af684d36
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-06-03 12:32:07 +00:00
hjk
1b11c4d4b6 Utils: Fix a few strings after FileName renaming
Change-Id: I2c7f8d3ececeb9d505ce1cee1591d41604b3505c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-28 14:06:18 +00:00
hjk
613d2e7d23 Utils: Remove rarely used FilePath constructor
Not much benefit interface-wise.

Change-Id: I0e605ec235e8072efcbf7e777cf7e8f8ee5e0799
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-28 14:05:51 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
hjk
f7d224bf58 Utils: Remove now-unused FileName::appendPath()
Change-Id: I9d429a1f60930e27e3926e1242114bed3485f000
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-27 12:22:08 +00:00
hjk
d8f459d48e Utils: Make FileName comparison work with URLs
Change-Id: Idfd8623338f3a74250c4bf264579cbb4ec5e70b8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 16:05:46 +00:00
hjk
535f0da977 Utils: Make FileName::shortNativePath a member
Change-Id: If1ab02ae9dc7efb97792cdf3bbdce3bba18b3e3d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 13:07:38 +00:00
hjk
c04370aa26 Utils: Make FileName::isFileNewerThan a member
Easier to discover and more compact in use.

Change-Id: I93dae0570a1dfded4d40dd6ae69b99fe82e3788f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 13:06:06 +00:00
hjk
36daca80f3 Utils: Make FileName::canonicalPath a member
Change-Id: I8d7450dec5c4c14ae3e007d1d66f1a9c3c98f807
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 11:06:12 +00:00
hjk
c238fc88b1 Utils: Make FileName hold an QUrl optionally
This is meant to be helpful to piggy-back device information
in situations where the file resides on a remote file system.

The approach taken effectively duplicates the path data of the
url if the url constructor is actually used, but does not rely
on lossless path/fromPath conversions as it leaves the non-url
code paths unaffected in all situations.

The total overhead is deemed acceptable as the common use case
only default-constructs the m_url member which only sets a
pimpl nullptr.

Change-Id: Ie441cb1355ce086507333c31c7356ae5e6d10b96
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-17 08:35:18 +00:00
hjk
0e4df97f90 Some more FileName::appendPath -> pathAppended() changes
Change-Id: Ia05b54f157b08353d5a9efccee48dfc212d3a489
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-15 13:19:58 +00:00
hjk
d1f9e466da Utils: Introduce a non-mutating FileName::pathAppended
... and start using it. The plan is to replace all appendPath() uses.

Change-Id: I555bcfa742b99b0951b98b0c0e707422c348fadb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-15 11:45:24 +00:00
hjk
f99d69ee43 Utils: Replace mutating FileName::appendString
... by a non-mutating .stringAppended, doing the same.

Change-Id: I7adb6cae3415942cc9a80088bd75cda9d577d4a5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-15 07:42:59 +00:00
hjk
648f983f49 Utils: Use data member instead of inheritance in FileName
Change-Id: Ib0a9889dfa34ea877ee413881e87ab12c3a54956
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-13 14:57:49 +00:00
hjk
8b532c2cc5 Utils: Replace FileName::FileName(QFileInfo) by a named constructor
More consistent with the fromString case and avoiding false
conversions QString -> QFileInfo -> FileName in case the
inheritance of QString suddenly disappears.

Change-Id: Ib14646ab1a660fd45dd1ea6862a0b5faa52ad0e3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-13 11:33:33 +00:00
Cristian Adam
e5f7df2eaa Fix build with MinGW
Tested successfully with MinGW 8.1.0

Change-Id: Iac6493e055b74b8089afda2f076f0235b62af72a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2019-05-11 06:46:39 +00:00
Orgad Shaneh
24ec0b7708 Utils: Detect hardlinks also on Windows
Believe it or not, they exist :)

Git for Windows installs all its exectables as hardlinks for instance.

Logic copied from qfilesystemengine_{win,unix}.cpp in Qt.

This amends commit 118f713eb4.

Change-Id: Iafc64be4b2150378c7f9676fda0e01a43cd8b7cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-04-30 09:43:45 +00:00
hjk
4f3f73bc3b Utils: Rename one of the FileName::fromString overloads
Overloaded functions are ugly to use in algorithms like transform().

Change-Id: Ia4f191e1cd9a21ceb99dec23a8f4fd1ce5f24182
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-03-19 09:05:47 +00:00
David Schulz
1c0f83cd90 Utils: fix memory leak in normalizePathName on windows
The PIDLIST_ABSOLUTE item returned by SHParseDisplayName has to be freed
again by ILFree according to the documentation of ITEMIDLIST structure.

Change-Id: I29eb7576600287cdc8380e81a83ce2af79e13e33
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2019-03-06 08:47:20 +00:00
Friedemann Kleint
963dc84cc5 Fix some deprecation warnings in basic plugins
Fix warnings apppearing in 5.13, for example:
warning: ‘QDir& QDir::operator=(const QString&)’ is deprecated: Use QDir::setPath() instead [-Wdeprecated-declarations]
...
warning: ‘static QRgb QColorDialog::getRgba(QRgb, bool*, QWidget*)’ is deprecated: Use getColor() [-Wdeprecated-declarations]
warning: ‘Qt::DropAction QDrag::start(Qt::DropActions)’ is deprecated: Use QDrag::exec() instead [-Wdeprecated-declarations]
warning: ‘void QProcess::finished(int)’ is deprecated: Use QProcess::finished(int, QProcess::ExitStatus) instead [-Wdeprecated-declarations]
...
warning: ‘const QRect QDesktopWidget::availableGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::foreground() const’ is deprecated: Use QPalette::windowText() instead [-Wdeprecated-declarations]
...
warning: ‘void QTextOption::setTabStop(qreal)’ is deprecated [-Wdeprecated-declarations]
warning: ‘void QList<T>::swap(int, int) [with T = ProjectExplorer::BuildStep*]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations]
warning: ‘void QProcess::setReadChannelMode(QProcess::ProcessChannelMode)’ is deprecated: Use QProcess::setProcessChannelMode() instead [-Wdeprecated-declarations]
...
warning: ‘QString QFileInfo::readLink() const’ is deprecated: Use QFileInfo::symLinkTarget() instead [-Wdeprecated-declarations]

Change-Id: I1d893d42d372245892f2de8406f52dbe7bbd552a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 09:32:06 +00:00
Ivan Donchevskii
7f67e987ea CompilationDatabase: Add folders to Project view
Change-Id: I4cd480535c203aa923b27596ea4ca74f83c12a9e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-11-05 15:51:12 +00:00
Orgad Shaneh
b00017e0ad FileName: Add a soft assertion against invalid parent in parentDir
In case isRoot() returns false, but cleanPath fails to find the parent
directory, return an empty string.

For example: QDir::cleanPath("D:/..") returns "D:/.." on Windows.

I'm not aware of any concrete case when this can happen, but let's be
cautious.

Change-Id: I0f4af5f5c11bb768d99d90290a4a1a6a1bda7c27
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-10-25 07:08:25 +00:00
Alessandro Portale
f6943a712a Utils: Modernize further
Many issues, mostly in headers, were not addressed in
e38410b76c

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I320a51726db881e582b898948d53735ebb06887a
Reviewed-by: hjk <hjk@qt.io>
2018-07-24 12:21:42 +00:00
Alessandro Portale
e38410b76c Utils: Modernize
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I8d44d9405011a1878353baf9325f7af90b89db02
Reviewed-by: hjk <hjk@qt.io>
2018-07-20 13:36:22 +00:00
Orgad Shaneh
1958c2129e Revert "Windows: Match the name case of included files"
It breaks cross-compilation on linux/mingw.

This reverts commit 1c014ed3d9.

Change-Id: I3e8183ec318541a4393ad242eefbdeaa78b7be44
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-07-19 05:44:06 +00:00
Alessandro Portale
1c014ed3d9 Windows: Match the name case of included files
Although Windows is case insensitive, and lower case always works, Clang
complains:

Lexical or Preprocessor Issue: warning: non-portable path to file
'<FooBar.h>'; specified path differs in case from file name on disk

Change-Id: I8f94e9fb62f6afec8aa6b9d08a7c78f6ba8a4435
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2018-07-12 20:12:30 +00:00
Andre Hartmann
85ffe78e96 Utils: Properly name withNtfsPermissions()
Change-Id: I759e702b63f8bed9384ccbfae6345f858e50830b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-06-05 12:59:56 +00:00
Eike Ziller
6f91ce1c52 File System view: Add "New Folder" to context menu
Task-number: QTCREATORBUG-17358
Change-Id: I64b3d34ca0432369630382c40cf749f3cc1a08df
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-04-11 06:43:26 +00:00
Eike Ziller
36c88ba5fb Fix Utils::withNTFSPermissions with void function
Fix up of 9467ed42c3

Change-Id: I24343e5e1440210188742332ec6f725af3412100
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2018-02-20 08:26:03 +00:00
Ulf Hermann
565ebaeb9a FileUtils: Drop the QTC_CHECK for !endsWith(slash)
As exercised by the test directories as Utils::FileName are actually
supported. The resulting fileName() is empty.

Change-Id: Ie20ac58c1d0f416d711c8cc3281054c0d70c449e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-09-08 08:35:24 +00:00
Orgad Shaneh
139792ee25 Merge remote-tracking branch 'origin/4.4'
Change-Id: I9ab2c68d2bd07b0dd89051a2f5f6fa51676d8594
2017-08-30 01:24:11 +03:00
Friedemann Kleint
2605108f68 FileName::exists(): Check for empty files first
Fixes warnings
"Empty filename passed to function"
(introduced by qtbase  0dee566e98f5ff4f224e596de1c04de4f9685df4)
emitted when running Qt Creator against 5.10.
The warnings originate from Kit::icon().

Change-Id: I501914195b8e4d340fd02362b215ffc6e3dc99d4
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-08-28 15:04:41 +00:00
Orgad Shaneh
410e78e4fd Fix save for relative symbolic links on Windows
Works around QTBUG-62802.

Change-Id: I2edacb6d368e28fa240e7a866692391cf67f0ca2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2017-08-28 11:20:14 +00:00
Orgad Shaneh
f974fb4964 FileUtils: Recover deleted comment
It was deleted in 52ed384549. Not sure why.

Change-Id: Iccc1716e2fa994f649f5ac37f2288d1c6c44cb28
Reviewed-by: David Faure <david.faure@kdab.com>
2017-08-24 16:35:18 +00:00
Orgad Shaneh
1f443bde52 Replace QFileInfo(fileName.toString()) with fileName.toFileInfo()
Change-Id: Iac7f866b4846939af4dcee086ab07797cc6b8ff1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-08-24 08:54:16 +00:00
Eike Ziller
51e8a1730a HostOsInfo/FileUtils/PersistentSettings: Fix build without QtGui
Interesting for command line tools that want to pull this in but not
QtGui (e.g. sdktool)

Change-Id: Ic2f5c1f3126869cc38bf672345750d7d966560fd
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2017-08-22 13:32:43 +00:00
Eike Ziller
de7e0c58f8 FileUtils: Remove unused includes and forward declaration
Left over after moving functionality to dragsupport.cpp/.h

Change-Id: I909be9eb42fb96989e9469278b416e25f3ac7f62
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-08-22 10:39:30 +00:00
Ivan Donchevskii
277b331389 Fix build
Move constructor definition to .cpp file to
avoid it being inlined

Change-Id: I1c55095e5158740526af9e698c978abf33304e52
Reviewed-by: hjk <hjk@qt.io>
2017-07-03 10:23:41 +00:00
Ivan Donchevskii
07c3a37054 Utils: improve failed file saving behavior
Remove temporary files left after fail.
Set error string for locked file.

Task-number: QTCREATORBUG-15449
Change-Id: Ibc8b01a4ea47870c29493a69718db929070ac13f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2017-07-03 09:29:51 +00:00
Ivan Donchevskii
1607a34a9a Utils: use unique_ptr for QFile object
Do not use raw pointer.

Change-Id: I6810c3ec3a60a43829130cf5e5a00e52db95b965
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2017-07-03 09:28:53 +00:00
Eike Ziller
2897414d3b Add std::hash for FileName
Change-Id: Iaef49c826c0febf3a9cb1fdc97de9f92c261cf40
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-06-19 08:37:11 +00:00
Orgad Shaneh
da7cb91446 Merge remote-tracking branch 'origin/4.2' into 4.3
Change-Id: I4931dcc81be872d7712e67123e94d15ee696459f
2017-03-14 16:20:14 +02:00
Samuel Gaist
4033471aa9 QRegExp include cleanup
This patch adds the missing include statements for QRegExp.

Change-Id: Ibb03b929940adb84ae190b5090cb6b88653cc14c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-03-13 22:05:30 +00:00
Tim Jenssen
2631ffabd5 Remove spaces in initializer lists
Format initializer lists code style like.

Change-Id: Ib82c235e4ba7dc75ee96a7abc0c47eff7b0a9013
Reviewed-by: hjk <hjk@qt.io>
2017-02-22 16:25:09 +00:00
Tobias Hunger
88bcd6a304 Windows: Do not try to save files with reserved names
Do not try to save files with reserved names on windows. Doing so triggers
an assert in Qt.

Provide a nice warning instead.

Task-number: QTCREATORBUG-16984
Change-Id: I12be704f0aec0ab19b7f9f7023e9d28087dc30b1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-10-07 11:57:03 +00:00