Commit a8ea31bf authored by Tobias Hunger's avatar Tobias Hunger

FileUtils: Add static method to construct FileNames from Latin1

Change-Id: Ida513eb0537e2ef0c55887d0df21de956e85e983
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent a1935367
......@@ -533,6 +533,13 @@ FileName FileName::fromString(const QString &filename)
return FileName(filename);
}
/// Constructs a FileName from \a fileName
/// \a fileName is not checked for validity.
FileName FileName::fromLatin1(const QByteArray &filename)
{
return FileName(QString::fromLatin1(filename));
}
/// Constructs a FileName from \a fileName
/// \a fileName is only passed through QDir::cleanPath
FileName FileName::fromUserInput(const QString &filename)
......
......@@ -56,6 +56,7 @@ public:
explicit FileName(const QFileInfo &info);
QFileInfo toFileInfo() const;
static FileName fromString(const QString &filename);
static FileName fromLatin1(const QByteArray &filename);
static FileName fromUserInput(const QString &filename);
QString toString() const;
QString toUserOutput() const;
......
......@@ -334,7 +334,7 @@ FileName AndroidConfig::antToolPath() const
if (!m_antLocation.isEmpty())
return m_antLocation;
else
return FileName::fromString(QLatin1String("ant"));
return FileName::fromLatin1("ant");
}
FileName AndroidConfig::emulatorToolPath() const
......
......@@ -210,7 +210,7 @@ bool AndroidToolChain::fromMap(const QVariantMap &data)
QList<FileName> AndroidToolChain::suggestedMkspecList() const
{
return QList<FileName>()<< FileName::fromString(QLatin1String("android-g++"));
return QList<FileName>()<< FileName::fromLatin1("android-g++");
}
QString AndroidToolChain::makeCommand(const Utils::Environment &env) const
......
......@@ -350,7 +350,7 @@ void IosConfigurations::updateAutomaticKitList()
SysRootKitInformation::setSysRoot(kitAtt, p.sdkPath);
// QmakeProjectManager::QmakeKitInformation::setMkspec(newKit,
// Utils::FileName::fromString(QLatin1String("macx-ios-clang")));
// Utils::FileName::fromLatin1("macx-ios-clang")));
if (kitExists) {
kitAtt->unblockNotification();
} else {
......
......@@ -567,10 +567,10 @@ QList<FileName> GccToolChain::suggestedMkspecList() const
QString v = version();
// prefer versioned g++ on mac. This is required to enable building for older Mac OS versions
if (v.startsWith(QLatin1String("4.0")) && m_compilerCommand.endsWith(QLatin1String("-4.0")))
return QList<FileName>() << FileName::fromString(QLatin1String("macx-g++40"));
return QList<FileName>() << FileName::fromLatin1("macx-g++40");
if (v.startsWith(QLatin1String("4.2")) && m_compilerCommand.endsWith(QLatin1String("-4.2")))
return QList<FileName>() << FileName::fromString(QLatin1String("macx-g++42"));
return QList<FileName>() << FileName::fromString(QLatin1String("macx-g++"));
return QList<FileName>() << FileName::fromLatin1("macx-g++42");
return QList<FileName>() << FileName::fromLatin1("macx-g++");
}
if (abi.os() == Abi::LinuxOS) {
......@@ -579,14 +579,14 @@ QList<FileName> GccToolChain::suggestedMkspecList() const
if (abi.wordWidth() == host.wordWidth()) {
// no need to explicitly set the word width, but provide that mkspec anyway to make sure
// that the correct compiler is picked if a mkspec with a wordwidth is given.
return QList<FileName>() << FileName::fromString(QLatin1String("linux-g++"))
return QList<FileName>() << FileName::fromLatin1("linux-g++")
<< FileName::fromString(QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth()));
}
return QList<FileName>() << FileName::fromString(QLatin1String("linux-g++-") + QString::number(m_targetAbi.wordWidth()));
}
if (abi.os() == Abi::BsdOS && abi.osFlavor() == Abi::FreeBsdFlavor)
return QList<FileName>() << FileName::fromString(QLatin1String("freebsd-g++"));
return QList<FileName>() << FileName::fromLatin1("freebsd-g++");
return QList<FileName>();
}
......@@ -1059,14 +1059,14 @@ QList<FileName> ClangToolChain::suggestedMkspecList() const
Abi abi = targetAbi();
if (abi.os() == Abi::MacOS)
return QList<FileName>()
<< FileName::fromString(QLatin1String("macx-clang"))
<< FileName::fromString(QLatin1String("macx-clang-32"))
<< FileName::fromString(QLatin1String("unsupported/macx-clang"))
<< FileName::fromString(QLatin1String("macx-ios-clang"));
<< FileName::fromLatin1("macx-clang")
<< FileName::fromLatin1("macx-clang-32")
<< FileName::fromLatin1("unsupported/macx-clang")
<< FileName::fromLatin1("macx-ios-clang");
else if (abi.os() == Abi::LinuxOS)
return QList<FileName>()
<< FileName::fromString(QLatin1String("linux-clang"))
<< FileName::fromString(QLatin1String("unsupported/linux-clang"));
<< FileName::fromLatin1("linux-clang")
<< FileName::fromLatin1("unsupported/linux-clang");
return QList<FileName>(); // Note: Not supported by Qt yet, so default to the mkspec the Qt was build with
}
......@@ -1162,16 +1162,16 @@ QString MingwToolChain::typeDisplayName() const
QList<FileName> MingwToolChain::suggestedMkspecList() const
{
if (Utils::HostOsInfo::isWindowsHost())
return QList<FileName>() << FileName::fromString(QLatin1String("win32-g++"));
return QList<FileName>() << FileName::fromLatin1("win32-g++");
if (Utils::HostOsInfo::isLinuxHost()) {
if (version().startsWith(QLatin1String("4.6.")))
return QList<FileName>()
<< FileName::fromString(QLatin1String("win32-g++-4.6-cross"))
<< FileName::fromString(QLatin1String("unsupported/win32-g++-4.6-cross"));
<< FileName::fromLatin1("win32-g++-4.6-cross")
<< FileName::fromLatin1("unsupported/win32-g++-4.6-cross");
else
return QList<FileName>()
<< FileName::fromString(QLatin1String("win32-g++-cross"))
<< FileName::fromString(QLatin1String("unsupported/win32-g++-cross"));
<< FileName::fromLatin1("win32-g++-cross")
<< FileName::fromLatin1("unsupported/win32-g++-cross");
}
return QList<FileName>();
}
......
......@@ -84,7 +84,7 @@ public:
m_id = Id::fromString(QUuid::createUuid().toString());
m_displayName = QCoreApplication::translate("ProjectExplorer::Kit", "Unnamed");
m_iconPath = Utils::FileName::fromString(QLatin1String(":///DESKTOP///"));
m_iconPath = Utils::FileName::fromLatin1(":///DESKTOP///");
}
QString m_displayName;
......@@ -350,7 +350,7 @@ QIcon Kit::icon(const Utils::FileName &path)
{
if (path.isEmpty())
return QIcon();
if (path == Utils::FileName::fromString(QLatin1String(":///DESKTOP///")))
if (path == Utils::FileName::fromLatin1(":///DESKTOP///"))
return qApp->style()->standardIcon(QStyle::SP_ComputerIcon);
QFileInfo fi(path.toString());
......
......@@ -244,7 +244,7 @@ void KitManager::restoreKits()
defaultKit->setDisplayName(tr("Desktop"));
defaultKit->setSdkProvided(false);
defaultKit->setAutoDetected(false);
defaultKit->setIconPath(Utils::FileName::fromString(QLatin1String(":///DESKTOP///")));
defaultKit->setIconPath(Utils::FileName::fromLatin1(":///DESKTOP///"));
defaultKit->setup();
......
......@@ -351,21 +351,21 @@ QList<Utils::FileName> MsvcToolChain::suggestedMkspecList() const
{
switch (m_abi.osFlavor()) {
case ProjectExplorer::Abi::WindowsMsvc2005Flavor:
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("win32-msvc2005"));
return QList<Utils::FileName>() << Utils::FileName::fromLatin1("win32-msvc2005");
case ProjectExplorer::Abi::WindowsMsvc2008Flavor:
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("win32-msvc2008"));
return QList<Utils::FileName>() << Utils::FileName::fromLatin1("win32-msvc2008");
case ProjectExplorer::Abi::WindowsMsvc2010Flavor:
return QList<Utils::FileName>() << Utils::FileName::fromString(QLatin1String("win32-msvc2010"));
return QList<Utils::FileName>() << Utils::FileName::fromLatin1("win32-msvc2010");
case ProjectExplorer::Abi::WindowsMsvc2012Flavor:
QList<Utils::FileName>()
<< Utils::FileName::fromString(QLatin1String("win32-msvc2012"))
<< Utils::FileName::fromString(QLatin1String("win32-msvc2010"));
<< Utils::FileName::fromLatin1("win32-msvc2012")
<< Utils::FileName::fromLatin1("win32-msvc2010");
break;
case ProjectExplorer::Abi::WindowsMsvc2013Flavor:
QList<Utils::FileName>()
<< Utils::FileName::fromString(QLatin1String("win32-msvc2013"))
<< Utils::FileName::fromString(QLatin1String("win32-msvc2012"))
<< Utils::FileName::fromString(QLatin1String("win32-msvc2010"));
<< Utils::FileName::fromLatin1("win32-msvc2013")
<< Utils::FileName::fromLatin1("win32-msvc2012")
<< Utils::FileName::fromLatin1("win32-msvc2010");
break;
default:
break;
......
......@@ -2411,35 +2411,35 @@ QVariantMap Version11Handler::update(Project *project, const QVariantMap &map)
Kit *tmpKit = rawKit;
if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.AndroidDeviceTarget")) {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":/android/images/QtAndroid.png")));
tmpKit->setIconPath(FileName::fromLatin1(":/android/images/QtAndroid.png"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("Desktop"));
tmpKit->setValue("PE.Profile.Device", QString());
} else if (oldTargetId == QLatin1String("RemoteLinux.EmbeddedLinuxTarget")) {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":///DESKTOP///")));
tmpKit->setIconPath(FileName::fromLatin1(":///DESKTOP///"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("GenericLinuxOsType"));
tmpKit->setValue("PE.Profile.Device", QString());
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.HarmattanDeviceTarget")) {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":/projectexplorer/images/MaemoDevice.png")));
tmpKit->setIconPath(FileName::fromLatin1(":/projectexplorer/images/MaemoDevice.png"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("HarmattanOsType"));
tmpKit->setValue("PE.Profile.Device", QString());
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")) {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":/projectexplorer/images/MaemoDevice.png")));
tmpKit->setIconPath(FileName::fromLatin1(":/projectexplorer/images/MaemoDevice.png"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("Maemo5OsType"));
tmpKit->setValue("PE.Profile.Device", QString());
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.MeegoDeviceTarget")) {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":/projectexplorer/images/MaemoDevice.png")));
tmpKit->setIconPath(FileName::fromLatin1(":/projectexplorer/images/MaemoDevice.png"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("MeegoOsType"));
tmpKit->setValue("PE.Profile.Device", QString());
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.S60DeviceTarget")) {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":/projectexplorer/images/SymbianDevice.png")));
tmpKit->setIconPath(FileName::fromLatin1(":/projectexplorer/images/SymbianDevice.png"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("Qt4ProjectManager.SymbianDevice"));
tmpKit->setValue("PE.Profile.Device", QString::fromLatin1("Symbian Device"));
} else if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.QtSimulatorTarget")) {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":/projectexplorer/images/Simulator.png")));
tmpKit->setIconPath(FileName::fromLatin1(":/projectexplorer/images/Simulator.png"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("Desktop"));
tmpKit->setValue("PE.Profile.Device", QString::fromLatin1("Desktop Device"));
} else {
tmpKit->setIconPath(FileName::fromString(QLatin1String(":///DESKTOP///")));
tmpKit->setIconPath(FileName::fromLatin1(":///DESKTOP///"));
tmpKit->setValue("PE.Profile.DeviceType", QString::fromLatin1("Desktop"));
tmpKit->setValue("PE.Profile.Device", QString::fromLatin1("Desktop Device"));
}
......
......@@ -400,8 +400,8 @@ QmakeBuildConfiguration::MakefileState QmakeBuildConfiguration::compareToImportF
return MakefileMatches;
// Actual spec is the default one
// qDebug() << "AS vs VS" << actualSpec << version->mkspec();
if ((actualSpec == version->mkspec() || actualSpec == FileName::fromString(QLatin1String("default")))
&& (parsedSpec == version->mkspec() || parsedSpec == FileName::fromString(QLatin1String("default")) || parsedSpec.isEmpty()))
if ((actualSpec == version->mkspec() || actualSpec == FileName::fromLatin1("default"))
&& (parsedSpec == version->mkspec() || parsedSpec == FileName::fromLatin1("default") || parsedSpec.isEmpty()))
return MakefileMatches;
}
return MakefileIncompatible;
......
......@@ -114,7 +114,7 @@ QList<ProjectExplorer::BuildInfo *> QmakeProjectImporter::import(const Utils::Fi
Utils::FileName parsedSpec =
QmakeBuildConfiguration::extractSpecFromArguments(&additionalArguments, importPath.toString(), version);
Utils::FileName versionSpec = version->mkspec();
if (parsedSpec.isEmpty() || parsedSpec == Utils::FileName::fromString(QLatin1String("default")))
if (parsedSpec.isEmpty() || parsedSpec == Utils::FileName::fromLatin1("default"))
parsedSpec = versionSpec;
QString specArgument;
......
......@@ -335,7 +335,7 @@ Kit *BlackBerryConfiguration::createKit(
if (isSimulator)
QmakeProjectManager::QmakeKitInformation::setMkspec(
kit, FileName::fromString(QLatin1String("blackberry-x86-qcc")));
kit, FileName::fromLatin1("blackberry-x86-qcc"));
DeviceTypeKitInformation::setDeviceTypeId(kit, Constants::QNX_BB_OS_TYPE);
SysRootKitInformation::setSysRoot(kit, m_sysRoot);
......
......@@ -104,10 +104,10 @@ void QnxToolChain::addToEnvironment(Utils::Environment &env) const
QList<Utils::FileName> QnxToolChain::suggestedMkspecList() const
{
QList<Utils::FileName> mkspecList;
mkspecList << Utils::FileName::fromString(QLatin1String("qnx-armv7le-qcc"));
mkspecList << Utils::FileName::fromString(QLatin1String("qnx-x86-qcc"));
mkspecList << Utils::FileName::fromString(QLatin1String("blackberry-armv7le-qcc"));
mkspecList << Utils::FileName::fromString(QLatin1String("blackberry-x86-qcc"));
mkspecList << Utils::FileName::fromLatin1("qnx-armv7le-qcc");
mkspecList << Utils::FileName::fromLatin1("qnx-x86-qcc");
mkspecList << Utils::FileName::fromLatin1("blackberry-armv7le-qcc");
mkspecList << Utils::FileName::fromLatin1("blackberry-x86-qcc");
return mkspecList;
}
......
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