uic: Fix some clang-tidy warnings
- Repeated return types - Make member functions static - narrowing int conversions - Use auto * - Use list.isEmpty() - Use modern includes - Remove redundant access specifiers - minor fixes Change-Id: I14ddf1add667536739fbb5fabb357dbaa7ef35c3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit 6346c5b426935a767575ea758e99749bc6544f54) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
03f2dfca7c
commit
8fc29f208b
@ -55,7 +55,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
|||||||
exportMacro.append(u' ');
|
exportMacro.append(u' ');
|
||||||
|
|
||||||
QStringList namespaceList = qualifiedClassName.split("::"_L1);
|
QStringList namespaceList = qualifiedClassName.split("::"_L1);
|
||||||
if (namespaceList.size()) {
|
if (!namespaceList.isEmpty()) {
|
||||||
className = namespaceList.last();
|
className = namespaceList.last();
|
||||||
namespaceList.removeLast();
|
namespaceList.removeLast();
|
||||||
}
|
}
|
||||||
@ -66,14 +66,14 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
|||||||
// In this case the generated Ui helper classes will also end up in
|
// In this case the generated Ui helper classes will also end up in
|
||||||
// the Qt namespace (which is harmless, but not "pretty")
|
// the Qt namespace (which is harmless, but not "pretty")
|
||||||
const bool needsMacro = m_option.qtNamespace &&
|
const bool needsMacro = m_option.qtNamespace &&
|
||||||
(namespaceList.size() == 0 || namespaceList[0] == "qdesigner_internal"_L1);
|
(namespaceList.isEmpty() || namespaceList.at(0) == "qdesigner_internal"_L1);
|
||||||
|
|
||||||
if (needsMacro)
|
if (needsMacro)
|
||||||
m_output << "QT_BEGIN_NAMESPACE\n\n";
|
m_output << "QT_BEGIN_NAMESPACE\n\n";
|
||||||
|
|
||||||
openNameSpaces(namespaceList, m_output);
|
openNameSpaces(namespaceList, m_output);
|
||||||
|
|
||||||
if (namespaceList.size())
|
if (!namespaceList.isEmpty())
|
||||||
m_output << "\n";
|
m_output << "\n";
|
||||||
|
|
||||||
m_output << "class " << exportMacro << m_option.prefix << className << "\n"
|
m_output << "class " << exportMacro << m_option.prefix << className << "\n"
|
||||||
@ -98,7 +98,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
|||||||
|
|
||||||
closeNameSpaces(namespaceList, m_output);
|
closeNameSpaces(namespaceList, m_output);
|
||||||
|
|
||||||
if (namespaceList.size())
|
if (!namespaceList.isEmpty())
|
||||||
m_output << "\n";
|
m_output << "\n";
|
||||||
|
|
||||||
if (m_option.generateNamespace && !m_option.prefix.isEmpty()) {
|
if (m_option.generateNamespace && !m_option.prefix.isEmpty()) {
|
||||||
@ -110,7 +110,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
|
|||||||
|
|
||||||
closeNameSpaces(namespaceList, m_output);
|
closeNameSpaces(namespaceList, m_output);
|
||||||
|
|
||||||
if (namespaceList.size())
|
if (!namespaceList.isEmpty())
|
||||||
m_output << "\n";
|
m_output << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ void WriteDeclaration::acceptWidget(DomWidget *node)
|
|||||||
if (node->hasAttributeClass())
|
if (node->hasAttributeClass())
|
||||||
className = node->attributeClass();
|
className = node->attributeClass();
|
||||||
|
|
||||||
m_output << m_option.indent << m_uic->customWidgetsInfo()->realClassName(className) << " *" << m_driver->findOrInsertWidget(node) << ";\n";
|
m_output << m_option.indent << CustomWidgetsInfo::realClassName(className) << " *" << m_driver->findOrInsertWidget(node) << ";\n";
|
||||||
|
|
||||||
TreeWalker::acceptWidget(node);
|
TreeWalker::acceptWidget(node);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
#include <qtextstream.h>
|
#include <qtextstream.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ WriteIncludes::WriteIncludes(Uic *uic) : WriteIncludesBase(uic),
|
|||||||
for (const auto &e : classInfoEntries()) {
|
for (const auto &e : classInfoEntries()) {
|
||||||
const QString klass = QLatin1StringView(e.klass);
|
const QString klass = QLatin1StringView(e.klass);
|
||||||
const QString module = QLatin1StringView(e.module);
|
const QString module = QLatin1StringView(e.module);
|
||||||
QLatin1StringView header = QLatin1StringView(e.header);
|
QLatin1StringView header(e.header);
|
||||||
if (klass.contains(namespaceDelimiter)) {
|
if (klass.contains(namespaceDelimiter)) {
|
||||||
m_classToHeader.insert(klass, moduleHeader(module, header));
|
m_classToHeader.insert(klass, moduleHeader(module, header));
|
||||||
} else {
|
} else {
|
||||||
@ -73,7 +73,7 @@ void WriteIncludes::acceptUI(DomUI *node)
|
|||||||
void WriteIncludes::insertIncludeForClass(const QString &className, QString header, bool global)
|
void WriteIncludes::insertIncludeForClass(const QString &className, QString header, bool global)
|
||||||
{
|
{
|
||||||
if (debugWriteIncludes)
|
if (debugWriteIncludes)
|
||||||
fprintf(stderr, "%s %s '%s' %d\n", Q_FUNC_INFO, qPrintable(className), qPrintable(header), global);
|
std::fprintf(stderr, "%s %s '%s' %d\n", Q_FUNC_INFO, qPrintable(className), qPrintable(header), global);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!header.isEmpty())
|
if (!header.isEmpty())
|
||||||
@ -91,7 +91,7 @@ void WriteIncludes::insertIncludeForClass(const QString &className, QString head
|
|||||||
// Remove namespaces
|
// Remove namespaces
|
||||||
QString lowerClassName = className.toLower();
|
QString lowerClassName = className.toLower();
|
||||||
static const auto namespaceSeparator = "::"_L1;
|
static const auto namespaceSeparator = "::"_L1;
|
||||||
const int namespaceIndex = lowerClassName.lastIndexOf(namespaceSeparator);
|
const auto namespaceIndex = lowerClassName.lastIndexOf(namespaceSeparator);
|
||||||
if (namespaceIndex != -1)
|
if (namespaceIndex != -1)
|
||||||
lowerClassName.remove(0, namespaceIndex + namespaceSeparator.size());
|
lowerClassName.remove(0, namespaceIndex + namespaceSeparator.size());
|
||||||
if (m_includeBaseNames.contains(lowerClassName)) {
|
if (m_includeBaseNames.contains(lowerClassName)) {
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
@ -416,7 +414,7 @@ int SizePolicyHandle::compare(const SizePolicyHandle &rhs) const
|
|||||||
|
|
||||||
WriteInitialization::LayoutDefaultHandler::LayoutDefaultHandler()
|
WriteInitialization::LayoutDefaultHandler::LayoutDefaultHandler()
|
||||||
{
|
{
|
||||||
std::fill_n(m_state, int(NumProperties), 0u);
|
std::fill_n(m_state, int(NumProperties), 0U);
|
||||||
std::fill_n(m_defaultValues, int(NumProperties), 0);
|
std::fill_n(m_defaultValues, int(NumProperties), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +497,6 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri
|
|||||||
writeSetter(indent, objectName, setter, m_defaultValues[p], str);
|
writeSetter(indent, objectName, setter, m_defaultValues[p], str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -547,7 +544,7 @@ void WriteInitialization::acceptUI(DomUI *node)
|
|||||||
if (node->hasAttributeConnectslotsbyname())
|
if (node->hasAttributeConnectslotsbyname())
|
||||||
m_connectSlotsByName = node->attributeConnectslotsbyname();
|
m_connectSlotsByName = node->attributeConnectslotsbyname();
|
||||||
|
|
||||||
if (auto customSlots = node->elementSlots()) {
|
if (auto *customSlots = node->elementSlots()) {
|
||||||
m_customSlots = customSlots->elementSlot();
|
m_customSlots = customSlots->elementSlot();
|
||||||
m_customSignals = customSlots->elementSignal();
|
m_customSignals = customSlots->elementSignal();
|
||||||
}
|
}
|
||||||
@ -683,7 +680,8 @@ void WriteInitialization::acceptWidget(DomWidget *node)
|
|||||||
const QString className = node->attributeClass();
|
const QString className = node->attributeClass();
|
||||||
const QString varName = m_driver->findOrInsertWidget(node);
|
const QString varName = m_driver->findOrInsertWidget(node);
|
||||||
|
|
||||||
QString parentWidget, parentClass;
|
QString parentWidget;
|
||||||
|
QString parentClass;
|
||||||
if (m_widgetChain.top()) {
|
if (m_widgetChain.top()) {
|
||||||
parentWidget = m_driver->findOrInsertWidget(m_widgetChain.top());
|
parentWidget = m_driver->findOrInsertWidget(m_widgetChain.top());
|
||||||
parentClass = m_widgetChain.top()->attributeClass();
|
parentClass = m_widgetChain.top()->attributeClass();
|
||||||
@ -698,7 +696,7 @@ void WriteInitialization::acceptWidget(DomWidget *node)
|
|||||||
|
|
||||||
if (m_widgetChain.size() != 1) {
|
if (m_widgetChain.size() != 1) {
|
||||||
m_output << m_indent << varName << " = " << language::operatorNew
|
m_output << m_indent << varName << " = " << language::operatorNew
|
||||||
<< language::fixClassName(cwi->realClassName(className))
|
<< language::fixClassName(CustomWidgetsInfo::realClassName(className))
|
||||||
<< '(' << parentWidget << ')' << language::eol;
|
<< '(' << parentWidget << ')' << language::eol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,7 +930,7 @@ void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QStr
|
|||||||
// was present before the actual Designer support (4.5)
|
// was present before the actual Designer support (4.5)
|
||||||
const bool createGroupOnTheFly = group == nullptr;
|
const bool createGroupOnTheFly = group == nullptr;
|
||||||
if (createGroupOnTheFly) {
|
if (createGroupOnTheFly) {
|
||||||
DomButtonGroup *newGroup = new DomButtonGroup;
|
auto *newGroup = new DomButtonGroup;
|
||||||
newGroup->setAttributeName(attributeName);
|
newGroup->setAttributeName(attributeName);
|
||||||
group = newGroup;
|
group = newGroup;
|
||||||
fprintf(stderr, "%s: Warning: Creating button group `%s'\n",
|
fprintf(stderr, "%s: Warning: Creating button group `%s'\n",
|
||||||
@ -984,8 +982,10 @@ void WriteInitialization::acceptLayout(DomLayout *node)
|
|||||||
DomPropertyList propList = node->elementProperty();
|
DomPropertyList propList = node->elementProperty();
|
||||||
DomPropertyList newPropList;
|
DomPropertyList newPropList;
|
||||||
if (m_layoutWidget) {
|
if (m_layoutWidget) {
|
||||||
bool left, top, right, bottom;
|
bool left = false;
|
||||||
left = top = right = bottom = false;
|
bool top = false;
|
||||||
|
bool right = false;
|
||||||
|
bool bottom = false;
|
||||||
for (const DomProperty *p : propList) {
|
for (const DomProperty *p : propList) {
|
||||||
const QString propertyName = p->attributeName();
|
const QString propertyName = p->attributeName();
|
||||||
if (propertyName == "leftMargin"_L1 && p->kind() == DomProperty::Number)
|
if (propertyName == "leftMargin"_L1 && p->kind() == DomProperty::Number)
|
||||||
@ -998,25 +998,25 @@ void WriteInitialization::acceptLayout(DomLayout *node)
|
|||||||
bottom = true;
|
bottom = true;
|
||||||
}
|
}
|
||||||
if (!left) {
|
if (!left) {
|
||||||
DomProperty *p = new DomProperty();
|
auto *p = new DomProperty();
|
||||||
p->setAttributeName("leftMargin"_L1);
|
p->setAttributeName("leftMargin"_L1);
|
||||||
p->setElementNumber(0);
|
p->setElementNumber(0);
|
||||||
newPropList.append(p);
|
newPropList.append(p);
|
||||||
}
|
}
|
||||||
if (!top) {
|
if (!top) {
|
||||||
DomProperty *p = new DomProperty();
|
auto *p = new DomProperty();
|
||||||
p->setAttributeName("topMargin"_L1);
|
p->setAttributeName("topMargin"_L1);
|
||||||
p->setElementNumber(0);
|
p->setElementNumber(0);
|
||||||
newPropList.append(p);
|
newPropList.append(p);
|
||||||
}
|
}
|
||||||
if (!right) {
|
if (!right) {
|
||||||
DomProperty *p = new DomProperty();
|
auto *p = new DomProperty();
|
||||||
p->setAttributeName("rightMargin"_L1);
|
p->setAttributeName("rightMargin"_L1);
|
||||||
p->setElementNumber(0);
|
p->setElementNumber(0);
|
||||||
newPropList.append(p);
|
newPropList.append(p);
|
||||||
}
|
}
|
||||||
if (!bottom) {
|
if (!bottom) {
|
||||||
DomProperty *p = new DomProperty();
|
auto *p = new DomProperty();
|
||||||
p->setAttributeName("bottomMargin"_L1);
|
p->setAttributeName("bottomMargin"_L1);
|
||||||
p->setElementNumber(0);
|
p->setElementNumber(0);
|
||||||
newPropList.append(p);
|
newPropList.append(p);
|
||||||
@ -1054,9 +1054,8 @@ void WriteInitialization::writePropertyList(const QString &varName,
|
|||||||
{
|
{
|
||||||
if (value.isEmpty())
|
if (value.isEmpty())
|
||||||
return;
|
return;
|
||||||
const QStringList list = value.split(u',');
|
const auto list = QStringView{value}.split(u',');
|
||||||
const int count = list.size();
|
for (qsizetype i = 0, count = list.size(); i < count; i++) {
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
if (list.at(i) != defaultValue) {
|
if (list.at(i) != defaultValue) {
|
||||||
m_output << m_indent << varName << language::derefPointer << setFunction
|
m_output << m_indent << varName << language::derefPointer << setFunction
|
||||||
<< '(' << i << ", " << list.at(i) << ')' << language::eol;
|
<< '(' << i << ", " << list.at(i) << ')' << language::eol;
|
||||||
@ -1250,7 +1249,7 @@ static QString configKeyForProperty(const QString &propertyName)
|
|||||||
return shortcutConfigKey();
|
return shortcutConfigKey();
|
||||||
if (propertyName == "accessibleName"_L1 || propertyName == "accessibleDescription"_L1)
|
if (propertyName == "accessibleName"_L1 || propertyName == "accessibleDescription"_L1)
|
||||||
return accessibilityConfigKey();
|
return accessibilityConfigKey();
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteInitialization::writeProperties(const QString &varName,
|
void WriteInitialization::writeProperties(const QString &varName,
|
||||||
@ -1290,8 +1289,10 @@ void WriteInitialization::writeProperties(const QString &varName,
|
|||||||
<< language::charliteral(objectName, m_dindent) << ')' << language::eol;
|
<< language::charliteral(objectName, m_dindent) << ')' << language::eol;
|
||||||
}
|
}
|
||||||
|
|
||||||
int leftMargin, topMargin, rightMargin, bottomMargin;
|
int leftMargin = -1;
|
||||||
leftMargin = topMargin = rightMargin = bottomMargin = -1;
|
int topMargin = -1;
|
||||||
|
int rightMargin = -1;
|
||||||
|
int bottomMargin = -1;
|
||||||
bool frameShadowEncountered = false;
|
bool frameShadowEncountered = false;
|
||||||
|
|
||||||
for (const DomProperty *p : lst) {
|
for (const DomProperty *p : lst) {
|
||||||
@ -2006,8 +2007,8 @@ QString WriteInitialization::domColor2QString(const DomColor *c)
|
|||||||
static inline QVersionNumber colorRoleVersionAdded(const QString &roleName)
|
static inline QVersionNumber colorRoleVersionAdded(const QString &roleName)
|
||||||
{
|
{
|
||||||
if (roleName == "PlaceholderText"_L1)
|
if (roleName == "PlaceholderText"_L1)
|
||||||
return QVersionNumber(5, 12, 0);
|
return {5, 12, 0};
|
||||||
return QVersionNumber();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QString &group, const QString &paletteName)
|
void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QString &group, const QString &paletteName)
|
||||||
@ -2308,8 +2309,9 @@ void WriteInitialization::enableSorting(DomWidget *w, const QString &varName, co
|
|||||||
the initializer is omitted.
|
the initializer is omitted.
|
||||||
See above for other parameters.
|
See above for other parameters.
|
||||||
*/
|
*/
|
||||||
void WriteInitialization::addInitializer(Item *item,
|
void WriteInitialization::addInitializer(Item *item, const QString &name,
|
||||||
const QString &name, int column, const QString &value, const QString &directive, bool translatable) const
|
int column, const QString &value,
|
||||||
|
const QString &directive, bool translatable)
|
||||||
{
|
{
|
||||||
if (!value.isEmpty()) {
|
if (!value.isEmpty()) {
|
||||||
QString setter;
|
QString setter;
|
||||||
@ -2360,8 +2362,8 @@ void WriteInitialization::addBrushInitializer(Item *item,
|
|||||||
Create inititializer for a flag value in the Qt namespace.
|
Create inititializer for a flag value in the Qt namespace.
|
||||||
If the named property is not in the map, the initializer is omitted.
|
If the named property is not in the map, the initializer is omitted.
|
||||||
*/
|
*/
|
||||||
void WriteInitialization::addQtFlagsInitializer(Item *item,
|
void WriteInitialization::addQtFlagsInitializer(Item *item, const DomPropertyMap &properties,
|
||||||
const DomPropertyMap &properties, const QString &name, int column) const
|
const QString &name, int column)
|
||||||
{
|
{
|
||||||
if (const DomProperty *p = properties.value(name)) {
|
if (const DomProperty *p = properties.value(name)) {
|
||||||
const QString orOperator = u'|' + language::qtQualifier;
|
const QString orOperator = u'|' + language::qtQualifier;
|
||||||
@ -2500,10 +2502,10 @@ WriteInitialization::Items WriteInitialization::initializeTreeWidgetItems(const
|
|||||||
{
|
{
|
||||||
// items
|
// items
|
||||||
Items items;
|
Items items;
|
||||||
const int numDomItems = domItems.size();
|
const qsizetype numDomItems = domItems.size();
|
||||||
items.reserve(numDomItems);
|
items.reserve(numDomItems);
|
||||||
|
|
||||||
for (int i = 0; i < numDomItems; ++i) {
|
for (qsizetype i = 0; i < numDomItems; ++i) {
|
||||||
const DomItem *domItem = domItems.at(i);
|
const DomItem *domItem = domItems.at(i);
|
||||||
|
|
||||||
Item *item = new Item("QTreeWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
|
Item *item = new Item("QTreeWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
|
||||||
@ -2687,7 +2689,7 @@ QString WriteInitialization::noTrCall(DomString *str, const QString &defaultStri
|
|||||||
{
|
{
|
||||||
QString value = defaultString;
|
QString value = defaultString;
|
||||||
if (!str && defaultString.isEmpty())
|
if (!str && defaultString.isEmpty())
|
||||||
return QString();
|
return {};
|
||||||
if (str)
|
if (str)
|
||||||
value = str->text();
|
value = str->text();
|
||||||
QString ret;
|
QString ret;
|
||||||
@ -2815,7 +2817,7 @@ static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet<QS
|
|||||||
std::sort(list.begin(), list.end());
|
std::sort(list.begin(), list.end());
|
||||||
|
|
||||||
outputStream << "#if " << language::qtConfig(list.constFirst());
|
outputStream << "#if " << language::qtConfig(list.constFirst());
|
||||||
for (int i = 1, size = list.size(); i < size; ++i)
|
for (qsizetype i = 1, size = list.size(); i < size; ++i)
|
||||||
outputStream << " || " << language::qtConfig(list.at(i));
|
outputStream << " || " << language::qtConfig(list.at(i));
|
||||||
outputStream << Qt::endl;
|
outputStream << Qt::endl;
|
||||||
}
|
}
|
||||||
@ -2847,14 +2849,14 @@ WriteInitialization::Item::~Item()
|
|||||||
QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::EmptyItemPolicy emptyItemPolicy)
|
QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::EmptyItemPolicy emptyItemPolicy)
|
||||||
{
|
{
|
||||||
if (emptyItemPolicy == Item::DontConstruct && m_setupUiData.policy == ItemData::DontGenerate)
|
if (emptyItemPolicy == Item::DontConstruct && m_setupUiData.policy == ItemData::DontGenerate)
|
||||||
return QString();
|
return {};
|
||||||
|
|
||||||
bool generateMultiDirective = false;
|
bool generateMultiDirective = false;
|
||||||
if (emptyItemPolicy == Item::ConstructItemOnly && m_children.isEmpty()) {
|
if (emptyItemPolicy == Item::ConstructItemOnly && m_children.isEmpty()) {
|
||||||
if (m_setupUiData.policy == ItemData::DontGenerate) {
|
if (m_setupUiData.policy == ItemData::DontGenerate) {
|
||||||
m_setupUiStream << m_indent << language::operatorNew << m_itemClassName
|
m_setupUiStream << m_indent << language::operatorNew << m_itemClassName
|
||||||
<< '(' << parent << ')' << language::eol;
|
<< '(' << parent << ')' << language::eol;
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
if (m_setupUiData.policy == ItemData::GenerateWithMultiDirective)
|
if (m_setupUiData.policy == ItemData::GenerateWithMultiDirective)
|
||||||
generateMultiDirective = true;
|
generateMultiDirective = true;
|
||||||
|
@ -151,7 +151,7 @@ private:
|
|||||||
void writeRetranslateUi(const QString &parentPath);
|
void writeRetranslateUi(const QString &parentPath);
|
||||||
void addSetter(const QString &setter, const QString &directive = QString(), bool translatable = false); // don't call it if you already added *this as a child of another Item
|
void addSetter(const QString &setter, const QString &directive = QString(), bool translatable = false); // don't call it if you already added *this as a child of another Item
|
||||||
void addChild(Item *child); // all setters should already been added
|
void addChild(Item *child); // all setters should already been added
|
||||||
private:
|
|
||||||
struct ItemData
|
struct ItemData
|
||||||
{
|
{
|
||||||
QMultiMap<QString, QString> setters; // directive to setter
|
QMultiMap<QString, QString> setters; // directive to setter
|
||||||
@ -175,10 +175,10 @@ private:
|
|||||||
};
|
};
|
||||||
using Items = QList<Item *>;
|
using Items = QList<Item *>;
|
||||||
|
|
||||||
void addInitializer(Item *item,
|
static void addInitializer(Item *item, const QString &name, int column,
|
||||||
const QString &name, int column, const QString &value, const QString &directive = QString(), bool translatable = false) const;
|
const QString &value, const QString &directive = QString(), bool translatable = false);
|
||||||
void addQtFlagsInitializer(Item *item, const DomPropertyMap &properties,
|
static void addQtFlagsInitializer(Item *item, const DomPropertyMap &properties,
|
||||||
const QString &name, int column = -1) const;
|
const QString &name, int column = -1);
|
||||||
void addQtEnumInitializer(Item *item,
|
void addQtEnumInitializer(Item *item,
|
||||||
const DomPropertyMap &properties, const QString &name, int column = -1) const;
|
const DomPropertyMap &properties, const QString &name, int column = -1) const;
|
||||||
void addBrushInitializer(Item *item,
|
void addBrushInitializer(Item *item,
|
||||||
@ -206,7 +206,6 @@ private:
|
|||||||
|
|
||||||
Declaration findDeclaration(const QString &name);
|
Declaration findDeclaration(const QString &name);
|
||||||
|
|
||||||
private:
|
|
||||||
QString writeFontProperties(const DomFont *f);
|
QString writeFontProperties(const DomFont *f);
|
||||||
QString writeIconProperties(const DomResourceIcon *i);
|
QString writeIconProperties(const DomResourceIcon *i);
|
||||||
void writeThemeIconCheckAssignment(const QString &themeValue, const QString &iconName,
|
void writeThemeIconCheckAssignment(const QString &themeValue, const QString &iconName,
|
||||||
|
@ -163,7 +163,7 @@ bool CustomWidgetsInfo::isAmbiguousSlot(const QString &className,
|
|||||||
return isAmbiguous(className, signalSignature, QMetaMethod::Slot);
|
return isAmbiguous(className, signalSignature, QMetaMethod::Slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CustomWidgetsInfo::realClassName(const QString &className) const
|
QString CustomWidgetsInfo::realClassName(const QString &className)
|
||||||
{
|
{
|
||||||
if (className == "Line"_L1)
|
if (className == "Line"_L1)
|
||||||
return u"QFrame"_s;
|
return u"QFrame"_s;
|
||||||
@ -175,7 +175,7 @@ QString CustomWidgetsInfo::customWidgetAddPageMethod(const QString &name) const
|
|||||||
{
|
{
|
||||||
if (DomCustomWidget *dcw = m_customWidgets.value(name, nullptr))
|
if (DomCustomWidget *dcw = m_customWidgets.value(name, nullptr))
|
||||||
return dcw->elementAddPageMethod();
|
return dcw->elementAddPageMethod();
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// add page methods for simple containers taking only the widget parameter
|
// add page methods for simple containers taking only the widget parameter
|
||||||
@ -195,7 +195,7 @@ QString CustomWidgetsInfo::simpleContainerAddPageMethod(const QString &name) con
|
|||||||
if (extends(name, m.first))
|
if (extends(name, m.first))
|
||||||
return m.second;
|
return m.second;
|
||||||
}
|
}
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
QString customWidgetAddPageMethod(const QString &name) const;
|
QString customWidgetAddPageMethod(const QString &name) const;
|
||||||
QString simpleContainerAddPageMethod(const QString &name) const;
|
QString simpleContainerAddPageMethod(const QString &name) const;
|
||||||
|
|
||||||
QString realClassName(const QString &className) const;
|
static QString realClassName(const QString &className);
|
||||||
|
|
||||||
bool extends(const QString &className, QAnyStringView baseClassName) const;
|
bool extends(const QString &className, QAnyStringView baseClassName) const;
|
||||||
bool extendsOneOf(const QString &className, const QStringList &baseClassNames) const;
|
bool extendsOneOf(const QString &className, const QStringList &baseClassNames) const;
|
||||||
|
@ -28,7 +28,7 @@ void DatabaseInfo::acceptWidget(DomWidget *node)
|
|||||||
QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty());
|
QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty());
|
||||||
|
|
||||||
DomProperty *frameworkCode = properties.value("frameworkCode"_L1);
|
DomProperty *frameworkCode = properties.value("frameworkCode"_L1);
|
||||||
if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
|
if (frameworkCode && !toBool(frameworkCode->elementBool()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DomProperty *db = properties.value("database"_L1);
|
DomProperty *db = properties.value("database"_L1);
|
||||||
|
@ -17,9 +17,9 @@ QT_BEGIN_NAMESPACE
|
|||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
Driver::Driver()
|
Driver::Driver()
|
||||||
: m_stdout(stdout, QFile::WriteOnly | QFile::Text)
|
: m_stdout(stdout, QFile::WriteOnly | QFile::Text),
|
||||||
|
m_output(&m_stdout)
|
||||||
{
|
{
|
||||||
m_output = &m_stdout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Driver::~Driver() = default;
|
Driver::~Driver() = default;
|
||||||
@ -94,7 +94,7 @@ QString Driver::findOrInsertLayoutItem(const DomLayoutItem *ui_layoutItem)
|
|||||||
|
|
||||||
Q_ASSERT( 0 );
|
Q_ASSERT( 0 );
|
||||||
|
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Driver::findOrInsertActionGroup(const DomActionGroup *ui_group)
|
QString Driver::findOrInsertActionGroup(const DomActionGroup *ui_group)
|
||||||
@ -170,7 +170,7 @@ QString Driver::qtify(const QString &name)
|
|||||||
if (qname.at(0) == u'Q' || qname.at(0) == u'K')
|
if (qname.at(0) == u'Q' || qname.at(0) == u'K')
|
||||||
qname.remove(0, 1);
|
qname.remove(0, 1);
|
||||||
|
|
||||||
for (int i = 0, size = qname.size(); i < size && qname.at(i).isUpper(); ++i)
|
for (qsizetype i = 0, size = qname.size(); i < size && qname.at(i).isUpper(); ++i)
|
||||||
qname[i] = qname.at(i).toLower();
|
qname[i] = qname.at(i).toLower();
|
||||||
|
|
||||||
return qname;
|
return qname;
|
||||||
@ -203,7 +203,7 @@ QString Driver::headerFileName(const QString &fileName)
|
|||||||
// Transform into a valid C++ identifier
|
// Transform into a valid C++ identifier
|
||||||
if (!baseName.isEmpty() && baseName.at(0).isDigit())
|
if (!baseName.isEmpty() && baseName.at(0).isDigit())
|
||||||
baseName.prepend(u'_');
|
baseName.prepend(u'_');
|
||||||
for (int i = 0; i < baseName.size(); ++i) {
|
for (qsizetype i = 0; i < baseName.size(); ++i) {
|
||||||
QChar c = baseName.at(i);
|
QChar c = baseName.at(i);
|
||||||
if (!isAnsiCCharacter(c)) {
|
if (!isAnsiCCharacter(c)) {
|
||||||
// Replace character by its unicode value
|
// Replace character by its unicode value
|
||||||
|
@ -124,9 +124,9 @@ void WriteImports::acceptUI(DomUI *node)
|
|||||||
output << "import " << w << '\n';
|
output << "import " << w << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto resources = node->elementResources()) {
|
if (auto *resources = node->elementResources()) {
|
||||||
const auto includes = resources->elementInclude();
|
const auto &includes = resources->elementInclude();
|
||||||
for (auto include : includes) {
|
for (auto *include : includes) {
|
||||||
if (include->hasAttributeLocation())
|
if (include->hasAttributeLocation())
|
||||||
writeResourceImport(include->attributeLocation());
|
writeResourceImport(include->attributeLocation());
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
#include <QtCore/qstringview.h>
|
#include <QtCore/qstringview.h>
|
||||||
#include <QtCore/qstring.h>
|
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QTextStream)
|
QT_FORWARD_DECLARE_CLASS(QTextStream)
|
||||||
|
|
||||||
|
@ -108,10 +108,10 @@ static inline bool isCppCommentChar(QChar c)
|
|||||||
return c == u'/' || c == u'*';
|
return c == u'/' || c == u'*';
|
||||||
}
|
}
|
||||||
|
|
||||||
static int leadingCppCommentCharCount(QStringView s)
|
static qsizetype leadingCppCommentCharCount(QStringView s)
|
||||||
{
|
{
|
||||||
int i = 0;
|
qsizetype i = 0;
|
||||||
for (const int size = s.size(); i < size && isCppCommentChar(s.at(i)); ++i) {
|
for (const qsizetype size = s.size(); i < size && isCppCommentChar(s.at(i)); ++i) {
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ void Uic::writeCopyrightHeaderPython(const DomUI *ui) const
|
|||||||
if (!comment.isEmpty()) {
|
if (!comment.isEmpty()) {
|
||||||
const auto lines = QStringView{comment}.split(u'\n');
|
const auto lines = QStringView{comment}.split(u'\n');
|
||||||
for (const auto &line : lines) {
|
for (const auto &line : lines) {
|
||||||
if (const int leadingCommentChars = leadingCppCommentCharCount(line)) {
|
if (const auto leadingCommentChars = leadingCppCommentCharCount(line)) {
|
||||||
out << language::repeat(leadingCommentChars, '#')
|
out << language::repeat(leadingCommentChars, '#')
|
||||||
<< line.right(line.size() - leadingCommentChars);
|
<< line.right(line.size() - leadingCommentChars);
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,13 +68,12 @@ private:
|
|||||||
// copyright header
|
// copyright header
|
||||||
void writeCopyrightHeaderCpp(const DomUI *ui) const;
|
void writeCopyrightHeaderCpp(const DomUI *ui) const;
|
||||||
void writeCopyrightHeaderPython(const DomUI *ui) const;
|
void writeCopyrightHeaderPython(const DomUI *ui) const;
|
||||||
DomUI *parseUiFile(QXmlStreamReader &reader);
|
static DomUI *parseUiFile(QXmlStreamReader &reader);
|
||||||
|
|
||||||
// header protection
|
// header protection
|
||||||
void writeHeaderProtectionStart();
|
void writeHeaderProtectionStart();
|
||||||
void writeHeaderProtectionEnd();
|
void writeHeaderProtectionEnd();
|
||||||
|
|
||||||
private:
|
|
||||||
Driver *drv;
|
Driver *drv;
|
||||||
QTextStream &out;
|
QTextStream &out;
|
||||||
Option &opt;
|
Option &opt;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user