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