forked from qt-creator/qt-creator
C++: Do not apply "Lower-case file names" setting to file wizards
This setting is intended to derive file names from class names. It is not relevant if the user explicitly provides a file name. Fixes: QTCREATORBUG-14711 Change-Id: Ic31f8727220d99692286adf9ad0434ce06aa7c62 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -38,33 +38,16 @@
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
static QString fileName(const QString &path, const QString &extension)
|
||||
{
|
||||
return Utils::FileName::fromStringWithExtension(path, extension).toString();
|
||||
}
|
||||
|
||||
QString CppToolsJsExtension::headerGuard(const QString &in) const
|
||||
{
|
||||
return Utils::headerGuard(in);
|
||||
}
|
||||
|
||||
QString CppToolsJsExtension::fileName(const QString &path, const QString &extension) const
|
||||
{
|
||||
QString raw = Utils::FileName::fromStringWithExtension(path, extension).toString();
|
||||
CppFileSettings settings;
|
||||
settings.fromSettings(Core::ICore::settings());
|
||||
if (!settings.lowerCaseFiles)
|
||||
return raw;
|
||||
|
||||
QFileInfo fi = QFileInfo(raw);
|
||||
QString finalPath = fi.path();
|
||||
if (finalPath == QStringLiteral("."))
|
||||
finalPath.clear();
|
||||
if (!finalPath.isEmpty() && !finalPath.endsWith(QLatin1Char('/')))
|
||||
finalPath += QLatin1Char('/');
|
||||
QString name = fi.baseName().toLower();
|
||||
QString ext = fi.completeSuffix();
|
||||
if (!ext.isEmpty())
|
||||
ext = QString(QLatin1Char('.')) + ext;
|
||||
return finalPath + name + ext;
|
||||
}
|
||||
|
||||
|
||||
static QStringList parts(const QString &klass)
|
||||
{
|
||||
return klass.split(QStringLiteral("::"));
|
||||
@@ -85,7 +68,23 @@ QString CppToolsJsExtension::className(const QString &klass) const
|
||||
|
||||
QString CppToolsJsExtension::classToFileName(const QString &klass, const QString &extension) const
|
||||
{
|
||||
return fileName(className(klass), extension);
|
||||
const QString raw = fileName(className(klass), extension);
|
||||
CppFileSettings settings;
|
||||
settings.fromSettings(Core::ICore::settings());
|
||||
if (!settings.lowerCaseFiles)
|
||||
return raw;
|
||||
|
||||
QFileInfo fi = QFileInfo(raw);
|
||||
QString finalPath = fi.path();
|
||||
if (finalPath == QStringLiteral("."))
|
||||
finalPath.clear();
|
||||
if (!finalPath.isEmpty() && !finalPath.endsWith(QLatin1Char('/')))
|
||||
finalPath += QLatin1Char('/');
|
||||
QString name = fi.baseName().toLower();
|
||||
QString ext = fi.completeSuffix();
|
||||
if (!ext.isEmpty())
|
||||
ext = QString(QLatin1Char('.')) + ext;
|
||||
return finalPath + name + ext;
|
||||
}
|
||||
|
||||
QString CppToolsJsExtension::classToHeaderGuard(const QString &klass, const QString &extension) const
|
||||
|
||||
@@ -45,12 +45,10 @@ public:
|
||||
// Generate header guard:
|
||||
Q_INVOKABLE QString headerGuard(const QString &in) const;
|
||||
|
||||
// Fix the filename casing as configured in C++/File Naming:
|
||||
Q_INVOKABLE QString fileName(const QString &path, const QString &extension) const;
|
||||
|
||||
// Work with classes:
|
||||
Q_INVOKABLE QStringList namespaces(const QString &klass) const;
|
||||
Q_INVOKABLE QString className(const QString &klass) const;
|
||||
// Fix the filename casing as configured in C++/File Naming:
|
||||
Q_INVOKABLE QString classToFileName(const QString &klass,
|
||||
const QString &extension) const;
|
||||
Q_INVOKABLE QString classToHeaderGuard(const QString &klass, const QString &extension) const;
|
||||
|
||||
Reference in New Issue
Block a user