forked from qt-creator/qt-creator
Utils: add FilePath::baseName
Removing some FilePath::toFileInfo() calls Change-Id: I49be2ef260f225e07b64ee8ace6a8cd47a9d8bb2 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -603,7 +603,7 @@ FileSaver::FileSaver(const FilePath &filePath, QIODevice::OpenMode mode)
|
||||
= {"CON", "PRN", "AUX", "NUL",
|
||||
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
|
||||
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};
|
||||
const QString fn = filePath.toFileInfo().baseName().toUpper();
|
||||
const QString fn = filePath.baseName().toUpper();
|
||||
if (reservedNames.contains(fn)) {
|
||||
m_errorString = tr("%1: Is a reserved filename on Windows. Cannot save.")
|
||||
.arg(filePath.toString());
|
||||
@@ -761,6 +761,12 @@ QString FilePath::fileNameWithPathComponents(int pathComponents) const
|
||||
return m_data;
|
||||
}
|
||||
|
||||
QString FilePath::baseName() const
|
||||
{
|
||||
const QString &name = fileName();
|
||||
return name.left(name.indexOf('.'));
|
||||
}
|
||||
|
||||
void FilePath::setScheme(const QString &scheme)
|
||||
{
|
||||
QTC_CHECK(!scheme.contains('/'));
|
||||
|
@@ -103,6 +103,7 @@ public:
|
||||
|
||||
QString fileName() const;
|
||||
QString fileNameWithPathComponents(int pathComponents) const;
|
||||
QString baseName() const;
|
||||
|
||||
QString scheme() const { return m_scheme; }
|
||||
void setScheme(const QString &scheme);
|
||||
|
@@ -138,7 +138,7 @@ QString ShellCommand::displayName() const
|
||||
return d->m_displayName;
|
||||
if (!d->m_jobs.isEmpty()) {
|
||||
const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(0);
|
||||
QString result = job.command.executable().toFileInfo().baseName();
|
||||
QString result = job.command.executable().baseName();
|
||||
if (!result.isEmpty())
|
||||
result[0] = result.at(0).toTitleCase();
|
||||
else
|
||||
|
@@ -86,8 +86,7 @@ QString EBlinkGdbServerProvider::defaultResetCommands()
|
||||
QString EBlinkGdbServerProvider::scriptFileWoExt() const
|
||||
{
|
||||
// Server starts only without extension in scriptname
|
||||
return m_deviceScript.toFileInfo().absolutePath() +
|
||||
QDir::separator() + m_deviceScript.toFileInfo().baseName();
|
||||
return m_deviceScript.absolutePath().pathAppended(m_deviceScript.baseName()).toString();
|
||||
}
|
||||
|
||||
QString EBlinkGdbServerProvider::channelString() const
|
||||
|
@@ -67,7 +67,7 @@ static bool compilerExists(const FilePath &compilerPath)
|
||||
|
||||
static QString cppLanguageOption(const FilePath &compiler)
|
||||
{
|
||||
const QString baseName = compiler.toFileInfo().baseName();
|
||||
const QString baseName = compiler.baseName();
|
||||
if (baseName == "iccarm" || baseName == "iccrl78"
|
||||
|| baseName == "iccrh850" || baseName == "iccrx"
|
||||
|| baseName == "iccriscv") {
|
||||
|
@@ -792,7 +792,7 @@ void ClangdClient::Private::addSearchResultsForFile(ReferencesData &refData,
|
||||
if (refData.search->supportsReplace()) {
|
||||
const bool fileInSession = SessionManager::projectForFile(file);
|
||||
item.setSelectForReplacement(fileInSession);
|
||||
if (fileInSession && file.toFileInfo().baseName().compare(
|
||||
if (fileInSession && file.baseName().compare(
|
||||
refData.replacementData->oldSymbolName,
|
||||
Qt::CaseInsensitive) == 0) {
|
||||
refData.replacementData->fileRenameCandidates << file; // TODO: We want to do this only for types. Use SymbolInformation once we have it.
|
||||
|
@@ -194,7 +194,7 @@ std::vector<DbEntry> CompilationDbParser::readJsonObjects() const
|
||||
const QJsonObject object = document.object();
|
||||
const Utils::FilePath fileName = jsonObjectFilename(object);
|
||||
const QStringList flags = filterFromFileName(jsonObjectFlags(object, flagsCache),
|
||||
fileName.toFileInfo().baseName());
|
||||
fileName.baseName());
|
||||
result.push_back({flags, fileName, object["directory"].toString()});
|
||||
|
||||
objectStart = m_projectFileContents.indexOf('{', objectEnd + 1);
|
||||
|
@@ -375,7 +375,7 @@ void UvscEngine::insertBreakpoint(const Breakpoint &bp)
|
||||
if (requested.type == BreakpointByFileAndLine) {
|
||||
// Add target executable name.
|
||||
const DebuggerRunParameters &rp = runParameters();
|
||||
QString exe = rp.inferior.executable.toFileInfo().baseName();
|
||||
QString exe = rp.inferior.executable.baseName();
|
||||
exe.replace('-', '_');
|
||||
expression += "\\\\" + exe;
|
||||
// Add file name.
|
||||
|
@@ -212,7 +212,7 @@ CommandLine NimCompilerBuildStep::commandLine()
|
||||
|
||||
FilePath NimCompilerBuildStep::outFilePath() const
|
||||
{
|
||||
const QString targetName = m_targetNimFile.toFileInfo().baseName();
|
||||
const QString targetName = m_targetNimFile.baseName();
|
||||
return buildDirectory().pathAppended(HostOsInfo::withExecutableSuffix(targetName));
|
||||
}
|
||||
|
||||
|
@@ -176,9 +176,8 @@ bool QmakeMakeStep::init()
|
||||
relObjectsDir.clear();
|
||||
if (!relObjectsDir.isEmpty())
|
||||
relObjectsDir += '/';
|
||||
QString objectFile = relObjectsDir +
|
||||
bc->fileNodeBuild()->filePath().toFileInfo().baseName() +
|
||||
subProFile->objectExtension();
|
||||
QString objectFile = relObjectsDir + bc->fileNodeBuild()->filePath().baseName()
|
||||
+ subProFile->objectExtension();
|
||||
makeCmd.addArg(objectFile);
|
||||
}
|
||||
|
||||
|
@@ -1968,7 +1968,7 @@ TargetInformation QmakeProFile::targetInformation(QtSupport::ProFileReader *read
|
||||
// Target
|
||||
result.target = readerBuildPass->value(QLatin1String("TARGET"));
|
||||
if (result.target.isEmpty())
|
||||
result.target = projectFilePath.toFileInfo().baseName();
|
||||
result.target = projectFilePath.baseName();
|
||||
|
||||
result.valid = true;
|
||||
|
||||
|
@@ -649,7 +649,7 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
|
||||
|
||||
const Utils::FilePath currentDesignDocument = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument()->fileName();
|
||||
const QString fileName = currentDesignDocument.toString();
|
||||
const QString typeName = currentDesignDocument.toFileInfo().baseName();
|
||||
const QString typeName = currentDesignDocument.baseName();
|
||||
|
||||
QStringList signalNames = cleanSignalNames(getSortedSignalNameList(selectionState.selectedModelNodes().constFirst()));
|
||||
|
||||
|
@@ -604,9 +604,8 @@ void VcsBaseClient::commit(const QString &repositoryRoot,
|
||||
|
||||
QString VcsBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const
|
||||
{
|
||||
return vcsBinary().toFileInfo().baseName() +
|
||||
QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') +
|
||||
FilePath::fromString(sourceId).fileName();
|
||||
return vcsBinary().baseName() + QLatin1Char(' ') + vcsCmd + QLatin1Char(' ')
|
||||
+ FilePath::fromString(sourceId).fileName();
|
||||
}
|
||||
|
||||
void VcsBaseClient::statusParser(const QString &text)
|
||||
|
Reference in New Issue
Block a user