From 07071a23c3bc3f0444068383a57fbc9d50601240 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 8 May 2019 09:25:25 +0200 Subject: uic/Python: Fix tab stop/Z-Order and buddy handling The code compared the attribute names of the properties against the m_registeredWidgets hash which contained the qualified names (self.widget) and thus reported errors without actually generating anything. Replace the m_registeredWidgets hash by a lookup of the attribute name in the m_widgets hash and add a function widgetVariableName() returning the qualified variable name for an attribute name and use that for the checks. Remove unused m_registeredActions hash and rename some variables to make it clearer. Task-number: PYSIDE-797 Change-Id: Id31d95c1141d21c51eb85bcd8f8fc63486eb36a5 Reviewed-by: Cristian Maureira-Fredes --- src/tools/uic/driver.cpp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'src/tools/uic/driver.cpp') diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp index a0812932ce..eb88032e59 100644 --- a/src/tools/uic/driver.cpp +++ b/src/tools/uic/driver.cpp @@ -52,15 +52,25 @@ static inline QString actionGroupClass() { return QStringLiteral("QActionGroup") static inline QString actionClass() { return QStringLiteral("QAction"); } static inline QString buttonGroupClass() { return QStringLiteral("QButtonGroup"); } +template +Driver::DomObjectHashConstIt + Driver::findByAttributeNameIt(const DomObjectHash &domHash, + const QString &name) const +{ + const auto end = domHash.cend(); + for (auto it = domHash.cbegin(); it != end; ++it) { + if (it.key()->attributeName() == name) + return it; + } + return end; +} + template const DomClass *Driver::findByAttributeName(const DomObjectHash &domHash, const QString &name) const { - for (auto it = domHash.cbegin(), end = domHash.cend(); it != end; ++it) { - if (it.key()->attributeName() == name) - return it.key(); - } - return nullptr; + auto it = findByAttributeNameIt(domHash, name); + return it != domHash.cend() ? it.key() : nullptr; } template @@ -299,19 +309,25 @@ bool Driver::uic(const QString &fileName, QTextStream *out) return rtn; } -const DomWidget *Driver::widgetByName(const QString &name) const +const DomWidget *Driver::widgetByName(const QString &attributeName) const +{ + return findByAttributeName(m_widgets, attributeName); +} + +QString Driver::widgetVariableName(const QString &attributeName) const { - return findByAttributeName(m_widgets, name); + auto it = findByAttributeNameIt(m_widgets, attributeName); + return it != m_widgets.cend() ? it.value() : QString(); } -const DomActionGroup *Driver::actionGroupByName(const QString &name) const +const DomActionGroup *Driver::actionGroupByName(const QString &attributeName) const { - return findByAttributeName(m_actionGroups, name); + return findByAttributeName(m_actionGroups, attributeName); } -const DomAction *Driver::actionByName(const QString &name) const +const DomAction *Driver::actionByName(const QString &attributeName) const { - return findByAttributeName(m_actions, name); + return findByAttributeName(m_actions, attributeName); } QT_END_NAMESPACE -- cgit v1.2.3