forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -94,7 +94,7 @@ static FileName findQmakeInDir(const FileName &path)
|
|||||||
if (fi.fileName() == qmake)
|
if (fi.fileName() == qmake)
|
||||||
continue;
|
continue;
|
||||||
if (isQmake(fi.absoluteFilePath()))
|
if (isQmake(fi.absoluteFilePath()))
|
||||||
return FileName(fi);
|
return FileName::fromFileInfo(fi);
|
||||||
}
|
}
|
||||||
return FileName();
|
return FileName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -641,9 +641,9 @@ FileName::FileName()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs a FileName from \a info
|
/// Constructs a FileName from \a info
|
||||||
FileName::FileName(const QFileInfo &info)
|
FileName FileName::fromFileInfo(const QFileInfo &info)
|
||||||
: QString(info.absoluteFilePath())
|
|
||||||
{
|
{
|
||||||
|
return FileName::fromString(info.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \returns a QFileInfo
|
/// \returns a QFileInfo
|
||||||
|
|||||||
@@ -64,14 +64,16 @@ class QTCREATOR_UTILS_EXPORT FileName : private QString
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileName();
|
FileName();
|
||||||
explicit FileName(const QFileInfo &info);
|
|
||||||
QFileInfo toFileInfo() const;
|
|
||||||
static FileName fromString(const QString &filename);
|
static FileName fromString(const QString &filename);
|
||||||
|
static FileName fromFileInfo(const QFileInfo &info);
|
||||||
static FileName fromStringWithExtension(const QString &filename, const QString &defaultExtension);
|
static FileName fromStringWithExtension(const QString &filename, const QString &defaultExtension);
|
||||||
static FileName fromLatin1(const QByteArray &filename);
|
static FileName fromLatin1(const QByteArray &filename);
|
||||||
static FileName fromUserInput(const QString &filename);
|
static FileName fromUserInput(const QString &filename);
|
||||||
static FileName fromUtf8(const char *filename, int filenameSize = -1);
|
static FileName fromUtf8(const char *filename, int filenameSize = -1);
|
||||||
|
|
||||||
const QString &toString() const;
|
const QString &toString() const;
|
||||||
|
QFileInfo toFileInfo() const;
|
||||||
QString toUserOutput() const;
|
QString toUserOutput() const;
|
||||||
QString fileName(int pathComponents = 0) const;
|
QString fileName(int pathComponents = 0) const;
|
||||||
bool exists() const;
|
bool exists() const;
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ int ReadOnlyFilesDialog::exec()
|
|||||||
result = static_cast<ReadOnlyResult>(buttongroup.group->checkedId());
|
result = static_cast<ReadOnlyResult>(buttongroup.group->checkedId());
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case RO_MakeWritable:
|
case RO_MakeWritable:
|
||||||
if (!Utils::FileUtils::makeWritable(Utils::FileName(QFileInfo(buttongroup.fileName)))) {
|
if (!Utils::FileUtils::makeWritable(Utils::FileName::fromFileInfo(buttongroup.fileName))) {
|
||||||
failedToMakeWritable << buttongroup.fileName;
|
failedToMakeWritable << buttongroup.fileName;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ void ReadOnlyFilesDialogPrivate::initDialog(const QStringList &fileNames)
|
|||||||
auto item = new QTreeWidgetItem(ui.treeWidget);
|
auto item = new QTreeWidgetItem(ui.treeWidget);
|
||||||
item->setText(FileName, visibleName);
|
item->setText(FileName, visibleName);
|
||||||
item->setIcon(FileName, FileIconProvider::icon(fileName));
|
item->setIcon(FileName, FileIconProvider::icon(fileName));
|
||||||
item->setText(Folder, Utils::FileUtils::shortNativePath(Utils::FileName(QFileInfo(directory))));
|
item->setText(Folder, Utils::FileUtils::shortNativePath(Utils::FileName::fromFileInfo(directory)));
|
||||||
auto radioButtonGroup = new QButtonGroup;
|
auto radioButtonGroup = new QButtonGroup;
|
||||||
|
|
||||||
// Add a button for opening the file with a version control system
|
// Add a button for opening the file with a version control system
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil
|
|||||||
QFileInfo fi(path);
|
QFileInfo fi(path);
|
||||||
LocatorFilterEntry filterEntry(this, fi.fileName(), QString(path + fp.postfix));
|
LocatorFilterEntry filterEntry(this, fi.fileName(), QString(path + fp.postfix));
|
||||||
filterEntry.fileName = path;
|
filterEntry.fileName = path;
|
||||||
filterEntry.extraInfo = FileUtils::shortNativePath(FileName(fi));
|
filterEntry.extraInfo = FileUtils::shortNativePath(FileName::fromFileInfo(fi));
|
||||||
|
|
||||||
const int matchLevel = matchLevelFor(match, matchText);
|
const int matchLevel = matchLevelFor(match, matchText);
|
||||||
if (hasPathSeparator) {
|
if (hasPathSeparator) {
|
||||||
|
|||||||
@@ -653,7 +653,7 @@ void DebuggerItemManagerPrivate::autoDetectCdbDebuggers()
|
|||||||
// Pre Windows SDK 8: Check 'Debugging Tools for Windows'
|
// Pre Windows SDK 8: Check 'Debugging Tools for Windows'
|
||||||
for (const QFileInfo &fi : dir.entryInfoList({"Debugging Tools for Windows*"},
|
for (const QFileInfo &fi : dir.entryInfoList({"Debugging Tools for Windows*"},
|
||||||
QDir::Dirs | QDir::NoDotAndDotDot)) {
|
QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||||
FileName filePath(fi);
|
FileName filePath = FileName::fromFileInfo(fi);
|
||||||
filePath.appendPath("cdb.exe");
|
filePath.appendPath("cdb.exe");
|
||||||
if (!cdbs.contains(filePath))
|
if (!cdbs.contains(filePath))
|
||||||
cdbs.append(filePath);
|
cdbs.append(filePath);
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ void XcodeProbe::setupDefaultToolchains(const QString &devPath)
|
|||||||
|
|
||||||
const QFileInfo clangCInfo = getClangInfo("clang");
|
const QFileInfo clangCInfo = getClangInfo("clang");
|
||||||
if (clangCInfo.exists())
|
if (clangCInfo.exists())
|
||||||
clangProfile.cCompilerPath = Utils::FileName(clangCInfo);
|
clangProfile.cCompilerPath = Utils::FileName::fromFileInfo(clangCInfo);
|
||||||
|
|
||||||
const QFileInfo clangCppInfo = getClangInfo("clang++");
|
const QFileInfo clangCppInfo = getClangInfo("clang++");
|
||||||
if (clangCppInfo.exists())
|
if (clangCppInfo.exists())
|
||||||
clangProfile.cxxCompilerPath = Utils::FileName(clangCppInfo);
|
clangProfile.cxxCompilerPath = Utils::FileName::fromFileInfo(clangCppInfo);
|
||||||
|
|
||||||
QSet<QString> allArchitectures;
|
QSet<QString> allArchitectures;
|
||||||
static const std::map<QString, QStringList> sdkConfigs {
|
static const std::map<QString, QStringList> sdkConfigs {
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ void GnuMakeParser::taskAdded(const Task &task, int linkedLines, int skippedLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (possibleFiles.size() == 1)
|
if (possibleFiles.size() == 1)
|
||||||
editable.file = Utils::FileName(possibleFiles.first());
|
editable.file = Utils::FileName::fromFileInfo(possibleFiles.first());
|
||||||
// Let the Makestep apply additional heuristics (based on
|
// Let the Makestep apply additional heuristics (based on
|
||||||
// files in ther project) if we cannot uniquely
|
// files in ther project) if we cannot uniquely
|
||||||
// identify the file!
|
// identify the file!
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ void SelectableFilesFromDirModel::buildTree(const Utils::FileName &baseDir, Tree
|
|||||||
bool allChecked = true;
|
bool allChecked = true;
|
||||||
bool allUnchecked = true;
|
bool allUnchecked = true;
|
||||||
for (const QFileInfo &fileInfo : fileInfoList) {
|
for (const QFileInfo &fileInfo : fileInfoList) {
|
||||||
Utils::FileName fn = Utils::FileName(fileInfo);
|
Utils::FileName fn = Utils::FileName::fromFileInfo(fileInfo);
|
||||||
if (m_futureCount % 100) {
|
if (m_futureCount % 100) {
|
||||||
emit parsingProgress(fn);
|
emit parsingProgress(fn);
|
||||||
if (fi.isCanceled())
|
if (fi.isCanceled())
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ static FileName findQMakeBinaryFromMakefile(const QString &makefile)
|
|||||||
// Is qmake still installed?
|
// Is qmake still installed?
|
||||||
QFileInfo fi(qmakePath);
|
QFileInfo fi(qmakePath);
|
||||||
if (fi.exists())
|
if (fi.exists())
|
||||||
return FileName(fi);
|
return FileName::fromFileInfo(fi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ QSet<FileName> QmakePriFile::recursiveEnumerate(const QString &folder)
|
|||||||
if (file.isDir() && !file.isSymLink())
|
if (file.isDir() && !file.isSymLink())
|
||||||
result += recursiveEnumerate(file.absoluteFilePath());
|
result += recursiveEnumerate(file.absoluteFilePath());
|
||||||
else if (!Core::EditorManager::isAutoSaveFile(file.fileName()))
|
else if (!Core::EditorManager::isAutoSaveFile(file.fileName()))
|
||||||
result += FileName(file);
|
result += FileName::fromFileInfo(file);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1819,7 +1819,7 @@ FileNameList BaseQtVersion::qtCorePaths() const
|
|||||||
&& file.startsWith("QtCore")
|
&& file.startsWith("QtCore")
|
||||||
&& file.endsWith(".framework")) {
|
&& file.endsWith(".framework")) {
|
||||||
// handle Framework
|
// handle Framework
|
||||||
FileName lib(info);
|
FileName lib = FileName::fromFileInfo(info);
|
||||||
dynamicLibs.append(lib.appendPath(file.left(file.lastIndexOf('.'))));
|
dynamicLibs.append(lib.appendPath(file.left(file.lastIndexOf('.'))));
|
||||||
} else if (info.isReadable()) {
|
} else if (info.isReadable()) {
|
||||||
if (file.startsWith("libQtCore")
|
if (file.startsWith("libQtCore")
|
||||||
@@ -1827,12 +1827,12 @@ FileNameList BaseQtVersion::qtCorePaths() const
|
|||||||
|| file.startsWith("QtCore")
|
|| file.startsWith("QtCore")
|
||||||
|| file.startsWith("Qt5Core")) {
|
|| file.startsWith("Qt5Core")) {
|
||||||
if (file.endsWith(".a") || file.endsWith(".lib"))
|
if (file.endsWith(".a") || file.endsWith(".lib"))
|
||||||
staticLibs.append(FileName(info));
|
staticLibs.append(FileName::fromFileInfo(info));
|
||||||
else if (file.endsWith(".dll")
|
else if (file.endsWith(".dll")
|
||||||
|| file.endsWith(QString::fromLatin1(".so.") + versionString)
|
|| file.endsWith(QString::fromLatin1(".so.") + versionString)
|
||||||
|| file.endsWith(".so")
|
|| file.endsWith(".so")
|
||||||
|| file.endsWith(QLatin1Char('.') + versionString + ".dylib"))
|
|| file.endsWith(QLatin1Char('.') + versionString + ".dylib"))
|
||||||
dynamicLibs.append(FileName(info));
|
dynamicLibs.append(FileName::fromFileInfo(info));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ void UpdateInfoPlugin::startCheckForUpdates()
|
|||||||
d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates"));
|
d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates"));
|
||||||
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
|
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
|
||||||
connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
|
connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
|
||||||
d->m_checkUpdatesCommand->addJob(Utils::FileName(QFileInfo(d->m_maintenanceTool)), QStringList(QLatin1String("--checkupdates")),
|
d->m_checkUpdatesCommand->addJob(Utils::FileName::fromFileInfo(d->m_maintenanceTool), {"--checkupdates"},
|
||||||
60 * 3, // 3 minutes timeout
|
60 * 3, // 3 minutes timeout
|
||||||
/*workingDirectory=*/QString(),
|
/*workingDirectory=*/QString(),
|
||||||
[](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; });
|
[](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; });
|
||||||
|
|||||||
Reference in New Issue
Block a user