Commit 8b5dcc13 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by hjk
Browse files

Replace QFileInfo::fileName() with FileName::fileName()



Change-Id: I4852ff215abf25649fc5eac1e922ae901839ca3d
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 6fd0d4ed
......@@ -36,6 +36,7 @@
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <qtsingleapplication.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <QDebug>
......@@ -172,7 +173,7 @@ static bool copyRecursively(const QString &srcFilePath,
if (srcFileInfo.isDir()) {
QDir targetDir(tgtFilePath);
targetDir.cdUp();
if (!targetDir.mkdir(QFileInfo(tgtFilePath).fileName()))
if (!targetDir.mkdir(Utils::FileName::fromString(tgtFilePath).fileName()))
return false;
QDir sourceDir(srcFilePath);
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
......
......@@ -29,7 +29,8 @@
****************************************************************************/
#include "fileinprojectfinder.h"
#include <utils/qtcassert.h>
#include "fileutils.h"
#include "qtcassert.h"
#include <QDebug>
#include <QFileInfo>
......@@ -215,9 +216,9 @@ QString FileInProjectFinder::findFile(const QUrl &fileUrl, bool *success) const
if (debug)
qDebug() << "FileInProjectFinder: checking project files ...";
const QString fileName = QFileInfo(originalPath).fileName();
const QString fileName = FileName::fromString(originalPath).fileName();
foreach (const QString &f, m_projectFiles) {
if (QFileInfo(f).fileName() == fileName) {
if (FileName::fromString(f).fileName() == fileName) {
m_cache.insert(originalPath, f);
if (success)
*success = true;
......
......@@ -156,7 +156,7 @@ bool FileUtils::copyRecursively(const FileName &srcFilePath, const FileName &tgt
if (!tgtFilePath.exists()) {
QDir targetDir(tgtFilePath.toString());
targetDir.cdUp();
if (!targetDir.mkdir(tgtFilePath.toFileInfo().fileName())) {
if (!targetDir.mkdir(tgtFilePath.fileName())) {
if (error) {
*error = QCoreApplication::translate("Utils::FileUtils", "Failed to create directory \"%1\".")
.arg(tgtFilePath.toUserOutput());
......
......@@ -372,7 +372,7 @@ void MacroExpander::registerFileVariables(const QByteArray &prefix,
registerVariable(prefix + kFileNamePostfix,
tr("%1: File name without path.").arg(heading),
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : QFileInfo(tmp).fileName(); },
[base]() -> QString { QString tmp = base(); return tmp.isEmpty() ? QString() : Utils::FileName::fromString(tmp).fileName(); },
visibleInChooser);
registerVariable(prefix + kFileBaseNamePostfix,
......
......@@ -28,6 +28,7 @@
**
****************************************************************************/
#include "fileutils.h"
#include "reloadpromptutils.h"
#include <QCoreApplication>
......@@ -53,7 +54,7 @@ QTCREATOR_UTILS_EXPORT ReloadPromptAnswer reloadPrompt(const QString &fileName,
msg = QCoreApplication::translate("Utils::reloadPrompt",
"The file <i>%1</i> has changed outside Qt Creator. Do you want to reload it?");
}
msg = msg.arg(QFileInfo(fileName).fileName());
msg = msg.arg(FileName::fromString(fileName).fileName());
return reloadPrompt(title, msg, QDir::toNativeSeparators(fileName), parent);
}
......
......@@ -28,8 +28,9 @@
**
****************************************************************************/
#include "unixutils.h"
#include "fileutils.h"
#include <QSettings>
#include <QFileInfo>
#include <QCoreApplication>
......@@ -81,7 +82,7 @@ QString UnixUtils::substituteFileBrowserParameters(const QString &pre, const QSt
} else if (c == QLatin1Char('f')) {
s = QLatin1Char('"') + file + QLatin1Char('"');
} else if (c == QLatin1Char('n')) {
s = QLatin1Char('"') + QFileInfo(file).fileName() + QLatin1Char('"');
s = QLatin1Char('"') + FileName::fromString(file).fileName() + QLatin1Char('"');
} else if (c == QLatin1Char('%')) {
s = c;
} else {
......
......@@ -61,7 +61,7 @@ QString AndroidManifestDocument::defaultPath() const
QString AndroidManifestDocument::suggestedFileName() const
{
return filePath().toFileInfo().fileName();
return filePath().fileName();
}
bool AndroidManifestDocument::isModified() const
......
......@@ -301,7 +301,7 @@ QList<AndroidToolChainFactory::AndroidToolChainInformation> AndroidToolChainFact
QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(),
QStringList() << QLatin1String("*"), QDir::Dirs);
while (it.hasNext()) {
const QString &fileName = QFileInfo(it.next()).fileName();
const QString &fileName = FileName::fromString(it.next()).fileName();
int idx = versionRegExp.indexIn(fileName);
if (idx == -1)
continue;
......@@ -376,7 +376,7 @@ QList<ToolChain *> AndroidToolChainFactory::createToolChainsForNdk(const Utils::
QMap<Abi::Architecture, AndroidToolChain *> newestToolChainForArch;
while (it.hasNext()) {
const QString &fileName = QFileInfo(it.next()).fileName();
const QString &fileName = FileName::fromString(it.next()).fileName();
int idx = versionRegExp.indexIn(fileName);
if (idx == -1)
continue;
......@@ -417,7 +417,7 @@ QList<int> AndroidToolChainFactory::newestToolChainVersionForArch(Abi::Architect
QDirIterator it(path.appendPath(QLatin1String("toolchains")).toString(),
QStringList() << QLatin1String("*"), QDir::Dirs);
while (it.hasNext()) {
const QString &fileName = QFileInfo(it.next()).fileName();
const QString &fileName = FileName::fromString(it.next()).fileName();
int idx = versionRegExp.indexIn(fileName);
if (idx == -1)
continue;
......
......@@ -76,7 +76,7 @@ QString JavaDocument::defaultPath() const
QString JavaDocument::suggestedFileName() const
{
return filePath().toFileInfo().fileName();
return filePath().fileName();
}
......
......@@ -388,7 +388,7 @@ QVariant BookmarkManager::data(const QModelIndex &index, int role) const
Bookmark *bookMark = m_bookmarksList.at(index.row());
if (role == BookmarkManager::Filename)
return QFileInfo(bookMark->fileName()).fileName();
return FileName::fromString(bookMark->fileName()).fileName();
if (role == BookmarkManager::LineNumber)
return bookMark->lineNumber();
if (role == BookmarkManager::Directory)
......
......@@ -63,7 +63,7 @@ static QString shadowBuildDirectory(const QString &projectFilePath, const Kit *k
return QString();
QFileInfo info(projectFilePath);
const QString projectName = QFileInfo(info.absolutePath()).fileName();
const QString projectName = FileName::fromString(info.absolutePath()).fileName();
ProjectMacroExpander expander(projectName, k, bcName);
QDir projectDir = QDir(Project::projectDirectory(FileName::fromString(projectFilePath)).toString());
QString buildPath = expander.expand(Core::DocumentManager::buildDirectory());
......
......@@ -257,7 +257,7 @@ QString CMakeDocument::defaultPath() const
QString CMakeDocument::suggestedFileName() const
{
return filePath().toFileInfo().fileName();
return filePath().fileName();
}
//
......
......@@ -1213,7 +1213,7 @@ void CMakeCbpParser::parseUnit()
m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false));
} else {
bool generated = false;
QString onlyFileName = QFileInfo(fileName).fileName();
QString onlyFileName = Utils::FileName::fromString(fileName).fileName();
if ( (onlyFileName.startsWith(QLatin1String("moc_")) && onlyFileName.endsWith(QLatin1String(".cxx")))
|| (onlyFileName.startsWith(QLatin1String("ui_")) && onlyFileName.endsWith(QLatin1String(".h")))
|| (onlyFileName.startsWith(QLatin1String("qrc_")) && onlyFileName.endsWith(QLatin1String(".cxx"))))
......
......@@ -30,8 +30,9 @@
#include "openwithdialog.h"
#include <utils/fileutils.h>
#include <QPushButton>
#include <QFileInfo>
using namespace Core;
using namespace Core::Internal;
......@@ -41,7 +42,7 @@ OpenWithDialog::OpenWithDialog(const QString &fileName, QWidget *parent)
{
setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
label->setText(tr("Open file \"%1\" with:").arg(QFileInfo(fileName).fileName()));
label->setText(tr("Open file \"%1\" with:").arg(Utils::FileName::fromString(fileName).fileName()));
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()),
......
......@@ -1612,7 +1612,7 @@ void EditorManagerPrivate::copyFileNameFromContextMenu()
{
if (!d->m_contextMenuEntry)
return;
QApplication::clipboard()->setText(QFileInfo(d->m_contextMenuEntry->fileName()).fileName());
QApplication::clipboard()->setText(FileName::fromString(d->m_contextMenuEntry->fileName()).fileName());
}
void EditorManagerPrivate::saveDocumentFromContextMenu()
......
......@@ -32,6 +32,7 @@
#include "infobar.h"
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QFile>
......@@ -263,7 +264,7 @@ QString IDocument::displayName() const
{
if (!d->displayName.isEmpty())
return d->displayName;
return d->filePath.toFileInfo().fileName();
return d->filePath.fileName();
}
/*!
......
......@@ -119,7 +119,7 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF
// file names can match with +linenumber or :linenumber
name = entry;
const QString lineNoSuffix = EditorManager::splitLineNumber(&name);
name = QFileInfo(name).fileName();
name = Utils::FileName::fromString(name).fileName();
foreach (const QString &file, files) {
if (future.isCanceled())
break;
......
......@@ -149,7 +149,7 @@ void ToolSettings::apply()
if (tool->preset() && (*tool) != (*(tool->preset()))) {
// check if we need to choose a new file name
if (tool->preset()->fileName() == tool->fileName()) {
const QString &fileName = QFileInfo(tool->preset()->fileName()).fileName();
const QString &fileName = Utils::FileName::fromString(tool->preset()->fileName()).fileName();
const QString &newFilePath = getUserFilePath(fileName);
// TODO error handling if newFilePath.isEmpty() (i.e. failed to find a unused name)
tool->setFileName(newFilePath);
......
......@@ -30,7 +30,8 @@
#include "argumentscollector.h"
#include <QFileInfo>
#include <utils/fileutils.h>
#include <QCoreApplication>
static QString pasteRequestString() { return QLatin1String("paste"); }
......@@ -72,7 +73,7 @@ bool ArgumentsCollector::collect(const QStringList &args)
QString ArgumentsCollector::usageString() const
{
QString usage = QString::fromLatin1("Usage:\n\t%1 <request> [ <request options>]\n\t")
.arg(QFileInfo(QCoreApplication::applicationFilePath()).fileName());
.arg(Utils::FileName::fromString(QCoreApplication::applicationFilePath()).fileName());
usage += QString::fromLatin1("Possible requests: \"%1\", \"%2\", \"%3\"\n\t")
.arg(pasteRequestString(), listProtocolsRequestString(), helpRequestString());
usage += QString::fromLatin1("Possible options for request \"%1\": \"%2 <file>\" (default: stdin), "
......
......@@ -38,7 +38,6 @@
#include <cplusplus/TypeOfExpression.h>
#include <QDir>
#include <QFileInfo>
#include <QSet>
#include <QQueue>
......@@ -258,7 +257,7 @@ Unknown::Unknown(const QString &type) : type(type)
CppInclude::CppInclude(const Document::Include &includeFile) :
path(QDir::toNativeSeparators(includeFile.resolvedFileName())),
fileName(QFileInfo(includeFile.resolvedFileName()).fileName())
fileName(Utils::FileName::fromString(includeFile.resolvedFileName()).fileName())
{
helpCategory = TextEditor::HelpItem::Brief;
helpIdCandidates = QStringList(fileName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment