uic: replace QLatin1String uses with _L1 or _s
Task-number: QTBUG-98434 Change-Id: I5a9b01d1dd2a2a727cfb71e829dbf631bf25e2db Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
07071e3c0c
commit
cd9cbc34db
@ -39,6 +39,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
void openNameSpaces(const QStringList &namespaceList, QTextStream &output)
|
||||
{
|
||||
@ -77,7 +79,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
||||
if (!exportMacro.isEmpty())
|
||||
exportMacro.append(u' ');
|
||||
|
||||
QStringList namespaceList = qualifiedClassName.split(QLatin1String("::"));
|
||||
QStringList namespaceList = qualifiedClassName.split("::"_L1);
|
||||
if (namespaceList.count()) {
|
||||
className = namespaceList.last();
|
||||
namespaceList.removeLast();
|
||||
@ -89,7 +91,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
||||
// In this case the generated Ui helper classes will also end up in
|
||||
// the Qt namespace (which is harmless, but not "pretty")
|
||||
const bool needsMacro = namespaceList.count() == 0
|
||||
|| namespaceList[0] == QLatin1String("qdesigner_internal");
|
||||
|| namespaceList[0] == "qdesigner_internal"_L1;
|
||||
|
||||
if (needsMacro)
|
||||
m_output << "QT_BEGIN_NAMESPACE\n\n";
|
||||
@ -105,7 +107,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
||||
|
||||
const QStringList connections = m_uic->databaseInfo()->connections();
|
||||
for (const QString &connection : connections) {
|
||||
if (connection != QLatin1String("(default)"))
|
||||
if (connection != "(default)"_L1)
|
||||
m_output << m_option.indent << "QSqlDatabase " << connection << "Connection;\n";
|
||||
}
|
||||
|
||||
@ -125,7 +127,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
||||
m_output << "\n";
|
||||
|
||||
if (m_option.generateNamespace && !m_option.prefix.isEmpty()) {
|
||||
namespaceList.append(QLatin1String("Ui"));
|
||||
namespaceList.append("Ui"_L1);
|
||||
|
||||
openNameSpaces(namespaceList, m_output);
|
||||
|
||||
@ -143,7 +145,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
||||
|
||||
void WriteDeclaration::acceptWidget(DomWidget *node)
|
||||
{
|
||||
QString className = QLatin1String("QWidget");
|
||||
QString className = "QWidget"_L1;
|
||||
if (node->hasAttributeClass())
|
||||
className = node->attributeClass();
|
||||
|
||||
@ -160,7 +162,7 @@ void WriteDeclaration::acceptSpacer(DomSpacer *node)
|
||||
|
||||
void WriteDeclaration::acceptLayout(DomLayout *node)
|
||||
{
|
||||
QString className = QLatin1String("QLayout");
|
||||
QString className = "QLayout"_L1;
|
||||
if (node->hasAttributeClass())
|
||||
className = node->attributeClass();
|
||||
|
||||
|
@ -40,6 +40,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
enum { debugWriteIncludes = 0 };
|
||||
enum { warnHeaderGeneration = 0 };
|
||||
|
||||
@ -60,7 +62,7 @@ WriteIncludes::WriteIncludes(Uic *uic) : WriteIncludesBase(uic),
|
||||
// When possible (no namespace) use the "QtModule/QClass" convention
|
||||
// and create a re-mapping of the old header "qclass.h" to it. Do not do this
|
||||
// for the "Phonon::Someclass" classes, however.
|
||||
const QString namespaceDelimiter = QLatin1String("::");
|
||||
const QString namespaceDelimiter = "::"_L1;
|
||||
for (const auto &e : classInfoEntries()) {
|
||||
const QString klass = QLatin1String(e.klass);
|
||||
const QString module = QLatin1String(e.module);
|
||||
@ -113,7 +115,7 @@ void WriteIncludes::insertIncludeForClass(const QString &className, QString head
|
||||
// Quick check by class name to detect includehints provided for custom widgets.
|
||||
// Remove namespaces
|
||||
QString lowerClassName = className.toLower();
|
||||
static const QString namespaceSeparator = QLatin1String("::");
|
||||
static const QString namespaceSeparator = "::"_L1;
|
||||
const int namespaceIndex = lowerClassName.lastIndexOf(namespaceSeparator);
|
||||
if (namespaceIndex != -1)
|
||||
lowerClassName.remove(0, namespaceIndex + namespaceSeparator.size());
|
||||
@ -126,7 +128,7 @@ void WriteIncludes::insertIncludeForClass(const QString &className, QString head
|
||||
if (!uic()->option().implicitIncludes)
|
||||
break;
|
||||
header = lowerClassName;
|
||||
header += QLatin1String(".h");
|
||||
header += ".h"_L1;
|
||||
if (warnHeaderGeneration) {
|
||||
qWarning("%s: Warning: generated header '%s' for class '%s'.",
|
||||
qPrintable(uic()->option().messagePrefix()),
|
||||
@ -157,7 +159,7 @@ void WriteIncludes::addCppCustomWidget(const QString &className, const DomCustom
|
||||
QString header;
|
||||
bool global = false;
|
||||
if (!m_classToHeader.contains(className)) {
|
||||
global = domHeader->attributeLocation().toLower() == QLatin1String("global");
|
||||
global = domHeader->attributeLocation().toLower() == "global"_L1;
|
||||
header = domHeader->text();
|
||||
}
|
||||
insertIncludeForClass(className, header, global);
|
||||
@ -169,7 +171,7 @@ void WriteIncludes::acceptInclude(DomInclude *node)
|
||||
{
|
||||
bool global = true;
|
||||
if (node->hasAttributeLocation())
|
||||
global = node->attributeLocation() == QLatin1String("global");
|
||||
global = node->attributeLocation() == "global"_L1;
|
||||
insertInclude(node->text(), global);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -120,8 +120,8 @@ bool CustomWidgetsInfo::isAmbiguousSignal(const QString &className,
|
||||
|
||||
QString CustomWidgetsInfo::realClassName(const QString &className) const
|
||||
{
|
||||
if (className == QLatin1String("Line"))
|
||||
return QLatin1String("QFrame");
|
||||
if (className == "Line"_L1)
|
||||
return "QFrame"_L1;
|
||||
|
||||
return className;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
DatabaseInfo::DatabaseInfo() = default;
|
||||
|
||||
void DatabaseInfo::acceptUI(DomUI *node)
|
||||
@ -50,11 +52,11 @@ void DatabaseInfo::acceptWidget(DomWidget *node)
|
||||
{
|
||||
QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty());
|
||||
|
||||
DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"));
|
||||
DomProperty *frameworkCode = properties.value("frameworkCode"_L1);
|
||||
if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
|
||||
return;
|
||||
|
||||
DomProperty *db = properties.value(QLatin1String("database"));
|
||||
DomProperty *db = properties.value("database"_L1);
|
||||
if (db && db->elementStringList()) {
|
||||
QStringList info = db->elementStringList()->elementString();
|
||||
if (info.isEmpty() || info.constFirst().isEmpty())
|
||||
|
@ -39,6 +39,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
Driver::Driver()
|
||||
: m_stdout(stdout, QFile::WriteOnly | QFile::Text)
|
||||
{
|
||||
@ -172,7 +174,7 @@ QString Driver::unique(const QString &instanceName, const QString &className)
|
||||
} else if (!className.isEmpty()) {
|
||||
name = unique(qtify(className));
|
||||
} else {
|
||||
name = unique(QLatin1String("var"));
|
||||
name = unique("var"_L1);
|
||||
}
|
||||
|
||||
if (alreadyUsed && !className.isEmpty()) {
|
||||
@ -209,7 +211,7 @@ QString Driver::headerFileName() const
|
||||
QString name = m_option.outputFile;
|
||||
|
||||
if (name.isEmpty()) {
|
||||
name = QLatin1String("ui_"); // ### use ui_ as prefix.
|
||||
name = "ui_"_L1; // ### use ui_ as prefix.
|
||||
name.append(m_option.inputFile);
|
||||
}
|
||||
|
||||
@ -219,7 +221,7 @@ QString Driver::headerFileName() const
|
||||
QString Driver::headerFileName(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return headerFileName(QLatin1String("noname"));
|
||||
return headerFileName("noname"_L1);
|
||||
|
||||
QFileInfo info(fileName);
|
||||
QString baseName = info.baseName();
|
||||
@ -235,7 +237,7 @@ QString Driver::headerFileName(const QString &fileName)
|
||||
i += hex.size() + 1;
|
||||
}
|
||||
}
|
||||
return baseName.toUpper() + QLatin1String("_H");
|
||||
return baseName.toUpper() + "_H"_L1;
|
||||
}
|
||||
|
||||
bool Driver::printDependencies(const QString &fileName)
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
int runUic(int argc, char *argv[])
|
||||
{
|
||||
qSetGlobalQHashSeed(0); // set the hash seed to 0
|
||||
@ -134,15 +136,15 @@ int runUic(int argc, char *argv[])
|
||||
driver.option().includeFile = parser.value(includeOption);
|
||||
if (parser.isSet(connectionsOption)) {
|
||||
const auto value = parser.value(connectionsOption);
|
||||
if (value == QLatin1String("pmf"))
|
||||
if (value == "pmf"_L1)
|
||||
driver.option().forceMemberFnPtrConnectionSyntax = 1;
|
||||
else if (value == QLatin1String("string"))
|
||||
else if (value == "string"_L1)
|
||||
driver.option().forceStringConnectionSyntax = 1;
|
||||
}
|
||||
|
||||
Language language = Language::Cpp;
|
||||
if (parser.isSet(generatorOption)) {
|
||||
if (parser.value(generatorOption).compare(QLatin1String("python")) == 0)
|
||||
if (parser.value(generatorOption).compare("python"_L1) == 0)
|
||||
language = Language::Python;
|
||||
}
|
||||
language::setLanguage(language);
|
||||
|
@ -38,6 +38,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace Python {
|
||||
|
||||
WriteDeclaration::WriteDeclaration(Uic *uic) :
|
||||
@ -51,7 +53,7 @@ WriteDeclaration::WriteDeclaration(Uic *uic) :
|
||||
void WriteDeclaration::acceptUI(DomUI *node)
|
||||
{
|
||||
// remove any left-over C++ namespaces
|
||||
const QString qualifiedClassName = QLatin1String("Ui_") + node->elementClass()
|
||||
const QString qualifiedClassName = "Ui_"_L1 + node->elementClass()
|
||||
+ m_option.postfix;
|
||||
m_output << "class " << language::fixClassName(qualifiedClassName) << "(object):\n";
|
||||
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
// Generate imports for Python. Note some things differ from C++:
|
||||
// - qItemView->header()->setFoo() does not require QHeaderView to be imported
|
||||
// - qLabel->setFrameShape(QFrame::Box) however requires QFrame to be imported
|
||||
@ -84,9 +86,9 @@ static QString pythonResource(QString resource)
|
||||
const qsizetype lastSlash = resource.lastIndexOf(u'/');
|
||||
if (lastSlash != -1)
|
||||
resource.remove(0, lastSlash + 1);
|
||||
if (resource.endsWith(QLatin1String(".qrc"))) {
|
||||
if (resource.endsWith(".qrc"_L1)) {
|
||||
resource.chop(4);
|
||||
resource.append(QLatin1String("_rc"));
|
||||
resource.append("_rc"_L1);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
@ -210,7 +212,7 @@ bool WriteImports::addQtClass(const QString &className)
|
||||
|
||||
void WriteImports::addPythonCustomWidget(const QString &className, const DomCustomWidget *node)
|
||||
{
|
||||
if (className.contains(QLatin1String("::")))
|
||||
if (className.contains("::"_L1))
|
||||
return; // Exclude namespaced names (just to make tests pass).
|
||||
|
||||
if (addQtClass(className)) // Qt custom widgets like QQuickWidget, QAxWidget, etc
|
||||
@ -225,7 +227,7 @@ void WriteImports::addPythonCustomWidget(const QString &className, const DomCust
|
||||
// Replace the '/' by '.'
|
||||
modulePath.replace(u'/', u'.');
|
||||
// '.h' is added by default on headers for <customwidget>
|
||||
if (modulePath.endsWith(QLatin1String(".h")))
|
||||
if (modulePath.endsWith(".h"_L1))
|
||||
modulePath.chop(2);
|
||||
insertClass(modulePath, className, &m_customWidgets);
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
namespace language {
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
static Encoding encoding = Encoding::Utf8;
|
||||
static Language _language = Language::Cpp;
|
||||
|
||||
@ -42,29 +44,29 @@ void setLanguage(Language l)
|
||||
_language = l;
|
||||
switch (_language) {
|
||||
case Language::Cpp:
|
||||
derefPointer = QLatin1String("->");
|
||||
derefPointer = u"->"_s;
|
||||
listStart = '{';
|
||||
listEnd = '}';
|
||||
nullPtr = QLatin1String("nullptr");
|
||||
operatorNew = QLatin1String("new ");
|
||||
qtQualifier = QLatin1String("Qt::");
|
||||
qualifier = QLatin1String("::");
|
||||
self = QLatin1String(""); // for testing: change to "this->";
|
||||
eol = QLatin1String(";\n");
|
||||
emptyString = QLatin1String("QString()");
|
||||
nullPtr = u"nullptr"_s;
|
||||
operatorNew = u"new "_s;
|
||||
qtQualifier = u"Qt::"_s;
|
||||
qualifier = u"::"_s;
|
||||
self = u""_s; // for testing: change to "this->";
|
||||
eol = u";\n"_s;
|
||||
emptyString = u"QString()"_s;
|
||||
encoding = Encoding::Utf8;
|
||||
break;
|
||||
case Language::Python:
|
||||
derefPointer = QLatin1String(".");
|
||||
derefPointer = u"."_s;
|
||||
listStart = '[';
|
||||
listEnd = ']';
|
||||
nullPtr = QLatin1String("None");
|
||||
operatorNew = QLatin1String("");
|
||||
qtQualifier = QLatin1String("Qt.");
|
||||
qualifier = QLatin1String(".");
|
||||
self = QLatin1String("self.");
|
||||
eol = QLatin1String("\n");
|
||||
emptyString = QLatin1String("\"\"");
|
||||
nullPtr = u"None"_s;
|
||||
operatorNew = u""_s;
|
||||
qtQualifier = u"Qt."_s;
|
||||
qualifier = u"."_s;
|
||||
self = u"self."_s;
|
||||
eol = u"\n"_s;
|
||||
emptyString = u"\"\""_s;
|
||||
encoding = Encoding::Unicode;
|
||||
break;
|
||||
}
|
||||
@ -81,9 +83,9 @@ QString self;
|
||||
QString eol;
|
||||
QString emptyString;
|
||||
|
||||
QString cppQualifier = QLatin1String("::");
|
||||
QString cppTrue = QLatin1String("true");
|
||||
QString cppFalse = QLatin1String("false");
|
||||
QString cppQualifier = "::"_L1;
|
||||
QString cppTrue = "true"_L1;
|
||||
QString cppFalse = "false"_L1;
|
||||
|
||||
QTextStream &operator<<(QTextStream &str, const qtConfig &c)
|
||||
{
|
||||
@ -125,7 +127,7 @@ const char *lookupEnum(const EnumLookup(&array)[N], int value, int defaultIndex
|
||||
QString fixClassName(QString className)
|
||||
{
|
||||
if (language() == Language::Python)
|
||||
className.replace(cppQualifier, QLatin1String("_"));
|
||||
className.replace(cppQualifier, "_"_L1);
|
||||
return className;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
Uic::Uic(Driver *d)
|
||||
: drv(d),
|
||||
out(d->output()),
|
||||
@ -169,7 +171,7 @@ void Uic::writeCopyrightHeaderPython(const DomUI *ui) const
|
||||
static double versionFromUiAttribute(QXmlStreamReader &reader)
|
||||
{
|
||||
const QXmlStreamAttributes attributes = reader.attributes();
|
||||
const QString versionAttribute = QLatin1String("version");
|
||||
const QString versionAttribute = "version"_L1;
|
||||
if (!attributes.hasAttribute(versionAttribute))
|
||||
return 4.0;
|
||||
const QStringView version = attributes.value(versionAttribute);
|
||||
@ -180,7 +182,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
|
||||
{
|
||||
DomUI *ui = nullptr;
|
||||
|
||||
const QString uiElement = QLatin1String("ui");
|
||||
const QString uiElement = "ui"_L1;
|
||||
while (!reader.atEnd()) {
|
||||
if (reader.readNext() == QXmlStreamReader::StartElement) {
|
||||
if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0
|
||||
@ -195,7 +197,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
|
||||
ui = new DomUI();
|
||||
ui->read(reader);
|
||||
} else {
|
||||
reader.raiseError(QLatin1String("Unexpected element ") + reader.name().toString());
|
||||
reader.raiseError("Unexpected element "_L1 + reader.name().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,7 +233,7 @@ bool Uic::write(QIODevice *in)
|
||||
const QString &language = ui->attributeLanguage();
|
||||
driver()->setUseIdBasedTranslations(ui->attributeIdbasedtr());
|
||||
|
||||
if (!language.isEmpty() && language.compare(QLatin1String("c++"), Qt::CaseInsensitive) != 0) {
|
||||
if (!language.isEmpty() && language.compare("c++"_L1, Qt::CaseInsensitive) != 0) {
|
||||
fprintf(stderr, "uic: File is not a \"c++\" ui file, language=%s\n", qPrintable(language));
|
||||
return false;
|
||||
}
|
||||
@ -266,8 +268,7 @@ bool Uic::write(DomUI *ui)
|
||||
}
|
||||
|
||||
pixFunction = ui->elementPixmapFunction();
|
||||
if (pixFunction == QLatin1String("QPixmap::fromMimeSource")
|
||||
|| pixFunction == QLatin1String("qPixmapFromMimeSource")) {
|
||||
if (pixFunction == "QPixmap::fromMimeSource"_L1 || pixFunction == "qPixmapFromMimeSource"_L1) {
|
||||
fprintf(stderr, "%s: Warning: Obsolete pixmap function '%s' specified in the UI file.\n",
|
||||
qPrintable(opt.messagePrefix()), qPrintable(pixFunction));
|
||||
pixFunction.clear();
|
||||
@ -315,9 +316,9 @@ void Uic::writeHeaderProtectionEnd()
|
||||
bool Uic::isButton(const QString &className) const
|
||||
{
|
||||
static const QStringList buttons = {
|
||||
QLatin1String("QRadioButton"), QLatin1String("QToolButton"),
|
||||
QLatin1String("QCheckBox"), QLatin1String("QPushButton"),
|
||||
QLatin1String("QCommandLinkButton")
|
||||
"QRadioButton"_L1, "QToolButton"_L1,
|
||||
"QCheckBox"_L1, "QPushButton"_L1,
|
||||
"QCommandLinkButton"_L1
|
||||
};
|
||||
return customWidgetsInfo()->extendsOneOf(className, buttons);
|
||||
}
|
||||
@ -325,10 +326,10 @@ bool Uic::isButton(const QString &className) const
|
||||
bool Uic::isContainer(const QString &className) const
|
||||
{
|
||||
static const QStringList containers = {
|
||||
QLatin1String("QStackedWidget"), QLatin1String("QToolBox"),
|
||||
QLatin1String("QTabWidget"), QLatin1String("QScrollArea"),
|
||||
QLatin1String("QMdiArea"), QLatin1String("QWizard"),
|
||||
QLatin1String("QDockWidget")
|
||||
"QStackedWidget"_L1, "QToolBox"_L1,
|
||||
"QTabWidget"_L1, "QScrollArea"_L1,
|
||||
"QMdiArea"_L1, "QWizard"_L1,
|
||||
"QDockWidget"_L1
|
||||
};
|
||||
|
||||
return customWidgetsInfo()->extendsOneOf(className, containers);
|
||||
@ -337,7 +338,7 @@ bool Uic::isContainer(const QString &className) const
|
||||
bool Uic::isMenu(const QString &className) const
|
||||
{
|
||||
static const QStringList menus = {
|
||||
QLatin1String("QMenu"), QLatin1String("QPopupMenu")
|
||||
"QMenu"_L1, "QPopupMenu"_L1
|
||||
};
|
||||
return customWidgetsInfo()->extendsOneOf(className, menus);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user